curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From randg...@apache.org
Subject [5/7] git commit: path children cache wip
Date Thu, 29 May 2014 20:54:26 GMT
path children cache wip


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

Branch: refs/heads/curator-rpc
Commit: 4c626a7a700d6b9b49552509737e1c1e05ce2215
Parents: 0f52fa2
Author: randgalt <randgalt@apache.org>
Authored: Thu May 29 15:44:33 2014 -0500
Committer: randgalt <randgalt@apache.org>
Committed: Thu May 29 15:44:33 2014 -0500

----------------------------------------------------------------------
 .../x/rpc/idl/event/RpcCuratorEvent.java        |  24 ++++
 .../x/rpc/idl/event/RpcCuratorEventType.java    |   3 +-
 .../idl/event/RpcPathChildrenCacheEvent.java    |  11 +-
 .../projection/CuratorProjectionService.java    |  11 +-
 curator-x-rpc/src/main/thrift/curator.thrift    |  14 ++-
 .../apache/curator/generated/CuratorEvent.java  | 113 ++++++++++++++++-
 .../curator/generated/CuratorEventType.java     |   5 +-
 .../generated/PathChildrenCacheEvent.java       | 126 +++++++++++++++++--
 .../org/apache/curator/x/rpc/TestClient.java    |   3 +-
 9 files changed, 276 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/4c626a7a/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 92be564..aacf076 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
@@ -67,6 +67,9 @@ public class RpcCuratorEvent
     @ThriftField(12)
     public LeaderEvent leaderEvent;
 
+    @ThriftField(13)
+    public RpcPathChildrenCacheEvent childrenCacheEvent;
+
     public RpcCuratorEvent()
     {
         this.type = RpcCuratorEventType.PING;
@@ -80,6 +83,23 @@ public class RpcCuratorEvent
         this.aclList = null;
         this.watchedEvent = null;
         this.leaderEvent = null;
+        this.childrenCacheEvent = null;
+    }
+
+    public RpcCuratorEvent(RpcPathChildrenCacheEvent childrenCacheEvent)
+    {
+        this.type = RpcCuratorEventType.PATH_CHILDREN_CACHE;
+        this.resultCode = 0;
+        this.path = null;
+        this.context = null;
+        this.stat = null;
+        this.data = null;
+        this.name = null;
+        this.children = null;
+        this.aclList = null;
+        this.watchedEvent = null;
+        this.leaderEvent = null;
+        this.childrenCacheEvent = childrenCacheEvent;
     }
 
     public RpcCuratorEvent(CuratorEvent event)
@@ -95,6 +115,7 @@ public class RpcCuratorEvent
         this.aclList = toRpcAclList(event.getACLList());
         this.watchedEvent = toRpcWatchedEvent(event.getWatchedEvent());
         this.leaderEvent = null;
+        this.childrenCacheEvent = null;
     }
 
     public RpcCuratorEvent(ConnectionState newState)
@@ -110,6 +131,7 @@ public class RpcCuratorEvent
         this.aclList = null;
         this.watchedEvent = null;
         this.leaderEvent = null;
+        this.childrenCacheEvent = null;
     }
 
     public RpcCuratorEvent(WatchedEvent event)
@@ -125,6 +147,7 @@ public class RpcCuratorEvent
         this.aclList = null;
         this.watchedEvent = new RpcWatchedEvent(RpcKeeperState.valueOf(event.getState().name()),
RpcEventType.valueOf(event.getType().name()), event.getPath());
         this.leaderEvent = null;
+        this.childrenCacheEvent = null;
     }
 
     public RpcCuratorEvent(LeaderEvent event)
@@ -140,6 +163,7 @@ public class RpcCuratorEvent
         this.aclList = null;
         this.watchedEvent = null;
         this.leaderEvent = event;
+        this.childrenCacheEvent = null;
     }
 
     public static RpcStat toRpcStat(Stat stat)

http://git-wip-us.apache.org/repos/asf/curator/blob/4c626a7a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcCuratorEventType.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcCuratorEventType.java
b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcCuratorEventType.java
index 1102740..eee5929 100644
--- a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcCuratorEventType.java
+++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcCuratorEventType.java
@@ -40,5 +40,6 @@ public enum RpcCuratorEventType
     CONNECTION_RECONNECTED,
     CONNECTION_LOST,
     CONNECTION_READ_ONLY,
