You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2015/01/12 21:31:11 UTC

[1/6] curator git commit: If zookeeper is down when discovery is started, it fails to register when the zookeeper comes up for the first time. This commit has fix for this issue

Repository: curator
Updated Branches:
  refs/heads/CURATOR-175 [created] 7a97315dd


If zookeeper is down when discovery is started, it fails to register
when the zookeeper comes up for the first time. This commit has fix for
this issue

Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/4190147d
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/4190147d
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/4190147d

Branch: refs/heads/CURATOR-175
Commit: 4190147dbedb350ce1d42eb1ace86de0d0c9aef9
Parents: ef2ca57
Author: gopi <go...@gmail.com>
Authored: Sun Dec 28 19:23:26 2014 +0530
Committer: gopi <go...@gmail.com>
Committed: Sun Dec 28 19:23:26 2014 +0530

----------------------------------------------------------------------
 .../discovery/details/ServiceDiscoveryImpl.java |  8 +++--
 .../x/discovery/TestServiceDiscovery.java       | 35 ++++++++++++++++++++
 2 files changed, 41 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/4190147d/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceDiscoveryImpl.java
----------------------------------------------------------------------
diff --git a/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceDiscoveryImpl.java b/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceDiscoveryImpl.java
index ad6ce89..5f001a1 100644
--- a/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceDiscoveryImpl.java
+++ b/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceDiscoveryImpl.java
@@ -69,7 +69,7 @@ public class ServiceDiscoveryImpl<T> implements ServiceDiscovery<T>
         @Override
         public void stateChanged(CuratorFramework client, ConnectionState newState)
         {
-            if ( newState == ConnectionState.RECONNECTED )
+            if ( newState == ConnectionState.RECONNECTED || newState == ConnectionState.CONNECTED )
             {
                 try
                 {
@@ -109,8 +109,12 @@ public class ServiceDiscoveryImpl<T> implements ServiceDiscovery<T>
     @Override
     public void start() throws Exception
     {
+        try {
+    	    reRegisterServices();
+        } catch (Exception ex) {
+            log.error("Could not register instances", ex);
+        }
         client.getConnectionStateListenable().addListener(connectionStateListener);
-        reRegisterServices();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/curator/blob/4190147d/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceDiscovery.java
----------------------------------------------------------------------
diff --git a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceDiscovery.java b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceDiscovery.java
index 73de7fc..a9a8896 100644
--- a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceDiscovery.java
+++ b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceDiscovery.java
@@ -24,6 +24,7 @@ import org.apache.curator.test.BaseClassForTests;
 import org.apache.curator.utils.CloseableUtils;
 import org.apache.curator.framework.CuratorFramework;
 import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.retry.RetryNTimes;
 import org.apache.curator.retry.RetryOneTime;
 import org.apache.curator.test.KillSession;
 import org.apache.curator.test.Timing;
@@ -263,4 +264,38 @@ public class TestServiceDiscovery extends BaseClassForTests
             }
         }
     }
+    
+    @Test
+    public void         testNoServerOnStart() throws Exception
+    {
+        server.stop();
+        List<Closeable>     closeables = Lists.newArrayList();
+        try
+        {
+            CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryNTimes(0,1000));
+            closeables.add(client);
+            client.start();
+            
+            ServiceInstance<String>     instance = ServiceInstance.<String>builder().payload("thing").name("test").port(10064).build();
+            ServiceDiscovery<String>    discovery = ServiceDiscoveryBuilder.builder(String.class).basePath("/test").client(client).thisInstance(instance).build();
+            closeables.add(discovery);
+            discovery.start();
+
+            server.restart();
+            Assert.assertEquals(discovery.queryForNames(), Arrays.asList("test"));
+
+            List<ServiceInstance<String>> list = Lists.newArrayList();
+            list.add(instance);
+            Assert.assertEquals(discovery.queryForInstances("test"), list);
+        }
+        finally
+        {
+            Collections.reverse(closeables);
+            for ( Closeable c : closeables )
+            {
+                CloseableUtils.closeQuietly(c);
+            }
+        }
+    }
+
 }


[5/6] curator git commit: Merge branch 'CURATOR-175.2' into CURATOR-175

Posted by ra...@apache.org.
Merge branch 'CURATOR-175.2' into CURATOR-175


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/f2f03ce8
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/f2f03ce8
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/f2f03ce8

Branch: refs/heads/CURATOR-175
Commit: f2f03ce82179d74177f2595e0221ee4cbbcd86fa
Parents: ab6ad24 94fce2c
Author: randgalt <ra...@apache.org>
Authored: Mon Jan 12 15:30:07 2015 -0500
Committer: randgalt <ra...@apache.org>
Committed: Mon Jan 12 15:30:07 2015 -0500

