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 2014/02/06 20:30:29 UTC

[1/3] git commit: Updated for changes in connection state logic

Updated Branches:
  refs/heads/CURATOR-86 [created] 1ecaef657


Updated for changes in connection state logic


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

Branch: refs/heads/CURATOR-86
Commit: e55a98fc66e363eaa981dcac5b60ee8bd88e5fc4
Parents: f5384e5
Author: randgalt <ra...@apache.org>
Authored: Wed Feb 5 14:06:59 2014 -0500
Committer: randgalt <ra...@apache.org>
Committed: Wed Feb 5 14:06:59 2014 -0500

----------------------------------------------------------------------
 .../java/org/apache/curator/framework/imps/TestNeverConnected.java | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/e55a98fc/curator-framework/src/test/java/org/apache/curator/framework/imps/TestNeverConnected.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestNeverConnected.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestNeverConnected.java
index 6445d7b..ecfd8b4 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestNeverConnected.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestNeverConnected.java
@@ -58,6 +58,8 @@ public class TestNeverConnected
             client.create().inBackground().forPath("/");
 
             ConnectionState polled = queue.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS);
+            Assert.assertEquals(polled, ConnectionState.SUSPENDED);
+            polled = queue.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS);
             Assert.assertEquals(polled, ConnectionState.LOST);
         }
         finally


[3/3] git commit: Added getAllInstances() to ServiceProvider

Posted by ra...@apache.org.
Added getAllInstances() to ServiceProvider


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

Branch: refs/heads/CURATOR-86
Commit: 1ecaef6570650b58fac97e3d03bf2cf8a541502b
Parents: eb67ad6
Author: randgalt <ra...@apache.org>
Authored: Thu Feb 6 14:30:11 2014 -0500
Committer: randgalt <ra...@apache.org>
Committed: Thu Feb 6 14:30:11 2014 -0500

----------------------------------------------------------------------
 .../apache/curator/x/discovery/ServiceProvider.java   | 10 ++++++++++
 .../x/discovery/details/ServiceProviderImpl.java      | 14 ++++++++++++++
 .../apache/curator/x/discovery/TestServiceCache.java  | 12 +++++++++++-
 3 files changed, 35 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/1ecaef65/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/ServiceProvider.java
----------------------------------------------------------------------
diff --git a/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/ServiceProvider.java b/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/ServiceProvider.java
index e8fcdcf..d606649 100644
--- a/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/ServiceProvider.java
+++ b/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/ServiceProvider.java
@@ -21,6 +21,7 @@ package org.apache.curator.x.discovery;
 
 import org.apache.curator.x.discovery.details.InstanceProvider;
 import java.io.Closeable;
+import java.util.Collection;
 
 /**
  * The main API for Discovery. This class is essentially a facade over a {@link ProviderStrategy}
@@ -45,6 +46,15 @@ public interface ServiceProvider<T> extends Closeable
     public ServiceInstance<T> getInstance() throws Exception;
 
     /**
+     * Return the current available set of instances <b>IMPORTANT: </b> users
+     * should not hold on to the instance returned. They should always get a fresh list.
+     *
+     * @return all known instances
+     * @throws Exception any errors
+     */
+    public Collection<ServiceInstance<T>> getAllInstances() throws Exception;
+
+    /**
      * Take note of an error connecting to the given instance. The instance will potentially
      * be marked as "down" depending on the {@link DownInstancePolicy}.
      *

http://git-wip-us.apache.org/repos/asf/curator/blob/1ecaef65/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceProviderImpl.java
----------------------------------------------------------------------
diff --git a/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceProviderImpl.java b/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceProviderImpl.java
index 40dcf59..5c63836 100644
--- a/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceProviderImpl.java
+++ b/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceProviderImpl.java
@@ -27,6 +27,7 @@ import org.apache.curator.x.discovery.ServiceInstance;
 import org.apache.curator.x.discovery.ServiceProvider;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 import java.util.concurrent.ThreadFactory;
 
@@ -78,6 +79,19 @@ public class ServiceProviderImpl<T> implements ServiceProvider<T>
     }
 
     /**
+     * Return the current available set of instances <b>IMPORTANT: </b> users
+     * should not hold on to the instance returned. They should always get a fresh list.
+     *
+     * @return all known instances
+     * @throws Exception any errors
+     */
+    @Override
+    public Collection<ServiceInstance<T>> getAllInstances() throws Exception
+    {
+        return instanceProvider.getInstances();
+    }
+
+    /**
      * Return an instance for a single use. <b>IMPORTANT: </b> users
      * should not hold on to the instance returned. They should always get a fresh instance.
      *

http://git-wip-us.apache.org/repos/asf/curator/blob/1ecaef65/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceCache.java
----------------------------------------------------------------------
diff --git a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceCache.java b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceCache.java
index 3f4346b..d1dc3bd 100644
--- a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceCache.java
+++ b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/TestServiceCache.java
@@ -19,6 +19,7 @@
 package org.apache.curator.x.discovery;
 
 import com.google.common.collect.Lists;
+import org.apache.curator.test.Timing;
 import org.apache.curator.utils.CloseableUtils;
 import org.apache.curator.framework.CuratorFramework;
 import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -29,6 +30,7 @@ import org.apache.curator.x.discovery.details.ServiceCacheListener;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 import java.io.Closeable;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
@@ -101,6 +103,8 @@ public class TestServiceCache
     @Test
     public void     testViaProvider() throws Exception
     {
+        Timing timing = new Timing();
+
         List<Closeable> closeables = Lists.newArrayList();
         TestingServer server = new TestingServer();
         closeables.add(server);
@@ -127,9 +131,15 @@ public class TestServiceCache
             {
                 Assert.assertTrue(count++ < 5);
                 foundInstance = serviceProvider.getInstance();
-                Thread.sleep(1000);
+                timing.sleepABit();
             }
             Assert.assertEquals(foundInstance, instance);
+
+            ServiceInstance<String>     instance2 = ServiceInstance.<String>builder().address("foo").payload("thing").name("test").port(10064).build();
+            discovery.registerService(instance2);
+            timing.sleepABit();
+            Collection<ServiceInstance<String>> allInstances = serviceProvider.getAllInstances();
+            Assert.assertEquals(allInstances.size(), 2);
         }
         finally
         {


[2/3] git commit: I'm now -5 UTC

Posted by ra...@apache.org.
I'm now -5 UTC


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

Branch: refs/heads/CURATOR-86
Commit: eb67ad6ff36d7e7e2f25afe792c1c0037e139dd2
Parents: e55a98f
Author: randgalt <ra...@apache.org>
Authored: Wed Feb 5 22:31:24 2014 -0500
Committer: randgalt <ra...@apache.org>
Committed: Wed Feb 5 22:31:24 2014 -0500

----------------------------------------------------------------------
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/eb67ad6f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 50e5c3b..981e405 100644
--- a/pom.xml
+++ b/pom.xml
@@ -132,7 +132,7 @@
             <id>randgalt</id>
             <name>Jordan Zimmerman</name>
             <email>randgalt@apache.org</email>
-            <timezone>-8</timezone>
+            <timezone>-5</timezone>
             <roles>
                 <role>Committer</role>
                 <role>PMC Chair</role>