curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From randg...@apache.org
Subject [4/7] git commit: refactoring
Date Thu, 29 May 2014 20:54:25 GMT
refactoring


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

Branch: refs/heads/curator-rpc
Commit: 0f52fa24f08bd5d55dab5a8278b3bb38a479cdb4
Parents: 41ac42b
Author: randgalt <randgalt@apache.org>
Authored: Thu May 29 15:31:41 2014 -0500
Committer: randgalt <randgalt@apache.org>
Committed: Thu May 29 15:31:41 2014 -0500

----------------------------------------------------------------------
 .../curator/x/rpc/idl/event/RpcChildData.java   |  28 +
 .../x/rpc/idl/event/RpcCuratorEvent.java        | 201 +-----
 .../idl/event/RpcPathChildrenCacheEvent.java    |  31 +
 .../event/RpcPathChildrenCacheEventType.java    |  15 +
 .../apache/curator/x/rpc/idl/event/RpcStat.java |  17 +
 .../x/rpc/idl/event/RpcWatchedEvent.java        |   8 +
 .../x/rpc/idl/projection/CreateMode.java        |  27 -
 .../x/rpc/idl/projection/CreateSpec.java        |   5 +-
 .../projection/CuratorProjectionService.java    |  61 +-
 .../x/rpc/idl/projection/RpcCreateMode.java     |  30 +
 curator-x-rpc/src/main/thrift/curator.thrift    |  39 +-
 .../org/apache/curator/generated/ChildData.java | 604 +++++++++++++++++++
 .../generated/PathChildrenCacheEvent.java       | 509 ++++++++++++++++
 .../generated/PathChildrenCacheEventType.java   |  60 ++
 .../org/apache/curator/x/rpc/TestClient.java    |  13 +-
 .../org/apache/curator/x/rpc/TestServer.java    |   3 +
 16 files changed, 1353 insertions(+), 298 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/0f52fa24/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcChildData.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcChildData.java b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcChildData.java
new file mode 100644
index 0000000..4c7827b
--- /dev/null
+++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcChildData.java
@@ -0,0 +1,28 @@
+package org.apache.curator.x.rpc.idl.event;
+
+import com.facebook.swift.codec.ThriftField;
+import com.facebook.swift.codec.ThriftStruct;
+
+@ThriftStruct("ChildData")
+public class RpcChildData
+{
+    @ThriftField(1)
+    public String path;
+
+    @ThriftField(2)
+    public RpcStat stat;
+
+    @ThriftField(3)
+    public byte[] data;
+
+    public RpcChildData()
+    {
+    }
+
+    public RpcChildData(String path, RpcStat stat, byte[] data)
+    {
+        this.path = path;
+        this.stat = stat;
+        this.data = data;
+    }
+}

http://git-wip-us.apache.org/repos/asf/curator/blob/0f52fa24/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcCuratorEvent.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcCuratorEvent.java b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcCuratorEvent.java
index 7835b39..92be564 100644
--- a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcCuratorEvent.java
+++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcCuratorEvent.java
@@ -23,10 +23,8 @@ import com.facebook.swift.codec.ThriftStruct;
 import com.google.common.base.Function;
 import com.google.common.collect.Lists;
 import org.apache.curator.framework.api.CuratorEvent;
-import org.apache.curator.framework.api.CuratorEventType;
 import org.apache.curator.framework.state.ConnectionState;
 import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.Watcher;
 import org.apache.zookeeper.data.ACL;
 import org.apache.zookeeper.data.Stat;
 import javax.annotation.Nullable;
@@ -86,7 +84,7 @@ public class RpcCuratorEvent
 
     public RpcCuratorEvent(CuratorEvent event)
     {
-        this.type = toRpcCuratorEventType(event.getType());
+        this.type = RpcCuratorEventType.valueOf(event.getType().name());
         this.resultCode = event.getResultCode();
         this.path = event.getPath();
         this.context = (event.getContext() != null) ? String.valueOf(event.getContext()) : null;
@@ -101,7 +99,7 @@ public class RpcCuratorEvent
 
     public RpcCuratorEvent(ConnectionState newState)
     {
-        this.type = toRpcCuratorEventType(newState);
+        this.type = RpcCuratorEventType.valueOf(newState.name());
         this.resultCode = 0;
         this.path = null;
         this.context = null;
@@ -125,7 +123,7 @@ public class RpcCuratorEvent
         this.name = null;
         this.children = null;
         this.aclList = null;
-        this.watchedEvent = new RpcWatchedEvent(toRpcKeeperState(event.getState()), toRpcEventType(event.getType()), event.getPath());
+        this.watchedEvent = new RpcWatchedEvent(RpcKeeperState.valueOf(event.getState().name()), RpcEventType.valueOf(event.getType().name()), event.getPath());
         this.leaderEvent = null;
     }
 
@@ -144,119 +142,11 @@ public class RpcCuratorEvent
         this.leaderEvent = event;
     }
 
-    private RpcCuratorEventType toRpcCuratorEventType(ConnectionState state)
-    {
-        switch ( state )
-        {
-            case CONNECTED:
-            {
-                return RpcCuratorEventType.CONNECTION_CONNECTED;
-            }
-
-            case SUSPENDED:
-            {
-                return RpcCuratorEventType.CONNECTION_SUSPENDED;
-            }
-
-            case RECONNECTED:
-            {
-                return RpcCuratorEventType.CONNECTION_RECONNECTED;
-            }
-
-            case LOST:
-            {
-                return RpcCuratorEventType.CONNECTION_LOST;
-            }
-
-            case READ_ONLY:
-            {
-                return RpcCuratorEventType.CONNECTION_READ_ONLY;
-            }
-        }
-        throw new IllegalStateException("Unknown state: " + state);
-    }
-
-    private RpcCuratorEventType toRpcCuratorEventType(CuratorEventType eventType)
-    {
-        switch ( eventType )
-        {
-            case CREATE:
-            {
-                return RpcCuratorEventType.CREATE;
-            }
-
-            case DELETE:
-            {
-                return RpcCuratorEventType.DELETE;
-            }
-
-            case EXISTS:
-            {
-                return RpcCuratorEventType.EXISTS;
-            }
-
-            case GET_DATA:
-            {
-                return RpcCuratorEventType.GET_DATA;
-            }
-
-            case SET_DATA:
-            {
-                return RpcCuratorEventType.SET_DATA;
-            }
-
-            case CHILDREN:
-            {
-                return RpcCuratorEventType.CHILDREN;
-            }
-
-            case SYNC:
-            {
-                return RpcCuratorEventType.SYNC;
-            }
-
-            case GET_ACL:
-            {
-                return RpcCuratorEventType.GET_ACL;
-            }
-
-            case SET_ACL:
-            {
-                return RpcCuratorEventType.SET_ACL;
-            }
-
-            case WATCHED:
-            {
-                return RpcCuratorEventType.WATCHED;
-            }
-
-            case CLOSING:
-            {
-                return RpcCuratorEventType.CLOSING;
-            }
-        }
-
-        throw new IllegalStateException("Unknown type: " + eventType);
-    }
-
     public static RpcStat toRpcStat(Stat stat)
     {
         if ( stat != null )
         {
-            return new RpcStat
-            (
-                stat.getCzxid(),
-                stat.getMzxid(),
-                stat.getCtime(),
-                stat.getMtime(),
-                stat.getVersion(),
-                stat.getCversion(),
-                stat.getAversion(),
-                stat.getEphemeralOwner(),
-                stat.getDataLength(),
-                stat.getNumChildren(),
-                stat.getPzxid()
-            );
+            return new RpcStat(stat);
         }
         return null;
     }