-    LEADER
+    LEADER,
+    PATH_CHILDREN_CACHE
 }

http://git-wip-us.apache.org/repos/asf/curator/blob/4c626a7a/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
index 0213559..9321157 100644
--- 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
@@ -8,23 +8,28 @@ import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent;
 public class RpcPathChildrenCacheEvent
 {
     @ThriftField(1)
-    public RpcPathChildrenCacheEventType type;
+    public String cachedPath;
 
     @ThriftField(2)
+    public RpcPathChildrenCacheEventType type;
+
+    @ThriftField(3)
     public RpcChildData data;
 
     public RpcPathChildrenCacheEvent()
     {
     }
 
-    public RpcPathChildrenCacheEvent(PathChildrenCacheEvent event)
+    public RpcPathChildrenCacheEvent(String cachedPath, PathChildrenCacheEvent event)
     {
+        this.cachedPath = cachedPath;
         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)
+    public RpcPathChildrenCacheEvent(String cachedPath, RpcPathChildrenCacheEventType type,
RpcChildData data)
     {
+        this.cachedPath = cachedPath;
         this.type = type;
         this.data = data;
     }

http://git-wip-us.apache.org/repos/asf/curator/blob/4c626a7a/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 fd7384e..1084507 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
@@ -48,6 +48,7 @@ import org.apache.curator.x.rpc.idl.event.OptionalPath;
 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.RpcPathChildrenCacheEvent;
 import org.apache.curator.x.rpc.idl.event.RpcStat;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.data.Stat;
@@ -274,7 +275,7 @@ public class CuratorProjectionService
         InterProcessSemaphoreMutex lock = new InterProcessSemaphoreMutex(entry.getClient(),
path);
         if ( !lock.acquire(maxWaitMs, TimeUnit.MILLISECONDS) )
         {
-            return null;    // TODO
+            return new GenericProjection();
         }
 
         Closer<InterProcessSemaphoreMutex> closer = new Closer<InterProcessSemaphoreMutex>()
@@ -379,9 +380,9 @@ public class CuratorProjectionService
     @ThriftMethod
     public PathChildrenCacheProjection startPathChildrenCache(final CuratorProjection projection,
final String path, boolean cacheData, boolean dataIsCompressed, PathChildrenCacheStartMode
startMode) throws Exception
     {
-        CuratorEntry entry = getEntry(projection);
+        final CuratorEntry entry = getEntry(projection);
 
-        PathChildrenCache cache = new PathChildrenCache(entry.getClient(), path, cacheData,
dataIsCompressed, ThreadUtils.newThreadFactory("PathChildrenCacheResource-%d"));
+        PathChildrenCache cache = new PathChildrenCache(entry.getClient(), path, cacheData,
dataIsCompressed, ThreadUtils.newThreadFactory("PathChildrenCacheResource"));
         cache.start(PathChildrenCache.StartMode.valueOf(startMode.name()));
 
         Closer<PathChildrenCache> closer = new Closer<PathChildrenCache>()
@@ -407,7 +408,7 @@ public class CuratorProjectionService
             @Override
             public void childEvent(CuratorFramework client, PathChildrenCacheEvent event)
throws Exception
             {
-                // TODO
+                entry.addEvent(new RpcCuratorEvent(new RpcPathChildrenCacheEvent(path, event)));
             }
         };
         cache.getListenable().addListener(listener);
@@ -440,7 +441,7 @@ public class CuratorProjectionService
         {
             return clazz.cast(createBuilder);
         }
-        throw new Exception("That operation is not available"); // TODO
+        throw new Exception("That operation is not available");
     }
 
     private <T> T getThis(CuratorEntry entry, String id, Class<T> clazz)

http://git-wip-us.apache.org/repos/asf/curator/blob/4c626a7a/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 c553c1f..765b93c 100644
--- a/curator-x-rpc/src/main/thrift/curator.thrift
+++ b/curator-x-rpc/src/main/thrift/curator.thrift
@@ -12,7 +12,7 @@ enum CreateMode {
 }
 
 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
