summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2010-10-13 06:05:51 (EDT)
committerCaspar De Groot2010-10-13 06:05:51 (EDT)
commit5048ec0ffc5b19002ab771ffd5fbb9b5a7cb5ce9 (patch)
treefca9fb34c290e81f9dbf539fb5c9742415b728d9
parent259e1fed023ca87bb17f4c5edb924c1a6a5963bc (diff)
downloadcdo-5048ec0ffc5b19002ab771ffd5fbb9b5a7cb5ce9.zip
cdo-5048ec0ffc5b19002ab771ffd5fbb9b5a7cb5ce9.tar.gz
cdo-5048ec0ffc5b19002ab771ffd5fbb9b5a7cb5ce9.tar.bz2
[327428] Failed-over session broken
https://bugs.eclipse.org/bugs/show_bug.cgi?id=327428
-rw-r--r--plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/server/FailoverExample.java35
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/FailoverCDOSessionConfigurationImpl.java19
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/FailoverCDOSessionImpl.java26
3 files changed, 70 insertions, 10 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 9283031..b8b5ac9 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
@@ -15,6 +15,8 @@ import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
import org.eclipse.emf.cdo.common.revision.cache.CDORevisionCache;
import org.eclipse.emf.cdo.common.util.RepositoryStateChangedEvent;
import org.eclipse.emf.cdo.common.util.RepositoryTypeChangedEvent;
+import org.eclipse.emf.cdo.examples.company.CompanyFactory;
+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;
@@ -33,6 +35,8 @@ import org.eclipse.emf.cdo.server.net4j.FailoverMonitor.AgentProtocol;
import org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory;
import org.eclipse.emf.cdo.spi.server.InternalFailoverParticipant;
import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
import org.eclipse.net4j.Net4jUtil;
import org.eclipse.net4j.acceptor.IAcceptor;
@@ -550,7 +554,13 @@ public abstract class FailoverExample
CDOSessionConfiguration configuration = CDONet4jUtil.createFailoverSessionConfiguration(REPOSITORY_MONITOR_HOST
+ ":" + REPOSITORY_MONITOR_PORT, REPOSITORY_GROUP, container);
- CDOSession session = configuration.openSession();
+ final CDOSession session = configuration.openSession();
+ System.out.println("Connected");
+
+ final CDOTransaction tx = session.openTransaction();
+ addObject(tx);
+ System.out.println("Succesfully committed an object to the original tx/session");
+
session.addListener(new IListener()
{
public void notifyEvent(IEvent event)
@@ -559,16 +569,37 @@ public abstract class FailoverExample
{
CDOSessionFailoverEvent e = (CDOSessionFailoverEvent)event;
System.out.println("Failover " + e.getType() + ": " + e.getSource().getRepositoryInfo());
+
+ if (e.getType() == CDOSessionFailoverEvent.Type.FINISHED)
+ {
+ // Let's see if the TX in the failed-over session is usable:
+ //
+ addObject(tx);
+ System.out.println("Succesfully committed an object to the failed-over tx/session");
+ }
}
}
});
- System.out.println("Connected");
while (!session.isClosed())
{
Thread.sleep(100);
}
}
+
+ private static void addObject(CDOTransaction tx)
+ {
+ try
+ {
+ Customer customer = CompanyFactory.eINSTANCE.createCustomer();
+ tx.getOrCreateResource("/r1").getContents().add(customer);
+ tx.commit();
+ }
+ catch (CommitException x)
+ {
+ throw new RuntimeException(x);
+ }
+ }
}
}
}
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 f805e07..ee92d40 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
@@ -70,11 +70,18 @@ public class FailoverCDOSessionConfigurationImpl extends CDONet4jSessionConfigur
@Override
public InternalCDOSession createSession()
{
- FailoverCDOSessionImpl session = new FailoverCDOSessionImpl();
- session.setMonitorConnectionDescription(monitorConnectorDescription);
- session.setRepositoryGroup(repositoryGroup);
- session.setContainer(container);
- session.updateConnectorAndRepositoryName(); // TODO (CD) Can't we leave it to the session to call this?
- return session;
+ return new FailoverCDOSessionImpl();
+ }
+
+ @Override
+ protected void configureSession(InternalCDOSession session)
+ {
+ super.configureSession(session);
+
+ FailoverCDOSessionImpl sessionImpl = (FailoverCDOSessionImpl)session;
+ sessionImpl.setMonitorConnectionDescription(monitorConnectorDescription);
+ sessionImpl.setRepositoryGroup(repositoryGroup);
+ sessionImpl.setContainer(container);
+ sessionImpl.updateConnectorAndRepositoryName(); // TODO (CD) Can't we leave it to the session to call this?
}
}
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 f27ad87..28d5642 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
@@ -14,6 +14,9 @@ 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.connector.IConnector;
@@ -109,6 +112,25 @@ public class FailoverCDOSessionImpl extends CDONet4jSessionImpl
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)
@@ -126,10 +148,10 @@ public class FailoverCDOSessionImpl extends CDONet4jSessionImpl
// TODO (CD) Default access allows config object to call this once. Does this make sense?
void updateConnectorAndRepositoryName()
{
- System.out.println("Querying fail-over monitor...");
+ // System.out.println("Querying fail-over monitor...");
queryRepositoryInfoFromMonitor();
- System.out.println("Connecting to " + repositoryConnectorDescription + "/" + repositoryName + "...");
+ // System.out.println("Connecting to " + repositoryConnectorDescription + "/" + repositoryName + "...");
IConnector connector = getConnector(repositoryConnectorDescription);
new HeartBeatProtocol(connector, container).start(1000L, 5000L);