diff --git a/src/helma/objectmodel/db/NodeManager.java b/src/helma/objectmodel/db/NodeManager.java index f96b7c56..17b24fae 100644 --- a/src/helma/objectmodel/db/NodeManager.java +++ b/src/helma/objectmodel/db/NodeManager.java @@ -55,9 +55,10 @@ public final class NodeManager { // nullNode = new Node ("nullNode", "nullNode", null, safe); String replicationUrl = props.getProperty ("replicationUrl"); - if (replicationUrl != null) - replicator = new Replicator (replicationUrl); - else + if (replicationUrl != null) { + replicator = new Replicator (); + replicator.addUrl (replicationUrl); + } else replicator = null; // get the initial id generator value @@ -647,6 +648,10 @@ public final class NodeManager { */ public List getNodes (Node home, Relation rel) throws Exception { + // This does not apply for groupby nodes - use getNodeIDs instead + if (rel.groupby != null) + return getNodeIDs (home, rel); + Transactor tx = (Transactor) Thread.currentThread (); // tx.timer.beginEvent ("getNodes "+home); @@ -982,6 +987,12 @@ public final class NodeManager { return replicator; } + public void registerReplicatedApp (helma.framework.IReplicatedApp rapp) { + if (replicator == null) + replicator = new Replicator (); + replicator.addApp (rapp); + } + public void replicateCache (Vector add, Vector delete) { synchronized (cache) { for (Enumeration en=add.elements(); en.hasMoreElements(); ) { diff --git a/src/helma/objectmodel/db/Replicator.java b/src/helma/objectmodel/db/Replicator.java index 0e5d519c..a949704c 100644 --- a/src/helma/objectmodel/db/Replicator.java +++ b/src/helma/objectmodel/db/Replicator.java @@ -3,7 +3,7 @@ package helma.objectmodel.db; -import helma.framework.IRemoteApp; +import helma.framework.IReplicatedApp; import java.rmi.*; import java.util.*; @@ -13,28 +13,47 @@ import java.util.*; public class Replicator implements Runnable { - String url; + Vector urls; + Vector apps; Vector add, delete, currentAdd, currentDelete; Thread runner; - public Replicator (String url) { - this.url = url; + public Replicator () { + urls = new Vector (); + apps = new Vector (); add = new Vector (); delete = new Vector (); runner = new Thread (this); runner.start (); } + public void addUrl (String url) { + urls.addElement (url); + } + + public void addApp (IReplicatedApp app) { + apps.addElement (app); + } public void run () { while (Thread.currentThread () == runner) { - try { - if (prepareReplication ()) { - IRemoteApp app = (IRemoteApp) Naming.lookup (url); - app.replicateCache (currentAdd, currentDelete); + if (prepareReplication ()) { + for (int i=0; i