+  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, PATH_CHILDREN_CACHE
 }
 
 enum EventType {
@@ -157,6 +157,12 @@ struct ChildData {
   3: binary data;
 }
 
+struct PathChildrenCacheEvent {
+  1: string cachedPath;
+  2: PathChildrenCacheEventType type;
+  3: ChildData data;
+}
+
 struct CuratorEvent {
   2: CuratorEventType type;
   3: i32 resultCode;
@@ -169,11 +175,7 @@ struct CuratorEvent {
   10: list<Acl> aclList;
   11: WatchedEvent watchedEvent;
   12: LeaderEvent leaderEvent;
-}
-
-struct PathChildrenCacheEvent {
-  1: PathChildrenCacheEventType type;
-  2: ChildData data;
+  13: PathChildrenCacheEvent childrenCacheEvent;
 }
 
 service CuratorService {

http://git-wip-us.apache.org/repos/asf/curator/blob/4c626a7a/curator-x-rpc/src/test/java/org/apache/curator/generated/CuratorEvent.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/test/java/org/apache/curator/generated/CuratorEvent.java b/curator-x-rpc/src/test/java/org/apache/curator/generated/CuratorEvent.java
index 847e89e..23ecbf4 100644
--- a/curator-x-rpc/src/test/java/org/apache/curator/generated/CuratorEvent.java
+++ b/curator-x-rpc/src/test/java/org/apache/curator/generated/CuratorEvent.java
@@ -46,6 +46,7 @@ public class CuratorEvent implements org.apache.thrift.TBase<CuratorEvent,
Curat
   private static final org.apache.thrift.protocol.TField ACL_LIST_FIELD_DESC = new org.apache.thrift.protocol.TField("aclList",
org.apache.thrift.protocol.TType.LIST, (short)10);
   private static final org.apache.thrift.protocol.TField WATCHED_EVENT_FIELD_DESC = new org.apache.thrift.protocol.TField("watchedEvent",
org.apache.thrift.protocol.TType.STRUCT, (short)11);
   private static final org.apache.thrift.protocol.TField LEADER_EVENT_FIELD_DESC = new org.apache.thrift.protocol.TField("leaderEvent",
org.apache.thrift.protocol.TType.STRUCT, (short)12);
+  private static final org.apache.thrift.protocol.TField CHILDREN_CACHE_EVENT_FIELD_DESC
= new org.apache.thrift.protocol.TField("childrenCacheEvent", org.apache.thrift.protocol.TType.STRUCT,
(short)13);
 
   private static final Map<Class<? extends IScheme>, SchemeFactory> schemes =
new HashMap<Class<? extends IScheme>, SchemeFactory>();
   static {
@@ -68,6 +69,7 @@ public class CuratorEvent implements org.apache.thrift.TBase<CuratorEvent,
Curat
   public List<Acl> aclList; // required
   public WatchedEvent watchedEvent; // required
   public LeaderEvent leaderEvent; // required
+  public PathChildrenCacheEvent childrenCacheEvent; // 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 {
@@ -85,7 +87,8 @@ public class CuratorEvent implements org.apache.thrift.TBase<CuratorEvent,
Curat
     CHILDREN((short)9, "children"),
     ACL_LIST((short)10, "aclList"),
     WATCHED_EVENT((short)11, "watchedEvent"),
-    LEADER_EVENT((short)12, "leaderEvent");
+    LEADER_EVENT((short)12, "leaderEvent"),
+    CHILDREN_CACHE_EVENT((short)13, "childrenCacheEvent");
 
     private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
 
@@ -122,6 +125,8 @@ public class CuratorEvent implements org.apache.thrift.TBase<CuratorEvent,
Curat
           return WATCHED_EVENT;
         case 12: // LEADER_EVENT
           return LEADER_EVENT;
+        case 13: // CHILDREN_CACHE_EVENT
+          return CHILDREN_CACHE_EVENT;
         default:
           return null;
       }
@@ -191,6 +196,8 @@ public class CuratorEvent implements org.apache.thrift.TBase<CuratorEvent,
Curat
         new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
WatchedEvent.class)));
     tmpMap.put(_Fields.LEADER_EVENT, new org.apache.thrift.meta_data.FieldMetaData("leaderEvent",
org.apache.thrift.TFieldRequirementType.DEFAULT, 
         new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
LeaderEvent.class)));
+    tmpMap.put(_Fields.CHILDREN_CACHE_EVENT, new org.apache.thrift.meta_data.FieldMetaData("childrenCacheEvent",
org.apache.thrift.TFieldRequirementType.DEFAULT, 
+        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
PathChildrenCacheEvent.class)));
     metaDataMap = Collections.unmodifiableMap(tmpMap);
     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(CuratorEvent.class, metaDataMap);
   }
