You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2014/05/30 04:11:52 UTC
[2/2] git commit: support PersistentEphemeralNode
support PersistentEphemeralNode
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/cbd174a6
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/cbd174a6
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/cbd174a6
Branch: refs/heads/curator-rpc
Commit: cbd174a693f018f8ef6a79d22b0fe5efb530f50a
Parents: 6e9fa2a
Author: randgalt <ra...@apache.org>
Authored: Thu May 29 21:11:42 2014 -0500
Committer: randgalt <ra...@apache.org>
Committed: Thu May 29 21:11:42 2014 -0500
----------------------------------------------------------------------
.../event/RpcPersistentEphemeralNodeMode.java | 12 +
.../projection/CuratorProjectionService.java | 28 +
.../PersistentEphemeralNodeProjection.java | 20 +
curator-x-rpc/src/main/thrift/curator.thrift | 9 +
.../curator/generated/CuratorService.java | 1189 ++++++++++++++++++
.../generated/PersistentEphemeralNodeMode.java | 51 +
.../PersistentEphemeralNodeProjection.java | 388 ++++++
.../org/apache/curator/x/rpc/TestClient.java | 6 +
8 files changed, 1703 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/cbd174a6/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcPersistentEphemeralNodeMode.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcPersistentEphemeralNodeMode.java b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcPersistentEphemeralNodeMode.java
new file mode 100644
index 0000000..bda8b4d
--- /dev/null
+++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcPersistentEphemeralNodeMode.java
@@ -0,0 +1,12 @@
+package org.apache.curator.x.rpc.idl.event;
+
+import com.facebook.swift.codec.ThriftEnum;
+
+@ThriftEnum("PersistentEphemeralNodeMode")
+public enum RpcPersistentEphemeralNodeMode
+{
+ EPHEMERAL,
+ EPHEMERAL_SEQUENTIAL,
+ PROTECTED_EPHEMERAL,
+ PROTECTED_EPHEMERAL_SEQUENTIAL
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/cbd174a6/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 c82ad5c..cb7a3cc 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
@@ -36,6 +36,7 @@ import org.apache.curator.framework.recipes.leader.LeaderLatch;
import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
import org.apache.curator.framework.recipes.leader.Participant;
import org.apache.curator.framework.recipes.locks.InterProcessSemaphoreMutex;
+import org.apache.curator.framework.recipes.nodes.PersistentEphemeralNode;
import org.apache.curator.framework.state.ConnectionState;
import org.apache.curator.framework.state.ConnectionStateListener;
import org.apache.curator.utils.ThreadUtils;
@@ -476,6 +477,33 @@ public class CuratorProjectionService
}
@ThriftMethod
+ public PersistentEphemeralNodeProjection startPersistentEphemeralNode(CuratorProjection projection, final String path, byte[] data, RpcPersistentEphemeralNodeMode mode) throws Exception
+ {
+ final CuratorEntry entry = getEntry(projection);
+
+ PersistentEphemeralNode node = new PersistentEphemeralNode(entry.getClient(), PersistentEphemeralNode.Mode.valueOf(mode.name()), path, data);
+ node.start();
+
+ Closer<PersistentEphemeralNode> closer = new Closer<PersistentEphemeralNode>()
+ {
+ @Override
+ public void close(PersistentEphemeralNode node)
+ {
+ try
+ {
+ node.close();
+ }
+ catch ( Exception e )
+ {
+ log.error("Could not release left-over persistent ephemeral node for path: " + path, e);
+ }
+ }
+ };
+ String id = entry.addThing(node, closer);
+ return new PersistentEphemeralNodeProjection(id);
+ }
+
+ @ThriftMethod
public RpcChildData getNodeCacheData(CuratorProjection projection, NodeCacheProjection cacheProjection) throws Exception
{
final CuratorEntry entry = getEntry(projection);
http://git-wip-us.apache.org/repos/asf/curator/blob/cbd174a6/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/projection/PersistentEphemeralNodeProjection.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/projection/PersistentEphemeralNodeProjection.java b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/projection/PersistentEphemeralNodeProjection.java
new file mode 100644
index 0000000..a58d3c3
--- /dev/null
+++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/projection/PersistentEphemeralNodeProjection.java
@@ -0,0 +1,20 @@
+package org.apache.curator.x.rpc.idl.projection;
+
+import com.facebook.swift.codec.ThriftField;
+import com.facebook.swift.codec.ThriftStruct;
+
+@ThriftStruct
+public class PersistentEphemeralNodeProjection
+{
+ @ThriftField(1)
+ public String id;
+
+ public PersistentEphemeralNodeProjection()
+ {
+ }
+
+ public PersistentEphemeralNodeProjection(String id)
+ {
+ this.id = id;
+ }
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/cbd174a6/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 bd4753a..601d775 100644
--- a/curator-x-rpc/src/main/thrift/curator.thrift
+++ b/curator-x-rpc/src/main/thrift/curator.thrift
@@ -27,6 +27,10 @@ enum PathChildrenCacheEventType {
CHILD_ADDED, CHILD_UPDATED, CHILD_REMOVED, CONNECTION_SUSPENDED, CONNECTION_RECONNECTED, CONNECTION_LOST, INITIALIZED
}
+enum PersistentEphemeralNodeMode {
+ EPHEMERAL, EPHEMERAL_SEQUENTIAL, PROTECTED_EPHEMERAL, PROTECTED_EPHEMERAL_SEQUENTIAL
+}
+
struct CuratorProjection {
1: string id;
}
@@ -70,6 +74,10 @@ struct PathChildrenCacheProjection {
1: string id;
}
+struct PersistentEphemeralNodeProjection {
+ 1: string id;
+}
+
struct Version {
1: i32 version;
}
@@ -205,6 +213,7 @@ service CuratorService {
LeaderResult startLeaderSelector(1: CuratorProjection projection, 2: string path, 3: string participantId, 4: i32 waitForLeadershipMs);
NodeCacheProjection startNodeCache(1: CuratorProjection projection, 2: string path, 3: bool dataIsCompressed, 4: bool buildInitial);
PathChildrenCacheProjection startPathChildrenCache(1: CuratorProjection projection, 2: string path, 3: bool cacheData, 4: bool dataIsCompressed, 5: PathChildrenCacheStartMode startMode);
+ PersistentEphemeralNodeProjection startPersistentEphemeralNode(1: CuratorProjection projection, 2: string path, 3: binary data, 4: PersistentEphemeralNodeMode mode);
}
service EventService {
http://git-wip-us.apache.org/repos/asf/curator/blob/cbd174a6/curator-x-rpc/src/test/java/org/apache/curator/generated/CuratorService.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/test/java/org/apache/curator/generated/CuratorService.java b/curator-x-rpc/src/test/java/org/apache/curator/generated/CuratorService.java
index 100b6c7..4c49c67 100644
--- a/curator-x-rpc/src/test/java/org/apache/curator/generated/CuratorService.java
+++ b/curator-x-rpc/src/test/java/org/apache/curator/generated/CuratorService.java
@@ -72,6 +72,8 @@ public class CuratorService {
public PathChildrenCacheProjection startPathChildrenCache(CuratorProjection projection, String path, boolean cacheData, boolean dataIsCompressed, PathChildrenCacheStartMode startMode) throws org.apache.thrift.TException;
+ public PersistentEphemeralNodeProjection startPersistentEphemeralNode(CuratorProjection projection, String path, ByteBuffer data, PersistentEphemeralNodeMode mode) throws org.apache.thrift.TException;
+
}
public interface AsyncIface {
@@ -112,6 +114,8 @@ public class CuratorService {
public void startPathChildrenCache(CuratorProjection projection, String path, boolean cacheData, boolean dataIsCompressed, PathChildrenCacheStartMode startMode, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
+ public void startPersistentEphemeralNode(CuratorProjection projection, String path, ByteBuffer data, PersistentEphemeralNodeMode mode, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
+
}
public static class Client extends org.apache.thrift.TServiceClient implements Iface {
@@ -567,6 +571,32 @@ public class CuratorService {
throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "startPathChildrenCache failed: unknown result");
}
+ public PersistentEphemeralNodeProjection startPersistentEphemeralNode(CuratorProjection projection, String path, ByteBuffer data, PersistentEphemeralNodeMode mode) throws org.apache.thrift.TException
+ {
+ send_startPersistentEphemeralNode(projection, path, data, mode);
+ return recv_startPersistentEphemeralNode();
+ }
+
+ public void send_startPersistentEphemeralNode(CuratorProjection projection, String path, ByteBuffer data, PersistentEphemeralNodeMode mode) throws org.apache.thrift.TException
+ {
+ startPersistentEphemeralNode_args args = new startPersistentEphemeralNode_args();
+ args.setProjection(projection);
+ args.setPath(path);
+ args.setData(data);
+ args.setMode(mode);
+ sendBase("startPersistentEphemeralNode", args);
+ }
+
+ public PersistentEphemeralNodeProjection recv_startPersistentEphemeralNode() throws org.apache.thrift.TException
+ {
+ startPersistentEphemeralNode_result result = new startPersistentEphemeralNode_result();
+ receiveBase(result, "startPersistentEphemeralNode");
+ if (result.isSetSuccess()) {
+ return result.success;
+ }
+ throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "startPersistentEphemeralNode failed: unknown result");
+ }
+
}
public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface {
public static class Factory implements org.apache.thrift.async.TAsyncClientFactory<AsyncClient> {
@@ -1236,6 +1266,47 @@ public class CuratorService {
}
}
+ public void startPersistentEphemeralNode(CuratorProjection projection, String path, ByteBuffer data, PersistentEphemeralNodeMode mode, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException {
+ checkReady();
+ startPersistentEphemeralNode_call method_call = new startPersistentEphemeralNode_call(projection, path, data, mode, resultHandler, this, ___protocolFactory, ___transport);
+ this.___currentMethod = method_call;
+ ___manager.call(method_call);
+ }
+
+ public static class startPersistentEphemeralNode_call extends org.apache.thrift.async.TAsyncMethodCall {
+ private CuratorProjection projection;
+ private String path;
+ private ByteBuffer data;
+ private PersistentEphemeralNodeMode mode;
+ public startPersistentEphemeralNode_call(CuratorProjection projection, String path, ByteBuffer data, PersistentEphemeralNodeMode mode, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+ super(client, protocolFactory, transport, resultHandler, false);
+ this.projection = projection;
+ this.path = path;
+ this.data = data;
+ this.mode = mode;
+ }
+
+ public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+ prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("startPersistentEphemeralNode", org.apache.thrift.protocol.TMessageType.CALL, 0));
+ startPersistentEphemeralNode_args args = new startPersistentEphemeralNode_args();
+ args.setProjection(projection);
+ args.setPath(path);
+ args.setData(data);
+ args.setMode(mode);
+ args.write(prot);
+ prot.writeMessageEnd();
+ }
+
+ public PersistentEphemeralNodeProjection getResult() throws org.apache.thrift.TException {
+ if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
+ throw new IllegalStateException("Method call not finished!");
+ }
+ org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array());
+ org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport);
+ return (new Client(prot)).recv_startPersistentEphemeralNode();
+ }
+ }
+
}
public static class Processor<I extends Iface> extends org.apache.thrift.TBaseProcessor<I> implements org.apache.thrift.TProcessor {
@@ -1267,6 +1338,7 @@ public class CuratorService {
processMap.put("startLeaderSelector", new startLeaderSelector());
processMap.put("startNodeCache", new startNodeCache());
processMap.put("startPathChildrenCache", new startPathChildrenCache());
+ processMap.put("startPersistentEphemeralNode", new startPersistentEphemeralNode());
return processMap;
}
@@ -1632,6 +1704,26 @@ public class CuratorService {
}
}
+ public static class startPersistentEphemeralNode<I extends Iface> extends org.apache.thrift.ProcessFunction<I, startPersistentEphemeralNode_args> {
+ public startPersistentEphemeralNode() {
+ super("startPersistentEphemeralNode");
+ }
+
+ public startPersistentEphemeralNode_args getEmptyArgsInstance() {
+ return new startPersistentEphemeralNode_args();
+ }
+
+ protected boolean isOneway() {
+ return false;
+ }
+
+ public startPersistentEphemeralNode_result getResult(I iface, startPersistentEphemeralNode_args args) throws org.apache.thrift.TException {
+ startPersistentEphemeralNode_result result = new startPersistentEphemeralNode_result();
+ result.success = iface.startPersistentEphemeralNode(args.projection, args.path, args.data, args.mode);
+ return result;
+ }
+ }
+
}
public static class AsyncProcessor<I extends AsyncIface> extends org.apache.thrift.TBaseAsyncProcessor<I> {
@@ -1663,6 +1755,7 @@ public class CuratorService {
processMap.put("startLeaderSelector", new startLeaderSelector());
processMap.put("startNodeCache", new startNodeCache());
processMap.put("startPathChildrenCache", new startPathChildrenCache());
+ processMap.put("startPersistentEphemeralNode", new startPersistentEphemeralNode());
return processMap;
}
@@ -2584,6 +2677,57 @@ public class CuratorService {
}
}
+ public static class startPersistentEphemeralNode<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, startPersistentEphemeralNode_args, PersistentEphemeralNodeProjection> {
+ public startPersistentEphemeralNode() {
+ super("startPersistentEphemeralNode");
+ }
+
+ public startPersistentEphemeralNode_args getEmptyArgsInstance() {
+ return new startPersistentEphemeralNode_args();
+ }
+
+ public AsyncMethodCallback<PersistentEphemeralNodeProjection> getResultHandler(final AsyncFrameBuffer fb, final int seqid) {
+ final org.apache.thrift.AsyncProcessFunction fcall = this;
+ return new AsyncMethodCallback<PersistentEphemeralNodeProjection>() {
+ public void onComplete(PersistentEphemeralNodeProjection o) {
+ startPersistentEphemeralNode_result result = new startPersistentEphemeralNode_result();
+ result.success = o;
+ try {
+ fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+ return;
+ } catch (Exception e) {
+ LOGGER.error("Exception writing to internal frame buffer", e);
+ }
+ fb.close();
+ }
+ public void onError(Exception e) {
+ byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+ org.apache.thrift.TBase msg;
+ startPersistentEphemeralNode_result result = new startPersistentEphemeralNode_result();
+ {
+ msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+ msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+ }
+ try {
+ fcall.sendResponse(fb,msg,msgType,seqid);
+ return;
+ } catch (Exception ex) {
+ LOGGER.error("Exception writing to internal frame buffer", ex);
+ }
+ fb.close();
+ }
+ };
+ }
+
+ protected boolean isOneway() {
+ return false;
+ }
+
+ public void start(I iface, startPersistentEphemeralNode_args args, org.apache.thrift.async.AsyncMethodCallback<PersistentEphemeralNodeProjection> resultHandler) throws TException {
+ iface.startPersistentEphemeralNode(args.projection, args.path, args.data, args.mode,resultHandler);
+ }
+ }
+
}
public static class acquireLock_args implements org.apache.thrift.TBase<acquireLock_args, acquireLock_args._Fields>, java.io.Serializable, Cloneable, Comparable<acquireLock_args> {
@@ -17924,4 +18068,1049 @@ public class CuratorService {
}
+ public static class startPersistentEphemeralNode_args implements org.apache.thrift.TBase<startPersistentEphemeralNode_args, startPersistentEphemeralNode_args._Fields>, java.io.Serializable, Cloneable, Comparable<startPersistentEphemeralNode_args> {
+ private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("startPersistentEphemeralNode_args");
+
+ private static final org.apache.thrift.protocol.TField PROJECTION_FIELD_DESC = new org.apache.thrift.protocol.TField("projection", org.apache.thrift.protocol.TType.STRUCT, (short)1);
+ 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)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 org.apache.thrift.protocol.TField MODE_FIELD_DESC = new org.apache.thrift.protocol.TField("mode", org.apache.thrift.protocol.TType.I32, (short)4);
+
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new startPersistentEphemeralNode_argsStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new startPersistentEphemeralNode_argsTupleSchemeFactory());
+ }
+
+ public CuratorProjection projection; // required
+ public String path; // required
+ public ByteBuffer data; // required
+ /**
+ *
+ * @see PersistentEphemeralNodeMode
+ */
+ public PersistentEphemeralNodeMode mode; // 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 {
+ PROJECTION((short)1, "projection"),
+ PATH((short)2, "path"),
+ DATA((short)3, "data"),
+ /**
+ *
+ * @see PersistentEphemeralNodeMode
+ */
+ MODE((short)4, "mode");
+
+ 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: // PROJECTION
+ return PROJECTION;
+ case 2: // PATH
+ return PATH;
+ case 3: // DATA
+ return DATA;
+ case 4: // MODE
+ return MODE;
+ 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.PROJECTION, new org.apache.thrift.meta_data.FieldMetaData("projection", org.apache.thrift.TFieldRequirementType.DEFAULT,
+ new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, CuratorProjection.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.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)));
+ tmpMap.put(_Fields.MODE, new org.apache.thrift.meta_data.FieldMetaData("mode", org.apache.thrift.TFieldRequirementType.DEFAULT,
+ new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, PersistentEphemeralNodeMode.class)));
+ metaDataMap = Collections.unmodifiableMap(tmpMap);
+ org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(startPersistentEphemeralNode_args.class, metaDataMap);
+ }
+
+ public startPersistentEphemeralNode_args() {
+ }
+
+ public startPersistentEphemeralNode_args(
+ CuratorProjection projection,
+ String path,
+ ByteBuffer data,
+ PersistentEphemeralNodeMode mode)
+ {
+ this();
+ this.projection = projection;
+ this.path = path;
+ this.data = data;
+ this.mode = mode;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public startPersistentEphemeralNode_args(startPersistentEphemeralNode_args other) {
+ if (other.isSetProjection()) {
+ this.projection = new CuratorProjection(other.projection);
+ }
+ if (other.isSetPath()) {
+ this.path = other.path;
+ }
+ if (other.isSetData()) {
+ this.data = org.apache.thrift.TBaseHelper.copyBinary(other.data);
+;
+ }
+ if (other.isSetMode()) {
+ this.mode = other.mode;
+ }
+ }
+
+ public startPersistentEphemeralNode_args deepCopy() {
+ return new startPersistentEphemeralNode_args(this);
+ }
+
+ @Override
+ public void clear() {
+ this.projection = null;
+ this.path = null;
+ this.data = null;
+ this.mode = null;
+ }
+
+ public CuratorProjection getProjection() {
+ return this.projection;
+ }
+
+ public startPersistentEphemeralNode_args setProjection(CuratorProjection projection) {
+ this.projection = projection;
+ return this;
+ }
+
+ public void unsetProjection() {
+ this.projection = null;
+ }
+
+ /** Returns true if field projection is set (has been assigned a value) and false otherwise */
+ public boolean isSetProjection() {
+ return this.projection != null;
+ }
+
+ public void setProjectionIsSet(boolean value) {
+ if (!value) {
+ this.projection = null;
+ }
+ }
+
+ public String getPath() {
+ return this.path;
+ }
+
+ public startPersistentEphemeralNode_args 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 byte[] getData() {
+ setData(org.apache.thrift.TBaseHelper.rightSize(data));
+ return data == null ? null : data.array();
+ }
+
+ public ByteBuffer bufferForData() {
+ return data;
+ }
+
+ public startPersistentEphemeralNode_args setData(byte[] data) {
+ setData(data == null ? (ByteBuffer)null : ByteBuffer.wrap(data));
+ return this;
+ }
+
+ public startPersistentEphemeralNode_args 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;
+ }
+ }
+
+ /**
+ *
+ * @see PersistentEphemeralNodeMode
+ */
+ public PersistentEphemeralNodeMode getMode() {
+ return this.mode;
+ }
+
+ /**
+ *
+ * @see PersistentEphemeralNodeMode
+ */
+ public startPersistentEphemeralNode_args setMode(PersistentEphemeralNodeMode mode) {
+ this.mode = mode;
+ return this;
+ }
+
+ public void unsetMode() {
+ this.mode = null;
+ }
+
+ /** Returns true if field mode is set (has been assigned a value) and false otherwise */
+ public boolean isSetMode() {
+ return this.mode != null;
+ }
+
+ public void setModeIsSet(boolean value) {
+ if (!value) {
+ this.mode = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case PROJECTION:
+ if (value == null) {
+ unsetProjection();
+ } else {
+ setProjection((CuratorProjection)value);
+ }
+ break;
+
+ case PATH:
+ if (value == null) {
+ unsetPath();
+ } else {
+ setPath((String)value);
+ }
+ break;
+
+ case DATA:
+ if (value == null) {
+ unsetData();
+ } else {
+ setData((ByteBuffer)value);
+ }
+ break;
+
+ case MODE:
+ if (value == null) {
+ unsetMode();
+ } else {
+ setMode((PersistentEphemeralNodeMode)value);
+ }
+ break;
+
+ }
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case PROJECTION:
+ return getProjection();
+
+ case PATH:
+ return getPath();
+
+ case DATA:
+ return getData();
+
+ case MODE:
+ return getMode();
+
+ }
+ 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 PROJECTION:
+ return isSetProjection();
+ case PATH:
+ return isSetPath();
+ case DATA:
+ return isSetData();
+ case MODE:
+ return isSetMode();
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof startPersistentEphemeralNode_args)
+ return this.equals((startPersistentEphemeralNode_args)that);
+ return false;
+ }
+
+ public boolean equals(startPersistentEphemeralNode_args that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_projection = true && this.isSetProjection();
+ boolean that_present_projection = true && that.isSetProjection();
+ if (this_present_projection || that_present_projection) {
+ if (!(this_present_projection && that_present_projection))
+ return false;
+ if (!this.projection.equals(that.projection))
+ 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_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;
+ }
+
+ boolean this_present_mode = true && this.isSetMode();
+ boolean that_present_mode = true && that.isSetMode();
+ if (this_present_mode || that_present_mode) {
+ if (!(this_present_mode && that_present_mode))
+ return false;
+ if (!this.mode.equals(that.mode))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ @Override
+ public int compareTo(startPersistentEphemeralNode_args other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+
+ lastComparison = Boolean.valueOf(isSetProjection()).compareTo(other.isSetProjection());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetProjection()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.projection, other.projection);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ 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(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;
+ }
+ }
+ lastComparison = Boolean.valueOf(isSetMode()).compareTo(other.isSetMode());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetMode()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.mode, other.mode);
+ 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("startPersistentEphemeralNode_args(");
+ boolean first = true;
+
+ sb.append("projection:");
+ if (this.projection == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.projection);
+ }
+ first = false;
+ if (!first) sb.append(", ");
+ sb.append("path:");
+ if (this.path == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.path);
+ }
+ 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;
+ if (!first) sb.append(", ");
+ sb.append("mode:");
+ if (this.mode == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.mode);
+ }
+ 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 (projection != null) {
+ projection.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 startPersistentEphemeralNode_argsStandardSchemeFactory implements SchemeFactory {
+ public startPersistentEphemeralNode_argsStandardScheme getScheme() {
+ return new startPersistentEphemeralNode_argsStandardScheme();
+ }
+ }
+
+ private static class startPersistentEphemeralNode_argsStandardScheme extends StandardScheme<startPersistentEphemeralNode_args> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, startPersistentEphemeralNode_args 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: // PROJECTION
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+ struct.projection = new CuratorProjection();
+ struct.projection.read(iprot);
+ struct.setProjectionIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ case 2: // 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 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;
+ case 4: // MODE
+ if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
+ struct.mode = PersistentEphemeralNodeMode.findByValue(iprot.readI32());
+ struct.setModeIsSet(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, startPersistentEphemeralNode_args struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (struct.projection != null) {
+ oprot.writeFieldBegin(PROJECTION_FIELD_DESC);
+ struct.projection.write(oprot);
+ oprot.writeFieldEnd();
+ }
+ if (struct.path != null) {
+ oprot.writeFieldBegin(PATH_FIELD_DESC);
+ oprot.writeString(struct.path);
+ oprot.writeFieldEnd();
+ }
+ if (struct.data != null) {
+ oprot.writeFieldBegin(DATA_FIELD_DESC);
+ oprot.writeBinary(struct.data);
+ oprot.writeFieldEnd();
+ }
+ if (struct.mode != null) {
+ oprot.writeFieldBegin(MODE_FIELD_DESC);
+ oprot.writeI32(struct.mode.getValue());
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class startPersistentEphemeralNode_argsTupleSchemeFactory implements SchemeFactory {
+ public startPersistentEphemeralNode_argsTupleScheme getScheme() {
+ return new startPersistentEphemeralNode_argsTupleScheme();
+ }
+ }
+
+ private static class startPersistentEphemeralNode_argsTupleScheme extends TupleScheme<startPersistentEphemeralNode_args> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, startPersistentEphemeralNode_args struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ BitSet optionals = new BitSet();
+ if (struct.isSetProjection()) {
+ optionals.set(0);
+ }
+ if (struct.isSetPath()) {
+ optionals.set(1);
+ }
+ if (struct.isSetData()) {
+ optionals.set(2);
+ }
+ if (struct.isSetMode()) {
+ optionals.set(3);
+ }
+ oprot.writeBitSet(optionals, 4);
+ if (struct.isSetProjection()) {
+ struct.projection.write(oprot);
+ }
+ if (struct.isSetPath()) {
+ oprot.writeString(struct.path);
+ }
+ if (struct.isSetData()) {
+ oprot.writeBinary(struct.data);
+ }
+ if (struct.isSetMode()) {
+ oprot.writeI32(struct.mode.getValue());
+ }
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, startPersistentEphemeralNode_args struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ BitSet incoming = iprot.readBitSet(4);
+ if (incoming.get(0)) {
+ struct.projection = new CuratorProjection();
+ struct.projection.read(iprot);
+ struct.setProjectionIsSet(true);
+ }
+ if (incoming.get(1)) {
+ struct.path = iprot.readString();
+ struct.setPathIsSet(true);
+ }
+ if (incoming.get(2)) {
+ struct.data = iprot.readBinary();
+ struct.setDataIsSet(true);
+ }
+ if (incoming.get(3)) {
+ struct.mode = PersistentEphemeralNodeMode.findByValue(iprot.readI32());
+ struct.setModeIsSet(true);
+ }
+ }
+ }
+
+ }
+
+ public static class startPersistentEphemeralNode_result implements org.apache.thrift.TBase<startPersistentEphemeralNode_result, startPersistentEphemeralNode_result._Fields>, java.io.Serializable, Cloneable, Comparable<startPersistentEphemeralNode_result> {
+ private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("startPersistentEphemeralNode_result");
+
+ private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0);
+
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new startPersistentEphemeralNode_resultStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new startPersistentEphemeralNode_resultTupleSchemeFactory());
+ }
+
+ public PersistentEphemeralNodeProjection success; // 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 {
+ SUCCESS((short)0, "success");
+
+ 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 0: // SUCCESS
+ return SUCCESS;
+ 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.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT,
+ new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, PersistentEphemeralNodeProjection.class)));
+ metaDataMap = Collections.unmodifiableMap(tmpMap);
+ org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(startPersistentEphemeralNode_result.class, metaDataMap);
+ }
+
+ public startPersistentEphemeralNode_result() {
+ }
+
+ public startPersistentEphemeralNode_result(
+ PersistentEphemeralNodeProjection success)
+ {
+ this();
+ this.success = success;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public startPersistentEphemeralNode_result(startPersistentEphemeralNode_result other) {
+ if (other.isSetSuccess()) {
+ this.success = new PersistentEphemeralNodeProjection(other.success);
+ }
+ }
+
+ public startPersistentEphemeralNode_result deepCopy() {
+ return new startPersistentEphemeralNode_result(this);
+ }
+
+ @Override
+ public void clear() {
+ this.success = null;
+ }
+
+ public PersistentEphemeralNodeProjection getSuccess() {
+ return this.success;
+ }
+
+ public startPersistentEphemeralNode_result setSuccess(PersistentEphemeralNodeProjection success) {
+ this.success = success;
+ return this;
+ }
+
+ public void unsetSuccess() {
+ this.success = null;
+ }
+
+ /** Returns true if field success is set (has been assigned a value) and false otherwise */
+ public boolean isSetSuccess() {
+ return this.success != null;
+ }
+
+ public void setSuccessIsSet(boolean value) {
+ if (!value) {
+ this.success = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case SUCCESS:
+ if (value == null) {
+ unsetSuccess();
+ } else {
+ setSuccess((PersistentEphemeralNodeProjection)value);
+ }
+ break;
+
+ }
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return getSuccess();
+
+ }
+ 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 SUCCESS:
+ return isSetSuccess();
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof startPersistentEphemeralNode_result)
+ return this.equals((startPersistentEphemeralNode_result)that);
+ return false;
+ }
+
+ public boolean equals(startPersistentEphemeralNode_result that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_success = true && this.isSetSuccess();
+ boolean that_present_success = true && that.isSetSuccess();
+ if (this_present_success || that_present_success) {
+ if (!(this_present_success && that_present_success))
+ return false;
+ if (!this.success.equals(that.success))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ @Override
+ public int compareTo(startPersistentEphemeralNode_result other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+
+ lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetSuccess()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success);
+ 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("startPersistentEphemeralNode_result(");
+ boolean first = true;
+
+ sb.append("success:");
+ if (this.success == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.success);
+ }
+ 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 (success != null) {
+ success.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 startPersistentEphemeralNode_resultStandardSchemeFactory implements SchemeFactory {
+ public startPersistentEphemeralNode_resultStandardScheme getScheme() {
+ return new startPersistentEphemeralNode_resultStandardScheme();
+ }
+ }
+
+ private static class startPersistentEphemeralNode_resultStandardScheme extends StandardScheme<startPersistentEphemeralNode_result> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, startPersistentEphemeralNode_result 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 0: // SUCCESS
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+ struct.success = new PersistentEphemeralNodeProjection();
+ struct.success.read(iprot);
+ struct.setSuccessIsSet(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, startPersistentEphemeralNode_result struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (struct.success != null) {
+ oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+ struct.success.write(oprot);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class startPersistentEphemeralNode_resultTupleSchemeFactory implements SchemeFactory {
+ public startPersistentEphemeralNode_resultTupleScheme getScheme() {
+ return new startPersistentEphemeralNode_resultTupleScheme();
+ }
+ }
+
+ private static class startPersistentEphemeralNode_resultTupleScheme extends TupleScheme<startPersistentEphemeralNode_result> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, startPersistentEphemeralNode_result struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ BitSet optionals = new BitSet();
+ if (struct.isSetSuccess()) {
+ optionals.set(0);
+ }
+ oprot.writeBitSet(optionals, 1);
+ if (struct.isSetSuccess()) {
+ struct.success.write(oprot);
+ }
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, startPersistentEphemeralNode_result struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ BitSet incoming = iprot.readBitSet(1);
+ if (incoming.get(0)) {
+ struct.success = new PersistentEphemeralNodeProjection();
+ struct.success.read(iprot);
+ struct.setSuccessIsSet(true);
+ }
+ }
+ }
+
+ }
+
}
http://git-wip-us.apache.org/repos/asf/curator/blob/cbd174a6/curator-x-rpc/src/test/java/org/apache/curator/generated/PersistentEphemeralNodeMode.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/test/java/org/apache/curator/generated/PersistentEphemeralNodeMode.java b/curator-x-rpc/src/test/java/org/apache/curator/generated/PersistentEphemeralNodeMode.java
new file mode 100644
index 0000000..422d35f
--- /dev/null
+++ b/curator-x-rpc/src/test/java/org/apache/curator/generated/PersistentEphemeralNodeMode.java
@@ -0,0 +1,51 @@
+/**
+ * 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 PersistentEphemeralNodeMode implements org.apache.thrift.TEnum {
+ EPHEMERAL(0),
+ EPHEMERAL_SEQUENTIAL(1),
+ PROTECTED_EPHEMERAL(2),
+ PROTECTED_EPHEMERAL_SEQUENTIAL(3);
+
+ private final int value;
+
+ private PersistentEphemeralNodeMode(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 PersistentEphemeralNodeMode findByValue(int value) {
+ switch (value) {
+ case 0:
+ return EPHEMERAL;
+ case 1:
+ return EPHEMERAL_SEQUENTIAL;
+ case 2:
+ return PROTECTED_EPHEMERAL;
+ case 3:
+ return PROTECTED_EPHEMERAL_SEQUENTIAL;
+ default:
+ return null;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/cbd174a6/curator-x-rpc/src/test/java/org/apache/curator/generated/PersistentEphemeralNodeProjection.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/test/java/org/apache/curator/generated/PersistentEphemeralNodeProjection.java b/curator-x-rpc/src/test/java/org/apache/curator/generated/PersistentEphemeralNodeProjection.java
new file mode 100644
index 0000000..607f247
--- /dev/null
+++ b/curator-x-rpc/src/test/java/org/apache/curator/generated/PersistentEphemeralNodeProjection.java
@@ -0,0 +1,388 @@
+/**
+ * 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 PersistentEphemeralNodeProjection implements org.apache.thrift.TBase<PersistentEphemeralNodeProjection, PersistentEphemeralNodeProjection._Fields>, java.io.Serializable, Cloneable, Comparable<PersistentEphemeralNodeProjection> {
+ private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("PersistentEphemeralNodeProjection");
+
+ private static final org.apache.thrift.protocol.TField ID_FIELD_DESC = new org.apache.thrift.protocol.TField("id", org.apache.thrift.protocol.TType.STRING, (short)1);
+
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new PersistentEphemeralNodeProjectionStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new PersistentEphemeralNodeProjectionTupleSchemeFactory());
+ }
+
+ public String id; // 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 {
+ ID((short)1, "id");
+
+ 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: // ID
+ return ID;
+ 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.ID, new org.apache.thrift.meta_data.FieldMetaData("id", org.apache.thrift.TFieldRequirementType.DEFAULT,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+ metaDataMap = Collections.unmodifiableMap(tmpMap);
+ org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(PersistentEphemeralNodeProjection.class, metaDataMap);
+ }
+
+ public PersistentEphemeralNodeProjection() {
+ }
+
+ public PersistentEphemeralNodeProjection(
+ String id)
+ {
+ this();
+ this.id = id;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public PersistentEphemeralNodeProjection(PersistentEphemeralNodeProjection other) {
+ if (other.isSetId()) {
+ this.id = other.id;
+ }
+ }
+
+ public PersistentEphemeralNodeProjection deepCopy() {
+ return new PersistentEphemeralNodeProjection(this);
+ }
+
+ @Override
+ public void clear() {
+ this.id = null;
+ }
+
+ public String getId() {
+ return this.id;
+ }
+
+ public PersistentEphemeralNodeProjection setId(String id) {
+ this.id = id;
+ return this;
+ }
+
+ public void unsetId() {
+ this.id = null;
+ }
+
+ /** Returns true if field id is set (has been assigned a value) and false otherwise */
+ public boolean isSetId() {
+ return this.id != null;
+ }
+
+ public void setIdIsSet(boolean value) {
+ if (!value) {
+ this.id = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case ID:
+ if (value == null) {
+ unsetId();
+ } else {
+ setId((String)value);
+ }
+ break;
+
+ }
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case ID:
+ return getId();
+
+ }
+ 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 ID:
+ return isSetId();
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof PersistentEphemeralNodeProjection)
+ return this.equals((PersistentEphemeralNodeProjection)that);
+ return false;
+ }
+
+ public boolean equals(PersistentEphemeralNodeProjection that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_id = true && this.isSetId();
+ boolean that_present_id = true && that.isSetId();
+ if (this_present_id || that_present_id) {
+ if (!(this_present_id && that_present_id))
+ return false;
+ if (!this.id.equals(that.id))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ @Override
+ public int compareTo(PersistentEphemeralNodeProjection other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+
+ lastComparison = Boolean.valueOf(isSetId()).compareTo(other.isSetId());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetId()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.id, other.id);
+ 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("PersistentEphemeralNodeProjection(");
+ boolean first = true;
+
+ sb.append("id:");
+ if (this.id == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.id);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws org.apache.thrift.TException {
+ // check for required fields
+ // check for sub-struct validity
+ }
+
+ 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 PersistentEphemeralNodeProjectionStandardSchemeFactory implements SchemeFactory {
+ public PersistentEphemeralNodeProjectionStandardScheme getScheme() {
+ return new PersistentEphemeralNodeProjectionStandardScheme();
+ }
+ }
+
+ private static class PersistentEphemeralNodeProjectionStandardScheme extends StandardScheme<PersistentEphemeralNodeProjection> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, PersistentEphemeralNodeProjection 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: // ID
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+ struct.id = iprot.readString();
+ struct.setIdIsSet(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, PersistentEphemeralNodeProjection struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (struct.id != null) {
+ oprot.writeFieldBegin(ID_FIELD_DESC);
+ oprot.writeString(struct.id);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class PersistentEphemeralNodeProjectionTupleSchemeFactory implements SchemeFactory {
+ public PersistentEphemeralNodeProjectionTupleScheme getScheme() {
+ return new PersistentEphemeralNodeProjectionTupleScheme();
+ }
+ }
+
+ private static class PersistentEphemeralNodeProjectionTupleScheme extends TupleScheme<PersistentEphemeralNodeProjection> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, PersistentEphemeralNodeProjection struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ BitSet optionals = new BitSet();
+ if (struct.isSetId()) {
+ optionals.set(0);
+ }
+ oprot.writeBitSet(optionals, 1);
+ if (struct.isSetId()) {
+ oprot.writeString(struct.id);
+ }
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, PersistentEphemeralNodeProjection struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ BitSet incoming = iprot.readBitSet(1);
+ if (incoming.get(0)) {
+ struct.id = iprot.readString();
+ struct.setIdIsSet(true);
+ }
+ }
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/curator/blob/cbd174a6/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 8b65beb..9da935c 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
@@ -126,5 +126,11 @@ public class TestClient
nodeCacheData = client.getNodeCacheData(curatorProjection, nodeCache);
System.out.println("nodeCacheData: " + nodeCacheData);
+
+ PersistentEphemeralNodeProjection node = client.startPersistentEphemeralNode(curatorProjection, "/my/path", ByteBuffer.wrap("hey".getBytes()), PersistentEphemeralNodeMode.EPHEMERAL);
+ existsSpec.path = "/my/path";
+ OptionalStat nodeExists = client.exists(curatorProjection, existsSpec);
+ System.out.println("nodeExists: " + nodeExists);
+ client.closeGenericProjection(curatorProjection, node.id);
}
}