Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2010-10-13 10:05:51 +0000
committerCaspar De Groot2010-10-13 10:05:51 +0000
commit5048ec0ffc5b19002ab771ffd5fbb9b5a7cb5ce9 (patch)
treefca9fb34c290e81f9dbf539fb5c9742415b728d9 /plugins/org.eclipse.emf.cdo.examples/src
parent259e1fed023ca87bb17f4c5edb924c1a6a5963bc (diff)
downloadcdo-5048ec0ffc5b19002ab771ffd5fbb9b5a7cb5ce9.tar.gz
cdo-5048ec0ffc5b19002ab771ffd5fbb9b5a7cb5ce9.tar.xz
cdo-5048ec0ffc5b19002ab771ffd5fbb9b5a7cb5ce9.zip
[327428] Failed-over session broken
https://bugs.eclipse.org/bugs/show_bug.cgi?id=327428
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.examples/src')
-rw-r--r--plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/server/FailoverExample.java35
1 files changed, 33 insertions, 2 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 928303113a..b8b5ac9cba 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);
+ }
+ }
}
}
}

Back to the top