@@ -209,7 +216,8 @@ public class CuratorEvent implements org.apache.thrift.TBase<CuratorEvent,
Curat
     List<String> children,
     List<Acl> aclList,
     WatchedEvent watchedEvent,
-    LeaderEvent leaderEvent)
+    LeaderEvent leaderEvent,
+    PathChildrenCacheEvent childrenCacheEvent)
   {
     this();
     this.type = type;
@@ -224,6 +232,7 @@ public class CuratorEvent implements org.apache.thrift.TBase<CuratorEvent,
Curat
     this.aclList = aclList;
     this.watchedEvent = watchedEvent;
     this.leaderEvent = leaderEvent;
+    this.childrenCacheEvent = childrenCacheEvent;
   }
 
   /**
@@ -268,6 +277,9 @@ public class CuratorEvent implements org.apache.thrift.TBase<CuratorEvent,
Curat
     if (other.isSetLeaderEvent()) {
       this.leaderEvent = new LeaderEvent(other.leaderEvent);
     }
+    if (other.isSetChildrenCacheEvent()) {
+      this.childrenCacheEvent = new PathChildrenCacheEvent(other.childrenCacheEvent);
+    }
   }
 
   public CuratorEvent deepCopy() {
@@ -288,6 +300,7 @@ public class CuratorEvent implements org.apache.thrift.TBase<CuratorEvent,
Curat
     this.aclList = null;
     this.watchedEvent = null;
     this.leaderEvent = null;
+    this.childrenCacheEvent = null;
   }
 
   /**
@@ -601,6 +614,30 @@ public class CuratorEvent implements org.apache.thrift.TBase<CuratorEvent,
Curat
     }
   }
 
+  public PathChildrenCacheEvent getChildrenCacheEvent() {
+    return this.childrenCacheEvent;
+  }
+
+  public CuratorEvent setChildrenCacheEvent(PathChildrenCacheEvent childrenCacheEvent) {
+    this.childrenCacheEvent = childrenCacheEvent;
+    return this;
+  }
+
+  public void unsetChildrenCacheEvent() {
+    this.childrenCacheEvent = null;
+  }
+
+  /** Returns true if field childrenCacheEvent is set (has been assigned a value) and false
otherwise */
+  public boolean isSetChildrenCacheEvent() {
+    return this.childrenCacheEvent != null;
+  }
+
+  public void setChildrenCacheEventIsSet(boolean value) {
+    if (!value) {
+      this.childrenCacheEvent = null;
+    }
+  }
+
   public void setFieldValue(_Fields field, Object value) {
     switch (field) {
     case TYPE:
@@ -691,6 +728,14 @@ public class CuratorEvent implements org.apache.thrift.TBase<CuratorEvent,
Curat
       }
       break;
 
+    case CHILDREN_CACHE_EVENT:
+      if (value == null) {
+        unsetChildrenCacheEvent();
+      } else {
+        setChildrenCacheEvent((PathChildrenCacheEvent)value);
+      }
+      break;
+
     }
   }
 
@@ -729,6 +774,9 @@ public class CuratorEvent implements org.apache.thrift.TBase<CuratorEvent,
Curat
     case LEADER_EVENT:
       return getLeaderEvent();
 
+    case CHILDREN_CACHE_EVENT:
+      return getChildrenCacheEvent();
+
     }
     throw new IllegalStateException();
   }