----------------------------------------------------------------------
 .../org/apache/curator/utils/ThreadUtils.java   |   5 +
 .../framework/imps/CuratorFrameworkImpl.java    |   2 +-
 .../imps/CuratorTempFrameworkImpl.java          |  10 +-
 .../framework/recipes/cache/TestTreeCache.java  |  14 +++
 .../x/discovery/ServiceDiscoveryBuilder.java    |  45 +++++---
 .../discovery/details/ServiceDiscoveryImpl.java |  82 ++++++++++++---
 .../x/discovery/TestServiceDiscovery.java       | 102 ++++++++++++-------
 .../discovery/details/TestWatchedInstances.java |  94 +++++++++++++++++
 8 files changed, 289 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/f2f03ce8/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceDiscovery.java
----------------------------------------------------------------------


[3/6] curator git commit: use standard test retry

Posted by ra...@apache.org.
use standard test retry


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/ab6ad24e
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/ab6ad24e
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/ab6ad24e

Branch: refs/heads/CURATOR-175
Commit: ab6ad24ef368da6921c2aedcb866f4f41ee06d8a
Parents: 9a487e2
Author: randgalt <ra...@apache.org>
Authored: Sun Jan 4 19:38:18 2015 -0500
Committer: randgalt <ra...@apache.org>
Committed: Sun Jan 4 19:38:18 2015 -0500

----------------------------------------------------------------------
 .../org/apache/curator/x/discovery/TestServiceDiscovery.java  | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/ab6ad24e/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceDiscovery.java
----------------------------------------------------------------------
diff --git a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceDiscovery.java b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceDiscovery.java
index a9a8896..4188a70 100644
--- a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceDiscovery.java
+++ b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceDiscovery.java
@@ -20,14 +20,13 @@ package org.apache.curator.x.discovery;
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
-import org.apache.curator.test.BaseClassForTests;
-import org.apache.curator.utils.CloseableUtils;
 import org.apache.curator.framework.CuratorFramework;
 import org.apache.curator.framework.CuratorFrameworkFactory;
-import org.apache.curator.retry.RetryNTimes;
 import org.apache.curator.retry.RetryOneTime;
+import org.apache.curator.test.BaseClassForTests;
 import org.apache.curator.test.KillSession;
 import org.apache.curator.test.Timing;
+import org.apache.curator.utils.CloseableUtils;
 import org.apache.curator.x.discovery.details.JsonInstanceSerializer;
 import org.apache.curator.x.discovery.details.ServiceDiscoveryImpl;
 import org.testng.Assert;
@@ -272,7 +271,7 @@ public class TestServiceDiscovery extends BaseClassForTests
         List<Closeable>     closeables = Lists.newArrayList();
         try
         {
-            CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryNTimes(0,1000));
+            CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
             closeables.add(client);
             client.start();
             


[4/6] curator git commit: Look for connection errors and merely log when starting. Also, reset instances on initial connection

Posted by ra...@apache.org.
Look for connection errors and merely log when starting. Also, reset instances on initial connection


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/94fce2ca
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/94fce2ca
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/94fce2ca

Branch: refs/heads/CURATOR-175
Commit: 94fce2ca94f827cd3d3c793dbf044bff39ef52a7
Parents: 40b2cd8
Author: randgalt <ra...@apache.org>
Authored: Mon Jan 12 15:28:56 2015 -0500
Committer: randgalt <ra...@apache.org>
Committed: Mon Jan 12 15:28:56 2015 -0500

----------------------------------------------------------------------
 .../discovery/details/ServiceDiscoveryImpl.java | 11 +++++--
 .../x/discovery/TestServiceDiscovery.java       | 33 ++++++++++++++++++++
 2 files changed, 42 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/94fce2ca/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceDiscoveryImpl.java
