Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2010-09-22 17:30:25 +0000
committerEike Stepper2010-09-22 17:30:25 +0000
commit16e28b8a6070952bd0fffd9d2c8df6316170d11e (patch)
tree0fd42894b9429ce1f6b470eb7f83bb781dadf828
parent70dda6326113fbf48486e1e1906e04654e4b869f (diff)
downloadcdo-16e28b8a6070952bd0fffd9d2c8df6316170d11e.tar.gz
cdo-16e28b8a6070952bd0fffd9d2c8df6316170d11e.tar.xz
cdo-16e28b8a6070952bd0fffd9d2c8df6316170d11e.zip
[325928] Provide FailoverMonitor server and FailoverAgents to coordinate fail-over scenarios
https://bugs.eclipse.org/bugs/show_bug.cgi?id=325928
-rw-r--r--plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/server/FailoverExample.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionConfigurationImpl.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/FailoverCDOSessionConfigurationImpl.java52
-rw-r--r--plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/net4j/FailoverMonitor.java8
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java10
5 files changed, 55 insertions, 37 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 3662029eab..ae62aafa44 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
@@ -48,6 +48,8 @@ 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.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.log.PrintLogHandler;
import org.h2.jdbcx.JdbcDataSource;
@@ -77,8 +79,8 @@ public abstract class FailoverExample
static
{
// OMPlatform.INSTANCE.setDebugging(true);
- // OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
// OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
+ OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
}
public FailoverExample()
@@ -441,8 +443,8 @@ public abstract class FailoverExample
agent.setConnectorDescription(host + ":" + port);
agent.setRepository(repository);
agent.setGroup(REPOSITORY_GROUP);
- agent.setRate(500L);
- agent.setTimeout(2000L);
+ agent.setRate(60000L);
+ agent.setTimeout(200000L);
agent.activate();
return repository;
@@ -464,13 +466,13 @@ public abstract class FailoverExample
@Override
protected void onAdded(IContainer<AgentProtocol> monitor, AgentProtocol agent)
{
- dump((FailoverMonitor)monitor, "Added", agent);
+ dump((FailoverMonitor)monitor, "Registered", agent);
}
@Override
protected void onRemoved(IContainer<AgentProtocol> monitor, AgentProtocol agent)
{
- dump((FailoverMonitor)monitor, "Removed", agent);
+ dump((FailoverMonitor)monitor, "Deregistered", agent);
}
private void dump(FailoverMonitor monitor, String event, AgentProtocol agent)
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 86cdc3f6ef..a8f6b877a2 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
@@ -80,6 +80,11 @@ public class CDONet4jSessionConfigurationImpl extends CDOSessionConfigurationImp
public void setRepositoryName(String repositoryName)
{
checkNotOpen();
+ uncheckedSetRepositoryName(repositoryName);
+ }
+
+ protected void uncheckedSetRepositoryName(String repositoryName)
+ {
this.repositoryName = repositoryName;
}
@@ -91,6 +96,11 @@ public class CDONet4jSessionConfigurationImpl extends CDOSessionConfigurationImp
public void setConnector(IConnector connector)
{
checkNotOpen();
+ uncheckedSetConnector(connector);
+ }
+
+ protected void uncheckedSetConnector(IConnector connector)
+ {
this.connector = connector;
}
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 814ba8b10f..2ba951c7f1 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
@@ -46,6 +46,10 @@ public class FailoverCDOSessionConfigurationImpl extends CDONet4jSessionConfigur
private String repositoryGroup;
+ private IConnector monitorConnector;
+
+ private SignalProtocol<Object> monitorProtocol;
+
public FailoverCDOSessionConfigurationImpl(String monitorConnectorDescription, String repositoryGroup)
{
this.monitorConnectorDescription = monitorConnectorDescription;
@@ -86,26 +90,6 @@ public class FailoverCDOSessionConfigurationImpl extends CDONet4jSessionConfigur
throw new UnsupportedOperationException();
}
- public void superSetRepositoryName(String repositoryName)
- {
- super.setRepositoryName(repositoryName);
- }
-
- public void superSetConnector(IConnector connector)
- {
- super.setConnector(connector);
- }
-
- public void superSetFailOverStrategy(IFailOverStrategy failOverStrategy)
- {
- super.setFailOverStrategy(failOverStrategy);
- }
-
- public void superSetExceptionHandler(ExceptionHandler exceptionHandler)
- {
- super.setExceptionHandler(exceptionHandler);
- }
-
@Override
public InternalCDOSession createSession()
{
@@ -118,8 +102,8 @@ public class FailoverCDOSessionConfigurationImpl extends CDONet4jSessionConfigur
try
{
List<Object> targets = getViewTargets(session);
- setPassiveUpdateEnabled(session.options().isPassiveUpdateEnabled());
- setPassiveUpdateMode(session.options().getPassiveUpdateMode());
+ uncheckedSetPassiveUpdateEnabled(session.options().isPassiveUpdateEnabled());
+ uncheckedSetPassiveUpdateMode(session.options().getPassiveUpdateMode());
updateConnectorAndRepositoryName();
initProtocol(session);
@@ -147,18 +131,22 @@ public class FailoverCDOSessionConfigurationImpl extends CDONet4jSessionConfigur
System.out.println("Connecting to " + info.getElement1() + "/" + repositoryName);
- superSetConnector(connector);
- superSetRepositoryName(repositoryName);
+ uncheckedSetConnector(connector);
+ uncheckedSetRepositoryName(repositoryName);
}
protected Pair<String, String> queryRepositoryInfoFromMonitor()
{
- SignalProtocol<Object> protocol = new SignalProtocol<Object>("failover-client");
+ if (monitorConnector == null)
+ {
+ monitorConnector = getConnector(monitorConnectorDescription);
+ monitorProtocol = new SignalProtocol<Object>("failover-client");
+ monitorProtocol.open(monitorConnector);
+ }
try
{
- protocol.open(getConnector(monitorConnectorDescription));
- return new RequestWithConfirmation<Pair<String, String>>(protocol, (short)1)
+ return new RequestWithConfirmation<Pair<String, String>>(monitorProtocol, (short)1, "QueryRepositoryInfo")
{
@Override
protected void requesting(ExtendedDataOutputStream out) throws Exception
@@ -181,13 +169,19 @@ public class FailoverCDOSessionConfigurationImpl extends CDONet4jSessionConfigur
}
finally
{
- protocol.close();
+ // protocol.close();
+ // if (connector.getChannels().isEmpty())
+ // {
+ // connector.close();
+ // }
}
}
protected IConnector getConnector(String description)
{
- return (IConnector)getContainer().getElement("org.eclipse.net4j.connectors", "tcp", description);
+ IManagedContainer container = getContainer();
+ // container.removeElement("org.eclipse.net4j.connectors", "tcp", description);
+ return (IConnector)container.getElement("org.eclipse.net4j.connectors", "tcp", description);
}
protected IManagedContainer getContainer()
diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/net4j/FailoverMonitor.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/net4j/FailoverMonitor.java
index eda3e30375..c651c6d344 100644
--- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/net4j/FailoverMonitor.java
+++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/net4j/FailoverMonitor.java
@@ -99,8 +99,9 @@ public class FailoverMonitor extends Container<AgentProtocol>
if (newMasterAgent != null)
{
publishNewMaster(newAgents, newMasterAgent);
- fireElementAddedEvent(agent);
}
+
+ fireElementAddedEvent(agent);
}
public void deregisterAgent(AgentProtocol agent)
@@ -134,8 +135,9 @@ public class FailoverMonitor extends Container<AgentProtocol>
if (newMasterAgent != null)
{
publishNewMaster(newAgents, newMasterAgent);
- fireElementRemovedEvent(agent);
}
+
+ fireElementRemovedEvent(agent);
}
@Override
@@ -345,7 +347,7 @@ public class FailoverMonitor extends Container<AgentProtocol>
switch (signalID)
{
case SIGNAL_QUERY_REPOSITORY_INFO:
- return new IndicationWithResponse(this, SIGNAL_QUERY_REPOSITORY_INFO)
+ return new IndicationWithResponse(this, SIGNAL_QUERY_REPOSITORY_INFO, "QueryRepositoryInfo")
{
@Override
protected void indicating(ExtendedDataInputStream in) throws Exception
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java
index aacc5b13c0..59bcf8ae04 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java
@@ -58,6 +58,11 @@ public abstract class CDOSessionConfigurationImpl implements InternalCDOSessionC
public void setPassiveUpdateEnabled(boolean passiveUpdateEnabled)
{
checkNotOpen();
+ uncheckedSetPassiveUpdateEnabled(passiveUpdateEnabled);
+ }
+
+ protected void uncheckedSetPassiveUpdateEnabled(boolean passiveUpdateEnabled)
+ {
this.passiveUpdateEnabled = passiveUpdateEnabled;
}
@@ -69,6 +74,11 @@ public abstract class CDOSessionConfigurationImpl implements InternalCDOSessionC
public void setPassiveUpdateMode(PassiveUpdateMode passiveUpdateMode)
{
checkNotOpen();
+ uncheckedSetPassiveUpdateMode(passiveUpdateMode);
+ }
+
+ protected void uncheckedSetPassiveUpdateMode(PassiveUpdateMode passiveUpdateMode)
+ {
this.passiveUpdateMode = passiveUpdateMode;
}

Back to the top