@@ -762,6 +810,8 @@ public class CuratorEvent implements org.apache.thrift.TBase<CuratorEvent,
Curat
       return isSetWatchedEvent();
     case LEADER_EVENT:
       return isSetLeaderEvent();
+    case CHILDREN_CACHE_EVENT:
+      return isSetChildrenCacheEvent();
     }
     throw new IllegalStateException();
   }
@@ -878,6 +928,15 @@ public class CuratorEvent implements org.apache.thrift.TBase<CuratorEvent,
Curat
         return false;
     }
 
+    boolean this_present_childrenCacheEvent = true && this.isSetChildrenCacheEvent();
+    boolean that_present_childrenCacheEvent = true && that.isSetChildrenCacheEvent();
+    if (this_present_childrenCacheEvent || that_present_childrenCacheEvent) {
+      if (!(this_present_childrenCacheEvent && that_present_childrenCacheEvent))
+        return false;
+      if (!this.childrenCacheEvent.equals(that.childrenCacheEvent))
+        return false;
+    }
+
     return true;
   }
 
@@ -1004,6 +1063,16 @@ public class CuratorEvent implements org.apache.thrift.TBase<CuratorEvent,
Curat
         return lastComparison;
       }
     }
+    lastComparison = Boolean.valueOf(isSetChildrenCacheEvent()).compareTo(other.isSetChildrenCacheEvent());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetChildrenCacheEvent()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.childrenCacheEvent, other.childrenCacheEvent);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
     return 0;
   }
 
@@ -1107,6 +1176,14 @@ public class CuratorEvent implements org.apache.thrift.TBase<CuratorEvent,
Curat
       sb.append(this.leaderEvent);
     }
     first = false;
+    if (!first) sb.append(", ");
+    sb.append("childrenCacheEvent:");
+    if (this.childrenCacheEvent == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.childrenCacheEvent);
+    }
+    first = false;
     sb.append(")");
     return sb.toString();
   }
@@ -1123,6 +1200,9 @@ public class CuratorEvent implements org.apache.thrift.TBase<CuratorEvent,
Curat
     if (leaderEvent != null) {
       leaderEvent.validate();
     }
+    if (childrenCacheEvent != null) {
+      childrenCacheEvent.validate();
+    }
   }
 
   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
@@ -1273,6 +1353,15 @@ public class CuratorEvent implements org.apache.thrift.TBase<CuratorEvent,
Curat
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
+          case 13: // CHILDREN_CACHE_EVENT
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+              struct.childrenCacheEvent = new PathChildrenCacheEvent();
+              struct.childrenCacheEvent.read(iprot);
+              struct.setChildrenCacheEventIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
           default:
             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
         }
@@ -1355,6 +1444,11 @@ public class CuratorEvent implements org.apache.thrift.TBase<CuratorEvent,
Curat
         struct.leaderEvent.write(oprot);
         oprot.writeFieldEnd();
       }
+      if (struct.childrenCacheEvent != null) {
+        oprot.writeFieldBegin(CHILDREN_CACHE_EVENT_FIELD_DESC);
+        struct.childrenCacheEvent.write(oprot);
+        oprot.writeFieldEnd();
+      }
       oprot.writeFieldStop();
       oprot.writeStructEnd();
     }
@@ -1406,7 +1500,10 @@ public class CuratorEvent implements org.apache.thrift.TBase<CuratorEvent,
Curat
       if (struct.isSetLeaderEvent()) {
         optionals.set(10);
       }
-      oprot.writeBitSet(optionals, 11);
+      if (struct.isSetChildrenCacheEvent()) {
+        optionals.set(11);
+      }
+      oprot.writeBitSet(optionals, 12);
       if (struct.isSetType()) {
         oprot.writeI32(struct.type.getValue());
       }
@@ -1452,12 +1549,15 @@ public class CuratorEvent implements org.apache.thrift.TBase<CuratorEvent,
Curat
       if (struct.isSetLeaderEvent()) {
         struct.leaderEvent.write(oprot);
       }
+      if (struct.isSetChildrenCacheEvent()) {
+        struct.childrenCacheEvent.write(oprot);
+      }
     }
 
     @Override
     public void read(org.apache.thrift.protocol.TProtocol prot, CuratorEvent struct) throws