@@ -287,89 +177,8 @@ public class RpcCuratorEvent
     {
         if ( watchedEvent != null )
         {
-            RpcKeeperState keeperState = toRpcKeeperState(watchedEvent.getState());
-            RpcEventType eventType = toRpcEventType(watchedEvent.getType());
-            return new RpcWatchedEvent(keeperState, eventType, watchedEvent.getPath());
+            return new RpcWatchedEvent(watchedEvent);
         }
         return null;
     }
-
-    private RpcEventType toRpcEventType(Watcher.Event.EventType type)
-    {
-        switch ( type )
-        {
-            case None:
-            {
-                return RpcEventType.None;
-            }
-
-            case NodeCreated:
-            {
-                return RpcEventType.NodeCreated;
-            }
-
-            case NodeDeleted:
-            {
-                return RpcEventType.NodeDeleted;
-            }
-
-            case NodeDataChanged:
-            {
-                return RpcEventType.NodeDataChanged;
-            }
-
-            case NodeChildrenChanged:
-            {
-                return RpcEventType.NodeChildrenChanged;
-            }
-        }
-        throw new IllegalStateException("Unknown type: " + type);
-    }
-
-    private RpcKeeperState toRpcKeeperState(Watcher.Event.KeeperState state)
-    {
-        switch ( state )
-        {
-            case Unknown:
-            {
-                return RpcKeeperState.Unknown;
-            }
-
-            case Disconnected:
-            {
-                return RpcKeeperState.Disconnected;
-            }
-
-            case NoSyncConnected:
-            {
-                return RpcKeeperState.NoSyncConnected;
-            }
-
-            case SyncConnected:
-            {
-                return RpcKeeperState.SyncConnected;
-            }
-
-            case AuthFailed:
-            {
-                return RpcKeeperState.AuthFailed;
-            }
-
-            case ConnectedReadOnly:
-            {
-                return RpcKeeperState.ConnectedReadOnly;
-            }
-
-            case SaslAuthenticated:
-            {
-                return RpcKeeperState.SaslAuthenticated;
-            }
-
-            case Expired:
-            {
-                return RpcKeeperState.Expired;
-            }
-        }
-        throw new IllegalStateException("Unknown state: " + state);
-    }
 }

http://git-wip-us.apache.org/repos/asf/curator/blob/0f52fa24/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcPathChildrenCacheEvent.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcPathChildrenCacheEvent.java b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcPathChildrenCacheEvent.java
new file mode 100644
index 0000000..0213559
--- /dev/null
+++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcPathChildrenCacheEvent.java
@@ -0,0 +1,31 @@
+package org.apache.curator.x.rpc.idl.event;
+
+import com.facebook.swift.codec.ThriftField;
+import com.facebook.swift.codec.ThriftStruct;
+import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent;
+
+@ThriftStruct("PathChildrenCacheEvent")
+public class RpcPathChildrenCacheEvent
+{
+    @ThriftField(1)
+    public RpcPathChildrenCacheEventType type;
+
+    @ThriftField(2)
+    public RpcChildData data;
+
+    public RpcPathChildrenCacheEvent()
+    {
+    }
+
+    public RpcPathChildrenCacheEvent(PathChildrenCacheEvent event)
+    {
+        type = RpcPathChildrenCacheEventType.valueOf(event.getType().name());
+        data = (event.getData() != null) ? new RpcChildData(event.getData().getPath(), RpcCuratorEvent.toRpcStat(event.getData().getStat()), event.getData().getData()) : null;
+    }
+
+    public RpcPathChildrenCacheEvent(RpcPathChildrenCacheEventType type, RpcChildData data)
+    {
+        this.type = type;
+        this.data = data;
+    }
+}

http://git-wip-us.apache.org/repos/asf/curator/blob/0f52fa24/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcPathChildrenCacheEventType.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcPathChildrenCacheEventType.java b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcPathChildrenCacheEventType.java
new file mode 100644
index 0000000..4ec5541
--- /dev/null
+++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcPathChildrenCacheEventType.java
@@ -0,0 +1,15 @@
+package org.apache.curator.x.rpc.idl.event;
+
+import com.facebook.swift.codec.ThriftEnum;
+
+@ThriftEnum("PathChildrenCacheEventType")
+public enum RpcPathChildrenCacheEventType
+{
+    CHILD_ADDED,
+    CHILD_UPDATED,
+    CHILD_REMOVED,
+    CONNECTION_SUSPENDED,
+    CONNECTION_RECONNECTED,
+    CONNECTION_LOST,
+    INITIALIZED
+}

http://git-wip-us.apache.org/repos/asf/curator/blob/0f52fa24/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcStat.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcStat.java b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcStat.java
index e5fd919..f5d2300 100644
--- a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcStat.java
+++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcStat.java
@@ -16,10 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.curator.x.rpc.idl.event;
 
 import com.facebook.swift.codec.ThriftField;
 import com.facebook.swift.codec.ThriftStruct;
+import org.apache.zookeeper.data.Stat;
 
 @ThriftStruct("Stat")
 public class RpcStat
@@ -61,6 +63,21 @@ public class RpcStat
     {
     }
 
