summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2010-10-26 03:27:48 (EDT)
committerCaspar De Groot2010-10-26 03:27:48 (EDT)
commit2bd6aba65752a8b92086fdff38a75dfa2487f690 (patch)
treee0fe8f2aef4a2bd412481952c812259b64feac95
parentf96f93c502dc02eb5dbd13130055363ba792a93a (diff)
downloadcdo-2bd6aba65752a8b92086fdff38a75dfa2487f690.zip
cdo-2bd6aba65752a8b92086fdff38a75dfa2487f690.tar.gz
cdo-2bd6aba65752a8b92086fdff38a75dfa2487f690.tar.bz2
[278181] 278181 Enabling reconnects to enhance fault tolerance
https://bugs.eclipse.org/bugs/show_bug.cgi?id=278181
-rw-r--r--plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/server/FailoverExample.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionConfigurationImpl.java20
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionImpl.java85
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDOSessionRecoveryEventImpl.java40
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/FailoverCDOSessionConfigurationImpl.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/FailoverCDOSessionImpl.java175
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/ReconnectingCDOSessionConfigurationImpl.java90
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/ReconnectingCDOSessionImpl.java127
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/RecoveringCDOSessionConfigurationImpl.java102
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/RecoveringCDOSessionImpl.java299
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDONet4jUtil.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDOSessionConfiguration.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDOSessionRecoveryEvent.java (renamed from plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDOSessionFailoverEvent.java)3
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/FailoverCDOSessionConfiguration.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/ReconnectingCDOSessionConfiguration.java26
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/RecoveringCDOSessionConfiguration.java34
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSession.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionConfiguration.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_327604_Test.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOInteractiveExceptionHandler.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDORetryExceptionHandler.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSession.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java789
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/DelegatingSessionProtocol.java802
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/Net4jUtil.java2
25 files changed, 1698 insertions, 964 deletions
diff --git a/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/server/FailoverExample.java b/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/server/FailoverExample.java
index 1dbfdc1..148b9bd 100644
--- a/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/server/FailoverExample.java
+++ b/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/server/FailoverExample.java
@@ -20,7 +20,7 @@ import org.eclipse.emf.cdo.examples.company.Customer;
import org.eclipse.emf.cdo.net4j.CDONet4jUtil;
import org.eclipse.emf.cdo.net4j.CDOSession;
import org.eclipse.emf.cdo.net4j.CDOSessionConfiguration;
-import org.eclipse.emf.cdo.net4j.CDOSessionFailoverEvent;
+import org.eclipse.emf.cdo.net4j.CDOSessionRecoveryEvent;
import org.eclipse.emf.cdo.server.CDOServerUtil;
import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.IRepositorySynchronizer;
@@ -564,12 +564,12 @@ public abstract class FailoverExample
{
public void notifyEvent(IEvent event)
{
- if (event instanceof CDOSessionFailoverEvent)
+ if (event instanceof CDOSessionRecoveryEvent)
{
- CDOSessionFailoverEvent e = (CDOSessionFailoverEvent)event;
+ CDOSessionRecoveryEvent e = (CDOSessionRecoveryEvent)event;
System.out.println("Failover " + e.getType() + ": " + e.getSource().getRepositoryInfo());
- if (e.getType() == CDOSessionFailoverEvent.Type.FINISHED)
+ if (e.getType() == CDOSessionRecoveryEvent.Type.FINISHED)
{
// Let's see if the TX in the failed-over session is usable:
//
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionConfigurationImpl.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionConfigurationImpl.java
index c013a3a..73b8061 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionConfigurationImpl.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionConfigurationImpl.java
@@ -17,6 +17,7 @@ import org.eclipse.emf.cdo.session.CDORepositoryInfo;
import org.eclipse.emf.internal.cdo.session.CDOSessionConfigurationImpl;
import org.eclipse.net4j.connector.IConnector;
+import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.util.CheckUtil;
import org.eclipse.net4j.util.io.IStreamWrapper;
@@ -38,6 +39,8 @@ public class CDONet4jSessionConfigurationImpl extends CDOSessionConfigurationImp
private IStreamWrapper streamWrapper;
+ private long signalTimeout = SignalProtocol.DEFAULT_TIMEOUT;
+
public CDONet4jSessionConfigurationImpl()
{
}
@@ -49,12 +52,6 @@ public class CDONet4jSessionConfigurationImpl extends CDOSessionConfigurationImp
public void setRepositoryName(String repositoryName)
{
- checkNotOpen();
- uncheckedSetRepositoryName(repositoryName);
- }
-
- protected void uncheckedSetRepositoryName(String repositoryName)
- {
this.repositoryName = repositoryName;
}
@@ -85,6 +82,16 @@ public class CDONet4jSessionConfigurationImpl extends CDOSessionConfigurationImp
this.streamWrapper = streamWrapper;
}
+ public long getSignalTimeout()
+ {
+ return signalTimeout;
+ }
+
+ public void setSignalTimeout(long signalTimeout)
+ {
+ this.signalTimeout = signalTimeout;
+ }
+
@Override
public org.eclipse.emf.cdo.net4j.CDOSession openSession()
{
@@ -110,6 +117,7 @@ public class CDONet4jSessionConfigurationImpl extends CDOSessionConfigurationImp
sessionImpl.setStreamWrapper(streamWrapper);
sessionImpl.setConnector(connector);
sessionImpl.setRepositoryName(repositoryName);
+ sessionImpl.setSignalTimeout(signalTimeout);
}
/**
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionImpl.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionImpl.java
index 4d27cc1..5bc307a 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionImpl.java
@@ -34,9 +34,11 @@ import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
import org.eclipse.emf.internal.cdo.session.CDOSessionImpl;
+import org.eclipse.emf.internal.cdo.session.DelegatingSessionProtocol;
import org.eclipse.net4j.connector.IConnector;
import org.eclipse.net4j.signal.ISignalProtocol;
+import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.util.io.IStreamWrapper;
import org.eclipse.emf.ecore.EcorePackage;
@@ -52,27 +54,61 @@ public class CDONet4jSessionImpl extends CDOSessionImpl implements org.eclipse.e
private IConnector connector;
- protected String repositoryName; // TODO (CD) Eliminate? (Duplicates name in repoInfo field)
+ private String repositoryName;
+
+ private long signalTimeout = SignalProtocol.DEFAULT_TIMEOUT;
public CDONet4jSessionImpl()
{
}
+ public IStreamWrapper getStreamWrapper()
+ {
+ return streamWrapper;
+ }
+
public void setStreamWrapper(IStreamWrapper streamWrapper)
{
this.streamWrapper = streamWrapper;
}
+ public IConnector getConnector()
+ {
+ return connector;
+ }
+
public void setConnector(IConnector connector)
{
this.connector = connector;
}
+ public String getRepositoryName()
+ {
+ return repositoryName;
+ }
+
public void setRepositoryName(String repositoryName)
{
this.repositoryName = repositoryName;
}
+ public long getSignalTimeout()
+ {
+ return signalTimeout;
+ }
+
+ public void setSignalTimeout(long signalTimeout)
+ {
+ this.signalTimeout = signalTimeout;
+
+ // Deal with the possibility that the sessionProtocol has already been created.
+ CDOClientProtocol clientProtocol = getClientProtocol();
+ if (clientProtocol != null)
+ {
+ clientProtocol.setTimeout(this.signalTimeout);
+ }
+ }
+
@Override
public OptionsImpl options()
{
@@ -86,10 +122,11 @@ public class CDONet4jSessionImpl extends CDOSessionImpl implements org.eclipse.e
}
@Override
- protected void activateSession() throws Exception
+ protected void doActivate() throws Exception
{
- super.activateSession();
- OpenSessionResult result = initProtocol();
+ OpenSessionResult result = openSession();
+
+ super.doActivate();
InternalCDOPackageRegistry packageRegistry = getPackageRegistry();
if (packageRegistry == null)
@@ -153,18 +190,45 @@ public class CDONet4jSessionImpl extends CDOSessionImpl implements org.eclipse.e
}
}
- protected OpenSessionResult initProtocol()
+ private CDOClientProtocol createProtocol()
{
CDOClientProtocol protocol = new CDOClientProtocol();
+ protocol.setTimeout(signalTimeout);
protocol.setInfraStructure(this);
if (streamWrapper != null)
{
protocol.setStreamWrapper(streamWrapper);
}
+ protocol.open(connector);
+ return protocol;
+ }
+
+ /**
+ * Gets the CDOClientProtocol instance, which may be wrapped inside a DelegatingSessionProtocol
+ */
+ private CDOClientProtocol getClientProtocol()
+ {
+ CDOSessionProtocol protocol = getSessionProtocol();
+ CDOClientProtocol clientProtocol;
+ if (protocol instanceof DelegatingSessionProtocol)
+ {
+ clientProtocol = (CDOClientProtocol)((DelegatingSessionProtocol)protocol).getDelegate();
+ }
+ else
+ {
+ clientProtocol = (CDOClientProtocol)protocol;
+ }
+ return clientProtocol;
+ }
+
+ protected OpenSessionResult openSession()
+ {
+ CDOClientProtocol protocol = createProtocol();
setSessionProtocol(protocol);
- protocol.open(connector);
+ hookSessionProtocol();
+ // TODO (CD) The next call is on the CDOClientProtocol; shouldn't it be on the DelegatingSessionProtocol instead?
OpenSessionResult result = protocol.openSession(repositoryName, options().isPassiveUpdateEnabled(), options()
.getPassiveUpdateMode());
setSessionID(result.getSessionID());
@@ -175,15 +239,12 @@ public class CDONet4jSessionImpl extends CDOSessionImpl implements org.eclipse.e
}
@Override
- protected void deactivateSession() throws Exception
+ protected void doDeactivate() throws Exception
{
+ super.doDeactivate();
+
getCommitInfoManager().deactivate();
getRevisionManager().deactivate();
-
- // branchManager.deactivate();
- // packageRegistry.deactivate();
-
- super.deactivateSession();
}
/**
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDOSessionRecoveryEventImpl.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDOSessionRecoveryEventImpl.java
new file mode 100644
index 0000000..aeffe7e
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDOSessionRecoveryEventImpl.java
@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.net4j;
+
+import org.eclipse.emf.cdo.net4j.CDOSessionRecoveryEvent;
+import org.eclipse.emf.cdo.session.CDOSession;
+
+/**
+ * @author Caspar De Groot
+ */
+public class CDOSessionRecoveryEventImpl implements CDOSessionRecoveryEvent
+{
+ private CDOSession source;
+
+ private Type type;
+
+ public CDOSessionRecoveryEventImpl(CDOSession source, Type type)
+ {
+ this.type = type;
+ this.source = source;
+ }
+
+ public CDOSession getSource()
+ {
+ return source;
+ }
+
+ public Type getType()
+ {
+ return type;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/FailoverCDOSessionConfigurationImpl.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/FailoverCDOSessionConfigurationImpl.java
index b604cea..16d9263 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/FailoverCDOSessionConfigurationImpl.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/FailoverCDOSessionConfigurationImpl.java
@@ -22,21 +22,20 @@ import org.eclipse.emf.spi.cdo.InternalCDOSession;
* @author Eike Stepper
* @since 4.0
*/
-public class FailoverCDOSessionConfigurationImpl extends CDONet4jSessionConfigurationImpl implements
+public class FailoverCDOSessionConfigurationImpl extends RecoveringCDOSessionConfigurationImpl implements
FailoverCDOSessionConfiguration
{
private String monitorConnectorDescription;
private String repositoryGroup;
- private IManagedContainer container;
-
public FailoverCDOSessionConfigurationImpl(String monitorConnectorDescription, String repositoryGroup,
IManagedContainer container)
{
+ super(container);
+
this.monitorConnectorDescription = monitorConnectorDescription;
this.repositoryGroup = repositoryGroup;
- this.container = container;
}
public String getMonitorConnectorDescription()
@@ -81,6 +80,5 @@ public class FailoverCDOSessionConfigurationImpl extends CDONet4jSessionConfigur
FailoverCDOSessionImpl sessionImpl = (FailoverCDOSessionImpl)session;
sessionImpl.setMonitorConnectionDescription(monitorConnectorDescription);
sessionImpl.setRepositoryGroup(repositoryGroup);
- sessionImpl.setContainer(container);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/FailoverCDOSessionImpl.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/FailoverCDOSessionImpl.java
index f0e8033..34231a5 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/FailoverCDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/FailoverCDOSessionImpl.java
@@ -7,57 +7,31 @@
*
* Contributors:
* Eike Stepper - initial API and implementation
+ * Caspar De Groot - maintenance
*/
package org.eclipse.emf.cdo.internal.net4j;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.net4j.CDOSessionFailoverEvent;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
-import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.net4j.Net4jUtil;
import org.eclipse.net4j.connector.IConnector;
import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.signal.heartbeat.HeartBeatProtocol;
import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
-import org.eclipse.emf.spi.cdo.InternalCDOView;
-
-import java.util.ArrayList;
-import java.util.List;
-
/**
* @author Eike Stepper
*/
-public class FailoverCDOSessionImpl extends CDONet4jSessionImpl
+public class FailoverCDOSessionImpl extends RecoveringCDOSessionImpl
{
- private IManagedContainer container;
-
private String monitorConnectorDescription;
private String repositoryGroup;
- private String repositoryConnectorDescription;
-
public FailoverCDOSessionImpl()
{
}
- public void setContainer(IManagedContainer container)
- {
- this.container = container;
- }
-
public void setMonitorConnectionDescription(String monitorConnectorDescription)
{
this.monitorConnectorDescription = monitorConnectorDescription;
@@ -69,116 +43,26 @@ public class FailoverCDOSessionImpl extends CDONet4jSessionImpl
}
@Override
- protected void sessionProtocolDeactivated()
- {
- fireFailoverEvent(CDOSessionFailoverEvent.Type.STARTED);
-
- unhookSessionProtocol();
- List<AfterFailoverRunnable> runnables = failover();
- CDOSessionProtocol sessionProtocol = hookSessionProtocol();
-
- for (AfterFailoverRunnable runnable : runnables)
- {
- runnable.run(sessionProtocol);
- }
-
- fireFailoverEvent(CDOSessionFailoverEvent.Type.FINISHED);
- }
-
- private void fireFailoverEvent(final CDOSessionFailoverEvent.Type type)
- {
- fireEvent(new CDOSessionFailoverEvent()
- {
- public CDOSession getSource()
- {
- return FailoverCDOSessionImpl.this;
- }
-
- public Type getType()
- {
- return type;
- }
- });
- }
-
- public List<AfterFailoverRunnable> failover()
- {
- try
- {
- List<AfterFailoverRunnable> runnables = new ArrayList<AfterFailoverRunnable>();
- for (InternalCDOView view : getViews())
- {
- runnables.add(new OpenViewRunnable(view));
- }
-
- updateConnectorAndRepositoryName();
- initProtocol();
-
- // The revisionManager, branchManager, and commitInfoManager, hold their own
- // references to the sessionProtocol. We need to update those:
-
- InternalCDORevisionManager revisionManager = getRevisionManager();
- revisionManager.deactivate();
- revisionManager.setRevisionLoader(getSessionProtocol());
- revisionManager.activate();
-
- InternalCDOBranchManager branchManager = getBranchManager();
- branchManager.deactivate();
- branchManager.setBranchLoader(getSessionProtocol());
- branchManager.activate();
-
- InternalCDOCommitInfoManager commitInfoManager = getCommitInfoManager();
- commitInfoManager.deactivate();
- commitInfoManager.setCommitInfoLoader(getSessionProtocol());
- commitInfoManager.activate();
-
- return runnables;
- }
- catch (RuntimeException ex)
- {
- deactivate();
- throw ex;
- }
- catch (Error ex)
- {
- deactivate();
- throw ex;
- }
- }
-
- @Override
- protected void activateSession() throws Exception
- {
- updateConnectorAndRepositoryName();
- super.activateSession();
- }
-
- private void updateConnectorAndRepositoryName()
+ protected void updateConnectorAndRepositoryName()
{
- // System.out.println("Querying fail-over monitor...");
queryRepositoryInfoFromMonitor();
-
- // System.out.println("Connecting to " + repositoryConnectorDescription + "/" + repositoryName + "...");
- IConnector connector = getConnector(repositoryConnectorDescription);
- new HeartBeatProtocol(connector, container).start(1000L, 5000L);
-
+ IConnector connector = createTCPConnector(getUseHeartBeat());
setConnector(connector);
- setRepositoryName(repositoryName);
}
protected void queryRepositoryInfoFromMonitor()
{
- IConnector connector = getConnector(monitorConnectorDescription);
+ IConnector connector = getTCPConnector(monitorConnectorDescription);
SignalProtocol<Object> protocol = new SignalProtocol<Object>("failover-client");
protocol.open(connector);
try
{
- String oldRepositoryConnectorDescription = repositoryConnectorDescription;
- String oldRepositoryName = repositoryName;
+ String oldRepositoryConnectorDescription = getRepositoryConnectorDescription();
+ String oldRepositoryName = getRepositoryName();
- while (ObjectUtil.equals(repositoryConnectorDescription, oldRepositoryConnectorDescription)
- && ObjectUtil.equals(repositoryName, oldRepositoryName))
+ while (ObjectUtil.equals(getRepositoryConnectorDescription(), oldRepositoryConnectorDescription)
+ && ObjectUtil.equals(getRepositoryName(), oldRepositoryName))
{
new RequestWithConfirmation<Boolean>(protocol, (short)1, "QueryRepositoryInfo")
{
@@ -191,8 +75,8 @@ public class FailoverCDOSessionImpl extends CDONet4jSessionImpl
@Override
protected Boolean confirming(ExtendedDataInputStream in) throws Exception
{
- repositoryConnectorDescription = in.readString();
- repositoryName = in.readString();
+ setRepositoryConnectorDescription(in.readString());
+ setRepositoryName(in.readString());
return true;
}
}.send();
@@ -211,41 +95,4 @@ public class FailoverCDOSessionImpl extends CDONet4jSessionImpl
}
}
}
-
- protected IConnector getConnector(String description)
- {
- return Net4jUtil.getConnector(container, "tcp", description);
- }
-
- /**
- * @author Eike Stepper
- */
- public static interface AfterFailoverRunnable
- {
- public void run(CDOSessionProtocol sessionProtocol);
- }
-
- /**
- * @author Eike Stepper
- */
- private final class OpenViewRunnable implements AfterFailoverRunnable
- {
- private int viewID;
-
- private CDOBranchPoint branchPoint;
-
- private boolean transaction;
-
- public OpenViewRunnable(InternalCDOView view)
- {
- viewID = view.getViewID();
- branchPoint = CDOBranchUtil.copyBranchPoint(view);
- transaction = view instanceof CDOTransaction;
- }
-
- public void run(CDOSessionProtocol sessionProtocol)
- {
- sessionProtocol.openView(viewID, branchPoint, !transaction);
- }
- }
}
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/ReconnectingCDOSessionConfigurationImpl.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/ReconnectingCDOSessionConfigurationImpl.java
new file mode 100644
index 0000000..b71f5bf
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/ReconnectingCDOSessionConfigurationImpl.java
@@ -0,0 +1,90 @@
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.net4j;
+
+import org.eclipse.emf.cdo.net4j.ReconnectingCDOSessionConfiguration;
+import org.eclipse.emf.cdo.session.CDOSession.ExceptionHandler;
+
+import org.eclipse.net4j.util.container.IManagedContainer;
+
+import org.eclipse.emf.spi.cdo.InternalCDOSession;
+
+/**
+ * @author Caspar De Groot
+ */
+public class ReconnectingCDOSessionConfigurationImpl extends RecoveringCDOSessionConfigurationImpl implements
+ ReconnectingCDOSessionConfiguration
+{
+ private String hostAndPort;
+
+ private long reconnectInterval = 0;
+
+ private int maxReconnectAttempts = Integer.MAX_VALUE;
+
+ public ReconnectingCDOSessionConfigurationImpl(String hostAndPort, String repositoryName, IManagedContainer container)
+ {
+ super(container);
+
+ this.hostAndPort = hostAndPort;
+ setRepositoryName(repositoryName);
+ }
+
+ public long getReconnectInterval()
+ {
+ return reconnectInterval;
+ }
+
+ public void setReconnectInterval(long reconnectInterval)
+ {
+ this.reconnectInterval = reconnectInterval;
+ }
+
+ public int getMaxReconnectAttempts()
+ {
+ return maxReconnectAttempts;
+ }
+
+ public void setMaxReconnectAttempts(int maxReconnectAttempts)
+ {
+ this.maxReconnectAttempts = maxReconnectAttempts;
+ }
+
+ @Override
+ public void setExceptionHandler(ExceptionHandler handler)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public InternalCDOSession createSession()
+ {
+ ReconnectingCDOSessionImpl session = new ReconnectingCDOSessionImpl();
+
+ // A ReconnectingCDOSessionImpl has its own exceptionHandler; but the configuration mechanism
+ // expects the configuration object (i.e. *this*) to hold a reference to the desired handler.
+ // We therefore fetch the handler from the session and plug it into *this*, so that the
+ // config mechanism can proceed normally. (It will "set" the same handler again.)
+ //
+ super.setExceptionHandler(session.getExceptionHandler());
+ return session;
+ }
+
+ @Override
+ protected void configureSession(InternalCDOSession session)
+ {
+ super.configureSession(session);
+
+ ReconnectingCDOSessionImpl sessionImpl = (ReconnectingCDOSessionImpl)session;
+ sessionImpl.setRepositoryConnectorDescription(hostAndPort);
+ sessionImpl.setReconnectInterval(reconnectInterval);
+ sessionImpl.setMaxReconnectAttempts(maxReconnectAttempts);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/ReconnectingCDOSessionImpl.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/ReconnectingCDOSessionImpl.java
new file mode 100644
index 0000000..1f29b9e
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/ReconnectingCDOSessionImpl.java
@@ -0,0 +1,127 @@
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.net4j;
+
+import org.eclipse.net4j.connector.ConnectorException;
+import org.eclipse.net4j.connector.IConnector;
+
+/**
+ * @author Caspar De Groot
+ */
+public class ReconnectingCDOSessionImpl extends RecoveringCDOSessionImpl
+{
+ private long reconnectInterval = 0;
+
+ private int maxReconnectAttempts = Integer.MAX_VALUE;
+
+ public ReconnectingCDOSessionImpl()
+ {
+ }
+
+ public long getReconnectInterval()
+ {
+ return reconnectInterval;
+ }
+
+ public void setReconnectInterval(long reconnectInterval)
+ {
+ this.reconnectInterval = reconnectInterval;
+ }
+
+ public int getMaxReconnectAttempts()
+ {
+ return maxReconnectAttempts;
+ }
+
+ public void setMaxReconnectAttempts(int maxReconnectAttempts)
+ {
+ this.maxReconnectAttempts = maxReconnectAttempts;
+ }
+
+ @Override
+ public void setConnector(IConnector connector)
+ {
+ // Do nothing (ignore an externally configured connector)
+ // Note: we cannot throw UnsupportedOperationException because the
+ // SessionConfig object will call this.
+ }
+
+ @Override
+ public void setRepositoryConnectorDescription(String description)
+ {
+ if (getRepositoryConnectorDescription() != null)
+ {
+ throw new IllegalStateException("Don't call setRepositoryConnectorDescription more than once");
+ }
+
+ super.setRepositoryConnectorDescription(description);
+ }
+
+ @Override
+ protected void updateConnectorAndRepositoryName()
+ {
+ removeTCPConnector();
+
+ IConnector newConnector = null;
+ int failedAttempts = 0;
+ long startOfLastAttempt = 0;
+
+ while (newConnector == null && failedAttempts < maxReconnectAttempts)
+ {
+ try
+ {
+ if (startOfLastAttempt > 0)
+ {
+ delayAsNeeded(startOfLastAttempt);
+ }
+
+ startOfLastAttempt = System.currentTimeMillis();
+ newConnector = createTCPConnector(getUseHeartBeat());
+ }
+ catch (ConnectorException ex)
+ {
+ failedAttempts++;
+ }
+ }
+
+ if (newConnector == null)
+ {
+ throw new RuntimeException("Recovery failed"); // TODO (CD) Create custom exception type?
+ }
+
+ super.setConnector(newConnector);
+ }
+
+ private void delayAsNeeded(long startOfLastAttempt)
+ {
+ long timeToWait = requiredDelay(startOfLastAttempt);
+ while (timeToWait > 0)
+ {
+ try
+ {
+ Thread.sleep(timeToWait);
+ timeToWait = 0;
+ }
+ catch (InterruptedException ex)
+ {
+ timeToWait = requiredDelay(startOfLastAttempt);
+ }
+ }
+ }
+
+ private long requiredDelay(long startOfLastAttempt)
+ {
+ long now = System.currentTimeMillis();
+ long timeSinceLastAttempt = now - startOfLastAttempt;
+ long timeToWait = reconnectInterval - timeSinceLastAttempt;
+ return timeToWait;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/RecoveringCDOSessionConfigurationImpl.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/RecoveringCDOSessionConfigurationImpl.java
new file mode 100644
index 0000000..fbda8ef
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/RecoveringCDOSessionConfigurationImpl.java
@@ -0,0 +1,102 @@
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.net4j;
+
+import org.eclipse.emf.cdo.net4j.RecoveringCDOSessionConfiguration;
+
+import org.eclipse.net4j.util.container.IManagedContainer;
+
+import org.eclipse.emf.spi.cdo.InternalCDOSession;
+
+/**
+ * @author Caspar De Groot
+ */
+public abstract class RecoveringCDOSessionConfigurationImpl extends CDONet4jSessionConfigurationImpl implements
+ RecoveringCDOSessionConfiguration
+{
+ private IManagedContainer container;
+
+ private boolean heartBeatEnabled;
+
+ private long heartBeatPeriod;
+
+ private long heartBeatTimeout;
+
+ private long connectorTimeout;
+
+ public RecoveringCDOSessionConfigurationImpl(IManagedContainer container)
+ {
+ this.container = container;
+ }
+
+ protected IManagedContainer getContainer()
+ {
+ return container;
+ }
+
+ public long getConnectorTimeout()
+ {
+ return connectorTimeout;
+ }
+
+ public void setConnectorTimeout(long timeout)
+ {
+ connectorTimeout = timeout;
+ }
+
+ public boolean isHeartBeatEnabled()
+ {
+ return heartBeatEnabled;
+ }
+
+ public void setHeartBeatEnabled(boolean enabled)
+ {
+ heartBeatEnabled = enabled;
+ }
+
+ public long getHeartBeatTimeout()
+ {
+ return heartBeatTimeout;
+ }
+
+ public void setHeartBeatTimeout(long timeout)
+ {
+ heartBeatTimeout = timeout;
+ }
+
+ public long getHeartBeatPeriod()
+ {
+ return heartBeatPeriod;
+ }
+
+ public void setHeartBeatPeriod(long period)
+ {
+ heartBeatPeriod = period;
+ }
+
+ @Override
+ protected void configureSession(InternalCDOSession session)
+ {
+ super.configureSession(session);
+
+ if (heartBeatEnabled && (heartBeatPeriod == 0 || heartBeatTimeout == 0))
+ {
+ throw new IllegalStateException("Cannot use a heartbeat with zero value set for period or timeout.");
+ }
+
+ RecoveringCDOSessionImpl sessionImpl = (RecoveringCDOSessionImpl)session;
+ sessionImpl.setContainer(getContainer());
+ sessionImpl.setUseHeartBeat(heartBeatEnabled);
+ sessionImpl.setHeartBeatPeriod(heartBeatPeriod);
+ sessionImpl.setHeartBeatTimeout(heartBeatTimeout);
+ sessionImpl.setConnectorTimeout(connectorTimeout);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/RecoveringCDOSessionImpl.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/RecoveringCDOSessionImpl.java
new file mode 100644
index 0000000..589c8b0
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/RecoveringCDOSessionImpl.java
@@ -0,0 +1,299 @@
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.net4j;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.net4j.CDOSessionRecoveryEvent;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.session.CDOSessionEvent;
+import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
+import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.net4j.Net4jUtil;
+import org.eclipse.net4j.connector.IConnector;
+import org.eclipse.net4j.signal.heartbeat.HeartBeatProtocol;
+import org.eclipse.net4j.util.container.IContainerDelta;
+import org.eclipse.net4j.util.container.IContainerEvent;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+
+import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
+import org.eclipse.emf.spi.cdo.InternalCDOView;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Caspar De Groot
+ */
+public abstract class RecoveringCDOSessionImpl extends CDONet4jSessionImpl
+{
+ private IManagedContainer container;
+
+ private String repositoryConnectorDescription;
+
+ private boolean useHeartBeat;
+
+ private long heartBeatPeriod = 1000L;
+
+ private long heartBeatTimeout = 5000L;
+
+ private long connectorTimeout = 10000L;
+
+ public RecoveringCDOSessionImpl()
+ {
+ setExceptionHandler(new RecoveringExceptionHandler());
+ }
+
+ public long getConnectorTimeout()
+ {
+ return connectorTimeout;
+ }
+
+ public void setConnectorTimeout(long connectorTimeout)
+ {
+ this.connectorTimeout = connectorTimeout;
+ }
+
+ public void setContainer(IManagedContainer container)
+ {
+ this.container = container;
+ }
+
+ public IManagedContainer getContainer()
+ {
+ return container;
+ }
+
+ public void setUseHeartBeat(boolean useHeartBeat)
+ {
+ this.useHeartBeat = useHeartBeat;
+ }
+
+ public boolean getUseHeartBeat()
+ {
+ return useHeartBeat;
+ }
+
+ public void setHeartBeatTimeout(long timeout)
+ {
+ heartBeatTimeout = timeout;
+ }
+
+ public long getHeartBeatTimeout()
+ {
+ return heartBeatTimeout;
+ }
+
+ public void setHeartBeatPeriod(long period)
+ {
+ heartBeatPeriod = period;
+ }
+
+ public long getHeartBeatPeriod()
+ {
+ return heartBeatPeriod;
+ }
+
+ @Override
+ protected void sessionProtocolDeactivated()
+ {
+ recover();
+ }
+
+ protected void recover()
+ {
+ fireEvent(createRecoveryStartedEvent());
+
+ CDOSessionProtocol oldSessionProtocol = getSessionProtocol();
+ unhookSessionProtocol();
+ List<AfterRecoveryRunnable> runnables = recoverSession();
+
+ // Check if the the sessionProtocol was replaced. (This may not be the case
+ // if the protocol is wrapped inside a DelegatingSessionProtocol.)
+ //
+ CDOSessionProtocol newSessionProtocol = getSessionProtocol();
+ if (newSessionProtocol != oldSessionProtocol)
+ {
+ handleProtocolChange(oldSessionProtocol, newSessionProtocol);
+ }
+
+ for (AfterRecoveryRunnable runnable : runnables)
+ {
+ runnable.run(newSessionProtocol);
+ }
+
+ fireEvent(createRecoveryFinishedEvent());
+ }
+
+ protected void handleProtocolChange(CDOSessionProtocol oldProtocol, CDOSessionProtocol newProtocol)
+ {
+ // The revisionManager, branchManager, and commitInfoManager, hold their own
+ // references to the sessionProtocol. We need to update those:
+
+ InternalCDORevisionManager revisionManager = getRevisionManager();
+ revisionManager.deactivate();
+ revisionManager.setRevisionLoader(newProtocol);
+ revisionManager.activate();
+
+ InternalCDOBranchManager branchManager = getBranchManager();
+ branchManager.deactivate();
+ branchManager.setBranchLoader(newProtocol);
+ branchManager.activate();
+
+ InternalCDOCommitInfoManager commitInfoManager = getCommitInfoManager();
+ commitInfoManager.deactivate();
+ commitInfoManager.setCommitInfoLoader(newProtocol);
+ commitInfoManager.activate();
+ }
+
+ protected CDOSessionEvent createRecoveryStartedEvent()
+ {
+ return new CDOSessionRecoveryEventImpl(this, CDOSessionRecoveryEvent.Type.STARTED);
+ }
+
+ protected CDOSessionEvent createRecoveryFinishedEvent()
+ {
+ return new CDOSessionRecoveryEventImpl(this, CDOSessionRecoveryEvent.Type.FINISHED);
+ }
+
+ protected IConnector createTCPConnector(boolean heartBeat)
+ {
+ IConnector connector = getTCPConnector(repositoryConnectorDescription);
+ if (heartBeat)
+ {
+ new HeartBeatProtocol(connector, container).start(heartBeatPeriod, heartBeatTimeout);
+ }
+
+ connector.addListener(new AutoCloser());
+ return connector;
+ }
+
+ protected IConnector getTCPConnector(String description)
+ {
+ return Net4jUtil.getConnector(getContainer(), "tcp", description, connectorTimeout);
+ }
+
+ protected List<AfterRecoveryRunnable> recoverSession()
+ {
+ try
+ {
+ List<AfterRecoveryRunnable> runnables = new ArrayList<AfterRecoveryRunnable>();
+ for (InternalCDOView view : getViews())
+ {
+ runnables.add(new OpenViewRunnable(view));
+ }
+
+ updateConnectorAndRepositoryName();
+ openSession();
+
+ return runnables;
+ }
+ catch (RuntimeException ex)
+ {
+ deactivate();
+ throw ex;
+ }
+ catch (Error ex)
+ {
+ deactivate();
+ throw ex;
+ }
+ }
+
+ protected IConnector removeTCPConnector()
+ {
+ return (IConnector)container.removeElement("org.eclipse.net4j.connectors", "tcp", repositoryConnectorDescription);
+ }
+
+ protected void setRepositoryConnectorDescription(String description)
+ {
+ repositoryConnectorDescription = description;
+ }
+
+ protected String getRepositoryConnectorDescription()
+ {
+ return repositoryConnectorDescription;
+ }
+
+ @Override
+ protected void doActivate() throws Exception
+ {
+ updateConnectorAndRepositoryName();
+ super.doActivate();
+ }
+
+ protected abstract void updateConnectorAndRepositoryName();
+
+ /**
+ * @author Eike Stepper
+ */
+ public static interface AfterRecoveryRunnable
+ {
+ public void run(CDOSessionProtocol sessionProtocol);
+ }
+
+ private class RecoveringExceptionHandler implements ExceptionHandler
+ {
+ public void handleException(CDOSession session, int attempt, Exception exception) throws Exception
+ {
+ recover();
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public final class OpenViewRunnable implements AfterRecoveryRunnable
+ {
+ private int viewID;
+
+ private CDOBranchPoint branchPoint;
+
+ private boolean transaction;
+
+ public OpenViewRunnable(InternalCDOView view)
+ {
+ viewID = view.getViewID();
+ branchPoint = CDOBranchUtil.copyBranchPoint(view);
+ transaction = view instanceof CDOTransaction;
+ }
+
+ public void run(CDOSessionProtocol sessionProtocol)
+ {
+ sessionProtocol.openView(viewID, branchPoint, !transaction);
+ }
+ }
+
+ private static class AutoCloser implements IListener
+ {
+ public void notifyEvent(IEvent event)
+ {
+ if (event instanceof IContainerEvent<?>)
+ {
+ IContainerEvent<?> containerEvent = (IContainerEvent<?>)event;
+ if (containerEvent.getDelta().getKind() == IContainerDelta.Kind.REMOVED)
+ {
+ IConnector connector = (IConnector)event.getSource();
+ if (connector.getChannels().size() == 0)
+ {
+ LifecycleUtil.deactivate(connector);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDONet4jUtil.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDONet4jUtil.java
index 271ea81..6ced663 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDONet4jUtil.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDONet4jUtil.java
@@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.eresource.CDOResourceFactory;
import org.eclipse.emf.cdo.internal.net4j.CDONet4jSessionConfigurationImpl;
import org.eclipse.emf.cdo.internal.net4j.FailoverCDOSessionConfigurationImpl;
import org.eclipse.emf.cdo.internal.net4j.Net4jSessionFactory;
+import org.eclipse.emf.cdo.internal.net4j.ReconnectingCDOSessionConfigurationImpl;
import org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientProtocolFactory;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.view.CDOViewProvider;
@@ -80,6 +81,15 @@ public final class CDONet4jUtil
/**
* @since 4.0
*/
+ public static ReconnectingCDOSessionConfiguration createReconnectingSessionConfiguration(String hostAndPort,
+ String repoName, IManagedContainer container)
+ {
+ return new ReconnectingCDOSessionConfigurationImpl(hostAndPort, repoName, container);
+ }
+
+ /**
+ * @since 4.0
+ */
public static FailoverCDOSessionConfiguration createFailoverSessionConfiguration(String monitorConnectorDescription,
String repositoryGroup)
{
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDOSessionConfiguration.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDOSessionConfiguration.java
index d2ec0f9..f202a65 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDOSessionConfiguration.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDOSessionConfiguration.java
@@ -37,6 +37,16 @@ public interface CDOSessionConfiguration extends org.eclipse.emf.cdo.session.CDO
public void setStreamWrapper(IStreamWrapper streamWrapper);
/**
+ * @since 4.0
+ */
+ public long getSignalTimeout();
+
+ /**
+ * @since 4.0
+ */
+ public void setSignalTimeout(long timeout);
+
+ /**
* @see CDOSession#getPackageRegistry()
*/
public CDOPackageRegistry getPackageRegistry();
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDOSessionFailoverEvent.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDOSessionRecoveryEvent.java
index 8da6229..96679b7 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDOSessionFailoverEvent.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDOSessionRecoveryEvent.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Eike Stepper - initial API and implementation
+ * Caspar De Groot - maintenance
*/
package org.eclipse.emf.cdo.net4j;
@@ -16,7 +17,7 @@ import org.eclipse.emf.cdo.session.CDOSessionEvent;
* @author Eike Stepper
* @since 4.0
*/
-public interface CDOSessionFailoverEvent extends CDOSessionEvent
+public interface CDOSessionRecoveryEvent extends CDOSessionEvent
{
public Type getType();
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/FailoverCDOSessionConfiguration.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/FailoverCDOSessionConfiguration.java
index 1833630..2ae5889 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/FailoverCDOSessionConfiguration.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/FailoverCDOSessionConfiguration.java
@@ -14,7 +14,7 @@ package org.eclipse.emf.cdo.net4j;
* @author Eike Stepper
* @since 4.0
*/
-public interface FailoverCDOSessionConfiguration extends CDOSessionConfiguration
+public interface FailoverCDOSessionConfiguration extends RecoveringCDOSessionConfiguration
{
public String getMonitorConnectorDescription();
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/ReconnectingCDOSessionConfiguration.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/ReconnectingCDOSessionConfiguration.java
new file mode 100644
index 0000000..eb2ecd9
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/ReconnectingCDOSessionConfiguration.java
@@ -0,0 +1,26 @@
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.net4j;
+
+/**
+ * @author Caspar De Groot
+ * @since 4.0
+ */
+public interface ReconnectingCDOSessionConfiguration extends RecoveringCDOSessionConfiguration
+{
+ public long getReconnectInterval();
+
+ public void setReconnectInterval(long interval);
+
+ public int getMaxReconnectAttempts();
+
+ public void setMaxReconnectAttempts(int attempts);
+}
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/RecoveringCDOSessionConfiguration.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/RecoveringCDOSessionConfiguration.java
new file mode 100644
index 0000000..675b18e
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/RecoveringCDOSessionConfiguration.java
@@ -0,0 +1,34 @@
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.net4j;
+
+/**
+ * @author Caspar De Groot
+ * @since 4.0
+ */
+public interface RecoveringCDOSessionConfiguration extends CDOSessionConfiguration
+{
+ public boolean isHeartBeatEnabled();
+
+ public void setHeartBeatEnabled(boolean enabled);
+
+ public long getHeartBeatPeriod();
+
+ public void setHeartBeatPeriod(long period);
+
+ public long getHeartBeatTimeout();
+
+ public void setHeartBeatTimeout(long timeout);
+
+ public long getConnectorTimeout();
+
+ public void setConnectorTimeout(long timeout);
+}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSession.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSession.java
index 89e6230..eb0f8e2 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSession.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSession.java
@@ -65,9 +65,10 @@ public class EmbeddedClientSession extends CDOSessionImpl implements CDOSession
}
@Override
- protected void activateSession() throws Exception
+ protected void doActivate() throws Exception
{
- super.activateSession();
+ super.doActivate();
+
EmbeddedClientSessionProtocol protocol = new EmbeddedClientSessionProtocol(this);
setSessionProtocol(protocol);
protocol.activate();
@@ -86,10 +87,11 @@ public class EmbeddedClientSession extends CDOSessionImpl implements CDOSession
}
@Override
- protected void deactivateSession() throws Exception
+ protected void doDeactivate() throws Exception
{
+ super.doDeactivate();
+
getRevisionManager().deactivate();
setRevisionManager(null);
- super.deactivateSession();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionConfiguration.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionConfiguration.java
index 14731eb..8a4df8d 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionConfiguration.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionConfiguration.java
@@ -60,9 +60,7 @@ public class EmbeddedClientSessionConfiguration extends CDOSessionConfigurationI
CheckUtil.checkState(repository, "Specify a repository"); //$NON-NLS-1$
}
- EmbeddedClientSession session = new EmbeddedClientSession();
- // TODO (CD) Additional config here
- return session;
+ return new EmbeddedClientSession();
}
/**
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_327604_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_327604_Test.java
index 168e706..ce4e035 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_327604_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_327604_Test.java
@@ -18,7 +18,6 @@ import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.emf.cdo.server.mem.MEMStoreUtil;
import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.session.CDOSession.ExceptionHandler;
import org.eclipse.emf.cdo.session.CDOSessionConfiguration;
import org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory;
import org.eclipse.emf.cdo.spi.workspace.InternalCDOWorkspace;
@@ -285,7 +284,7 @@ public class Bugzilla_327604_Test extends AbstractCDOTest
throw new UnsupportedOperationException();
}
- public void setExceptionHandler(ExceptionHandler exceptionHandler)
+ public void setExceptionHandler(CDOSession.ExceptionHandler exceptionHandler)
{
throw new UnsupportedOperationException();
}
@@ -315,7 +314,7 @@ public class Bugzilla_327604_Test extends AbstractCDOTest
throw new UnsupportedOperationException();
}
- public ExceptionHandler getExceptionHandler()
+ public CDOSession.ExceptionHandler getExceptionHandler()
{
throw new UnsupportedOperationException();
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOInteractiveExceptionHandler.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOInteractiveExceptionHandler.java
index f778473..5474d2f 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOInteractiveExceptionHandler.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOInteractiveExceptionHandler.java
@@ -13,7 +13,6 @@ package org.eclipse.emf.cdo.ui;
import org.eclipse.emf.cdo.internal.ui.SharedIcons;
import org.eclipse.emf.cdo.internal.ui.messages.Messages;
import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.session.CDOSession.ExceptionHandler;
import org.eclipse.net4j.util.container.IElementProcessor;
import org.eclipse.net4j.util.container.IManagedContainer;
@@ -39,12 +38,15 @@ import java.text.MessageFormat;
* @author Eike Stepper
* @since 2.0
*/
-public class CDOInteractiveExceptionHandler implements ExceptionHandler, IElementProcessor
+public class CDOInteractiveExceptionHandler implements CDOSession.ExceptionHandler, IElementProcessor
{
public CDOInteractiveExceptionHandler()
{
}
+ /**
+ * @since 4.0
+ */
public void handleException(final CDOSession session, final int attempt, Exception exception) throws Exception
{
final Exception[] result = { exception };
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDORetryExceptionHandler.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDORetryExceptionHandler.java
index cb7b64b..05b1abe 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDORetryExceptionHandler.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDORetryExceptionHandler.java
@@ -42,6 +42,9 @@ public class CDORetryExceptionHandler implements CDOSession.ExceptionHandler
return retries < 0;
}
+ /**
+ * @since 4.0
+ */
public void handleException(CDOSession session, int attempt, Exception exception) throws Exception
{
int max = isRetryingForever() ? Integer.MAX_VALUE : retries;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSession.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSession.java
index bcc9eaf..f459d43 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSession.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSession.java
@@ -108,7 +108,7 @@ public interface CDOSession extends CDOCommonSession, CDOUpdatable, IContainer<C
*/
public CDOCommitInfoManager getCommitInfoManager();
- public ExceptionHandler getExceptionHandler();
+ public CDOSession.ExceptionHandler getExceptionHandler();
/**
* Opens and returns a new {@link CDOTransaction transaction} on the given EMF {@link ResourceSet resource set}.
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
index 5a3ab52..1a836bf 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
@@ -15,30 +15,21 @@
*/
package org.eclipse.emf.internal.cdo.session;
-import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.common.CDOCommonRepository;
-import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchHandler;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPointRange;
import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
import org.eclipse.emf.cdo.common.commit.CDOChangeKind;
import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.common.commit.CDOCommitData;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDAndVersion;
-import org.eclipse.emf.cdo.common.id.CDOIDProvider;
import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.model.lob.CDOLob;
import org.eclipse.emf.cdo.common.model.lob.CDOLobInfo;
import org.eclipse.emf.cdo.common.model.lob.CDOLobStore;
import org.eclipse.emf.cdo.common.protocol.CDOAuthenticator;
import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionHandler;
import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOClearFeatureDelta;
@@ -57,14 +48,9 @@ import org.eclipse.emf.cdo.session.CDOCollectionLoadingPolicy;
import org.eclipse.emf.cdo.session.CDORepositoryInfo;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.session.CDOSessionInvalidationEvent;
-import org.eclipse.emf.cdo.session.remote.CDORemoteSession;
import org.eclipse.emf.cdo.session.remote.CDORemoteSessionManager;
-import org.eclipse.emf.cdo.session.remote.CDORemoteSessionMessage;
-import org.eclipse.emf.cdo.spi.common.CDORawReplicationContext;
-import org.eclipse.emf.cdo.spi.common.CDOReplicationContext;
import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
-import org.eclipse.emf.cdo.spi.common.commit.CDORevisionAvailabilityInfo;
import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
import org.eclipse.emf.cdo.spi.common.model.CDOLobStoreImpl;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
@@ -73,7 +59,6 @@ import org.eclipse.emf.cdo.spi.common.revision.CDOFeatureDeltaVisitorImpl;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
-import org.eclipse.emf.cdo.spi.common.revision.RevisionInfo;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.view.CDOFetchRuleManager;
import org.eclipse.emf.cdo.view.CDOView;
@@ -101,31 +86,25 @@ import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.event.Notifier;
import org.eclipse.net4j.util.io.IOUtil;
import org.eclipse.net4j.util.lifecycle.ILifecycle;
-import org.eclipse.net4j.util.lifecycle.Lifecycle;
import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.options.IOptionsContainer;
import org.eclipse.net4j.util.options.OptionsEvent;
import org.eclipse.emf.common.util.ECollections;
-import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.spi.cdo.AbstractQueryIterator;
import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
import org.eclipse.emf.spi.cdo.CDOSessionProtocol.RefreshSessionResult;
-import org.eclipse.emf.spi.cdo.InternalCDOObject;
import org.eclipse.emf.spi.cdo.InternalCDORemoteSessionManager;
import org.eclipse.emf.spi.cdo.InternalCDOSession;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
import org.eclipse.emf.spi.cdo.InternalCDOView;
import org.eclipse.emf.spi.cdo.InternalCDOViewSet;
-import org.eclipse.emf.spi.cdo.InternalCDOXATransaction.InternalCDOXACommitContext;
import java.io.File;
import java.io.FileNotFoundException;
@@ -136,7 +115,6 @@ import java.io.InputStream;
import java.io.Reader;
import java.text.MessageFormat;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -311,7 +289,21 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
public void setSessionProtocol(CDOSessionProtocol sessionProtocol)
{
- this.sessionProtocol = sessionProtocol;
+ if (exceptionHandler == null)
+ {
+ this.sessionProtocol = sessionProtocol;
+ }
+ else
+ {
+ if (this.sessionProtocol instanceof DelegatingSessionProtocol)
+ {
+ ((DelegatingSessionProtocol)this.sessionProtocol).setDelegate(sessionProtocol);
+ }
+ else
+ {
+ this.sessionProtocol = new DelegatingSessionProtocol(sessionProtocol, exceptionHandler);
+ }
+ }
}
/**
@@ -1171,29 +1163,14 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
protected void doActivate() throws Exception
{
super.doActivate();
- activateSession();
- checkState(sessionProtocol, "sessionProtocol"); //$NON-NLS-1$
- checkState(remoteSessionManager, "remoteSessionManager"); //$NON-NLS-1$
- hookSessionProtocol();
- }
- protected void activateSession() throws Exception
- {
InternalCDORemoteSessionManager remoteSessionManager = new CDORemoteSessionManagerImpl();
remoteSessionManager.setLocalSession(this);
setRemoteSessionManager(remoteSessionManager);
remoteSessionManager.activate();
- }
-
- protected void deactivateSession() throws Exception
- {
- CDORemoteSessionManager remoteSessionManager = getRemoteSessionManager();
- setRemoteSessionManager(null);
- LifecycleUtil.deactivate(remoteSessionManager);
- CDOSessionProtocol sessionProtocol = getSessionProtocol();
- LifecycleUtil.deactivate(sessionProtocol);
- setSessionProtocol(null);
+ checkState(sessionProtocol, "sessionProtocol"); //$NON-NLS-1$
+ checkState(remoteSessionManager, "remoteSessionManager"); //$NON-NLS-1$
}
@Override
@@ -1219,21 +1196,30 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
}
unhookSessionProtocol();
- deactivateSession();
+
+ CDORemoteSessionManager remoteSessionManager = getRemoteSessionManager();
+ setRemoteSessionManager(null);
+ LifecycleUtil.deactivate(remoteSessionManager);
+
+ CDOSessionProtocol sessionProtocol = getSessionProtocol();
+ LifecycleUtil.deactivate(sessionProtocol);
+ setSessionProtocol(null);
+
super.doDeactivate();
}
+ /**
+ * Makes this session start listening to its protocol
+ */
protected CDOSessionProtocol hookSessionProtocol()
{
- if (exceptionHandler != null)
- {
- sessionProtocol = new DelegatingSessionProtocol(sessionProtocol);
- }
-
EventUtil.addListener(sessionProtocol, sessionProtocolListener);
return sessionProtocol;
}
+ /**
+ * Makes this session stop listening to its protocol
+ */
protected void unhookSessionProtocol()
{
EventUtil.removeListener(sessionProtocol, sessionProtocolListener);
@@ -1681,715 +1667,4 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
return "CDOSessionInvalidationEvent[" + commitInfo + "]"; //$NON-NLS-1$ //$NON-NLS-2$
}
}
-
- /**
- * @author Eike Stepper
- */
- public class DelegatingSessionProtocol extends Lifecycle implements CDOSessionProtocol
- {
- private CDOSessionProtocol delegate;
-
- @ExcludeFromDump
- private IListener delegateListener = new LifecycleEventAdapter()
- {
- @Override
- protected void onDeactivated(ILifecycle lifecycle)
- {
- DelegatingSessionProtocol.this.deactivate();
- }
- };
-
- public DelegatingSessionProtocol(CDOSessionProtocol delegate)
- {
- this.delegate = delegate;
- activate();
- }
-
- public CDOSessionProtocol getDelegate()
- {
- return delegate;
- }
-
- public CDOSession getSession()
- {
- return (CDOSession)delegate.getSession();
- }
-
- public boolean cancelQuery(int queryId)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.cancelQuery(queryId);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public void changeSubscription(int viewID, List<CDOID> cdoIDs, boolean subscribeMode, boolean clear)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- delegate.changeSubscription(viewID, cdoIDs, subscribeMode, clear);
- return;
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public void openView(int viewID, CDOBranchPoint branchPoint, boolean readOnly)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- delegate.openView(viewID, branchPoint, readOnly);
- return;
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public boolean[] changeView(int viewID, CDOBranchPoint branchPoint, List<InternalCDOObject> invalidObjects)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.changeView(viewID, branchPoint, invalidObjects);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public void closeView(int viewID)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- if (delegate != null)
- {
- delegate.closeView(viewID);
- }
-
- return;
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public List<byte[]> queryLobs(Set<byte[]> ids)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.queryLobs(ids);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public void loadLob(CDOLobInfo info, Object outputStreamOrWriter)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- delegate.loadLob(info, outputStreamOrWriter);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public void handleRevisions(EClass eClass, CDOBranch branch, boolean exactBranch, long timeStamp,
- boolean exactTime, CDORevisionHandler handler)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- delegate.handleRevisions(eClass, branch, exactBranch, timeStamp, exactTime, handler);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public CommitTransactionResult commitTransaction(int transactionID, String comment, boolean releaseLocks,
- CDOIDProvider idProvider, CDOCommitData commitData, Collection<CDOLob<?>> lobs, OMMonitor monitor)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate
- .commitTransaction(transactionID, comment, releaseLocks, idProvider, commitData, lobs, monitor);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public CommitTransactionResult commitDelegation(CDOBranch branch, String userID, String comment,
- CDOCommitData commitData, Map<CDOID, EClass> detachedObjectTypes, Collection<CDOLob<?>> lobs, OMMonitor monitor)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.commitDelegation(branch, userID, comment, commitData, detachedObjectTypes, lobs, monitor);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public CommitTransactionResult commitXATransactionCancel(InternalCDOXACommitContext xaContext, OMMonitor monitor)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.commitXATransactionCancel(xaContext, monitor);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public CommitTransactionResult commitXATransactionPhase1(InternalCDOXACommitContext xaContext, OMMonitor monitor)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.commitXATransactionPhase1(xaContext, monitor);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public CommitTransactionResult commitXATransactionPhase2(InternalCDOXACommitContext xaContext, OMMonitor monitor)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.commitXATransactionPhase2(xaContext, monitor);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public CommitTransactionResult commitXATransactionPhase3(InternalCDOXACommitContext xaContext, OMMonitor monitor)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.commitXATransactionPhase3(xaContext, monitor);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public RepositoryTimeResult getRepositoryTime()
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.getRepositoryTime();
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public boolean isObjectLocked(CDOView view, CDOObject object, LockType lockType, boolean byOthers)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.isObjectLocked(view, object, lockType, byOthers);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public EPackage[] loadPackages(CDOPackageUnit packageUnit)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.loadPackages(packageUnit);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public Pair<Integer, Long> createBranch(int branchID, BranchInfo branchInfo)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.createBranch(branchID, branchInfo);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public BranchInfo loadBranch(int branchID)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.loadBranch(branchID);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public SubBranchInfo[] loadSubBranches(int branchID)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.loadSubBranches(branchID);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public int loadBranches(int startID, int endID, CDOBranchHandler branchHandler)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.loadBranches(startID, endID, branchHandler);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public void loadCommitInfos(CDOBranch branch, long startTime, long endTime, CDOCommitInfoHandler handler)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- delegate.loadCommitInfos(branch, startTime, endTime, handler);
- return;
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public CDOCommitData loadCommitData(long timeStamp)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.loadCommitData(timeStamp);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public Object loadChunk(InternalCDORevision revision, EStructuralFeature feature, int accessIndex, int fetchIndex,
- int fromIndex, int toIndex)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.loadChunk(revision, feature, accessIndex, fetchIndex, fromIndex, toIndex);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public List<InternalCDORevision> loadRevisions(List<RevisionInfo> infos, CDOBranchPoint branchPoint,
- int referenceChunk, int prefetchDepth)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.loadRevisions(infos, branchPoint, referenceChunk, prefetchDepth);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public InternalCDORevision loadRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int referenceChunk)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.loadRevisionByVersion(id, branchVersion, referenceChunk);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public RefreshSessionResult lockObjects(long lastUpdateTime,
- Map<CDOBranch, Map<CDOID, InternalCDORevision>> viewedRevisions, int viewID, LockType lockType, long timeout)
- throws InterruptedException
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.lockObjects(lastUpdateTime, viewedRevisions, viewID, lockType, timeout);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public void query(CDOView view, AbstractQueryIterator<?> queryResult)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- delegate.query(view, queryResult);
- return;
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public void disablePassiveUpdate()
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- delegate.disablePassiveUpdate();
- return;
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public void setPassiveUpdateMode(PassiveUpdateMode mode)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- delegate.setPassiveUpdateMode(mode);
- return;
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public RefreshSessionResult refresh(long lastUpdateTime,
- Map<CDOBranch, Map<CDOID, InternalCDORevision>> viewedRevisions, int initialChunkSize,
- boolean enablePassiveUpdates)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.refresh(lastUpdateTime, viewedRevisions, initialChunkSize, enablePassiveUpdates);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public void unlockObjects(CDOView view, Collection<? extends CDOObject> objects, LockType lockType)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- delegate.unlockObjects(view, objects, lockType);
- return;
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public List<CDORemoteSession> getRemoteSessions(InternalCDORemoteSessionManager manager, boolean subscribe)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.getRemoteSessions(manager, subscribe);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public Set<Integer> sendRemoteMessage(CDORemoteSessionMessage message, List<CDORemoteSession> recipients)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.sendRemoteMessage(message, recipients);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public boolean unsubscribeRemoteSessions()
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.unsubscribeRemoteSessions();
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public void replicateRepository(CDOReplicationContext context, OMMonitor monitor)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- delegate.replicateRepository(context, monitor);
- return;
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public void replicateRepositoryRaw(CDORawReplicationContext context, OMMonitor monitor)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- delegate.replicateRepositoryRaw(context, monitor);
- return;
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public CDOChangeSetData[] loadChangeSets(CDOBranchPointRange... ranges)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.loadChangeSets(ranges);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- public Set<CDOID> loadMergeData(CDORevisionAvailabilityInfo ancestorInfo, CDORevisionAvailabilityInfo targetInfo,
- CDORevisionAvailabilityInfo sourceInfo)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.loadMergeData(ancestorInfo, targetInfo, sourceInfo);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
- @Override
- protected void doActivate() throws Exception
- {
- super.doActivate();
- EventUtil.addListener(delegate, delegateListener);
- }
-
- @Override
- protected void doDeactivate() throws Exception
- {
- EventUtil.removeListener(delegate, delegateListener);
- LifecycleUtil.deactivate(delegate);
- delegate = null;
- super.doDeactivate();
- }
-
- private void handleException(int attempt, Exception exception)
- {
- try
- {
- getExceptionHandler().handleException(CDOSessionImpl.this, attempt, exception);
- }
- catch (Exception ex)
- {
- throw WrappedException.wrap(ex);
- }
- }
- }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/DelegatingSessionProtocol.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/DelegatingSessionProtocol.java
new file mode 100644
index 0000000..0b6080c
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/DelegatingSessionProtocol.java
@@ -0,0 +1,802 @@
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.internal.cdo.session;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchHandler;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPointRange;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
+import org.eclipse.emf.cdo.common.commit.CDOCommitData;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDProvider;
+import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
+import org.eclipse.emf.cdo.common.model.lob.CDOLob;
+import org.eclipse.emf.cdo.common.model.lob.CDOLobInfo;
+import org.eclipse.emf.cdo.common.revision.CDORevisionHandler;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.session.CDOSession.ExceptionHandler;
+import org.eclipse.emf.cdo.session.remote.CDORemoteSession;
+import org.eclipse.emf.cdo.session.remote.CDORemoteSessionMessage;
+import org.eclipse.emf.cdo.spi.common.CDORawReplicationContext;
+import org.eclipse.emf.cdo.spi.common.CDOReplicationContext;
+import org.eclipse.emf.cdo.spi.common.commit.CDORevisionAvailabilityInfo;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.RevisionInfo;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
+import org.eclipse.net4j.util.WrappedException;
+import org.eclipse.net4j.util.collection.Pair;
+import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
+import org.eclipse.net4j.util.event.EventUtil;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.lifecycle.ILifecycle;
+import org.eclipse.net4j.util.lifecycle.Lifecycle;
+import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.spi.cdo.AbstractQueryIterator;
+import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
+import org.eclipse.emf.spi.cdo.InternalCDOObject;
+import org.eclipse.emf.spi.cdo.InternalCDORemoteSessionManager;
+import org.eclipse.emf.spi.cdo.InternalCDOXATransaction.InternalCDOXACommitContext;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class DelegatingSessionProtocol extends Lifecycle implements CDOSessionProtocol
+{
+ private CDOSessionProtocol delegate;
+
+ private ExceptionHandler exceptionHandler;
+
+ @ExcludeFromDump
+ private IListener delegateListener = new LifecycleEventAdapter()
+ {
+ @Override
+ protected void onDeactivated(ILifecycle lifecycle)
+ {
+ DelegatingSessionProtocol.this.deactivate();
+ }
+ };
+
+ public DelegatingSessionProtocol(CDOSessionProtocol delegate, ExceptionHandler handler)
+ {
+ this.delegate = delegate;
+ exceptionHandler = handler;
+ activate();
+ }
+
+ public CDOSessionProtocol getDelegate()
+ {
+ return delegate;
+ }
+
+ public void setDelegate(CDOSessionProtocol delegate)
+ {
+ if (delegate != null)
+ {
+ unhookDelegate();
+ if (LifecycleUtil.isActive(this.delegate))
+ {
+ LifecycleUtil.deactivate(this.delegate);
+ }
+ }
+
+ this.delegate = delegate;
+ hookDelegate();
+ }
+
+ public CDOSession getSession()
+ {
+ return (CDOSession)delegate.getSession();
+ }
+
+ public boolean cancelQuery(int queryId)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.cancelQuery(queryId);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public void changeSubscription(int viewID, List<CDOID> cdoIDs, boolean subscribeMode, boolean clear)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ delegate.changeSubscription(viewID, cdoIDs, subscribeMode, clear);
+ return;
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public void openView(int viewID, CDOBranchPoint branchPoint, boolean readOnly)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ delegate.openView(viewID, branchPoint, readOnly);
+ return;
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public boolean[] changeView(int viewID, CDOBranchPoint branchPoint, List<InternalCDOObject> invalidObjects)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.changeView(viewID, branchPoint, invalidObjects);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public void closeView(int viewID)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ if (delegate != null)
+ {
+ delegate.closeView(viewID);
+ }
+
+ return;
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public List<byte[]> queryLobs(Set<byte[]> ids)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.queryLobs(ids);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public void loadLob(CDOLobInfo info, Object outputStreamOrWriter)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ delegate.loadLob(info, outputStreamOrWriter);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public void handleRevisions(EClass eClass, CDOBranch branch, boolean exactBranch, long timeStamp, boolean exactTime,
+ CDORevisionHandler handler)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ delegate.handleRevisions(eClass, branch, exactBranch, timeStamp, exactTime, handler);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public CommitTransactionResult commitTransaction(int transactionID, String comment, boolean releaseLocks,
+ CDOIDProvider idProvider, CDOCommitData commitData, Collection<CDOLob<?>> lobs, OMMonitor monitor)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.commitTransaction(transactionID, comment, releaseLocks, idProvider, commitData, lobs, monitor);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public CommitTransactionResult commitDelegation(CDOBranch branch, String userID, String comment,
+ CDOCommitData commitData, Map<CDOID, EClass> detachedObjectTypes, Collection<CDOLob<?>> lobs, OMMonitor monitor)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.commitDelegation(branch, userID, comment, commitData, detachedObjectTypes, lobs, monitor);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public CommitTransactionResult commitXATransactionCancel(InternalCDOXACommitContext xaContext, OMMonitor monitor)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.commitXATransactionCancel(xaContext, monitor);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public CommitTransactionResult commitXATransactionPhase1(InternalCDOXACommitContext xaContext, OMMonitor monitor)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.commitXATransactionPhase1(xaContext, monitor);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public CommitTransactionResult commitXATransactionPhase2(InternalCDOXACommitContext xaContext, OMMonitor monitor)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.commitXATransactionPhase2(xaContext, monitor);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public CommitTransactionResult commitXATransactionPhase3(InternalCDOXACommitContext xaContext, OMMonitor monitor)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.commitXATransactionPhase3(xaContext, monitor);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public RepositoryTimeResult getRepositoryTime()
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.getRepositoryTime();
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public boolean isObjectLocked(CDOView view, CDOObject object, LockType lockType, boolean byOthers)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.isObjectLocked(view, object, lockType, byOthers);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public EPackage[] loadPackages(CDOPackageUnit packageUnit)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.loadPackages(packageUnit);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public Pair<Integer, Long> createBranch(int branchID, BranchInfo branchInfo)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.createBranch(branchID, branchInfo);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public BranchInfo loadBranch(int branchID)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.loadBranch(branchID);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public SubBranchInfo[] loadSubBranches(int branchID)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.loadSubBranches(branchID);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public int loadBranches(int startID, int endID, CDOBranchHandler branchHandler)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.loadBranches(startID, endID, branchHandler);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public void loadCommitInfos(CDOBranch branch, long startTime, long endTime, CDOCommitInfoHandler handler)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ delegate.loadCommitInfos(branch, startTime, endTime, handler);
+ return;
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public CDOCommitData loadCommitData(long timeStamp)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.loadCommitData(timeStamp);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public Object loadChunk(InternalCDORevision revision, EStructuralFeature feature, int accessIndex, int fetchIndex,
+ int fromIndex, int toIndex)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.loadChunk(revision, feature, accessIndex, fetchIndex, fromIndex, toIndex);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public List<InternalCDORevision> loadRevisions(List<RevisionInfo> infos, CDOBranchPoint branchPoint,
+ int referenceChunk, int prefetchDepth)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.loadRevisions(infos, branchPoint, referenceChunk, prefetchDepth);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public InternalCDORevision loadRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int referenceChunk)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.loadRevisionByVersion(id, branchVersion, referenceChunk);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public RefreshSessionResult lockObjects(long lastUpdateTime,
+ Map<CDOBranch, Map<CDOID, InternalCDORevision>> viewedRevisions, int viewID, LockType lockType, long timeout)
+ throws InterruptedException
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.lockObjects(lastUpdateTime, viewedRevisions, viewID, lockType, timeout);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public void query(CDOView view, AbstractQueryIterator<?> queryResult)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ delegate.query(view, queryResult);
+ return;
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public void disablePassiveUpdate()
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ delegate.disablePassiveUpdate();
+ return;
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public void setPassiveUpdateMode(PassiveUpdateMode mode)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ delegate.setPassiveUpdateMode(mode);
+ return;
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public RefreshSessionResult refresh(long lastUpdateTime,
+ Map<CDOBranch, Map<CDOID, InternalCDORevision>> viewedRevisions, int initialChunkSize,
+ boolean enablePassiveUpdates)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.refresh(lastUpdateTime, viewedRevisions, initialChunkSize, enablePassiveUpdates);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public void unlockObjects(CDOView view, Collection<? extends CDOObject> objects, LockType lockType)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ delegate.unlockObjects(view, objects, lockType);
+ return;
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public List<CDORemoteSession> getRemoteSessions(InternalCDORemoteSessionManager manager, boolean subscribe)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.getRemoteSessions(manager, subscribe);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public Set<Integer> sendRemoteMessage(CDORemoteSessionMessage message, List<CDORemoteSession> recipients)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.sendRemoteMessage(message, recipients);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public boolean unsubscribeRemoteSessions()
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.unsubscribeRemoteSessions();
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public void replicateRepository(CDOReplicationContext context, OMMonitor monitor)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ delegate.replicateRepository(context, monitor);
+ return;
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public void replicateRepositoryRaw(CDORawReplicationContext context, OMMonitor monitor)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ delegate.replicateRepositoryRaw(context, monitor);
+ return;
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public CDOChangeSetData[] loadChangeSets(CDOBranchPointRange... ranges)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.loadChangeSets(ranges);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ public Set<CDOID> loadMergeData(CDORevisionAvailabilityInfo ancestorInfo, CDORevisionAvailabilityInfo targetInfo,
+ CDORevisionAvailabilityInfo sourceInfo)
+ {
+ int attempt = 0;
+ for (;;)
+ {
+ try
+ {
+ return delegate.loadMergeData(ancestorInfo, targetInfo, sourceInfo);
+ }
+ catch (Exception ex)
+ {
+ handleException(++attempt, ex);
+ }
+ }
+ }
+
+ @Override
+ protected void doActivate() throws Exception
+ {
+ super.doActivate();
+ hookDelegate();
+ }
+
+ private void hookDelegate()
+ {
+ EventUtil.addListener(delegate, delegateListener);
+ }
+
+ @Override
+ protected void doDeactivate() throws Exception
+ {
+ unhookDelegate();
+ LifecycleUtil.deactivate(delegate);
+ delegate = null;
+ super.doDeactivate();
+ }
+
+ private void unhookDelegate()
+ {
+ EventUtil.removeListener(delegate, delegateListener);
+ }
+
+ private void handleException(int attempt, Exception exception)
+ {
+ try
+ {
+ exceptionHandler.handleException(getSession(), attempt, exception);
+ }
+ catch (Exception ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/Net4jUtil.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/Net4jUtil.java
index 881514a..e37eb70 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/Net4jUtil.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/Net4jUtil.java
@@ -82,7 +82,7 @@ public final class Net4jUtil
}
catch (ConnectorException ex)
{
- container.removeElement("org.eclipse.net4j.connectors", type, description);
+ container.removeElement(ConnectorFactory.PRODUCT_GROUP, type, description);
throw ex;
}