Hi there,

I attach a patch to TestPersistentEphemeralNode that adds to tests that are 
showing 2 problems with ConnectionStateListeners mixed with 
PersistentEphemeralNodes.
- First problem is that first state obtained for listeners is LOST instead of 
CONNECTED
- Second problem is that RECONNECTED state is extremely low.

I made one test for each issue.

Let me know if you prefer a new JIRA for this or if we can reopen CURATOR-53 or 
CURATOR-59

Thanks in advance and congrats for Curator 2.3.0. It has great fixes.

Evaristo


________________________________
 De: Jordan Zimmerman <[email protected]>
Para: [email protected]; Evaristo José Camarero 
<[email protected]> 
Enviado: Sábado 9 de noviembre de 2013 5:42
Asunto: Re: [VOTE] Release Apache Curator version 2.3.0
 

I tested both enclosed tests attached to 
https://issues.apache.org/jira/browse/CURATOR-53 and they both work with 2.3.0. 
 NOTE: for FailurePenStart2 I had to uncomment node.start();

-Jordan


On Nov 5, 2013, at 9:58 AM, Evaristo José Camarero <[email protected]> 
wrote:

> Hi there,
> 
> In previous releases I found problems with PersistentEphemeralNodes 
> themselves or with ConnectionStateListener when used on a CuratorFramework 
> related with a PersistentEphemeralNode.
> 
> I reported the problems in https://issues.apache.org/jira/browse/CURATOR-53
> and from there another JIRA was issued by Jordan: 
> https://issues.apache.org/jira/browse/CURATOR-59
> 
> I tested the release with my app and I found some issues with listeners and 
> PersistentEpehemarlNodes
> 
> I attach one example that shows that listener in CF related with 
> PersistentEphemeralNode is extremely slow compared with a CF non related with 
> a PersistentEphemeralNode
> 
> I see 2 issues here:
> - The client with PEN shows a LOST and the other client does not show it
> - The RECONNECT for the client with PEN is extremely slow
> 
> 
> This is the output of my program in my case:
> 2013/11/05 18:43:18  Client with PEN new stateLOST
> 2013/11/05 18:43:19  Client with PEN new stateCONNECTED
> 2013/11/05 18:43:19  Client without PEN new stateCONNECTED
> Closing server
> 2013/11/05 18:43:19  Client without PEN new stateSUSPENDED
> 2013/11/05 18:43:19  Client with PEN new stateSUSPENDED
> 2013/11/05 18:43:23  Client with PEN new stateLOST
> 2013/11/05 18:43:23  Client without PEN new stateLOST
> Starting server again
> 2013/11/05 18:43:25  Client without PEN new stateRECONNECTED
> 2013/11/05 18:43:48  Client with PEN new stateRECONNECTED
> 
> 
> My app shows also the same problems.
> 
> 
> The rest of functionalities I have tested (LeaderSelector, Caches, Curator 
> Framework looks OK for me). I have test with my own app and I did not find 
> any issue.
> 
> 
> 
> Regards,
> 
> Evaristo
> 
> 
> 
> De: Eric Tschetter <[email protected]>
> Para: [email protected] 
> Enviado: Martes 5 de noviembre de 2013 17:22
> Asunto: Re: [VOTE] Release Apache Curator version 2.3.0
> 
> +1
> 
> 
> On Mon, Nov 4, 2013 at 8:53 PM, Luciano Resende <[email protected]>wrote:
> 
> > On Mon, Nov 4, 2013 at 12:12 PM, Jordan Zimmerman <
> > [email protected]> wrote:
> >
> > > Hello,
> > >
> > > This is a vote to release Apache Curator, version 2.3.0.
> > >
> > > *** Please download, test and vote. The vote will be open for approx. 72
> > > hours
> > >
> > > Note that we are voting upon the source (tag), binaries are provided for
> > > convenience.
> > >
> > > Link to release notes:
> > >
> > >
> > https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12314425&version=12324984
> > >
> > > Staging repo:
> > > https://dist.apache.org/repos/dist/dev/incubator/curator/2.3.0/
> > >        NOTE: still using incubator repo as INFRA hasn’t create TLP yet
> > >
> > > Binary artifacts:
> > > https://repository.apache.org/content/repositories/orgapachecurator-066/
> > >
> > > The tag to be voted upon:
> > >
> > >
> > https://git-wip-us.apache.org/repos/asf?p=curator.git;a=tag;h=8062805203b48b72a4f5cc2cf27fc97a57993afc
> > >
> > > Curator's KEYS file containing PGP keys we use to sign the release:
> > > https://dist.apache.org/repos/dist/release/incubator/curator/KEYS
> > >
> > > [ ] +1  approve
> > > [ ] +0  no opinion
> > > [ ] -1  disapprove (and reason why)
> >
> >
> >
> > +1
> >
> > --
> > Luciano Resende
> > http://people.apache.org/~lresende
> > http://twitter.com/lresende1975
> > http://lresende.blogspot.com/
> >
> 
> 
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java
index 767afb0..53350a3 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java
@@ -43,6 +43,8 @@
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
 
 import static org.testng.Assert.*;
 
