curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cammcken...@apache.org
Subject [50/50] curator git commit: Merge branch 'master' into CURATOR-154
Date Tue, 21 Apr 2015 23:07:47 GMT
Merge branch 'master' into CURATOR-154

Conflicts:
	curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java


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

Branch: refs/heads/CURATOR-154
Commit: 6e16d0d5c35fa02b6976037d230a0e25e25d7572
Parents: 64973b0 c65e091
Author: Cameron McKenzie <cameron@unico.com.au>
Authored: Wed Apr 22 09:06:29 2015 +1000
Committer: Cameron McKenzie <cameron@unico.com.au>
Committed: Wed Apr 22 09:06:29 2015 +1000

----------------------------------------------------------------------
 curator-client/pom.xml                          |   4 +-
 .../org/apache/curator/utils/ThreadUtils.java   |   5 +
 .../java/org/apache/curator/utils/ZKPaths.java  | 103 ++++--
 .../org/apache/curator/utils/TestZKPaths.java   |  11 +
 curator-examples/pom.xml                        |   2 +-
 .../main/java/discovery/InstanceDetails.java    |   2 +-
 curator-framework/pom.xml                       |   4 +-
 .../org/apache/curator/framework/AuthInfo.java  |  51 +++
 .../framework/CuratorFrameworkFactory.java      | 127 +++++--
 .../framework/imps/CreateBuilderImpl.java       |  16 +-
 .../framework/imps/CuratorFrameworkImpl.java    | 116 +++---
 .../imps/CuratorTempFrameworkImpl.java          |  10 +-
 .../framework/imps/DeleteBuilderImpl.java       | 103 +++---
 .../curator/framework/imps/NamespaceFacade.java |   8 +-
 .../curator/framework/imps/NamespaceImpl.java   |   6 +-
 .../curator/framework/imps/TestFramework.java   | 349 ++++++++++++-------
 .../framework/imps/TestFrameworkEdges.java      |  81 ++++-
 curator-recipes/pom.xml                         |   4 +-
 .../recipes/cache/PathChildrenCache.java        |  16 +-
 .../framework/recipes/cache/TreeCache.java      |   2 +-
 .../framework/recipes/locks/ChildReaper.java    | 157 ++++++++-
 .../locks/InterProcessReadWriteLock.java        |  34 +-
 .../recipes/locks/InterProcessSemaphoreV2.java  |   7 +
 .../curator/framework/recipes/locks/Reaper.java |  65 +++-
 .../recipes/nodes/PersistentEphemeralNode.java  |   2 +-
 .../src/site/confluence/Tree-cache.confluence   |  39 ---
 .../src/site/confluence/tree-cache.confluence   |  39 +++
 .../framework/recipes/cache/TestTreeCache.java  |  43 +++
 .../recipes/leader/TestLeaderSelector.java      |  67 ++++
 .../recipes/locks/TestChildReaper.java          | 248 ++++++++++++-
 .../locks/TestInterProcessReadWriteLock.java    |  33 ++
 .../locks/TestInterProcessSemaphore.java        |  40 +++
 .../framework/recipes/locks/TestReaper.java     |  90 ++++-
 .../nodes/TestPersistentEphemeralNode.java      |  37 ++
 curator-test/pom.xml                            |   4 +-
 curator-x-discovery-server/pom.xml              |   4 +-
 .../contexts/GenericDiscoveryContext.java       |   8 +-
 .../contexts/IntegerDiscoveryContext.java       |   4 +-
 .../server/contexts/StringDiscoveryContext.java |   4 +-
 .../entity/JsonServiceInstanceMarshaller.java   |   6 +-
 .../entity/JsonServiceInstancesMarshaller.java  |   8 +-
 .../entity/JsonServiceNamesMarshaller.java      |   8 +-
 .../discovery/server/rest/DiscoveryContext.java |   4 +-
 .../server/jetty_jersey/ServiceDetails.java     |   4 +-
 curator-x-discovery/pom.xml                     |  18 +-
 .../x/discovery/ServiceDiscoveryBuilder.java    |  45 ++-
 .../curator/x/discovery/ServiceInstance.java    |   6 +-
 .../details/JsonInstanceSerializer.java         |   4 +-
 .../discovery/details/ServiceDiscoveryImpl.java |  81 ++++-
 .../x/discovery/TestServiceDiscovery.java       | 106 ++++--
 .../discovery/details/TestWatchedInstances.java |  94 +++++
 curator-x-rpc/pom.xml                           |  23 +-
 .../java/org/apache/curator/x/rpc/RpcTests.java |   6 +-
 pom.xml                                         |  84 +----
 54 files changed, 1854 insertions(+), 588 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/6e16d0d5/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentEphemeralNode.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/curator/blob/6e16d0d5/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java
