http://git-wip-us.apache.org/repos/asf/curator/blob/3a0f6472/curator-x-rpc/src/test/java/org/apache/curator/generated/DeleteSpec.java ---------------------------------------------------------------------- diff --git a/curator-x-rpc/src/test/java/org/apache/curator/generated/DeleteSpec.java b/curator-x-rpc/src/test/java/org/apache/curator/generated/DeleteSpec.java index 96d9edb..f278e6e 100644 --- a/curator-x-rpc/src/test/java/org/apache/curator/generated/DeleteSpec.java +++ b/curator-x-rpc/src/test/java/org/apache/curator/generated/DeleteSpec.java @@ -38,8 +38,7 @@ public class DeleteSpec implements org.apache.thrift.TBase<DeleteSpec, DeleteSpe private static final org.apache.thrift.protocol.TField PATH_FIELD_DESC = new org.apache.thrift.protocol.TField("path", org.apache.thrift.protocol.TType.STRING, (short)1); private static final org.apache.thrift.protocol.TField GUARANTEED_FIELD_DESC = new org.apache.thrift.protocol.TField("guaranteed", org.apache.thrift.protocol.TType.BOOL, (short)2); private static final org.apache.thrift.protocol.TField ASYNC_CONTEXT_FIELD_DESC = new org.apache.thrift.protocol.TField("asyncContext", org.apache.thrift.protocol.TType.STRING, (short)3); - private static final org.apache.thrift.protocol.TField COMPRESSED_FIELD_DESC = new org.apache.thrift.protocol.TField("compressed", org.apache.thrift.protocol.TType.BOOL, (short)4); - private static final org.apache.thrift.protocol.TField VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("version", org.apache.thrift.protocol.TType.STRUCT, (short)5); + private static final org.apache.thrift.protocol.TField VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("version", org.apache.thrift.protocol.TType.STRUCT, (short)4); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { @@ -50,7 +49,6 @@ public class DeleteSpec implements org.apache.thrift.TBase<DeleteSpec, DeleteSpe public String path; // required public boolean guaranteed; // required public String asyncContext; // required - public boolean compressed; // required public Version version; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ @@ -58,8 +56,7 @@ public class DeleteSpec implements org.apache.thrift.TBase<DeleteSpec, DeleteSpe PATH((short)1, "path"), GUARANTEED((short)2, "guaranteed"), ASYNC_CONTEXT((short)3, "asyncContext"), - COMPRESSED((short)4, "compressed"), - VERSION((short)5, "version"); + VERSION((short)4, "version"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); @@ -80,9 +77,7 @@ public class DeleteSpec implements org.apache.thrift.TBase<DeleteSpec, DeleteSpe return GUARANTEED; case 3: // ASYNC_CONTEXT return ASYNC_CONTEXT; - case 4: // COMPRESSED - return COMPRESSED; - case 5: // VERSION + case 4: // VERSION return VERSION; default: return null; @@ -125,7 +120,6 @@ public class DeleteSpec implements org.apache.thrift.TBase<DeleteSpec, DeleteSpe // isset id assignments private static final int __GUARANTEED_ISSET_ID = 0; - private static final int __COMPRESSED_ISSET_ID = 1; private byte __isset_bitfield = 0; public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { @@ -136,8 +130,6 @@ public class DeleteSpec implements org.apache.thrift.TBase<DeleteSpec, DeleteSpe new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); tmpMap.put(_Fields.ASYNC_CONTEXT, new org.apache.thrift.meta_data.FieldMetaData("asyncContext", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.COMPRESSED, new org.apache.thrift.meta_data.FieldMetaData("compressed", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); tmpMap.put(_Fields.VERSION, new org.apache.thrift.meta_data.FieldMetaData("version", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, Version.class))); metaDataMap = Collections.unmodifiableMap(tmpMap); @@ -151,7 +143,6 @@ public class DeleteSpec implements org.apache.thrift.TBase<DeleteSpec, DeleteSpe String path, boolean guaranteed, String asyncContext, - boolean compressed, Version version) { this(); @@ -159,8 +150,6 @@ public class DeleteSpec implements org.apache.thrift.TBase<DeleteSpec, DeleteSpe this.guaranteed = guaranteed; setGuaranteedIsSet(true); this.asyncContext = asyncContext; - this.compressed = compressed; - setCompressedIsSet(true); this.version = version; } @@ -176,7 +165,6 @@ public class DeleteSpec implements org.apache.thrift.TBase<DeleteSpec, DeleteSpe if (other.isSetAsyncContext()) { this.asyncContext = other.asyncContext; } - this.compressed = other.compressed; if (other.isSetVersion()) { this.version = new Version(other.version); } @@ -192,8 +180,6 @@ public class DeleteSpec implements org.apache.thrift.TBase<DeleteSpec, DeleteSpe setGuaranteedIsSet(false); this.guaranteed = false; this.asyncContext = null; - setCompressedIsSet(false); - this.compressed = false; this.version = null; } @@ -268,29 +254,6 @@ public class DeleteSpec implements org.apache.thrift.TBase<DeleteSpec, DeleteSpe } } - public boolean isCompressed() { - return this.compressed; - } - - public DeleteSpec setCompressed(boolean compressed) { - this.compressed = compressed; - setCompressedIsSet(true); - return this; - } - - public void unsetCompressed() { - __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __COMPRESSED_ISSET_ID); - } - - /** Returns true if field compressed is set (has been assigned a value) and false otherwise */ - public boolean isSetCompressed() { - return EncodingUtils.testBit(__isset_bitfield, __COMPRESSED_ISSET_ID); - } - - public void setCompressedIsSet(boolean value) { - __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __COMPRESSED_ISSET_ID, value); - } - public Version getVersion() { return this.version; } @@ -341,14 +304,6 @@ public class DeleteSpec implements org.apache.thrift.TBase<DeleteSpec, DeleteSpe } break; - case COMPRESSED: - if (value == null) { - unsetCompressed(); - } else { - setCompressed((Boolean)value); - } - break; - case VERSION: if (value == null) { unsetVersion(); @@ -371,9 +326,6 @@ public class DeleteSpec implements org.apache.thrift.TBase<DeleteSpec, DeleteSpe case ASYNC_CONTEXT: return getAsyncContext(); - case COMPRESSED: - return Boolean.valueOf(isCompressed()); - case VERSION: return getVersion(); @@ -394,8 +346,6 @@ public class DeleteSpec implements org.apache.thrift.TBase<DeleteSpec, DeleteSpe return isSetGuaranteed(); case ASYNC_CONTEXT: return isSetAsyncContext(); - case COMPRESSED: - return isSetCompressed(); case VERSION: return isSetVersion(); } @@ -442,15 +392,6 @@ public class DeleteSpec implements org.apache.thrift.TBase<DeleteSpec, DeleteSpe return false; } - boolean this_present_compressed = true; - boolean that_present_compressed = true; - if (this_present_compressed || that_present_compressed) { - if (!(this_present_compressed && that_present_compressed)) - return false; - if (this.compressed != that.compressed) - return false; - } - boolean this_present_version = true && this.isSetVersion(); boolean that_present_version = true && that.isSetVersion(); if (this_present_version || that_present_version) { @@ -506,16 +447,6 @@ public class DeleteSpec implements org.apache.thrift.TBase<DeleteSpec, DeleteSpe return lastComparison; } } - lastComparison = Boolean.valueOf(isSetCompressed()).compareTo(other.isSetCompressed()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetCompressed()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.compressed, other.compressed); - if (lastComparison != 0) { - return lastComparison; - } - } lastComparison = Boolean.valueOf(isSetVersion()).compareTo(other.isSetVersion()); if (lastComparison != 0) { return lastComparison; @@ -566,10 +497,6 @@ public class DeleteSpec implements org.apache.thrift.TBase<DeleteSpec, DeleteSpe } first = false; if (!first) sb.append(", "); - sb.append("compressed:"); - sb.append(this.compressed); - first = false; - if (!first) sb.append(", "); sb.append("version:"); if (this.version == null) { sb.append("null"); @@ -649,15 +576,7 @@ public class DeleteSpec implements org.apache.thrift.TBase<DeleteSpec, DeleteSpe org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case 4: // COMPRESSED - if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { - struct.compressed = iprot.readBool(); - struct.setCompressedIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 5: // VERSION + case 4: // VERSION if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.version = new Version(); struct.version.read(iprot); @@ -694,9 +613,6 @@ public class DeleteSpec implements org.apache.thrift.TBase<DeleteSpec, DeleteSpe oprot.writeString(struct.asyncContext); oprot.writeFieldEnd(); } - oprot.writeFieldBegin(COMPRESSED_FIELD_DESC); - oprot.writeBool(struct.compressed); - oprot.writeFieldEnd(); if (struct.version != null) { oprot.writeFieldBegin(VERSION_FIELD_DESC); struct.version.write(oprot); @@ -729,13 +645,10 @@ public class DeleteSpec implements org.apache.thrift.TBase<DeleteSpec, DeleteSpe if (struct.isSetAsyncContext()) { optionals.set(2); } - if (struct.isSetCompressed()) { - optionals.set(3); - } if (struct.isSetVersion()) { - optionals.set(4); + optionals.set(3); } - oprot.writeBitSet(optionals, 5); + oprot.writeBitSet(optionals, 4); if (struct.isSetPath()) { oprot.writeString(struct.path); } @@ -745,9 +658,6 @@ public class DeleteSpec implements org.apache.thrift.TBase<DeleteSpec, DeleteSpe if (struct.isSetAsyncContext()) { oprot.writeString(struct.asyncContext); } - if (struct.isSetCompressed()) { - oprot.writeBool(struct.compressed); - } if (struct.isSetVersion()) { struct.version.write(oprot); } @@ -756,7 +666,7 @@ public class DeleteSpec implements org.apache.thrift.TBase<DeleteSpec, DeleteSpe @Override public void read(org.apache.thrift.protocol.TProtocol prot, DeleteSpec struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(5); + BitSet incoming = iprot.readBitSet(4); if (incoming.get(0)) { struct.path = iprot.readString(); struct.setPathIsSet(true); @@ -770,10 +680,6 @@ public class DeleteSpec implements org.apache.thrift.TBase<DeleteSpec, DeleteSpe struct.setAsyncContextIsSet(true); } if (incoming.get(3)) { - struct.compressed = iprot.readBool(); - struct.setCompressedIsSet(true); - } - if (incoming.get(4)) { struct.version = new Version(); struct.version.read(iprot); struct.setVersionIsSet(true);
http://git-wip-us.apache.org/repos/asf/curator/blob/3a0f6472/curator-x-rpc/src/test/java/org/apache/curator/generated/LeaderResult.java ---------------------------------------------------------------------- diff --git a/curator-x-rpc/src/test/java/org/apache/curator/generated/LeaderResult.java b/curator-x-rpc/src/test/java/org/apache/curator/generated/LeaderResult.java index 83c3dc8..4fba9d6 100644 --- a/curator-x-rpc/src/test/java/org/apache/curator/generated/LeaderResult.java +++ b/curator-x-rpc/src/test/java/org/apache/curator/generated/LeaderResult.java @@ -36,7 +36,7 @@ public class LeaderResult implements org.apache.thrift.TBase<LeaderResult, Leade private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("LeaderResult"); 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 HAS_LEADERSHIP_FIELD_DESC = new org.apache.thrift.protocol.TField("hasLeadership", org.apache.thrift.protocol.TType.BOOL, (short)2); + private static final org.apache.thrift.protocol.TField IS_LEADER_FIELD_DESC = new org.apache.thrift.protocol.TField("isLeader", org.apache.thrift.protocol.TType.BOOL, (short)2); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { @@ -45,12 +45,12 @@ public class LeaderResult implements org.apache.thrift.TBase<LeaderResult, Leade } public LeaderProjection projection; // required - public boolean hasLeadership; // required + public boolean isLeader; // 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"), - HAS_LEADERSHIP((short)2, "hasLeadership"); + IS_LEADER((short)2, "isLeader"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); @@ -67,8 +67,8 @@ public class LeaderResult implements org.apache.thrift.TBase<LeaderResult, Leade switch(fieldId) { case 1: // PROJECTION return PROJECTION; - case 2: // HAS_LEADERSHIP - return HAS_LEADERSHIP; + case 2: // IS_LEADER + return IS_LEADER; default: return null; } @@ -109,14 +109,14 @@ public class LeaderResult implements org.apache.thrift.TBase<LeaderResult, Leade } // isset id assignments - private static final int __HASLEADERSHIP_ISSET_ID = 0; + private static final int __ISLEADER_ISSET_ID = 0; private byte __isset_bitfield = 0; 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, LeaderProjection.class))); - tmpMap.put(_Fields.HAS_LEADERSHIP, new org.apache.thrift.meta_data.FieldMetaData("hasLeadership", org.apache.thrift.TFieldRequirementType.DEFAULT, + tmpMap.put(_Fields.IS_LEADER, new org.apache.thrift.meta_data.FieldMetaData("isLeader", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(LeaderResult.class, metaDataMap); @@ -127,12 +127,12 @@ public class LeaderResult implements org.apache.thrift.TBase<LeaderResult, Leade public LeaderResult( LeaderProjection projection, - boolean hasLeadership) + boolean isLeader) { this(); this.projection = projection; - this.hasLeadership = hasLeadership; - setHasLeadershipIsSet(true); + this.isLeader = isLeader; + setIsLeaderIsSet(true); } /** @@ -143,7 +143,7 @@ public class LeaderResult implements org.apache.thrift.TBase<LeaderResult, Leade if (other.isSetProjection()) { this.projection = new LeaderProjection(other.projection); } - this.hasLeadership = other.hasLeadership; + this.isLeader = other.isLeader; } public LeaderResult deepCopy() { @@ -153,8 +153,8 @@ public class LeaderResult implements org.apache.thrift.TBase<LeaderResult, Leade @Override public void clear() { this.projection = null; - setHasLeadershipIsSet(false); - this.hasLeadership = false; + setIsLeaderIsSet(false); + this.isLeader = false; } public LeaderProjection getProjection() { @@ -181,27 +181,27 @@ public class LeaderResult implements org.apache.thrift.TBase<LeaderResult, Leade } } - public boolean isHasLeadership() { - return this.hasLeadership; + public boolean isIsLeader() { + return this.isLeader; } - public LeaderResult setHasLeadership(boolean hasLeadership) { - this.hasLeadership = hasLeadership; - setHasLeadershipIsSet(true); + public LeaderResult setIsLeader(boolean isLeader) { + this.isLeader = isLeader; + setIsLeaderIsSet(true); return this; } - public void unsetHasLeadership() { - __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __HASLEADERSHIP_ISSET_ID); + public void unsetIsLeader() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ISLEADER_ISSET_ID); } - /** Returns true if field hasLeadership is set (has been assigned a value) and false otherwise */ - public boolean isSetHasLeadership() { - return EncodingUtils.testBit(__isset_bitfield, __HASLEADERSHIP_ISSET_ID); + /** Returns true if field isLeader is set (has been assigned a value) and false otherwise */ + public boolean isSetIsLeader() { + return EncodingUtils.testBit(__isset_bitfield, __ISLEADER_ISSET_ID); } - public void setHasLeadershipIsSet(boolean value) { - __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __HASLEADERSHIP_ISSET_ID, value); + public void setIsLeaderIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ISLEADER_ISSET_ID, value); } public void setFieldValue(_Fields field, Object value) { @@ -214,11 +214,11 @@ public class LeaderResult implements org.apache.thrift.TBase<LeaderResult, Leade } break; - case HAS_LEADERSHIP: + case IS_LEADER: if (value == null) { - unsetHasLeadership(); + unsetIsLeader(); } else { - setHasLeadership((Boolean)value); + setIsLeader((Boolean)value); } break; @@ -230,8 +230,8 @@ public class LeaderResult implements org.apache.thrift.TBase<LeaderResult, Leade case PROJECTION: return getProjection(); - case HAS_LEADERSHIP: - return Boolean.valueOf(isHasLeadership()); + case IS_LEADER: + return Boolean.valueOf(isIsLeader()); } throw new IllegalStateException(); @@ -246,8 +246,8 @@ public class LeaderResult implements org.apache.thrift.TBase<LeaderResult, Leade switch (field) { case PROJECTION: return isSetProjection(); - case HAS_LEADERSHIP: - return isSetHasLeadership(); + case IS_LEADER: + return isSetIsLeader(); } throw new IllegalStateException(); } @@ -274,12 +274,12 @@ public class LeaderResult implements org.apache.thrift.TBase<LeaderResult, Leade return false; } - boolean this_present_hasLeadership = true; - boolean that_present_hasLeadership = true; - if (this_present_hasLeadership || that_present_hasLeadership) { - if (!(this_present_hasLeadership && that_present_hasLeadership)) + boolean this_present_isLeader = true; + boolean that_present_isLeader = true; + if (this_present_isLeader || that_present_isLeader) { + if (!(this_present_isLeader && that_present_isLeader)) return false; - if (this.hasLeadership != that.hasLeadership) + if (this.isLeader != that.isLeader) return false; } @@ -309,12 +309,12 @@ public class LeaderResult implements org.apache.thrift.TBase<LeaderResult, Leade return lastComparison; } } - lastComparison = Boolean.valueOf(isSetHasLeadership()).compareTo(other.isSetHasLeadership()); + lastComparison = Boolean.valueOf(isSetIsLeader()).compareTo(other.isSetIsLeader()); if (lastComparison != 0) { return lastComparison; } - if (isSetHasLeadership()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.hasLeadership, other.hasLeadership); + if (isSetIsLeader()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.isLeader, other.isLeader); if (lastComparison != 0) { return lastComparison; } @@ -347,8 +347,8 @@ public class LeaderResult implements org.apache.thrift.TBase<LeaderResult, Leade } first = false; if (!first) sb.append(", "); - sb.append("hasLeadership:"); - sb.append(this.hasLeadership); + sb.append("isLeader:"); + sb.append(this.isLeader); first = false; sb.append(")"); return sb.toString(); @@ -407,10 +407,10 @@ public class LeaderResult implements org.apache.thrift.TBase<LeaderResult, Leade org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case 2: // HAS_LEADERSHIP + case 2: // IS_LEADER if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { - struct.hasLeadership = iprot.readBool(); - struct.setHasLeadershipIsSet(true); + struct.isLeader = iprot.readBool(); + struct.setIsLeaderIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -435,8 +435,8 @@ public class LeaderResult implements org.apache.thrift.TBase<LeaderResult, Leade struct.projection.write(oprot); oprot.writeFieldEnd(); } - oprot.writeFieldBegin(HAS_LEADERSHIP_FIELD_DESC); - oprot.writeBool(struct.hasLeadership); + oprot.writeFieldBegin(IS_LEADER_FIELD_DESC); + oprot.writeBool(struct.isLeader); oprot.writeFieldEnd(); oprot.writeFieldStop(); oprot.writeStructEnd(); @@ -459,15 +459,15 @@ public class LeaderResult implements org.apache.thrift.TBase<LeaderResult, Leade if (struct.isSetProjection()) { optionals.set(0); } - if (struct.isSetHasLeadership()) { + if (struct.isSetIsLeader()) { optionals.set(1); } oprot.writeBitSet(optionals, 2); if (struct.isSetProjection()) { struct.projection.write(oprot); } - if (struct.isSetHasLeadership()) { - oprot.writeBool(struct.hasLeadership); + if (struct.isSetIsLeader()) { + oprot.writeBool(struct.isLeader); } } @@ -481,8 +481,8 @@ public class LeaderResult implements org.apache.thrift.TBase<LeaderResult, Leade struct.setProjectionIsSet(true); } if (incoming.get(1)) { - struct.hasLeadership = iprot.readBool(); - struct.setHasLeadershipIsSet(true); + struct.isLeader = iprot.readBool(); + struct.setIsLeaderIsSet(true); } } } http://git-wip-us.apache.org/repos/asf/curator/blob/3a0f6472/curator-x-rpc/src/test/java/org/apache/curator/x/rpc/RpcTests.java ---------------------------------------------------------------------- diff --git a/curator-x-rpc/src/test/java/org/apache/curator/x/rpc/RpcTests.java b/curator-x-rpc/src/test/java/org/apache/curator/x/rpc/RpcTests.java index 0862b11..84b31de 100644 --- a/curator-x-rpc/src/test/java/org/apache/curator/x/rpc/RpcTests.java +++ b/curator-x-rpc/src/test/java/org/apache/curator/x/rpc/RpcTests.java @@ -1,13 +1,19 @@ package org.apache.curator.x.rpc; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.generated.*; +import org.apache.curator.retry.RetryOneTime; import org.apache.curator.test.BaseClassForTests; import org.apache.curator.test.InstanceSpec; import org.apache.curator.test.Timing; +import org.apache.curator.utils.CloseableUtils; import org.apache.curator.utils.ThreadUtils; import org.apache.thrift.protocol.TBinaryProtocol; import org.apache.thrift.protocol.TProtocol; import org.apache.thrift.transport.TSocket; +import org.apache.zookeeper.WatchedEvent; +import org.apache.zookeeper.Watcher; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.node.ArrayNode; import org.codehaus.jackson.node.ObjectNode; @@ -223,4 +229,43 @@ public class RpcTests extends BaseClassForTests Assert.assertEquals(e.nodeException, NodeExceptionType.NONODE); } } + + @Test + public void testEphemeralCleanup() throws Exception + { + CuratorProjection curatorProjection = curatorServiceClient.newCuratorProjection("test"); + CreateSpec spec = new CreateSpec(); + spec.path = "/test"; + spec.data = ByteBuffer.wrap("value".getBytes()); + spec.mode = CreateMode.EPHEMERAL; + OptionalPath node = curatorServiceClient.createNode(curatorProjection, spec); + System.out.println(node); + + final CountDownLatch latch = new CountDownLatch(1); + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); + try + { + client.start(); + Watcher watcher = new Watcher() + { + @Override + public void process(WatchedEvent event) + { + if ( event.getType() == Event.EventType.NodeDeleted ) + { + latch.countDown(); + } + } + }; + client.checkExists().usingWatcher(watcher).forPath("/test"); + + curatorServiceClient.closeCuratorProjection(curatorProjection); + + Assert.assertTrue(timing.awaitLatch(latch)); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } } http://git-wip-us.apache.org/repos/asf/curator/blob/3a0f6472/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 931cb8d..db8bc13 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 @@ -129,7 +129,7 @@ public class TestClient System.out.println("exists: " + client.exists(curatorProjection, existsSpec)); LeaderResult leader = client.startLeaderSelector(curatorProjection, "/leader", "me", 10000); - System.out.println("Has Leader: " + leader.hasLeadership); + System.out.println("Has Leader: " + leader.isLeader); List<Participant> leaderParticipants = client.getLeaderParticipants(curatorProjection, leader.projection); System.out.println("Participants: " + leaderParticipants); @@ -151,7 +151,7 @@ public class TestClient System.out.println("nodeExists: " + nodeExists); client.closeGenericProjection(curatorProjection, node.id); - List<LeaseProjection> leaseProjections = client.startSemaphore(curatorProjection, "/semi", 3, 1000, 10); + List<LeaseProjection> leaseProjections = client.acquireSemaphore(curatorProjection, "/semi", 3, 1000, 10); System.out.println("leaseProjections: " + leaseProjections); for ( LeaseProjection leaseProjection : leaseProjections ) {