+    public RpcStat(Stat stat)
+    {
+        czxid = stat.getCzxid();
+        mzxid = stat.getMzxid();
+        ctime = stat.getCtime();
+        mtime = stat.getMtime();
+        version = stat.getVersion();
+        cversion = stat.getCversion();
+        aversion = stat.getAversion();
+        ephemeralOwner = stat.getEphemeralOwner();
+        dataLength = stat.getDataLength();
+        numChildren = stat.getNumChildren();
+        pzxid = stat.getPzxid();
+    }
+
     public RpcStat(long czxid, long mzxid, long ctime, long mtime, int version, int cversion, int aversion, long ephemeralOwner, int dataLength, int numChildren, long pzxid)
     {
         this.czxid = czxid;

http://git-wip-us.apache.org/repos/asf/curator/blob/0f52fa24/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcWatchedEvent.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcWatchedEvent.java b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcWatchedEvent.java
index de696b9..11856b3 100644
--- a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcWatchedEvent.java
+++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcWatchedEvent.java
@@ -20,6 +20,7 @@ package org.apache.curator.x.rpc.idl.event;
 
 import com.facebook.swift.codec.ThriftField;
 import com.facebook.swift.codec.ThriftStruct;
+import org.apache.zookeeper.WatchedEvent;
 
 @ThriftStruct("WatchedEvent")
 public class RpcWatchedEvent
@@ -37,6 +38,13 @@ public class RpcWatchedEvent
     {
     }
 
+    public RpcWatchedEvent(WatchedEvent watchedEvent)
+    {
+        keeperState = RpcKeeperState.valueOf(watchedEvent.getState().name());
+        eventType = RpcEventType.valueOf(watchedEvent.getType().name());
+        path = watchedEvent.getPath();
+    }
+
     public RpcWatchedEvent(RpcKeeperState keeperState, RpcEventType eventType, String path)
     {
         this.keeperState = keeperState;

http://git-wip-us.apache.org/repos/asf/curator/blob/0f52fa24/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/projection/CreateMode.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/projection/CreateMode.java b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/projection/CreateMode.java
deleted file mode 100644
index d53cf8d..0000000
--- a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/projection/CreateMode.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.curator.x.rpc.idl.projection;
-
-public enum CreateMode
-{
-    PERSISTENT,
-    PERSISTENT_SEQUENTIAL,
-    EPHEMERAL,
-    EPHEMERAL_SEQUENTIAL
-}

http://git-wip-us.apache.org/repos/asf/curator/blob/0f52fa24/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/projection/CreateSpec.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/projection/CreateSpec.java b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/projection/CreateSpec.java
index 71bfb1e..7f156b4 100644
--- a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/projection/CreateSpec.java
+++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/projection/CreateSpec.java
@@ -20,7 +20,6 @@ package org.apache.curator.x.rpc.idl.projection;
 
 import com.facebook.swift.codec.ThriftField;
 import com.facebook.swift.codec.ThriftStruct;
-import org.apache.curator.framework.api.CreateBuilder;
 
 @ThriftStruct
 public class CreateSpec
@@ -32,7 +31,7 @@ public class CreateSpec
     public byte[] data;
 
     @ThriftField(3)
-    public CreateMode mode;
+    public RpcCreateMode mode;
 
     @ThriftField(4)
     public String asyncContext;
@@ -50,7 +49,7 @@ public class CreateSpec
     {
     }
 
-    public CreateSpec(String path, byte[] data, CreateMode mode, String asyncContext, boolean compressed, boolean creatingParentsIfNeeded, boolean withProtection)
+    public CreateSpec(String path, byte[] data, RpcCreateMode mode, String asyncContext, boolean compressed, boolean creatingParentsIfNeeded, boolean withProtection)
     {
         this.path = path;
         this.data = data;

http://git-wip-us.apache.org/repos/asf/curator/blob/0f52fa24/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/projection/CuratorProjectionService.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/projection/CuratorProjectionService.java b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/projection/CuratorProjectionService.java
index 03d0c9f..fd7384e 100644
--- a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/projection/CuratorProjectionService.java
+++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/projection/CuratorProjectionService.java
@@ -49,6 +49,7 @@ import org.apache.curator.x.rpc.idl.event.OptionalRpcStat;
 import org.apache.curator.x.rpc.idl.event.RpcCuratorEvent;
 import org.apache.curator.x.rpc.idl.event.RpcParticipant;
 import org.apache.curator.x.rpc.idl.event.RpcStat;
+import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.data.Stat;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -121,7 +122,7 @@ public class CuratorProjectionService
         }
         if ( spec.mode != null )
         {
-            builder = castBuilder(builder, CreateModable.class).withMode(getRealMode(spec.mode));
+            builder = castBuilder(builder, CreateModable.class).withMode(CreateMode.valueOf(spec.mode.name()));
         }
 
         if ( spec.asyncContext != null )
@@ -356,18 +357,14 @@ public class CuratorProjectionService
 
         LeaderLatch leaderLatch = getThis(entry, leaderProjection.projection.id, LeaderLatch.class);
         Collection<Participant> participants = leaderLatch.getParticipants();
-        return Lists.transform
-        (
-            Lists.newArrayList(participants),
-            new Function<Participant, RpcParticipant>()
+        return Lists.transform(Lists.newArrayList(participants), new Function<Participant, RpcParticipant>()
             {
                 @Override
                 public RpcParticipant apply(Participant participant)
                 {
                     return new RpcParticipant(participant.getId(), participant.isLeader());
                 }
-            }
-        );
+            });
     }
 
     @ThriftMethod
@@ -385,28 +382,7 @@ public class CuratorProjectionService
         CuratorEntry entry = getEntry(projection);
 
         PathChildrenCache cache = new PathChildrenCache(entry.getClient(), path, cacheData, dataIsCompressed, ThreadUtils.newThreadFactory("PathChildrenCacheResource-%d"));
-        PathChildrenCache.StartMode actualStartMode = PathChildrenCache.StartMode.NORMAL;
-        switch ( startMode )
-        {
-            case NORMAL:
-            {
-                actualStartMode = PathChildrenCache.StartMode.NORMAL;
-                break;
-            }
-
-            case BUILD_INITIAL_CACHE:
-            {
-                actualStartMode = PathChildrenCache.StartMode.BUILD_INITIAL_CACHE;
-                break;
-            }
-
-            case POST_INITIALIZED_EVENT:
-            {
-                actualStartMode = PathChildrenCache.StartMode.POST_INITIALIZED_EVENT;
-                break;
-            }
-        }
-        cache.start(actualStartMode);
+        cache.start(PathChildrenCache.StartMode.valueOf(startMode.name()));
 
         Closer<PathChildrenCache> closer = new Closer<PathChildrenCache>()
         {
@@ -448,33 +424,6 @@ public class CuratorProjectionService
         }
     }
 