org.apache.thrift.TException {
       TTupleProtocol iprot = (TTupleProtocol) prot;
-      BitSet incoming = iprot.readBitSet(11);
+      BitSet incoming = iprot.readBitSet(12);
       if (incoming.get(0)) {
         struct.type = CuratorEventType.findByValue(iprot.readI32());
         struct.setTypeIsSet(true);
@@ -1524,6 +1624,11 @@ public class CuratorEvent implements org.apache.thrift.TBase<CuratorEvent,
Curat
         struct.leaderEvent.read(iprot);
         struct.setLeaderEventIsSet(true);
       }
+      if (incoming.get(11)) {
+        struct.childrenCacheEvent = new PathChildrenCacheEvent();
+        struct.childrenCacheEvent.read(iprot);
+        struct.setChildrenCacheEventIsSet(true);
+      }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/curator/blob/4c626a7a/curator-x-rpc/src/test/java/org/apache/curator/generated/CuratorEventType.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/test/java/org/apache/curator/generated/CuratorEventType.java
b/curator-x-rpc/src/test/java/org/apache/curator/generated/CuratorEventType.java
index 4e6fad1..46c57ae 100644
--- a/curator-x-rpc/src/test/java/org/apache/curator/generated/CuratorEventType.java
+++ b/curator-x-rpc/src/test/java/org/apache/curator/generated/CuratorEventType.java
@@ -29,7 +29,8 @@ public enum CuratorEventType implements org.apache.thrift.TEnum {
   CONNECTION_RECONNECTED(14),
   CONNECTION_LOST(15),
   CONNECTION_READ_ONLY(16),
-  LEADER(17);
+  LEADER(17),
+  PATH_CHILDREN_CACHE(18);
 
   private final int value;
 
@@ -86,6 +87,8 @@ public enum CuratorEventType implements org.apache.thrift.TEnum {
         return CONNECTION_READ_ONLY;
       case 17:
         return LEADER;
+      case 18:
+        return PATH_CHILDREN_CACHE;
       default:
         return null;
     }

http://git-wip-us.apache.org/repos/asf/curator/blob/4c626a7a/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
index efa8aed..0532592 100644
--- 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
@@ -35,8 +35,9 @@ 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 org.apache.thrift.protocol.TField CACHED_PATH_FIELD_DESC = new org.apache.thrift.protocol.TField("cachedPath",
org.apache.thrift.protocol.TType.STRING, (short)1);
+  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)2);
+  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)3);
 
   private static final Map<Class<? extends IScheme>, SchemeFactory> schemes =
new HashMap<Class<? extends IScheme>, SchemeFactory>();
   static {
@@ -44,6 +45,7 @@ public class PathChildrenCacheEvent implements org.apache.thrift.TBase<PathChild
     schemes.put(TupleScheme.class, new PathChildrenCacheEventTupleSchemeFactory());
   }
 
+  public String cachedPath; // required
   /**
    * 
    * @see PathChildrenCacheEventType
@@ -53,12 +55,13 @@ public class PathChildrenCacheEvent implements org.apache.thrift.TBase<PathChild
 
   /** The set of fields this struct contains, along with convenience methods for finding
and manipulating them. */
   public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+    CACHED_PATH((short)1, "cachedPath"),
     /**
      * 
      * @see PathChildrenCacheEventType
      */
-    TYPE((short)1, "type"),
-    DATA((short)2, "data");
+    TYPE((short)2, "type"),
+    DATA((short)3, "data");
 
     private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
 
