summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-29 10:58:59 (EDT)
committerEike Stepper2007-08-29 10:58:59 (EDT)
commit39d85d3ec9ba38b08beb75cf71a46f7b32ae609f (patch)
treeaaf5a248371bc01f9947f62a7c03b3aaf9484af1
parent55c18634fd1997c7d89711360f3f252bea42b585 (diff)
downloadcdo-39d85d3ec9ba38b08beb75cf71a46f7b32ae609f.zip
cdo-39d85d3ec9ba38b08beb75cf71a46f7b32ae609f.tar.gz
cdo-39d85d3ec9ba38b08beb75cf71a46f7b32ae609f.tar.bz2
[201267] failover strategy for CDO/NET4J
https://bugs.eclipse.org/bugs/show_bug.cgi?id=201267
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java8
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java13
2 files changed, 12 insertions, 9 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
index 9a3e479..f619f69 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
@@ -20,6 +20,7 @@ import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
import org.eclipse.net4j.ConnectorException;
import org.eclipse.net4j.IConnector;
+import org.eclipse.net4j.signal.IFailOverStrategy;
import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
@@ -120,10 +121,11 @@ public final class CDOUtil
return packageTypes;
}
- public static CDOSession openSession(IConnector connector, String repositoryName, EPackage.Registry delegate)
- throws ConnectorException
+ public static CDOSession openSession(IConnector connector, String repositoryName, EPackage.Registry delegate,
+ IFailOverStrategy failOverStrategy) throws ConnectorException
{
CDOSessionImpl session = new CDOSessionImpl(delegate);
+ session.setFailOverStrategy(failOverStrategy);
session.setConnector(connector);
session.setRepositoryName(repositoryName);
LifecycleUtil.activate(session);
@@ -132,7 +134,7 @@ public final class CDOUtil
public static CDOSession openSession(IConnector connector, String repositoryName) throws ConnectorException
{
- return openSession(connector, repositoryName, null);
+ return openSession(connector, repositoryName, null, null);
}
public static CDOView getView(ResourceSet resourceSet)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
index 1c16c9c..0bfdabc 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
@@ -84,7 +84,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
if (event instanceof IFailOverEvent)
{
IFailOverEvent e = (IFailOverEvent)event;
- handleFailOver(e.getNewChannel());
+ handleFailOver(e.getOldChannel(), e.getNewChannel());
}
}
};
@@ -517,8 +517,11 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
fireElementAddedEvent(view);
}
- protected void handleFailOver(IChannel newChannel)
+ protected void handleFailOver(IChannel oldChannel, IChannel newChannel)
{
+ EventUtil.removeListener(oldChannel, channelListener);
+ EventUtil.addListener(newChannel, channelListener);
+
channel = newChannel;
connector = channel.getConnector();
}
@@ -547,15 +550,13 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
channel = connector.openChannel(CDOProtocolConstants.PROTOCOL_NAME, this);
}
- EventUtil.addListener(channel, channelListener);
-
- IFailOverStrategy failOverStrategy = getFailOverStrategy();
OpenSessionRequest request = new OpenSessionRequest(channel, repositoryName);
- OpenSessionResult result = failOverStrategy.send(request);
+ OpenSessionResult result = request.send();
sessionID = result.getSessionID();
repositoryUUID = result.getRepositoryUUID();
packageManager.addPackageProxies(result.getPackageInfos());
+ EventUtil.addListener(channel, channelListener);
}
@Override