Return-Path: X-Original-To: apmail-curator-commits-archive@minotaur.apache.org Delivered-To: apmail-curator-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 55C4511C4C for ; Sat, 7 Jun 2014 18:19:00 +0000 (UTC) Received: (qmail 31548 invoked by uid 500); 7 Jun 2014 18:19:00 -0000 Delivered-To: apmail-curator-commits-archive@curator.apache.org Received: (qmail 31509 invoked by uid 500); 7 Jun 2014 18:19:00 -0000 Mailing-List: contact commits-help@curator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@curator.apache.org Delivered-To: mailing list commits@curator.apache.org Received: (qmail 31500 invoked by uid 99); 7 Jun 2014 18:19:00 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 Jun 2014 18:19:00 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 0B9D28BBE2C; Sat, 7 Jun 2014 18:19:00 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: randgalt@apache.org To: commits@curator.apache.org Date: Sat, 07 Jun 2014 18:19:00 -0000 Message-Id: <537ac12cade94bea9ff0a28810a1eab7@git.apache.org> In-Reply-To: <29937670c88a49f291fad4a4fae0fddd@git.apache.org> References: <29937670c88a49f291fad4a4fae0fddd@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [02/50] [abbrv] git commit: Finished path children cache Finished path children cache Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/6f9a9ab4 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/6f9a9ab4 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/6f9a9ab4 Branch: refs/heads/master Commit: 6f9a9ab4ff218fb4aa8e961239bee45fe647f416 Parents: 4c626a7 Author: randgalt Authored: Thu May 29 15:54:10 2014 -0500 Committer: randgalt Committed: Thu May 29 15:54:10 2014 -0500 ---------------------------------------------------------------------- .../curator/x/rpc/idl/event/RpcChildData.java | 11 + .../idl/event/RpcPathChildrenCacheEvent.java | 2 +- .../projection/CuratorProjectionService.java | 46 +- curator-x-rpc/src/main/thrift/curator.thrift | 2 + .../curator/generated/CuratorService.java | 2071 ++++++++++++++++++ .../org/apache/curator/x/rpc/TestClient.java | 9 + 6 files changed, 2128 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/6f9a9ab4/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcChildData.java ---------------------------------------------------------------------- diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcChildData.java b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcChildData.java index 4c7827b..e490493 100644 --- a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcChildData.java +++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcChildData.java @@ -2,6 +2,7 @@ package org.apache.curator.x.rpc.idl.event; import com.facebook.swift.codec.ThriftField; import com.facebook.swift.codec.ThriftStruct; +import org.apache.curator.framework.recipes.cache.ChildData; @ThriftStruct("ChildData") public class RpcChildData @@ -19,6 +20,16 @@ public class RpcChildData { } + public RpcChildData(ChildData data) + { + if ( data != null ) + { + this.path = data.getPath(); + this.stat = RpcCuratorEvent.toRpcStat(data.getStat()); + this.data = data.getData(); + } + } + public RpcChildData(String path, RpcStat stat, byte[] data) { this.path = path; http://git-wip-us.apache.org/repos/asf/curator/blob/6f9a9ab4/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 9321157..59be6e2 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 @@ -24,7 +24,7 @@ public class RpcPathChildrenCacheEvent { 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; + data = (event.getData() != null) ? new RpcChildData(event.getData()) : null; } public RpcPathChildrenCacheEvent(String cachedPath, RpcPathChildrenCacheEventType type, RpcChildData data) http://git-wip-us.apache.org/repos/asf/curator/blob/6f9a9ab4/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 1084507..8b41353 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 @@ -26,6 +26,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.api.*; +import org.apache.curator.framework.recipes.cache.ChildData; import org.apache.curator.framework.recipes.cache.PathChildrenCache; import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener; @@ -41,15 +42,7 @@ import org.apache.curator.x.rpc.connections.ConnectionManager; import org.apache.curator.x.rpc.connections.CuratorEntry; import org.apache.curator.x.rpc.details.RpcBackgroundCallback; import org.apache.curator.x.rpc.details.RpcWatcher; -import org.apache.curator.x.rpc.idl.event.LeaderEvent; -import org.apache.curator.x.rpc.idl.event.LeaderResult; -import org.apache.curator.x.rpc.idl.event.OptionalChildrenList; -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.curator.x.rpc.idl.event.*; import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.data.Stat; import org.slf4j.Logger; @@ -356,7 +349,7 @@ public class CuratorProjectionService { CuratorEntry entry = getEntry(projection); - LeaderLatch leaderLatch = getThis(entry, leaderProjection.projection.id, LeaderLatch.class); + LeaderLatch leaderLatch = getThing(entry, leaderProjection.projection.id, LeaderLatch.class); Collection participants = leaderLatch.getParticipants(); return Lists.transform(Lists.newArrayList(participants), new Function() { @@ -373,7 +366,7 @@ public class CuratorProjectionService { CuratorEntry entry = getEntry(projection); - LeaderLatch leaderLatch = getThis(entry, leaderProjection.projection.id, LeaderLatch.class); + LeaderLatch leaderLatch = getThing(entry, leaderProjection.projection.id, LeaderLatch.class); return leaderLatch.hasLeadership(); } @@ -416,6 +409,35 @@ public class CuratorProjectionService return new PathChildrenCacheProjection(new GenericProjection(id)); } + @ThriftMethod + public List getPathChildrenCacheData(CuratorProjection projection, PathChildrenCacheProjection cacheProjection) throws Exception + { + CuratorEntry entry = getEntry(projection); + + PathChildrenCache pathChildrenCache = getThing(entry, cacheProjection.projection.id, PathChildrenCache.class); + return Lists.transform + ( + pathChildrenCache.getCurrentData(), + new Function() + { + @Override + public RpcChildData apply(ChildData childData) + { + return new RpcChildData(childData); + } + } + ); + } + + @ThriftMethod + public RpcChildData getPathChildrenCacheDataForPath(CuratorProjection projection, PathChildrenCacheProjection cacheProjection, String path) throws Exception + { + CuratorEntry entry = getEntry(projection); + + PathChildrenCache pathChildrenCache = getThing(entry, cacheProjection.projection.id, PathChildrenCache.class); + return new RpcChildData(pathChildrenCache.getCurrentData(path)); + } + public void addEvent(CuratorProjection projection, RpcCuratorEvent event) { CuratorEntry entry = connectionManager.get(projection.id); @@ -444,7 +466,7 @@ public class CuratorProjectionService throw new Exception("That operation is not available"); } - private T getThis(CuratorEntry entry, String id, Class clazz) + private T getThing(CuratorEntry entry, String id, Class clazz) { T thing = entry.getThing(id, clazz); Preconditions.checkNotNull(thing, "No item of type " + clazz.getSimpleName() + " found with id " + id); http://git-wip-us.apache.org/repos/asf/curator/blob/6f9a9ab4/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 765b93c..2b5e115 100644 --- a/curator-x-rpc/src/main/thrift/curator.thrift +++ b/curator-x-rpc/src/main/thrift/curator.thrift @@ -188,6 +188,8 @@ service CuratorService { OptionalChildrenList getChildren(1: CuratorProjection projection, 2: GetChildrenSpec spec); binary getData(1: CuratorProjection projection, 2: GetDataSpec spec); list getLeaderParticipants(1: CuratorProjection projection, 2: LeaderProjection leaderProjection); + list getPathChildrenCacheData(1: CuratorProjection projection, 2: PathChildrenCacheProjection cacheProjection); + ChildData getPathChildrenCacheDataForPath(1: CuratorProjection projection, 2: PathChildrenCacheProjection cacheProjection, 3: string path); bool isLeader(1: CuratorProjection projection, 2: LeaderProjection leaderProjection); CuratorProjection newCuratorProjection(1: string connectionName); Stat setData(1: CuratorProjection projection, 2: SetDataSpec spec);