----------------------------------------------------------------------
diff --git a/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceDiscoveryImpl.java b/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceDiscoveryImpl.java
index 3a92e7a..6472262 100644
--- a/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceDiscoveryImpl.java
+++ b/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceDiscoveryImpl.java
@@ -69,7 +69,7 @@ public class ServiceDiscoveryImpl<T> implements ServiceDiscovery<T>
         @Override
         public void stateChanged(CuratorFramework client, ConnectionState newState)
         {
-            if ( newState == ConnectionState.RECONNECTED )
+            if ( (newState == ConnectionState.RECONNECTED) || (newState == ConnectionState.CONNECTED) )
             {
                 try
                 {
@@ -111,8 +111,15 @@ public class ServiceDiscoveryImpl<T> implements ServiceDiscovery<T>
     @Override
     public void start() throws Exception
     {
+        try
+        {
+            reRegisterServices();
+        }
+        catch ( KeeperException e )
+        {
+            log.error("Could not register instances - will try again later", e);
+        }
         client.getConnectionStateListenable().addListener(connectionStateListener);
-        reRegisterServices();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/curator/blob/94fce2ca/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceDiscovery.java
----------------------------------------------------------------------
diff --git a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceDiscovery.java b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceDiscovery.java
index 0465599..6eb9ebb 100644
--- a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceDiscovery.java
+++ b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceDiscovery.java
@@ -264,4 +264,37 @@ public class TestServiceDiscovery extends BaseClassForTests
             }
         }
     }
+
+    @Test
+    public void testNoServerOnStart() throws Exception
+    {
+        server.stop();
+        List<Closeable>     closeables = Lists.newArrayList();
+        try
+        {
+            CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
+            closeables.add(client);
+            client.start();
+
+            ServiceInstance<String>     instance = ServiceInstance.<String>builder().payload("thing").name("test").port(10064).build();
+            ServiceDiscovery<String>    discovery = ServiceDiscoveryBuilder.builder(String.class).basePath("/test").client(client).thisInstance(instance).build();
+            closeables.add(discovery);
+            discovery.start();
+
+            server.restart();
+            Assert.assertEquals(discovery.queryForNames(), Arrays.asList("test"));
+
+            List<ServiceInstance<String>> list = Lists.newArrayList();
+            list.add(instance);
+            Assert.assertEquals(discovery.queryForInstances("test"), list);
+        }
+        finally
+        {
+            Collections.reverse(closeables);
+            for ( Closeable c : closeables )
+            {
+                CloseableUtils.closeQuietly(c);
+            }
+        }
+    }
 }


[6/6] curator git commit: remove duplicate

Posted by ra...@apache.org.
remove duplicate


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/7a97315d
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/7a97315d
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/7a97315d

Branch: refs/heads/CURATOR-175
Commit: 7a97315dd264a61cb3ea8c02b484cf744e39298c
Parents: f2f03ce
Author: randgalt <ra...@apache.org>
Authored: Mon Jan 12 15:30:43 2015 -0500
Committer: randgalt <ra...@apache.org>
Committed: Mon Jan 12 15:30:43 2015 -0500

----------------------------------------------------------------------
 .../x/discovery/TestServiceDiscovery.java       | 34 --------------------
 1 file changed, 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/7a97315d/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceDiscovery.java
----------------------------------------------------------------------
diff --git a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceDiscovery.java b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceDiscovery.java
index 4a586b4..6eb9ebb 100644
--- a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceDiscovery.java
+++ b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceDiscovery.java
@@ -297,38 +297,4 @@ public class TestServiceDiscovery extends BaseClassForTests
             }
         }
     }
-    
-    @Test
-    public void         testNoServerOnStart() throws Exception
-    {
-        server.stop();
-        List<Closeable>     closeables = Lists.newArrayList();
-        try
-        {
-            CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
-            closeables.add(client);
-            client.start();
-            
-            ServiceInstance<String>     instance = ServiceInstance.<String>builder().payload("thing").name("test").port(10064).build();
-            ServiceDiscovery<String>    discovery = ServiceDiscoveryBuilder.builder(String.class).basePath("/test").client(client).thisInstance(instance).build();
-            closeables.add(discovery);
-            discovery.start();
-
-            server.restart();
-            Assert.assertEquals(discovery.queryForNames(), Arrays.asList("test"));
-
-            List<ServiceInstance<String>> list = Lists.newArrayList();
-            list.add(instance);
-            Assert.assertEquals(discovery.queryForInstances("test"), list);
-        }
-        finally
-        {
-            Collections.reverse(closeables);
-            for ( Closeable c : closeables )
-            {
-                CloseableUtils.closeQuietly(c);
-            }
-        }
-    }
-
 }


[2/6] curator git commit: Merge branch 'CURATOR-175' of https://github.com/gopikori/curator into CURATOR-175

Posted by ra...@apache.org.
Merge branch 'CURATOR-175' of https://github.com/gopikori/curator into CURATOR-175


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/9a487e23
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/9a487e23
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/9a487e23

Branch: refs/heads/CURATOR-175
Commit: 9a487e23b18be80d85188b0d19647883a9007d32
Parents: 3eea676 4190147
Author: randgalt <ra...@apache.org>
Authored: Sun Jan 4 19:34:19 2015 -0500
Committer: randgalt <ra...@apache.org>
Committed: Sun Jan 4 19:34:19 2015 -0500

----------------------------------------------------------------------
 .../discovery/details/ServiceDiscoveryImpl.java |  8 +++--
 .../x/discovery/TestServiceDiscovery.java       | 35 ++++++++++++++++++++
 2 files changed, 41 insertions(+), 2 deletions(-)
----------------------------------------------------------------------