Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] recover from lost connection
[CDO] recover from lost connection [message #660464] Fri, 18 March 2011 14:15 Go to next message
Sebastian Paul is currently offline Sebastian PaulFriend
Messages: 106
Registered: July 2009
Senior Member
Hi,
I am investigating how CDO can handle instable connections. For this, I
wrote a small test which starts a TCP proxy. The CDO connection is
routed through this proxy. Stopping the proxy simulates a lost connection.

LOGGER.debug("starting proxy");
startProxy();

LOGGER.debug("creating session");
final CDOSession session = createSession(TCP_PROXY_URI);
try {
LOGGER.debug("stopping proxy (simulate disconnect)");
stopProxy();
Thread.sleep(1000);
LOGGER.debug("restarting proxy (simulate reconnect)");
startProxy();
LOGGER.debug("reactivate session (recover from lost connection)");
LifecycleUtil.activate(session);
LOGGER.debug("refreshing object caches");
session.refresh();
}
finally {
session.close();
stopProxy();
}


However, trying to reactivate the sessin fails with
org.eclipse.net4j.channel.ChannelException: java.lang.NullPointerException
at
org.eclipse.spi.net4j.ChannelMultiplexer.openChannel(Channel Multiplexer.java:171)
at
org.eclipse.spi.net4j.ChannelMultiplexer.openChannel(Channel Multiplexer.java:1)
at
org.eclipse.net4j.signal.failover.NOOPFailOverStrategy.handl eOpen(NOOPFailOverStrategy.java:53)
at org.eclipse.net4j.signal.SignalProtocol.open(SignalProtocol. java:169)
at
org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientProtoco l.openSession(CDOClientProtocol.java:91)
at
org.eclipse.emf.cdo.internal.net4j.CDONet4jSessionConfigurat ionImpl.activateSession(CDONet4jSessionConfigurationImpl.jav a:216)
at
org.eclipse.emf.internal.cdo.session.CDOSessionImpl.doActiva te(CDOSessionImpl.java:999)
at org.eclipse.net4j.util.lifecycle.Lifecycle.activate(Lifecycl e.java:72)
at
org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(Life cycleUtil.java:98)
at
org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(Life cycleUtil.java:88)
....

When skipping the reactivation, any operation on the session quits with
the error
java.lang.IllegalStateException: Not active: CDOSession[cmtmem, 77]
at
org.eclipse.net4j.util.lifecycle.LifecycleUtil.checkActive(L ifecycleUtil.java:71)
at
org.eclipse.net4j.util.lifecycle.Lifecycle.checkActive(Lifec ycle.java:190)
at
org.eclipse.emf.internal.cdo.session.CDOSessionImpl.refresh( CDOSessionImpl.java:505)
....


So what is the correct way to handle this? Is it possible to have this
done automagically?

--
Best regards,
Sebastian Paul
Re: [CDO] recover from lost connection [message #660489 is a reply to message #660464] Fri, 18 March 2011 15:46 Go to previous messageGo to next message
Victor Roldan Betancort is currently offline Victor Roldan BetancortFriend
Messages: 524
Registered: July 2009
Senior Member
Sebastian,

please take a look at ReconnectingCDOSessionConfiguration.

org.eclipse.emf.cdo.net4j.ReconnectingCDOSessionConfiguratio n

org.eclipse.emf.cdo.net4j.CDONet4jUtil.createReconnectingSes sionConfiguration(String,
String, IManagedContainer)

Haven't tried it, but seems what your looking for ;)

Cheers,
Víctor.

Sebastian Paul escribió:
> Hi,
> I am investigating how CDO can handle instable connections. For this, I
> wrote a small test which starts a TCP proxy. The CDO connection is
> routed through this proxy. Stopping the proxy simulates a lost connection.
>
> LOGGER.debug("starting proxy");
> startProxy();
>
> LOGGER.debug("creating session");
> final CDOSession session = createSession(TCP_PROXY_URI);
> try {
> LOGGER.debug("stopping proxy (simulate disconnect)");
> stopProxy();
> Thread.sleep(1000);
> LOGGER.debug("restarting proxy (simulate reconnect)");
> startProxy();
> LOGGER.debug("reactivate session (recover from lost connection)");
> LifecycleUtil.activate(session);
> LOGGER.debug("refreshing object caches");
> session.refresh();
> }
> finally {
> session.close();
> stopProxy();
> }
>
>
> However, trying to reactivate the sessin fails with
> org.eclipse.net4j.channel.ChannelException: java.lang.NullPointerException
> at
> org.eclipse.spi.net4j.ChannelMultiplexer.openChannel(Channel Multiplexer.java:171)
>
> at
> org.eclipse.spi.net4j.ChannelMultiplexer.openChannel(Channel Multiplexer.java:1)
>
> at
> org.eclipse.net4j.signal.failover.NOOPFailOverStrategy.handl eOpen(NOOPFailOverStrategy.java:53)
>
> at org.eclipse.net4j.signal.SignalProtocol.open(SignalProtocol. java:169)
> at
> org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientProtoco l.openSession(CDOClientProtocol.java:91)
>
> at
> org.eclipse.emf.cdo.internal.net4j.CDONet4jSessionConfigurat ionImpl.activateSession(CDONet4jSessionConfigurationImpl.jav a:216)
>
> at
> org.eclipse.emf.internal.cdo.session.CDOSessionImpl.doActiva te(CDOSessionImpl.java:999)
>
> at org.eclipse.net4j.util.lifecycle.Lifecycle.activate(Lifecycl e.java:72)
> at
> org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(Life cycleUtil.java:98)
>
> at
> org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(Life cycleUtil.java:88)
>
> ...
>
> When skipping the reactivation, any operation on the session quits with
> the error
> java.lang.IllegalStateException: Not active: CDOSession[cmtmem, 77]
> at
> org.eclipse.net4j.util.lifecycle.LifecycleUtil.checkActive(L ifecycleUtil.java:71)
>
> at
> org.eclipse.net4j.util.lifecycle.Lifecycle.checkActive(Lifec ycle.java:190)
> at
> org.eclipse.emf.internal.cdo.session.CDOSessionImpl.refresh( CDOSessionImpl.java:505)
>
> ...
>
>
> So what is the correct way to handle this? Is it possible to have this
> done automagically?
>
Re: [CDO] recover from lost connection [message #660499 is a reply to message #660489] Fri, 18 March 2011 16:22 Go to previous messageGo to next message
Sebastian Paul is currently offline Sebastian PaulFriend
Messages: 106
Registered: July 2009
Senior Member
Am 2011-03-18 16:46, schrieb Víctor Roldán Betancort:
> please take a look at ReconnectingCDOSessionConfiguration.

Hi, thanks for the hint. I forgot to mention that I am using the latest
stable release of CDO, which is 3.0.1. As I cannot find the type in my
workspace, I guess it will be introduced in CDO 4.0.

So I have to change my question and ask "How can I recover from a lost
connection in CDO 3.x" ;)

Kind regards, Sebastian
Re: [CDO] recover from lost connection [message #660535 is a reply to message #660499] Fri, 18 March 2011 22:52 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Sebastian,

I recall someone else has tried to backport our respective code from 4.0. And failed :P

It's not a trivial undertaking and I think you'd be better served with CDO 4.0.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Am 18.03.2011 17:22, schrieb Sebastian Paul:
> Am 2011-03-18 16:46, schrieb Víctor Roldán Betancort:
>> please take a look at ReconnectingCDOSessionConfiguration.
>
> Hi, thanks for the hint. I forgot to mention that I am using the latest stable release of CDO, which is 3.0.1. As I cannot find the type in my workspace, I guess it will be introduced in CDO 4.0.
>
> So I have to change my question and ask "How can I recover from a lost connection in CDO 3.x" ;)
>
> Kind regards, Sebastian


Re: [CDO] recover from lost connection [message #662100 is a reply to message #660535] Tue, 29 March 2011 09:55 Go to previous messageGo to next message
Sebastian Paul is currently offline Sebastian PaulFriend
Messages: 106
Registered: July 2009
Senior Member
Hi,
now I have got the time for testing this with CDO 4.0, with partial success:

public void testConnectionLostWithRecovery() throws Exception {
LOGGER.debug("creating session");
final CDOSession session = createReconnectingSession();
try {
LOGGER.debug("stopping proxy (simulate disconnect)");
tcpProxy.stop();
LOGGER.debug("restarting proxy (simulate reconnect)");
tcpProxy.start();
LOGGER.debug("refreshing object caches");
session.refresh();
}
finally {
session.close();
}
}

public void testTransactionWithLostConnectionAndRecovery() throws
Exception {
LOGGER.debug("creating session");
final CDOSession session = createReconnectingSession();
try {
LOGGER.debug("opening transaction");
final CDOTransaction transaction = session.openTransaction();
LOGGER.debug("modifying resource");
final CDOResource resource =
transaction.getOrCreateResource(CDO_RESOURCE_PATH);
resource.getContents().add(createContent());
LOGGER.debug("stopping proxy (simulate disconnect)");
tcpProxy.stop();
LOGGER.debug("restarting proxy (simulate reconnect)");
tcpProxy.start();
LOGGER.debug("committing transaction");
transaction.commit();
}
finally {
session.close();
}
}

private CDOSession createReconnectingSession() {
final String hostAndPort = TCP_PROXY_URI.getHost() + ':' +
TCP_PROXY_URI.getPort();
final Path path = new Path(TCP_PROXY_URI.getPath());
final String repoName = path.segment(0);
final IManagedContainer container =
org.eclipse.net4j.internal.util.container.PluginContainer.ge tInstance();
final CDOSessionConfiguration sessionConfiguration =
CDONet4jUtil.createReconnectingSessionConfiguration(hostAndP ort,
repoName, container);
final CDOSession session = sessionConfiguration.openSession();
return session;
}


The test "testConnectionLostWithRecovery" succeeds.
But the test "testTransactionWithLostConnectionAndRecovery" fails:
org.eclipse.emf.cdo.util.CommitException: java.lang.NullPointerException
at
org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl. commit(CDOTransactionImpl.java:1067)
at
org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl. commit(CDOTransactionImpl.java:1073)
at ITCdoConnection.testTransactionWithLostConnectionAndRecovery
....

Maybe my session configuration is wrong?
I am wondering about the IManagedContainer which I have to provide to
CDONet4jUtil#createReconnectingSessionConfiguration. Currently I am
accessing internal API. What is the correct way to get an instance?


Am 2011-03-18 23:52, schrieb Eike Stepper:
> Hi Sebastian,
>
> I recall someone else has tried to backport our respective code from
> 4.0. And failed :P
>
> It's not a trivial undertaking and I think you'd be better served with
> CDO 4.0.
>
> Cheers
> /Eike
>
> ----
> http://www.esc-net.de
> http://thegordian.blogspot.com
> http://twitter.com/eikestepper
>
>
> Am 18.03.2011 17:22, schrieb Sebastian Paul:
>> Am 2011-03-18 16:46, schrieb Víctor Roldán Betancort:
>>> please take a look at ReconnectingCDOSessionConfiguration.
>>
>> Hi, thanks for the hint. I forgot to mention that I am using the
>> latest stable release of CDO, which is 3.0.1. As I cannot find the
>> type in my workspace, I guess it will be introduced in CDO 4.0.
>>
>> So I have to change my question and ask "How can I recover from a lost
>> connection in CDO 3.x" ;)
>>
>> Kind regards, Sebastian


--
Best regards,
Sebastian Paul
Re: [CDO] recover from lost connection [message #662146 is a reply to message #662100] Tue, 29 March 2011 14:09 Go to previous messageGo to next message
Sebastian Paul is currently offline Sebastian PaulFriend
Messages: 106
Registered: July 2009
Senior Member
Sorry, the stacktrace was not complete. Here is the root cause:

Am 2011-03-29 11:55, schrieb Sebastian Paul:
> The test "testConnectionLostWithRecovery" succeeds.
> But the test "testTransactionWithLostConnectionAndRecovery" fails:
> org.eclipse.emf.cdo.util.CommitException: java.lang.NullPointerException
> at
> org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl. commit(CDOTransactionImpl.java:1067)
>
> at
> org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl. commit(CDOTransactionImpl.java:1073)
>
> at ITCdoConnection.testTransactionWithLostConnectionAndRecovery
> ...
Caused by: java.lang.NullPointerException
at
org.eclipse.emf.internal.cdo.session.DelegatingSessionProtoc ol.getSession(DelegatingSessionProtocol.java:117)
at
org.eclipse.emf.internal.cdo.session.DelegatingSessionProtoc ol.handleException(DelegatingSessionProtocol.java:799)
at
org.eclipse.emf.internal.cdo.session.DelegatingSessionProtoc ol.commitTransaction(DelegatingSessionProtocol.java:270)
at
org.eclipse.emf.internal.cdo.transaction.CDOSingleTransactio nStrategyImpl.commit(CDOSingleTransactionStrategyImpl.java:8 0)
at
org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl. commit(CDOTransactionImpl.java:1053)
... 40 more


--
Best regards,
Sebastian Paul
Re: [CDO] recover from lost connection [message #662193 is a reply to message #662146] Tue, 29 March 2011 16:07 Go to previous messageGo to next message
Sebastian Paul is currently offline Sebastian PaulFriend
Messages: 106
Registered: July 2009
Senior Member
The NPE comes from DelegatingSessionProtocol#commitTransaction.
Obviously, the call
ReconnectingCDOSessionImpl(CDOSessionImpl).setSessionProtoco l(CDOSessionProtocol)
line: 301 is done too late (runs in a different thread).
When I set a breakpoint, the other thread has the chance to set the
delegate and my test succeeds.
Any ideas to get connection recovery running?

--
Best regards,
Sebastian Paul
Re: [CDO] recover from lost connection [message #662254 is a reply to message #662193] Tue, 29 March 2011 21:24 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Sebastian,

I'll be back from the EclipseCon next week. In the meantime please submit a bugzilla and cc caspar_d@nomagicasia.com explicitely (I know he doesn't monitor the newsgroup regularly due to company restrictions).

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper



Am 29.03.2011 09:07, schrieb Sebastian Paul:
> The NPE comes from DelegatingSessionProtocol#commitTransaction.
> Obviously, the call ReconnectingCDOSessionImpl(CDOSessionImpl).setSessionProtoco l(CDOSessionProtocol) line: 301 is done too late (runs in a different thread).
> When I set a breakpoint, the other thread has the chance to set the delegate and my test succeeds.
> Any ideas to get connection recovery running?
>


Re: [CDO] recover from lost connection [message #662325 is a reply to message #662254] Wed, 30 March 2011 08:26 Go to previous message
Sebastian Paul is currently offline Sebastian PaulFriend
Messages: 106
Registered: July 2009
Senior Member
https://bugs.eclipse.org/bugs/show_bug.cgi?id=341319

Am 2011-03-29 23:24, schrieb Eike Stepper:
> please submit a bugzilla

--
Best regards,
Sebastian Paul
Previous Topic:Copying non-containment references
Next Topic:[CDO] SQL query results
Goto Forum:
  


Current Time: Sat Apr 20 00:27:30 GMT 2024

Powered by FUDForum. Page generated in 0.04022 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top