@@ -73,9 +76,11 @@ public class PathChildrenCacheEvent implements org.apache.thrift.TBase<PathChild
      */
     public static _Fields findByThriftId(int fieldId) {
       switch(fieldId) {
-        case 1: // TYPE
+        case 1: // CACHED_PATH
+          return CACHED_PATH;
+        case 2: // TYPE
           return TYPE;
-        case 2: // DATA
+        case 3: // DATA
           return DATA;
         default:
           return null;
@@ -120,6 +125,8 @@ public class PathChildrenCacheEvent implements org.apache.thrift.TBase<PathChild
   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.CACHED_PATH, new org.apache.thrift.meta_data.FieldMetaData("cachedPath",
org.apache.thrift.TFieldRequirementType.DEFAULT, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
     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,

@@ -132,10 +139,12 @@ public class PathChildrenCacheEvent implements org.apache.thrift.TBase<PathChild
   }
 
   public PathChildrenCacheEvent(
+    String cachedPath,
     PathChildrenCacheEventType type,
     ChildData data)
   {
     this();
+    this.cachedPath = cachedPath;
     this.type = type;
     this.data = data;
   }
@@ -144,6 +153,9 @@ public class PathChildrenCacheEvent implements org.apache.thrift.TBase<PathChild
    * Performs a deep copy on <i>other</i>.
    */
   public PathChildrenCacheEvent(PathChildrenCacheEvent other) {
+    if (other.isSetCachedPath()) {
+      this.cachedPath = other.cachedPath;
+    }
     if (other.isSetType()) {
       this.type = other.type;
     }
@@ -158,10 +170,35 @@ public class PathChildrenCacheEvent implements org.apache.thrift.TBase<PathChild
 
   @Override
   public void clear() {
+    this.cachedPath = null;
     this.type = null;
     this.data = null;
   }
 
+  public String getCachedPath() {
+    return this.cachedPath;
+  }
+
+  public PathChildrenCacheEvent setCachedPath(String cachedPath) {
+    this.cachedPath = cachedPath;
+    return this;
+  }
+
+  public void unsetCachedPath() {
+    this.cachedPath = null;
+  }
+
+  /** Returns true if field cachedPath is set (has been assigned a value) and false otherwise
*/
+  public boolean isSetCachedPath() {
+    return this.cachedPath != null;
+  }
+
+  public void setCachedPathIsSet(boolean value) {
+    if (!value) {
+      this.cachedPath = null;
+    }
+  }
+
   /**
    * 
    * @see PathChildrenCacheEventType
@@ -220,6 +257,14 @@ public class PathChildrenCacheEvent implements org.apache.thrift.TBase<PathChild
 
   public void setFieldValue(_Fields field, Object value) {
     switch (field) {
+    case CACHED_PATH:
+      if (value == null) {
+        unsetCachedPath();
+      } else {
+        setCachedPath((String)value);
+      }
+      break;
+
     case TYPE:
       if (value == null) {
         unsetType();
@@ -241,6 +286,9 @@ public class PathChildrenCacheEvent implements org.apache.thrift.TBase<PathChild
 
   public Object getFieldValue(_Fields field) {
     switch (field) {
+    case CACHED_PATH:
+      return getCachedPath();
+
     case TYPE:
       return getType();
 
@@ -258,6 +306,8 @@ public class PathChildrenCacheEvent implements org.apache.thrift.TBase<PathChild
     }
 
     switch (field) {
+    case CACHED_PATH:
+      return isSetCachedPath();
     case TYPE:
       return isSetType();
     case DATA:
@@ -279,6 +329,15 @@ public class PathChildrenCacheEvent implements org.apache.thrift.TBase<PathChild
     if (that == null)
       return false;
 
+    boolean this_present_cachedPath = true && this.isSetCachedPath();
+    boolean that_present_cachedPath = true && that.isSetCachedPath();
+    if (this_present_cachedPath || that_present_cachedPath) {
+      if (!(this_present_cachedPath && that_present_cachedPath))
+        return false;
+      if (!this.cachedPath.equals(that.cachedPath))
+        return false;
+    }
+
     boolean this_present_type = true && this.isSetType();
     boolean that_present_type = true && that.isSetType();
     if (this_present_type || that_present_type) {
@@ -313,6 +372,16 @@ public class PathChildrenCacheEvent implements org.apache.thrift.TBase<PathChild
 
     int lastComparison = 0;
 
+    lastComparison = Boolean.valueOf(isSetCachedPath()).compareTo(other.isSetCachedPath());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetCachedPath()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.cachedPath, other.cachedPath);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
     lastComparison = Boolean.valueOf(isSetType()).compareTo(other.isSetType());
     if (lastComparison != 0) {
       return lastComparison;
@@ -353,6 +422,14 @@ public class PathChildrenCacheEvent implements org.apache.thrift.TBase<PathChild
     StringBuilder sb = new StringBuilder("PathChildrenCacheEvent(");
     boolean first = true;
 
+    sb.append("cachedPath:");
+    if (this.cachedPath == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.cachedPath);
+    }
+    first = false;
+    if (!first) sb.append(", ");
     sb.append("type:");
     if (this.type == null) {
       sb.append("null");
@@ -414,7 +491,15 @@ public class PathChildrenCacheEvent implements org.apache.thrift.TBase<PathChild
           break;
         }
         switch (schemeField.id) {
-          case 1: // TYPE
+          case 1: // CACHED_PATH
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.cachedPath = iprot.readString();
+              struct.setCachedPathIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 2: // TYPE
             if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
               struct.type = PathChildrenCacheEventType.findByValue(iprot.readI32());
               struct.setTypeIsSet(true);
@@ -422,7 +507,7 @@ public class PathChildrenCacheEvent implements org.apache.thrift.TBase<PathChild
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
-          case 2: // DATA
+          case 3: // DATA
             if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
               struct.data = new ChildData();
               struct.data.read(iprot);
@@ -446,6 +531,11 @@ public class PathChildrenCacheEvent implements org.apache.thrift.TBase<PathChild
       struct.validate();
 
       oprot.writeStructBegin(STRUCT_DESC);
+      if (struct.cachedPath != null) {
+        oprot.writeFieldBegin(CACHED_PATH_FIELD_DESC);
+        oprot.writeString(struct.cachedPath);
+        oprot.writeFieldEnd();
+      }
       if (struct.type != null) {
         oprot.writeFieldBegin(TYPE_FIELD_DESC);
         oprot.writeI32(struct.type.getValue());
@@ -474,13 +564,19 @@ public class PathChildrenCacheEvent implements org.apache.thrift.TBase<PathChild
     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()) {
+      if (struct.isSetCachedPath()) {
         optionals.set(0);
       }
-      if (struct.isSetData()) {
+      if (struct.isSetType()) {
         optionals.set(1);
       }
-      oprot.writeBitSet(optionals, 2);
+      if (struct.isSetData()) {
+        optionals.set(2);
+      }
+      oprot.writeBitSet(optionals, 3);
+      if (struct.isSetCachedPath()) {
+        oprot.writeString(struct.cachedPath);
+      }
       if (struct.isSetType()) {
         oprot.writeI32(struct.type.getValue());
       }
@@ -492,12 +588,16 @@ public class PathChildrenCacheEvent implements org.apache.thrift.TBase<PathChild
     @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);
+      BitSet incoming = iprot.readBitSet(3);
       if (incoming.get(0)) {
+        struct.cachedPath = iprot.readString();
+        struct.setCachedPathIsSet(true);
+      }
+      if (incoming.get(1)) {
         struct.type = PathChildrenCacheEventType.findByValue(iprot.readI32());
         struct.setTypeIsSet(true);
       }
-      if (incoming.get(1)) {
+      if (incoming.get(2)) {
         struct.data = new ChildData();
         struct.data.read(iprot);
         struct.setDataIsSet(true);

http://git-wip-us.apache.org/repos/asf/curator/blob/4c626a7a/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 02c8ccb..fe14504 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
@@ -70,11 +70,12 @@ public class TestClient
         CreateSpec createSpec = new CreateSpec();
         createSpec.path = "/a/b/c";
         createSpec.creatingParentsIfNeeded = true;
-        createSpec.asyncContext = "foo";
         createSpec.data = ByteBuffer.wrap("hey".getBytes());
         OptionalPath path = client.createNode(curatorProjection, createSpec);
         System.out.println("Path: " + path);
 
+        PathChildrenCacheProjection pathChildrenCacheProjection = client.startPathChildrenCache(curatorProjection,
"/a/b", true, false, PathChildrenCacheStartMode.BUILD_INITIAL_CACHE);
+
         GetChildrenSpec getChildrenSpec = new GetChildrenSpec();
         getChildrenSpec.path = "/a";
         OptionalChildrenList children = client.getChildren(curatorProjection, getChildrenSpec);


Mime
View raw message