-    private org.apache.zookeeper.CreateMode getRealMode(CreateMode mode)
-    {
-        switch ( mode )
-        {
-            case PERSISTENT:
-            {
-                return org.apache.zookeeper.CreateMode.PERSISTENT;
-            }
-
-            case PERSISTENT_SEQUENTIAL:
-            {
-                return org.apache.zookeeper.CreateMode.PERSISTENT_SEQUENTIAL;
-            }
-
-            case EPHEMERAL:
-            {
-                return org.apache.zookeeper.CreateMode.EPHEMERAL;
-            }
-
-            case EPHEMERAL_SEQUENTIAL:
-            {
-                return org.apache.zookeeper.CreateMode.EPHEMERAL_SEQUENTIAL;
-            }
-        }
-        throw new UnsupportedOperationException("Bad mode: " + mode.toString());
-    }
-
     private CuratorEntry getEntry(CuratorProjection projection) throws Exception
     {
         CuratorEntry entry = connectionManager.get(projection.id);

http://git-wip-us.apache.org/repos/asf/curator/blob/0f52fa24/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/projection/RpcCreateMode.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/projection/RpcCreateMode.java b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/projection/RpcCreateMode.java
new file mode 100644
index 0000000..3ef6b45
--- /dev/null
+++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/projection/RpcCreateMode.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.curator.x.rpc.idl.projection;
+
+import com.facebook.swift.codec.ThriftEnum;
+
+@ThriftEnum("CreateMode")
+public enum RpcCreateMode
+{
+    PERSISTENT,
+    PERSISTENT_SEQUENTIAL,
+    EPHEMERAL,
+    EPHEMERAL_SEQUENTIAL
+}

http://git-wip-us.apache.org/repos/asf/curator/blob/0f52fa24/curator-x-rpc/src/main/thrift/curator.thrift
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/thrift/curator.thrift b/curator-x-rpc/src/main/thrift/curator.thrift
index 9ab4e62..c553c1f 100644
--- a/curator-x-rpc/src/main/thrift/curator.thrift
+++ b/curator-x-rpc/src/main/thrift/curator.thrift
@@ -3,14 +3,14 @@ namespace cpp org.apache.curator.generated
 namespace java org.apache.curator.generated
 
 
-enum CreateMode {
-  PERSISTENT, PERSISTENT_SEQUENTIAL, EPHEMERAL, EPHEMERAL_SEQUENTIAL
-}
-
 enum PathChildrenCacheStartMode {
   NORMAL, BUILD_INITIAL_CACHE, POST_INITIALIZED_EVENT
 }
 
+enum CreateMode {
+  PERSISTENT, PERSISTENT_SEQUENTIAL, EPHEMERAL, EPHEMERAL_SEQUENTIAL
+}
+
 enum CuratorEventType {
   PING, CREATE, DELETE, EXISTS, GET_DATA, SET_DATA, CHILDREN, SYNC, GET_ACL, SET_ACL, WATCHED, CLOSING, CONNECTION_CONNECTED, CONNECTION_SUSPENDED, CONNECTION_RECONNECTED, CONNECTION_LOST, CONNECTION_READ_ONLY, LEADER
 }
@@ -23,14 +23,8 @@ enum KeeperState {
   Unknown, Disconnected, NoSyncConnected, SyncConnected, AuthFailed, ConnectedReadOnly, SaslAuthenticated, Expired
 }
 
-struct CreateSpec {
-  1: string path;
-  2: binary data;
-  3: CreateMode mode;
-  4: string asyncContext;
-  5: bool compressed;
-  6: bool creatingParentsIfNeeded;
-  7: bool withProtection;
+enum PathChildrenCacheEventType {
+  CHILD_ADDED, CHILD_UPDATED, CHILD_REMOVED, CONNECTION_SUSPENDED, CONNECTION_RECONNECTED, CONNECTION_LOST, INITIALIZED
 }
 
 struct CuratorProjection {
@@ -121,6 +115,16 @@ struct WatchedEvent {
   3: string path;
 }
 
+struct CreateSpec {
+  1: string path;
+  2: binary data;
+  3: CreateMode mode;
+  4: string asyncContext;
+  5: bool compressed;
+  6: bool creatingParentsIfNeeded;
+  7: bool withProtection;
+}
+
 struct DeleteSpec {
   1: string path;
   2: bool guaranteed;
@@ -147,6 +151,12 @@ struct Acl {
   2: Id id;
 }
 
+struct ChildData {
+  1: string path;
+  2: Stat stat;
+  3: binary data;
+}
+
 struct CuratorEvent {
   2: CuratorEventType type;
   3: i32 resultCode;
@@ -161,6 +171,11 @@ struct CuratorEvent {
   12: LeaderEvent leaderEvent;
 }
 
+struct PathChildrenCacheEvent {
+  1: PathChildrenCacheEventType type;
+  2: ChildData data;
+}
+
 service CuratorService {
   GenericProjection acquireLock(1: CuratorProjection projection, 2: string path, 3: i32 maxWaitMs);
   void closeCuratorProjection(1: CuratorProjection projection);

http://git-wip-us.apache.org/repos/asf/curator/blob/0f52fa24/curator-x-rpc/src/test/java/org/apache/curator/generated/ChildData.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/test/java/org/apache/curator/generated/ChildData.java b/curator-x-rpc/src/test/java/org/apache/curator/generated/ChildData.java
new file mode 100644
index 0000000..368fda9
--- /dev/null
+++ b/curator-x-rpc/src/test/java/org/apache/curator/generated/ChildData.java
@@ -0,0 +1,604 @@
+/**
+ * Autogenerated by Thrift Compiler (0.9.1)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.curator.generated;
+
+import org.apache.thrift.scheme.IScheme;
+import org.apache.thrift.scheme.SchemeFactory;
+import org.apache.thrift.scheme.StandardScheme;
+
+import org.apache.thrift.scheme.TupleScheme;
+import org.apache.thrift.protocol.TTupleProtocol;
+import org.apache.thrift.protocol.TProtocolException;
+import org.apache.thrift.EncodingUtils;
+import org.apache.thrift.TException;
+import org.apache.thrift.async.AsyncMethodCallback;
+import org.apache.thrift.server.AbstractNonblockingServer.*;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.EnumMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.EnumSet;
+import java.util.Collections;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ChildData implements org.apache.thrift.TBase<ChildData, ChildData._Fields>, java.io.Serializable, Cloneable, Comparable<ChildData> {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ChildData");
+
+  private static final org.apache.thrift.protocol.TField PATH_FIELD_DESC = new org.apache.thrift.protocol.TField("path", org.apache.thrift.protocol.TType.STRING, (short)1);
+  private static final org.apache.thrift.protocol.TField STAT_FIELD_DESC = new org.apache.thrift.protocol.TField("stat", org.apache.thrift.protocol.TType.STRUCT, (short)2);
+  private static final org.apache.thrift.protocol.TField DATA_FIELD_DESC = new org.apache.thrift.protocol.TField("data", org.apache.thrift.protocol.TType.STRING, (short)3);
+
+  private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+  static {
+    schemes.put(StandardScheme.class, new ChildDataStandardSchemeFactory());
+    schemes.put(TupleScheme.class, new ChildDataTupleSchemeFactory());
+  }
+
+  public String path; // required
+  public Stat stat; // required
+  public ByteBuffer data; // required
+
+  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+    PATH((short)1, "path"),
+    STAT((short)2, "stat"),
+    DATA((short)3, "data");
+
+    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : EnumSet.allOf(_Fields.class)) {
+        byName.put(field.getFieldName(), field);
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, or null if its not found.
+     */
+    public static _Fields findByThriftId(int fieldId) {
+      switch(fieldId) {
+        case 1: // PATH
+          return PATH;
+        case 2: // STAT
+          return STAT;
+        case 3: // DATA
+          return DATA;
+        default:
+          return null;
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, throwing an exception
+     * if it is not found.
+     */
+    public static _Fields findByThriftIdOrThrow(int fieldId) {
+      _Fields fields = findByThriftId(fieldId);
+      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+      return fields;
+    }
+
+    /**
+     * Find the _Fields constant that matches name, or null if its not found.
+     */
+    public static _Fields findByName(String name) {
+      return byName.get(name);
+    }
+
+    private final short _thriftId;
+    private final String _fieldName;
+
+    _Fields(short thriftId, String fieldName) {
+      _thriftId = thriftId;
+      _fieldName = fieldName;
+    }
+
+    public short getThriftFieldId() {
+      return _thriftId;
+    }
+
+    public String getFieldName() {
+      return _fieldName;
+    }
+  }
+
+  // isset id assignments
+  public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+  static {
+    Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.PATH, new org.apache.thrift.meta_data.FieldMetaData("path", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.STAT, new org.apache.thrift.meta_data.FieldMetaData("stat", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, Stat.class)));
+    tmpMap.put(_Fields.DATA, new org.apache.thrift.meta_data.FieldMetaData("data", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , true)));
+    metaDataMap = Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ChildData.class, metaDataMap);
+  }
+
+  public ChildData() {
+  }
+
+  public ChildData(
+    String path,
+    Stat stat,
+    ByteBuffer data)
+  {
+    this();
+    this.path = path;
+    this.stat = stat;
+    this.data = data;
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public ChildData(ChildData other) {
+    if (other.isSetPath()) {
+      this.path = other.path;
+    }
+    if (other.isSetStat()) {
+      this.stat = new Stat(other.stat);
+    }
+    if (other.isSetData()) {
+      this.data = org.apache.thrift.TBaseHelper.copyBinary(other.data);
+;
+    }
+  }
+
+  public ChildData deepCopy() {
+    return new ChildData(this);
+  }
+
+  @Override
+  public void clear() {
+    this.path = null;
+    this.stat = null;
+    this.data = null;
+  }
+
+  public String getPath() {
+    return this.path;
+  }
+
+  public ChildData setPath(String path) {
+    this.path = path;
+    return this;
+  }
+
+  public void unsetPath() {
+    this.path = null;
+  }
+
+  /** Returns true if field path is set (has been assigned a value) and false otherwise */
+  public boolean isSetPath() {
+    return this.path != null;
+  }
+
+  public void setPathIsSet(boolean value) {
+    if (!value) {
+      this.path = null;
+    }
+  }
+
+  public Stat getStat() {
+    return this.stat;
+  }
+
+  public ChildData setStat(Stat stat) {
+    this.stat = stat;
+    return this;
+  }
+
+  public void unsetStat() {
+    this.stat = null;
+  }
+
+  /** Returns true if field stat is set (has been assigned a value) and false otherwise */
+  public boolean isSetStat() {
+    return this.stat != null;
+  }
+
+  public void setStatIsSet(boolean value) {
+    if (!value) {
+      this.stat = null;
+    }
+  }
+
+  public byte[] getData() {
+    setData(org.apache.thrift.TBaseHelper.rightSize(data));
+    return data == null ? null : data.array();
+  }
+
+  public ByteBuffer bufferForData() {
+    return data;
+  }
+
+  public ChildData setData(byte[] data) {
+    setData(data == null ? (ByteBuffer)null : ByteBuffer.wrap(data));
+    return this;
+  }
+
+  public ChildData setData(ByteBuffer data) {
+    this.data = data;
+    return this;
+  }
+
+  public void unsetData() {
+    this.data = null;
+  }
+
+  /** Returns true if field data is set (has been assigned a value) and false otherwise */
+  public boolean isSetData() {
+    return this.data != null;
+  }
+
+  public void setDataIsSet(boolean value) {
+    if (!value) {
+      this.data = null;
+    }
+  }
+
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
+    case PATH:
+      if (value == null) {
+        unsetPath();
+      } else {
+        setPath((String)value);
+      }
+      break;
+
+    case STAT:
+      if (value == null) {
+        unsetStat();
+      } else {
+        setStat((Stat)value);
+      }
+      break;
+
+    case DATA:
+      if (value == null) {
+        unsetData();
+      } else {
+        setData((ByteBuffer)value);
+      }
+      break;
+
+    }
+  }
+
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+    case PATH:
+      return getPath();
+
+    case STAT:
+      return getStat();
+
+    case DATA:
+      return getData();
+
+    }
+    throw new IllegalStateException();
+  }
+
+  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+  public boolean isSet(_Fields field) {
+    if (field == null) {
+      throw new IllegalArgumentException();
+    }
+
+    switch (field) {
+    case PATH:
+      return isSetPath();
+    case STAT:
+      return isSetStat();
+    case DATA:
+      return isSetData();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null)
+      return false;
+    if (that instanceof ChildData)
+      return this.equals((ChildData)that);
+    return false;
+  }
+
+  public boolean equals(ChildData that) {
+    if (that == null)
+      return false;
+
+    boolean this_present_path = true && this.isSetPath();
+    boolean that_present_path = true && that.isSetPath();
+    if (this_present_path || that_present_path) {
+      if (!(this_present_path && that_present_path))
+        return false;
+      if (!this.path.equals(that.path))
+        return false;
+    }
+
+    boolean this_present_stat = true && this.isSetStat();
+    boolean that_present_stat = true && that.isSetStat();
+    if (this_present_stat || that_present_stat) {
+      if (!(this_present_stat && that_present_stat))
+        return false;
+      if (!this.stat.equals(that.stat))
+        return false;
+    }
+
+    boolean this_present_data = true && this.isSetData();
+    boolean that_present_data = true && that.isSetData();
+    if (this_present_data || that_present_data) {
+      if (!(this_present_data && that_present_data))
+        return false;
+      if (!this.data.equals(that.data))
+        return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    return 0;
+  }
+
+  @Override
+  public int compareTo(ChildData other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+
+    lastComparison = Boolean.valueOf(isSetPath()).compareTo(other.isSetPath());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetPath()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.path, other.path);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetStat()).compareTo(other.isSetStat());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetStat()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.stat, other.stat);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetData()).compareTo(other.isSetData());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetData()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.data, other.data);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    return 0;
+  }
+
+  public _Fields fieldForId(int fieldId) {
+    return _Fields.findByThriftId(fieldId);
+  }
+
+  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+    schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+  }
+
+  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+    schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("ChildData(");
+    boolean first = true;
+
+    sb.append("path:");
+    if (this.path == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.path);
+    }
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("stat:");
+    if (this.stat == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.stat);
+    }
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("data:");
+    if (this.data == null) {
+      sb.append("null");
+    } else {
+      org.apache.thrift.TBaseHelper.toString(this.data, sb);
+    }
+    first = false;
+    sb.append(")");
+    return sb.toString();
+  }
+
+  public void validate() throws org.apache.thrift.TException {
+    // check for required fields
+    // check for sub-struct validity
+    if (stat != null) {
+      stat.validate();
+    }
+  }
+
+  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+    try {
+      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+    } catch (org.apache.thrift.TException te) {
+      throw new java.io.IOException(te);
+    }
+  }
+
+  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
+    try {
+      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
+    } catch (org.apache.thrift.TException te) {
+      throw new java.io.IOException(te);
+    }
+  }
+
+  private static class ChildDataStandardSchemeFactory implements SchemeFactory {
+    public ChildDataStandardScheme getScheme() {
+      return new ChildDataStandardScheme();
+    }
+  }
+
+  private static class ChildDataStandardScheme extends StandardScheme<ChildData> {
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot, ChildData struct) throws org.apache.thrift.TException {
+      org.apache.thrift.protocol.TField schemeField;
+      iprot.readStructBegin();
+      while (true)
+      {
+        schemeField = iprot.readFieldBegin();
+        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
+          break;
+        }
+        switch (schemeField.id) {
+          case 1: // PATH
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.path = iprot.readString();
+              struct.setPathIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 2: // STAT
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+              struct.stat = new Stat();
+              struct.stat.read(iprot);
+              struct.setStatIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 3: // DATA
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.data = iprot.readBinary();
+              struct.setDataIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          default:
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+        }
+        iprot.readFieldEnd();
+      }
+      iprot.readStructEnd();
+
+      // check for required fields of primitive type, which can't be checked in the validate method
+      struct.validate();
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot, ChildData struct) throws org.apache.thrift.TException {
+      struct.validate();
+
+      oprot.writeStructBegin(STRUCT_DESC);
+      if (struct.path != null) {
+        oprot.writeFieldBegin(PATH_FIELD_DESC);
+        oprot.writeString(struct.path);
+        oprot.writeFieldEnd();
+      }
+      if (struct.stat != null) {
+        oprot.writeFieldBegin(STAT_FIELD_DESC);
+        struct.stat.write(oprot);
+        oprot.writeFieldEnd();
+      }
+      if (struct.data != null) {
+        oprot.writeFieldBegin(DATA_FIELD_DESC);
+        oprot.writeBinary(struct.data);
+        oprot.writeFieldEnd();
+      }
+      oprot.writeFieldStop();
+      oprot.writeStructEnd();
+    }
+
+  }
+
+  private static class ChildDataTupleSchemeFactory implements SchemeFactory {
+    public ChildDataTupleScheme getScheme() {
+      return new ChildDataTupleScheme();
+    }
+  }
+
+  private static class ChildDataTupleScheme extends TupleScheme<ChildData> {
+
+    @Override
+    public void write(org.apache.thrift.protocol.TProtocol prot, ChildData struct) throws org.apache.thrift.TException {
+      TTupleProtocol oprot = (TTupleProtocol) prot;
+      BitSet optionals = new BitSet();
+      if (struct.isSetPath()) {
+        optionals.set(0);
+      }
+      if (struct.isSetStat()) {
+        optionals.set(1);
+      }
+      if (struct.isSetData()) {
+        optionals.set(2);
+      }
+      oprot.writeBitSet(optionals, 3);
+      if (struct.isSetPath()) {
+        oprot.writeString(struct.path);
+      }
+      if (struct.isSetStat()) {
+        struct.stat.write(oprot);
+      }
+      if (struct.isSetData()) {
+        oprot.writeBinary(struct.data);
+      }
+    }
+
+    @Override
+    public void read(org.apache.thrift.protocol.TProtocol prot, ChildData struct) throws org.apache.thrift.TException {
+      TTupleProtocol iprot = (TTupleProtocol) prot;
+      BitSet incoming = iprot.readBitSet(3);
+      if (incoming.get(0)) {
+        struct.path = iprot.readString();
+        struct.setPathIsSet(true);
+      }
+      if (incoming.get(1)) {
+        struct.stat = new Stat();
+        struct.stat.read(iprot);
+        struct.setStatIsSet(true);
+      }
+      if (incoming.get(2)) {
+        struct.data = iprot.readBinary();
+        struct.setDataIsSet(true);
+      }
+    }
+  }
+
+}
+

