Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-11-11 02:27:59 -0500
committerEike Stepper2012-11-11 02:27:59 -0500
commitcdc97f961b5ebfdb2693658f66c60eccb362b09a (patch)
tree8ce62fbdd22ecb937f34e2f4f4fdbc9eb7dececc
parent603df676b20ce72ec3bccd64dea78de17d1e42b9 (diff)
downloadcdo-cdc97f961b5ebfdb2693658f66c60eccb362b09a.tar.gz
cdo-cdc97f961b5ebfdb2693658f66c60eccb362b09a.tar.xz
cdo-cdc97f961b5ebfdb2693658f66c60eccb362b09a.zip
[393911] Create a complete offline and fail-over example suite
https://bugs.eclipse.org/bugs/show_bug.cgi?id=393911
-rw-r--r--plugins/org.eclipse.emf.cdo.examples.installer/examples/org.eclipse.emf.cdo.examples.client.offline/nodes/client1-repo1/node.properties4
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/RepositorySynchronizer.java34
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepositorySynchronizer.java4
3 files changed, 33 insertions, 9 deletions
diff --git a/plugins/org.eclipse.emf.cdo.examples.installer/examples/org.eclipse.emf.cdo.examples.client.offline/nodes/client1-repo1/node.properties b/plugins/org.eclipse.emf.cdo.examples.installer/examples/org.eclipse.emf.cdo.examples.client.offline/nodes/client1-repo1/node.properties
index 01ebf61a8d..743d46543b 100644
--- a/plugins/org.eclipse.emf.cdo.examples.installer/examples/org.eclipse.emf.cdo.examples.client.offline/nodes/client1-repo1/node.properties
+++ b/plugins/org.eclipse.emf.cdo.examples.installer/examples/org.eclipse.emf.cdo.examples.client.offline/nodes/client1-repo1/node.properties
@@ -1,7 +1,7 @@
#Node Settings
-#Sat Nov 10 04:42:56 CET 2012
+#Sat Nov 10 09:23:46 CET 2012
Name=client1-repo1
BrowserPort=7778
-Branch=MAIN
Type=Client
+Branch=MAIN
Server=repo1
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/RepositorySynchronizer.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/RepositorySynchronizer.java
index 5357de4866..7398a86daf 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/RepositorySynchronizer.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/RepositorySynchronizer.java
@@ -23,6 +23,7 @@ import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
import org.eclipse.emf.cdo.internal.common.revision.NOOPRevisionCache;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.emf.cdo.server.StoreThreadLocal;
+import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.session.CDOSessionConfiguration;
import org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory;
import org.eclipse.emf.cdo.session.CDOSessionInvalidationEvent;
@@ -34,6 +35,8 @@ import org.eclipse.emf.cdo.spi.server.InternalSynchronizableRepository;
import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
import org.eclipse.net4j.util.concurrent.PriorityQueueRunnable;
import org.eclipse.net4j.util.concurrent.PriorityQueueRunner;
+import org.eclipse.net4j.util.container.IContainerDelta;
+import org.eclipse.net4j.util.container.SingleDeltaContainerEvent;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.lifecycle.ILifecycleEvent;
@@ -170,6 +173,16 @@ public class RepositorySynchronizer extends PriorityQueueRunner implements Inter
this.recommitInterval = recommitInterval;
}
+ public boolean isEmpty()
+ {
+ return remoteSession == null;
+ }
+
+ public CDOSession[] getElements()
+ {
+ return new CDOSession[] { remoteSession };
+ }
+
@Override
protected String getThreadName()
{
@@ -211,7 +224,16 @@ public class RepositorySynchronizer extends PriorityQueueRunner implements Inter
super.doDeactivate();
}
- private void handleDisconnect()
+ protected void handleConnect()
+ {
+ remoteSession.addListener(remoteSessionListener);
+ remoteSession.getBranchManager().addListener(remoteSessionListener);
+
+ fireEvent(new SingleDeltaContainerEvent<CDOSession>(this, remoteSession, IContainerDelta.Kind.ADDED));
+ scheduleReplicate();
+ }
+
+ protected void handleDisconnect()
{
if (TRACER.isEnabled())
{
@@ -227,10 +249,13 @@ public class RepositorySynchronizer extends PriorityQueueRunner implements Inter
localRepository.setState(CDOCommonRepository.State.OFFLINE);
}
+ CDOSession element = remoteSession;
+
remoteSession.getBranchManager().removeListener(remoteSessionListener);
remoteSession.removeListener(remoteSessionListener);
remoteSession = null;
+ fireEvent(new SingleDeltaContainerEvent<CDOSession>(this, element, IContainerDelta.Kind.REMOVED));
reconnect();
}
@@ -356,6 +381,8 @@ public class RepositorySynchronizer extends PriorityQueueRunner implements Inter
}
catch (Exception ex)
{
+ remoteSession = null;
+
if (isActive())
{
if (TRACER.isEnabled())
@@ -376,10 +403,7 @@ public class RepositorySynchronizer extends PriorityQueueRunner implements Inter
TRACER.trace("Connected to master."); //$NON-NLS-1$
}
- scheduleReplicate();
-
- remoteSession.addListener(remoteSessionListener);
- remoteSession.getBranchManager().addListener(remoteSessionListener);
+ handleConnect();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepositorySynchronizer.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepositorySynchronizer.java
index f31b0da720..b8aa2c4b37 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepositorySynchronizer.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepositorySynchronizer.java
@@ -13,7 +13,7 @@ package org.eclipse.emf.cdo.server;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory;
-import org.eclipse.net4j.util.event.INotifier;
+import org.eclipse.net4j.util.container.IContainer;
/**
* Synchronizes a {@link ISynchronizableRepository synchronizable repository} with a master repository.
@@ -25,7 +25,7 @@ import org.eclipse.net4j.util.event.INotifier;
* @apiviz.landmark
* @apiviz.has {@link org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory} oneway - - remote
*/
-public interface IRepositorySynchronizer extends INotifier
+public interface IRepositorySynchronizer extends IContainer<CDOSession>
{
public int getRetryInterval();

Back to the top