----------------------------------------------------------------------
diff --cc curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java
index 31e7ef2,8bc8d3d..1c66271
--- 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
@@@ -465,76 -464,40 +466,112 @@@ public class TestPersistentEphemeralNod
      }
      
      /**
 +     * Test that if a persistent ephemeral node is created and the node already exists
 +     * that if data is present in the PersistentEphermalNode that it is still set. 
 +     * @throws Exception
 +     */
 +    @Test
 +    public void testSetDataWhenNodeExists() throws Exception
 +    {
 +        CuratorFramework curator = newCurator();
 +        curator.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath(PATH,
"InitialData".getBytes());
 +        
 +        byte[] data = "Hello World".getBytes();
 +             
 +        PersistentEphemeralNode node = new PersistentEphemeralNode(curator, PersistentEphemeralNode.Mode.EPHEMERAL,
PATH, data);
 +        node.start();
 +        try
 +        {
 +            node.waitForInitialCreate(timing.forWaiting().seconds(), TimeUnit.SECONDS);
 +            assertTrue(Arrays.equals(curator.getData().forPath(node.getActualPath()), data));
 +        }
 +        finally
 +        {
 +            node.close();
 +        }
 +    }
 +    
 +    @Test
 +    public void testSetDataWhenDisconnected() throws Exception
 +    {
 +        CuratorFramework curator = newCurator();
 +        
 +        byte[] initialData = "Hello World".getBytes();
 +        byte[] updatedData = "Updated".getBytes();
 +             
 +        PersistentEphemeralNode node = new PersistentEphemeralNode(curator, PersistentEphemeralNode.Mode.EPHEMERAL,
PATH, initialData);
 +        node.start();
 +        try
 +        {
 +            node.waitForInitialCreate(timing.forWaiting().seconds(), TimeUnit.SECONDS);
 +            assertTrue(Arrays.equals(curator.getData().forPath(node.getActualPath()), initialData));
 +            
 +            server.stop();
 +            
 +            final CountDownLatch dataUpdateLatch = new CountDownLatch(1);
 +            
 +            Watcher watcher = new Watcher()
 +            {
 +				@Override
 +				public void process(WatchedEvent event)
 +				{
 +					if ( event.getType() == EventType.NodeDataChanged )
 +					{
 +						dataUpdateLatch.countDown();
 +					}
 +				}            	
 +            };
 +            
 +            curator.getData().usingWatcher(watcher).inBackground().forPath(node.getActualPath());
 +            
 +            node.setData(updatedData);
 +            server.restart();
 +
 +            assertTrue(timing.awaitLatch(dataUpdateLatch));
 +                       
 +            assertTrue(Arrays.equals(curator.getData().forPath(node.getActualPath()), updatedData));
 +        }
 +        finally
 +        {
 +            node.close();
 +        }    	
 +    }
++    
++    /**
+      * See CURATOR-190
+      * For protected nodes on reconnect the current protected name was passed to the create
builder meaning that it got
+      * appended to the new protected node name. This meant that a new node got created on
each reconnect.
+      * @throws Exception
+      */
+     @Test
+     public void testProtected() throws Exception
+     {
+         CuratorFramework curator = newCurator();
+ 
+         PersistentEphemeralNode node = new PersistentEphemeralNode(curator, PersistentEphemeralNode.Mode.PROTECTED_EPHEMERAL,
PATH,
+                                                                    new byte[0]);
+         node.start();
+         try
+         {
+             node.waitForInitialCreate(timing.forWaiting().seconds(), TimeUnit.SECONDS);
+             assertNodeExists(curator, node.getActualPath());
+ 
+             server.restart();            
+             
+             curator.blockUntilConnected(5, TimeUnit.SECONDS);
+ 
+             assertNodeExists(curator, node.getActualPath());
+             
+             //There should only be a single child, the persisted ephemeral node
+             List<String> children = curator.getChildren().forPath(DIR);
+             assertFalse(children == null);
+             assertEquals(children.size(), 1);
+         }
+         finally
+         {
+             node.close();
+         }
+     }
  
      private void assertNodeExists(CuratorFramework curator, String path) throws Exception
      {


Mime
View raw message