http://git-wip-us.apache.org/repos/asf/curator/blob/0f52fa24/curator-x-rpc/src/test/java/org/apache/curator/generated/PathChildrenCacheEvent.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/test/java/org/apache/curator/generated/PathChildrenCacheEvent.java b/curator-x-rpc/src/test/java/org/apache/curator/generated/PathChildrenCacheEvent.java
new file mode 100644
index 0000000..efa8aed
--- /dev/null
+++ b/curator-x-rpc/src/test/java/org/apache/curator/generated/PathChildrenCacheEvent.java
@@ -0,0 +1,509 @@
+/**
+ * Autogenerated by Thrift Compiler (0.9.1)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.curator.generated;
+
+import org.apache.thrift.scheme.IScheme;
+import org.apache.thrift.scheme.SchemeFactory;
+import org.apache.thrift.scheme.StandardScheme;
+
+import org.apache.thrift.scheme.TupleScheme;
+import org.apache.thrift.protocol.TTupleProtocol;
+import org.apache.thrift.protocol.TProtocolException;
+import org.apache.thrift.EncodingUtils;
+import org.apache.thrift.TException;
+import org.apache.thrift.async.AsyncMethodCallback;
+import org.apache.thrift.server.AbstractNonblockingServer.*;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.EnumMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.EnumSet;
+import java.util.Collections;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PathChildrenCacheEvent implements org.apache.thrift.TBase<PathChildrenCacheEvent, PathChildrenCacheEvent._Fields>, java.io.Serializable, Cloneable, Comparable<PathChildrenCacheEvent> {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("PathChildrenCacheEvent");
+
+  private static final org.apache.thrift.protocol.TField TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("type", org.apache.thrift.protocol.TType.I32, (short)1);
+  private static final org.apache.thrift.protocol.TField DATA_FIELD_DESC = new org.apache.thrift.protocol.TField("data", org.apache.thrift.protocol.TType.STRUCT, (short)2);
+
+  private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+  static {
+    schemes.put(StandardScheme.class, new PathChildrenCacheEventStandardSchemeFactory());
+    schemes.put(TupleScheme.class, new PathChildrenCacheEventTupleSchemeFactory());
+  }
+
+  /**
+   * 
+   * @see PathChildrenCacheEventType
+   */
+  public PathChildrenCacheEventType type; // required
+  public ChildData data; // required
+
+  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+    /**
+     * 
+     * @see PathChildrenCacheEventType
+     */
+    TYPE((short)1, "type"),
+    DATA((short)2, "data");
+
+    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : EnumSet.allOf(_Fields.class)) {
+        byName.put(field.getFieldName(), field);
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, or null if its not found.
+     */
+    public static _Fields findByThriftId(int fieldId) {
+      switch(fieldId) {
+        case 1: // TYPE
+          return TYPE;
+        case 2: // DATA
+          return DATA;
+        default:
+          return null;
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, throwing an exception
+     * if it is not found.
+     */
+    public static _Fields findByThriftIdOrThrow(int fieldId) {
+      _Fields fields = findByThriftId(fieldId);
+      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+      return fields;
+    }
+
+    /**
+     * Find the _Fields constant that matches name, or null if its not found.
+     */
+    public static _Fields findByName(String name) {
+      return byName.get(name);
+    }
+
+    private final short _thriftId;
+    private final String _fieldName;
+
+    _Fields(short thriftId, String fieldName) {
+      _thriftId = thriftId;
+      _fieldName = fieldName;
+    }
+
+    public short getThriftFieldId() {
+      return _thriftId;
+    }
+
+    public String getFieldName() {
+      return _fieldName;
+    }
+  }
+
+  // isset id assignments
+  public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+  static {
+    Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.TYPE, new org.apache.thrift.meta_data.FieldMetaData("type", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+        new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, PathChildrenCacheEventType.class)));
+    tmpMap.put(_Fields.DATA, new org.apache.thrift.meta_data.FieldMetaData("data", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, ChildData.class)));
+    metaDataMap = Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(PathChildrenCacheEvent.class, metaDataMap);
+  }
+
+  public PathChildrenCacheEvent() {
+  }
+
+  public PathChildrenCacheEvent(
+    PathChildrenCacheEventType type,
+    ChildData data)
+  {
+    this();
+    this.type = type;
+    this.data = data;
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public PathChildrenCacheEvent(PathChildrenCacheEvent other) {
+    if (other.isSetType()) {
+      this.type = other.type;
+    }
+    if (other.isSetData()) {
+      this.data = new ChildData(other.data);
+    }
+  }
+
+  public PathChildrenCacheEvent deepCopy() {
+    return new PathChildrenCacheEvent(this);
+  }
+
+  @Override
+  public void clear() {
+    this.type = null;
+    this.data = null;
+  }
+
+  /**
+   * 
+   * @see PathChildrenCacheEventType
+   */
+  public PathChildrenCacheEventType getType() {
+    return this.type;
+  }
+
+  /**
+   * 
+   * @see PathChildrenCacheEventType
+   */
+  public PathChildrenCacheEvent setType(PathChildrenCacheEventType type) {
+    this.type = type;
+    return this;
+  }
+
+  public void unsetType() {
+    this.type = null;
+  }
+
+  /** Returns true if field type is set (has been assigned a value) and false otherwise */
+  public boolean isSetType() {
+    return this.type != null;
+  }
+
+  public void setTypeIsSet(boolean value) {
+    if (!value) {
+      this.type = null;
+    }
+  }
+
+  public ChildData getData() {
+    return this.data;
+  }
+
+  public PathChildrenCacheEvent setData(ChildData data) {
+    this.data = data;
+    return this;
+  }
+
+  public void unsetData() {
+    this.data = null;
+  }
+
+  /** Returns true if field data is set (has been assigned a value) and false otherwise */
+  public boolean isSetData() {
+    return this.data != null;
+  }
+
+  public void setDataIsSet(boolean value) {
+    if (!value) {
+      this.data = null;
+    }
+  }
+
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
+    case TYPE:
+      if (value == null) {
+        unsetType();
+      } else {
+        setType((PathChildrenCacheEventType)value);
+      }
+      break;
+
+    case DATA:
+      if (value == null) {
+        unsetData();
+      } else {
+        setData((ChildData)value);
+      }
+      break;
+
+    }
+  }
+
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+    case TYPE:
+      return getType();
+
+    case DATA:
+      return getData();
+
+    }
+    throw new IllegalStateException();
+  }
+
+  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+  public boolean isSet(_Fields field) {
+    if (field == null) {
+      throw new IllegalArgumentException();
+    }
+
+    switch (field) {
+    case TYPE:
+      return isSetType();
+    case DATA:
+      return isSetData();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null)
+      return false;
+    if (that instanceof PathChildrenCacheEvent)
+      return this.equals((PathChildrenCacheEvent)that);
+    return false;
+  }
+
+  public boolean equals(PathChildrenCacheEvent that) {
+    if (that == null)
+      return false;
+
+    boolean this_present_type = true && this.isSetType();
+    boolean that_present_type = true && that.isSetType();
+    if (this_present_type || that_present_type) {
+      if (!(this_present_type && that_present_type))
+        return false;
+      if (!this.type.equals(that.type))
+        return false;
+    }
+
+    boolean this_present_data = true && this.isSetData();
+    boolean that_present_data = true && that.isSetData();
+    if (this_present_data || that_present_data) {
+      if (!(this_present_data && that_present_data))
+        return false;
+      if (!this.data.equals(that.data))
+        return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    return 0;
+  }
+
+  @Override
+  public int compareTo(PathChildrenCacheEvent other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+
+    lastComparison = Boolean.valueOf(isSetType()).compareTo(other.isSetType());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetType()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.type, other.type);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetData()).compareTo(other.isSetData());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetData()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.data, other.data);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    return 0;
+  }
+
+  public _Fields fieldForId(int fieldId) {
+    return _Fields.findByThriftId(fieldId);
+  }
+
+  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+    schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+  }
+
+  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+    schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("PathChildrenCacheEvent(");
+    boolean first = true;
+
+    sb.append("type:");
+    if (this.type == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.type);
+    }
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("data:");
+    if (this.data == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.data);
+    }
+    first = false;
+    sb.append(")");
+    return sb.toString();
+  }
+
+  public void validate() throws org.apache.thrift.TException {
+    // check for required fields
+    // check for sub-struct validity
+    if (data != null) {
+      data.validate();
+    }
+  }
+
+  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+    try {
+      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+    } catch (org.apache.thrift.TException te) {
+      throw new java.io.IOException(te);
+    }
+  }
+
+  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
+    try {
+      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
+    } catch (org.apache.thrift.TException te) {
+      throw new java.io.IOException(te);
+    }
+  }
+
+  private static class PathChildrenCacheEventStandardSchemeFactory implements SchemeFactory {
+    public PathChildrenCacheEventStandardScheme getScheme() {
+      return new PathChildrenCacheEventStandardScheme();
+    }
+  }
+
+  private static class PathChildrenCacheEventStandardScheme extends StandardScheme<PathChildrenCacheEvent> {
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot, PathChildrenCacheEvent struct) throws org.apache.thrift.TException {
+      org.apache.thrift.protocol.TField schemeField;
+      iprot.readStructBegin();
+      while (true)
+      {
+        schemeField = iprot.readFieldBegin();
+        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
+          break;
+        }
+        switch (schemeField.id) {
+          case 1: // TYPE
+            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
+              struct.type = PathChildrenCacheEventType.findByValue(iprot.readI32());
+              struct.setTypeIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 2: // DATA
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+              struct.data = new ChildData();
+              struct.data.read(iprot);
+              struct.setDataIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          default:
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+        }
+        iprot.readFieldEnd();
+      }
+      iprot.readStructEnd();
+
+      // check for required fields of primitive type, which can't be checked in the validate method
+      struct.validate();
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot, PathChildrenCacheEvent struct) throws org.apache.thrift.TException {
+      struct.validate();
+
+      oprot.writeStructBegin(STRUCT_DESC);
+      if (struct.type != null) {
+        oprot.writeFieldBegin(TYPE_FIELD_DESC);
+        oprot.writeI32(struct.type.getValue());
+        oprot.writeFieldEnd();
+      }
+      if (struct.data != null) {
+        oprot.writeFieldBegin(DATA_FIELD_DESC);
+        struct.data.write(oprot);
+        oprot.writeFieldEnd();
+      }
+      oprot.writeFieldStop();
+      oprot.writeStructEnd();
+    }
+
+  }
+
+  private static class PathChildrenCacheEventTupleSchemeFactory implements SchemeFactory {
+    public PathChildrenCacheEventTupleScheme getScheme() {
+      return new PathChildrenCacheEventTupleScheme();
+    }
+  }
+
+  private static class PathChildrenCacheEventTupleScheme extends TupleScheme<PathChildrenCacheEvent> {
+
+    @Override
+    public void write(org.apache.thrift.protocol.TProtocol prot, PathChildrenCacheEvent struct) throws org.apache.thrift.TException {
+      TTupleProtocol oprot = (TTupleProtocol) prot;
+      BitSet optionals = new BitSet();
+      if (struct.isSetType()) {
+        optionals.set(0);
+      }
+      if (struct.isSetData()) {
+        optionals.set(1);
+      }
+      oprot.writeBitSet(optionals, 2);
+      if (struct.isSetType()) {
+        oprot.writeI32(struct.type.getValue());
+      }
+      if (struct.isSetData()) {
+        struct.data.write(oprot);
+      }
+    }
+
+    @Override
+    public void read(org.apache.thrift.protocol.TProtocol prot, PathChildrenCacheEvent struct) throws org.apache.thrift.TException {
+      TTupleProtocol iprot = (TTupleProtocol) prot;
+      BitSet incoming = iprot.readBitSet(2);
+      if (incoming.get(0)) {
+        struct.type = PathChildrenCacheEventType.findByValue(iprot.readI32());
+        struct.setTypeIsSet(true);
+      }
+      if (incoming.get(1)) {
+        struct.data = new ChildData();
+        struct.data.read(iprot);
+        struct.setDataIsSet(true);
+      }
+    }
+  }
+
+}
+