@@ -112,6 +114,107 @@
             Closeables.closeQuietly(client);
         }
     }
+    
+
+    @Test
+    public void testListenerConnectedAtStart() throws Exception
+    {
+        server.close();
+
+        Timing timing = new Timing();
+        CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1));
+        try
+        {
+            client.start();
+            PersistentEphemeralNode node = new PersistentEphemeralNode(client, PersistentEphemeralNode.Mode.EPHEMERAL, "/abc/node", "hello".getBytes());
+            node.start();
+
+            final CountDownLatch connectedLatch = new CountDownLatch(1);
+            final AtomicBoolean firstListenerAction = new AtomicBoolean(true);
+            final AtomicReference<ConnectionState> firstListenerState = new AtomicReference<ConnectionState>();
+            ConnectionStateListener listener = new ConnectionStateListener()
+            {
+                @Override
+                public void stateChanged(CuratorFramework client, ConnectionState newState)
+                {
+                    if ( firstListenerAction.compareAndSet(true, false) ) {
+                        firstListenerState.set(newState);
+                        System.out.println("First listener state is " + newState);
+                    }
+                    if ( newState == ConnectionState.CONNECTED )
+                    {
+                        connectedLatch.countDown();
+                    }
+                }
+            };
+            client.getConnectionStateListenable().addListener(listener);
+
+            timing.sleepABit();
+
+            server = new TestingServer(server.getPort());
+
+            Assert.assertTrue(timing.awaitLatch(connectedLatch));
+            Assert.assertFalse(firstListenerAction.get());
+            ConnectionState firstconnectionState = firstListenerState.get();
+            Assert.assertEquals(firstconnectionState, ConnectionState.CONNECTED, "First listener state MUST BE CONNECTED but is " + firstconnectionState);
+
+            timing.sleepABit();
+
+            Assert.assertTrue(node.waitForInitialCreate(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS));
+        }
+        finally
+        {
+            Closeables.closeQuietly(client);
+        }
+    }
+    
+    @Test
+    public void testListenersReconnectedIsFast() throws Exception
+    {
+        server.close();
+
+        Timing timing = new Timing();
+        CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1));
+        try
+        {
+            client.start();
+            PersistentEphemeralNode node = new PersistentEphemeralNode(client, PersistentEphemeralNode.Mode.EPHEMERAL, "/abc/node", "hello".getBytes());
+            node.start();
+
+            final CountDownLatch connectedLatch = new CountDownLatch(1);
+            final CountDownLatch reconnectedLatch = new CountDownLatch(1);
+            ConnectionStateListener listener = new ConnectionStateListener()
+            {
+                @Override
+                public void stateChanged(CuratorFramework client, ConnectionState newState)
+                {
+                    if ( newState == ConnectionState.CONNECTED )
+                    {
+                        connectedLatch.countDown();
+                    }
+                    if ( newState == ConnectionState.RECONNECTED )
+                    {
+                        reconnectedLatch.countDown();
+                    }
+                }
+            };
+            client.getConnectionStateListenable().addListener(listener);
+            timing.sleepABit();
+            server = new TestingServer(server.getPort());
+            Assert.assertTrue(timing.awaitLatch(connectedLatch));
+            timing.sleepABit();
+            Assert.assertTrue(node.waitForInitialCreate(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS));
+            server.close();
+            timing.sleepABit();
+            server = new TestingServer(server.getPort());
+            timing.sleepABit();
+            Assert.assertTrue(timing.awaitLatch(reconnectedLatch));
+        }
+        finally
+        {
+            Closeables.closeQuietly(client);
+        }
+    }
 
     @Test(expectedExceptions = NullPointerException.class)
     public void testNullCurator() throws Exception

Reply via email to