some generalization in the Cache Replicator. Not finished,
but should be usable.
This commit is contained in:
parent
f5923016c6
commit
cd6ee8ccbf
2 changed files with 43 additions and 13 deletions
|
@ -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(); ) {
|
||||
|
|
|
@ -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<urls.size(); i++) {
|
||||
try {
|
||||
IReplicatedApp app = (IReplicatedApp) Naming.lookup ((String) urls.elementAt (i));
|
||||
app.replicateCache (currentAdd, currentDelete);
|
||||
} catch (Exception x) {
|
||||
System.err.println ("ERROR REPLICATING CACHE: "+x);
|
||||
}
|
||||
}
|
||||
for (int i=0; i<apps.size(); i++) {
|
||||
try {
|
||||
IReplicatedApp app = (IReplicatedApp) apps.elementAt (i);
|
||||
app.replicateCache (currentAdd, currentDelete);
|
||||
} catch (Exception x) {
|
||||
System.err.println ("ERROR REPLICATING CACHE: "+x);
|
||||
}
|
||||
}
|
||||
} catch (Exception x) {
|
||||
System.err.println ("ERROR REPLICATING CACHE: "+x);
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
Loading…
Add table
Reference in a new issue