http://git-wip-us.apache.org/repos/asf/curator/blob/0f52fa24/curator-x-rpc/src/test/java/org/apache/curator/generated/PathChildrenCacheEventType.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/test/java/org/apache/curator/generated/PathChildrenCacheEventType.java b/curator-x-rpc/src/test/java/org/apache/curator/generated/PathChildrenCacheEventType.java
new file mode 100644
index 0000000..ad10558
--- /dev/null
+++ b/curator-x-rpc/src/test/java/org/apache/curator/generated/PathChildrenCacheEventType.java
@@ -0,0 +1,60 @@
+/**
+ * Autogenerated by Thrift Compiler (0.9.1)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.curator.generated;
+
+
+import java.util.Map;
+import java.util.HashMap;
+import org.apache.thrift.TEnum;
+
+public enum PathChildrenCacheEventType implements org.apache.thrift.TEnum {
+  CHILD_ADDED(0),
+  CHILD_UPDATED(1),
+  CHILD_REMOVED(2),
+  CONNECTION_SUSPENDED(3),
+  CONNECTION_RECONNECTED(4),
+  CONNECTION_LOST(5),
+  INITIALIZED(6);
+
+  private final int value;
+
+  private PathChildrenCacheEventType(int value) {
+    this.value = value;
+  }
+
+  /**
+   * Get the integer value of this enum value, as defined in the Thrift IDL.
+   */
+  public int getValue() {
+    return value;
+  }
+
+  /**
+   * Find a the enum type by its integer value, as defined in the Thrift IDL.
+   * @return null if the value is not found.
+   */
+  public static PathChildrenCacheEventType findByValue(int value) { 
+    switch (value) {
+      case 0:
+        return CHILD_ADDED;
+      case 1:
+        return CHILD_UPDATED;
+      case 2:
+        return CHILD_REMOVED;
+      case 3:
+        return CONNECTION_SUSPENDED;
+      case 4:
+        return CONNECTION_RECONNECTED;
+      case 5:
+        return CONNECTION_LOST;
+      case 6:
+        return INITIALIZED;
+      default:
+        return null;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/curator/blob/0f52fa24/curator-x-rpc/src/test/java/org/apache/curator/x/rpc/TestClient.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/test/java/org/apache/curator/x/rpc/TestClient.java b/curator-x-rpc/src/test/java/org/apache/curator/x/rpc/TestClient.java
index b1366a6..02c8ccb 100644
--- a/curator-x-rpc/src/test/java/org/apache/curator/x/rpc/TestClient.java
+++ b/curator-x-rpc/src/test/java/org/apache/curator/x/rpc/TestClient.java
@@ -19,20 +19,18 @@
 package org.apache.curator.x.rpc;
 
 import org.apache.curator.generated.*;
-import org.apache.curator.test.TestingServer;
 import org.apache.thrift.TException;
 import org.apache.thrift.protocol.TBinaryProtocol;
 import org.apache.thrift.protocol.TProtocol;
 import org.apache.thrift.transport.TSocket;
 import java.nio.ByteBuffer;
+import java.util.List;
 import java.util.concurrent.Executors;
 
 public class TestClient
 {
     public static void main(String[] args) throws Exception
     {
-        new TestingServer(2181);
-
         TSocket clientTransport = new TSocket("localhost", 8899);
         clientTransport.open();
         TProtocol clientProtocol = new TBinaryProtocol(clientTransport);
@@ -103,6 +101,13 @@ public class TestClient
 
         LeaderResult leader = client.startLeaderSelector(curatorProjection, "/leader", "me", 10000);
         System.out.println("Has Leader: " + leader.hasLeadership);
-        client.closeGenericProjection(curatorProjection, leader.projection);
+
+        List<Participant> leaderParticipants = client.getLeaderParticipants(curatorProjection, leader.projection);
+        System.out.println("Participants: " + leaderParticipants);
+
+        boolean isLeader = client.isLeader(curatorProjection, leader.projection);
+        System.out.println("isLeader: " + isLeader);
+
+        client.closeGenericProjection(curatorProjection, leader.projection.projection);
     }
 }

http://git-wip-us.apache.org/repos/asf/curator/blob/0f52fa24/curator-x-rpc/src/test/java/org/apache/curator/x/rpc/TestServer.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/test/java/org/apache/curator/x/rpc/TestServer.java b/curator-x-rpc/src/test/java/org/apache/curator/x/rpc/TestServer.java
index 9472dd8..f64d383 100644
--- a/curator-x-rpc/src/test/java/org/apache/curator/x/rpc/TestServer.java
+++ b/curator-x-rpc/src/test/java/org/apache/curator/x/rpc/TestServer.java
@@ -1,12 +1,15 @@
 package org.apache.curator.x.rpc;
 
 import com.google.common.io.Resources;
+import org.apache.curator.test.TestingServer;
 import java.nio.charset.Charset;
 
 public class TestServer
 {
     public static void main(String[] args) throws Exception
     {
+        new TestingServer(2181);
+
         String configurationSource = Resources.toString(Resources.getResource("configuration/test.json"), Charset.defaultCharset());
         CuratorProjectionServer.main(new String[]{configurationSource});
     }


Mime
View raw message