curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From randg...@apache.org
Subject [04/14] git commit: wip
Date Tue, 27 May 2014 13:57:26 GMT
wip


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

Branch: refs/heads/curator-rpc
Commit: cd3dbdcbe5f17c8db51d75e3d33f492b6e56dc14
Parents: f103e02
Author: randgalt <randgalt@apache.org>
Authored: Mon May 26 02:02:16 2014 -0500
Committer: randgalt <randgalt@apache.org>
Committed: Mon May 26 02:02:16 2014 -0500

----------------------------------------------------------------------
 .../curator/x/rpc/CuratorProjectionServer.java  |   4 +-
 .../x/rpc/idl/event/CuratorEventService.java    |  23 --
 .../x/rpc/idl/event/CuratorRpcEvent.java        | 279 -------------------
 .../x/rpc/idl/event/CuratorRpcEventType.java    |  19 --
 .../x/rpc/idl/event/RpcCuratorEvent.java        | 279 +++++++++++++++++++
 .../x/rpc/idl/event/RpcCuratorEventType.java    |  19 ++
 .../projection/CuratorProjectionService.java    |  22 +-
 curator-x-rpc/src/main/scripts/generate.sh      |   8 +-
 .../src/main/thrift/curator-event.thrift        |  64 -----
 curator-x-rpc/src/main/thrift/curator.thrift    |  59 +++-
 10 files changed, 375 insertions(+), 401 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/cd3dbdcb/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/CuratorProjectionServer.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/CuratorProjectionServer.java
b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/CuratorProjectionServer.java
index 489d5a6..cd35f42 100644
--- a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/CuratorProjectionServer.java
+++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/CuratorProjectionServer.java
@@ -6,15 +6,13 @@ import com.facebook.swift.service.ThriftServer;
 import com.facebook.swift.service.ThriftServerConfig;
 import com.facebook.swift.service.ThriftServiceProcessor;
 import com.google.common.collect.Lists;
-import org.apache.curator.x.rpc.idl.event.CuratorEventService;
 import org.apache.curator.x.rpc.idl.projection.CuratorProjectionService;
 
 public class CuratorProjectionServer
 {
     public static void main(String[] args)
     {
-        CuratorEventService eventService = new CuratorEventService();
-        CuratorProjectionService projectionService = new CuratorProjectionService(eventService);
+        CuratorProjectionService projectionService = new CuratorProjectionService();
         ThriftServiceProcessor processor = new ThriftServiceProcessor(new ThriftCodecManager(),
Lists.<ThriftEventHandler>newArrayList(), projectionService);
         ThriftServer server = new ThriftServer(processor, new ThriftServerConfig().setPort(8899));
 // TODO
         server.start();

http://git-wip-us.apache.org/repos/asf/curator/blob/cd3dbdcb/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/CuratorEventService.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/CuratorEventService.java
b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/CuratorEventService.java
deleted file mode 100644
index 844de0d..0000000
--- a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/CuratorEventService.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.apache.curator.x.rpc.idl.event;
-
-import com.facebook.swift.service.ThriftMethod;
-import com.facebook.swift.service.ThriftService;
-import com.google.common.collect.Queues;
-import java.util.concurrent.BlockingQueue;
-
-@ThriftService("CuratorEventService")
-public class CuratorEventService
-{
-    private final BlockingQueue<CuratorRpcEvent> events = Queues.newLinkedBlockingQueue();
-
-    @ThriftMethod
-    public CuratorRpcEvent getNextEvent() throws InterruptedException
-    {
-        return events.take();
-    }
-
-    public void addEvent(CuratorRpcEvent event)
-    {
-        events.offer(event);
-    }
-}

http://git-wip-us.apache.org/repos/asf/curator/blob/cd3dbdcb/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/CuratorRpcEvent.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/CuratorRpcEvent.java
b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/CuratorRpcEvent.java
deleted file mode 100644
index db2b278..0000000
--- a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/CuratorRpcEvent.java
+++ /dev/null
@@ -1,279 +0,0 @@
-package org.apache.curator.x.rpc.idl.event;
-
-import com.facebook.swift.codec.ThriftField;
-import com.facebook.swift.codec.ThriftStruct;
-import com.google.common.base.Function;
-import com.google.common.collect.Lists;
-import org.apache.curator.framework.api.CuratorEvent;
-import org.apache.curator.x.rpc.idl.projection.CuratorProjection;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.data.ACL;
-import org.apache.zookeeper.data.Stat;
-import javax.annotation.Nullable;
-import java.util.List;
-
-@SuppressWarnings("deprecation")
-@ThriftStruct("CuratorEvent")
-public class CuratorRpcEvent
-{
-    private final CuratorProjection projection;
-    private final CuratorEvent event;
-
-    public CuratorRpcEvent()
-    {
-        throw new UnsupportedOperationException();
-    }
-
-    public CuratorRpcEvent(CuratorProjection projection, CuratorEvent event)
-    {
-        this.projection = projection;
-        this.event = event;
-    }
-
-    @ThriftField(1)
-    public CuratorProjection getProjection()
-    {
-        return projection;
-    }
-
-    @ThriftField(2)
-    public CuratorRpcEventType getType()
-    {
-        switch ( event.getType() )
-        {
-            case CREATE:
-            {
-                return CuratorRpcEventType.CREATE;
-            }
-
-            case DELETE:
-            {
-                return CuratorRpcEventType.DELETE;
-            }
-
-            case EXISTS:
-            {
-                return CuratorRpcEventType.EXISTS;
-            }
-
-            case GET_DATA:
-            {
-                return CuratorRpcEventType.GET_DATA;
-            }
-
-            case SET_DATA:
-            {
-                return CuratorRpcEventType.SET_DATA;
-            }
-
-            case CHILDREN:
-            {
-                return CuratorRpcEventType.CHILDREN;
-            }
-
-            case SYNC:
-            {
-                return CuratorRpcEventType.SYNC;
-            }
-
-            case GET_ACL:
-            {
-                return CuratorRpcEventType.GET_ACL;
-            }
-
-            case SET_ACL:
-            {
-                return CuratorRpcEventType.SET_ACL;
-            }
-
-            case WATCHED:
-            {
-                return CuratorRpcEventType.WATCHED;
-            }
-
-            case CLOSING:
-            {
-                return CuratorRpcEventType.CLOSING;
-            }
-        }
-
-        throw new IllegalStateException("Unknown type: " + event.getType());
-    }
-
-    @ThriftField(3)
-    public int getResultCode()
-    {
-        return event.getResultCode();
-    }
-
-    @ThriftField(4)
-    public String getPath()
-    {
-        return event.getPath();
-    }
-
-    @ThriftField(5)
-    public String getContext()
-    {
-        return String.valueOf(event.getContext());
-    }
-
-    @ThriftField(6)
-    public RpcStat getStat()
-    {
-        Stat stat = event.getStat();
-        if ( stat != null )
-        {
-            return new RpcStat
-            (
-                stat.getCzxid(),
-                stat.getMzxid(),
-                stat.getCtime(),
-                stat.getMtime(),
-                stat.getVersion(),
-                stat.getCversion(),
-                stat.getAversion(),
-                stat.getEphemeralOwner(),
-                stat.getDataLength(),
-                stat.getNumChildren(),
-                stat.getPzxid()
-            );
-        }
-        return null;
-    }
-
-    @ThriftField(7)
-    public byte[] getData()
-    {
-        return event.getData();
-    }
-
-    @ThriftField(8)
-    public String getName()
-    {
-        return event.getPath();
-    }
-
-    @ThriftField(9)
-    public List<String> getChildren()
-    {
-        return event.getChildren();
-    }
-
-    @ThriftField(10)
-    public List<RpcAcl> getACLList()
-    {
-        List<ACL> aclList = event.getACLList();
-        if ( aclList != null )
-        {
-            return Lists.transform
-            (
-                aclList,
-                new Function<ACL, RpcAcl>()
-                {
-                    @Nullable
-                    @Override
-                    public RpcAcl apply(ACL acl)
-                    {
-                        RpcId id = new RpcId(acl.getId().getScheme(), acl.getId().getId());
-                        return new RpcAcl(acl.getPerms(), id);
-                    }
-                }
-            );
-        }
-        return null;
-    }
-
-    @ThriftField(11)
-    public RpcWatchedEvent getWatchedEvent()
-    {
-        WatchedEvent watchedEvent = event.getWatchedEvent();
-        if ( watchedEvent != null )
-        {
-            RpcKeeperState keeperState = toRpcKeeperState(watchedEvent.getState());
-            RpcEventType eventType = toRpcEventType(watchedEvent.getType());
-            return new RpcWatchedEvent(keeperState, eventType, watchedEvent.getPath());
-        }
-        return null;
-    }
-
-    private RpcEventType toRpcEventType(Watcher.Event.EventType type)
-    {
-        switch ( type )
-        {
-            case None:
-            {
-                return RpcEventType.None;
-            }
-
-            case NodeCreated:
-            {
-                return RpcEventType.NodeCreated;
-            }
-
-            case NodeDeleted:
-            {
-                return RpcEventType.NodeDeleted;
-            }
-
-            case NodeDataChanged:
-            {
-                return RpcEventType.NodeDataChanged;
-            }
-
-            case NodeChildrenChanged:
-            {
-                return RpcEventType.NodeChildrenChanged;
-            }
-        }
-        throw new IllegalStateException("Unknown type: " + type);
-    }
-
-    private RpcKeeperState toRpcKeeperState(Watcher.Event.KeeperState state)
-    {
-        switch ( state )
-        {
-            case Unknown:
-            {
-                return RpcKeeperState.Unknown;
-            }
-
-            case Disconnected:
-            {
-                return RpcKeeperState.Disconnected;
-            }
-
-            case NoSyncConnected:
-            {
-                return RpcKeeperState.NoSyncConnected;
-            }
-
-            case SyncConnected:
-            {
-                return RpcKeeperState.SyncConnected;
-            }
-
-            case AuthFailed:
-            {
-                return RpcKeeperState.AuthFailed;
-            }
-
-            case ConnectedReadOnly:
-            {
-                return RpcKeeperState.ConnectedReadOnly;
-            }
-
-            case SaslAuthenticated:
-            {
-                return RpcKeeperState.SaslAuthenticated;
-            }
-
-            case Expired:
-            {
-                return RpcKeeperState.Expired;
-            }
-        }
-        throw new IllegalStateException("Unknown state: " + state);
-    }
-}

http://git-wip-us.apache.org/repos/asf/curator/blob/cd3dbdcb/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/CuratorRpcEventType.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/CuratorRpcEventType.java
b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/CuratorRpcEventType.java
deleted file mode 100644
index b905075..0000000
--- a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/CuratorRpcEventType.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.apache.curator.x.rpc.idl.event;
-
-import com.facebook.swift.codec.ThriftEnum;
-
-@ThriftEnum("CuratorEventType")
-public enum CuratorRpcEventType
-{
-    CREATE,
-    DELETE,
-    EXISTS,
-    GET_DATA,
-    SET_DATA,
-    CHILDREN,
-    SYNC,
-    GET_ACL,
-    SET_ACL,
-    WATCHED,
-    CLOSING
-}

http://git-wip-us.apache.org/repos/asf/curator/blob/cd3dbdcb/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcCuratorEvent.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcCuratorEvent.java
b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcCuratorEvent.java
new file mode 100644
index 0000000..cfc8bbd
--- /dev/null
+++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcCuratorEvent.java
@@ -0,0 +1,279 @@
+package org.apache.curator.x.rpc.idl.event;
+
+import com.facebook.swift.codec.ThriftField;
+import com.facebook.swift.codec.ThriftStruct;
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.x.rpc.idl.projection.CuratorProjection;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import javax.annotation.Nullable;
+import java.util.List;
+
+@SuppressWarnings("deprecation")
+@ThriftStruct("CuratorEvent")
+public class RpcCuratorEvent
+{
+    private final CuratorProjection projection;
+    private final CuratorEvent event;
+
+    public RpcCuratorEvent()
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    public RpcCuratorEvent(CuratorProjection projection, CuratorEvent event)
+    {
+        this.projection = projection;
+        this.event = event;
+    }
+
+    @ThriftField(1)
+    public CuratorProjection getProjection()
+    {
+        return projection;
+    }
+
+    @ThriftField(2)
+    public RpcCuratorEventType getType()
+    {
+        switch ( event.getType() )
+        {
+            case CREATE:
+            {
+                return RpcCuratorEventType.CREATE;
+            }
+
+            case DELETE:
+            {
+                return RpcCuratorEventType.DELETE;
+            }
+
+            case EXISTS:
+            {
+                return RpcCuratorEventType.EXISTS;
+            }
+
+            case GET_DATA:
+            {
+                return RpcCuratorEventType.GET_DATA;
+            }
+
+            case SET_DATA:
+            {
+                return RpcCuratorEventType.SET_DATA;
+            }
+
+            case CHILDREN:
+            {
+                return RpcCuratorEventType.CHILDREN;
+            }
+
+            case SYNC:
+            {
+                return RpcCuratorEventType.SYNC;
+            }
+
+            case GET_ACL:
+            {
+                return RpcCuratorEventType.GET_ACL;
+            }
+
+            case SET_ACL:
+            {
+                return RpcCuratorEventType.SET_ACL;
+            }
+
+            case WATCHED:
+            {
+                return RpcCuratorEventType.WATCHED;
+            }
+
+            case CLOSING:
+            {
+                return RpcCuratorEventType.CLOSING;
+            }
+        }
+
+        throw new IllegalStateException("Unknown type: " + event.getType());
+    }
+
+    @ThriftField(3)
+    public int getResultCode()
+    {
+        return event.getResultCode();
+    }
+
+    @ThriftField(4)
+    public String getPath()
+    {
+        return event.getPath();
+    }
+
+    @ThriftField(5)
+    public String getContext()
+    {
+        return String.valueOf(event.getContext());
+    }
+
+    @ThriftField(6)
+    public RpcStat getStat()
+    {
+        Stat stat = event.getStat();
+        if ( stat != null )
+        {
+            return new RpcStat
+            (
+                stat.getCzxid(),
+                stat.getMzxid(),
+                stat.getCtime(),
+                stat.getMtime(),
+                stat.getVersion(),
+                stat.getCversion(),
+                stat.getAversion(),
+                stat.getEphemeralOwner(),
+                stat.getDataLength(),
+                stat.getNumChildren(),
+                stat.getPzxid()
+            );
+        }
+        return null;
+    }
+
+    @ThriftField(7)
+    public byte[] getData()
+    {
+        return event.getData();
+    }
+
+    @ThriftField(8)
+    public String getName()
+    {
+        return event.getPath();
+    }
+
+    @ThriftField(9)
+    public List<String> getChildren()
+    {
+        return event.getChildren();
+    }
+
+    @ThriftField(10)
+    public List<RpcAcl> getACLList()
+    {
+        List<ACL> aclList = event.getACLList();
+        if ( aclList != null )
+        {
+            return Lists.transform
+            (
+                aclList,
+                new Function<ACL, RpcAcl>()
+                {
+                    @Nullable
+                    @Override
+                    public RpcAcl apply(ACL acl)
+                    {
+                        RpcId id = new RpcId(acl.getId().getScheme(), acl.getId().getId());
+                        return new RpcAcl(acl.getPerms(), id);
+                    }
+                }
+            );
+        }
+        return null;
+    }
+
+    @ThriftField(11)
+    public RpcWatchedEvent getWatchedEvent()
+    {
+        WatchedEvent watchedEvent = event.getWatchedEvent();
+        if ( watchedEvent != null )
+        {
+            RpcKeeperState keeperState = toRpcKeeperState(watchedEvent.getState());
+            RpcEventType eventType = toRpcEventType(watchedEvent.getType());
+            return new RpcWatchedEvent(keeperState, eventType, watchedEvent.getPath());
+        }
+        return null;
+    }
+
+    private RpcEventType toRpcEventType(Watcher.Event.EventType type)
+    {
+        switch ( type )
+        {
+            case None:
+            {
+                return RpcEventType.None;
+            }
+
+            case NodeCreated:
+            {
+                return RpcEventType.NodeCreated;
+            }
+
+            case NodeDeleted:
+            {
+                return RpcEventType.NodeDeleted;
+            }
+
+            case NodeDataChanged:
+            {
+                return RpcEventType.NodeDataChanged;
+            }
+
+            case NodeChildrenChanged:
+            {
+                return RpcEventType.NodeChildrenChanged;
+            }
+        }
+        throw new IllegalStateException("Unknown type: " + type);
+    }
+
+    private RpcKeeperState toRpcKeeperState(Watcher.Event.KeeperState state)
+    {
+        switch ( state )
+        {
+            case Unknown:
+            {
+                return RpcKeeperState.Unknown;
+            }
+
+            case Disconnected:
+            {
+                return RpcKeeperState.Disconnected;
+            }
+
+            case NoSyncConnected:
+            {
+                return RpcKeeperState.NoSyncConnected;
+            }
+
+            case SyncConnected:
+            {
+                return RpcKeeperState.SyncConnected;
+            }
+
+            case AuthFailed:
+            {
+                return RpcKeeperState.AuthFailed;
+            }
+
+            case ConnectedReadOnly:
+            {
+                return RpcKeeperState.ConnectedReadOnly;
+            }
+
+            case SaslAuthenticated:
+            {
+                return RpcKeeperState.SaslAuthenticated;
+            }
+
+            case Expired:
+            {
+                return RpcKeeperState.Expired;
+            }
+        }
+        throw new IllegalStateException("Unknown state: " + state);
+    }
+}

http://git-wip-us.apache.org/repos/asf/curator/blob/cd3dbdcb/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcCuratorEventType.java
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcCuratorEventType.java
b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcCuratorEventType.java
new file mode 100644
index 0000000..3c23a69
--- /dev/null
+++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/idl/event/RpcCuratorEventType.java
@@ -0,0 +1,19 @@
+package org.apache.curator.x.rpc.idl.event;
+
+import com.facebook.swift.codec.ThriftEnum;
+
+@ThriftEnum("CuratorEventType")
+public enum RpcCuratorEventType
+{
+    CREATE,
+    DELETE,
+    EXISTS,
+    GET_DATA,
+    SET_DATA,
+    CHILDREN,
+    SYNC,
+    GET_ACL,
+    SET_ACL,
+    WATCHED,
+    CLOSING
+}

http://git-wip-us.apache.org/repos/asf/curator/blob/cd3dbdcb/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 aeb52c8..1846d31 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
@@ -3,6 +3,7 @@ package org.apache.curator.x.rpc.idl.projection;
 import com.facebook.swift.service.ThriftMethod;
 import com.facebook.swift.service.ThriftService;
 import com.google.common.collect.Maps;
+import com.google.common.collect.Queues;
 import org.apache.curator.framework.CuratorFramework;
 import org.apache.curator.framework.CuratorFrameworkFactory;
 import org.apache.curator.framework.api.BackgroundCallback;
@@ -13,24 +14,19 @@ import org.apache.curator.framework.api.CreateModable;
 import org.apache.curator.framework.api.CuratorEvent;
 import org.apache.curator.framework.api.PathAndBytesable;
 import org.apache.curator.retry.RetryOneTime;
-import org.apache.curator.x.rpc.idl.event.CuratorEventService;
-import org.apache.curator.x.rpc.idl.event.CuratorRpcEvent;
+import org.apache.curator.x.rpc.idl.event.RpcCuratorEvent;
 import java.util.Map;
 import java.util.UUID;
+import java.util.concurrent.BlockingQueue;
 
 @ThriftService("CuratorService")
 public class CuratorProjectionService
 {
     private final Map<String, CuratorFramework> projections = Maps.newConcurrentMap();
-    private final CuratorEventService eventService;
-
-    public CuratorProjectionService(CuratorEventService eventService)
-    {
-        this.eventService = eventService;
-    }
+    private final BlockingQueue<RpcCuratorEvent> events = Queues.newLinkedBlockingQueue();
 
     @ThriftMethod
-    public CuratorProjection newCuratorProjection(CuratorProjectionSpec spec)
+    public CuratorProjection newCuratorProjection(CuratorProjectionSpec spec)   // TODO
     {
         CuratorFramework client = CuratorFrameworkFactory.newClient("localhost:2181", new
RetryOneTime(1));
         String id = UUID.randomUUID().toString();
@@ -76,7 +72,7 @@ public class CuratorProjectionService
                 @Override
                 public void processResult(CuratorFramework client, CuratorEvent event) throws
Exception
                 {
-                    eventService.addEvent(new CuratorRpcEvent(projection, event));
+                    events.offer(new RpcCuratorEvent(projection, event));
                 }
             };
             builder = castBuilder(builder, Backgroundable.class).inBackground(backgroundCallback);
@@ -85,6 +81,12 @@ public class CuratorProjectionService
         return String.valueOf(castBuilder(builder, PathAndBytesable.class).forPath(createSpec.getPath(),
createSpec.getData().getBytes()));
     }
 
+    @ThriftMethod
+    public RpcCuratorEvent getNextEvent() throws InterruptedException
+    {
+        return events.take();
+    }
+
     private org.apache.zookeeper.CreateMode getRealMode(CreateMode mode)
     {
         switch ( mode )

http://git-wip-us.apache.org/repos/asf/curator/blob/cd3dbdcb/curator-x-rpc/src/main/scripts/generate.sh
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/scripts/generate.sh b/curator-x-rpc/src/main/scripts/generate.sh
index 9fdc4c6..10288d5 100755
--- a/curator-x-rpc/src/main/scripts/generate.sh
+++ b/curator-x-rpc/src/main/scripts/generate.sh
@@ -10,11 +10,14 @@ BASE_DIR="$( cd "$DIR/../../../.." && pwd )"
 
 RPC_PATH="$BASE_DIR/curator-x-rpc/target/classes"
 
+CLASSES=""
+
 PROJECTION_CLASSES=""
 for f in `ls -m1 $RPC_PATH/org/apache/curator/x/rpc/idl/projection/*.class | xargs -n 1 basename
| sed s/\.[^\.]*$//`;
     do
         if [[ $f != *[\$]* ]]; then
             PROJECTION_CLASSES="$PROJECTION_CLASSES $f";
+            CLASSES="$CLASSES org.apache.curator.x.rpc.idl.projection.$f";
         fi;
 done;
 
@@ -23,6 +26,7 @@ for f in `ls -m1 $RPC_PATH/org/apache/curator/x/rpc/idl/event/*.class |
xargs -n
     do
         if [[ $f != *[\$]* ]]; then
             EVENT_CLASSES="$EVENT_CLASSES $f";
+            CLASSES="$CLASSES org.apache.curator.x.rpc.idl.event.$f";
         fi;
 done;
 
@@ -34,8 +38,8 @@ PATHS="$PATHS:$BASE_DIR/curator-framework/target/classes"
 PATHS="$PATHS:$BASE_DIR/curator-recipes/target/classes"
 PATHS="$PATHS:$RPC_PATH"
 
+PACKAGE="org.apache.curator.x.rpc.idl"
 PROJECTION_PACKAGE="org.apache.curator.x.rpc.idl.projection"
 EVENT_PACKAGE="org.apache.curator.x.rpc.idl.event"
 
-java -cp $PATHS com.facebook.swift.generator.swift2thrift.Main -namespace cpp org.apache.curator
-out "$THRIFT_DIR/curator.thrift" -package $PROJECTION_PACKAGE $PROJECTION_CLASSES
-java -cp $PATHS com.facebook.swift.generator.swift2thrift.Main -map org.apache.curator.x.rpc.idl.projection.CuratorProjection
"curator.thrift" -namespace cpp org.apache.curator -out "$THRIFT_DIR/curator-event.thrift"
-package $EVENT_PACKAGE $EVENT_CLASSES
+java -cp $PATHS com.facebook.swift.generator.swift2thrift.Main -allow_multiple_packages org.apache.curator
-namespace cpp org.apache.curator -out "$THRIFT_DIR/curator.thrift" $CLASSES

http://git-wip-us.apache.org/repos/asf/curator/blob/cd3dbdcb/curator-x-rpc/src/main/thrift/curator-event.thrift
----------------------------------------------------------------------
diff --git a/curator-x-rpc/src/main/thrift/curator-event.thrift b/curator-x-rpc/src/main/thrift/curator-event.thrift
deleted file mode 100644
index 9c407eb..0000000
--- a/curator-x-rpc/src/main/thrift/curator-event.thrift
+++ /dev/null
@@ -1,64 +0,0 @@
-namespace java.swift org.apache.curator.x.rpc.idl.event
-namespace cpp org.apache.curator
-
-include "curator.thrift"
-
-enum CuratorEventType {
-  CREATE, DELETE, EXISTS, GET_DATA, SET_DATA, CHILDREN, SYNC, GET_ACL, SET_ACL, WATCHED,
CLOSING
-}
-
-enum EventType {
-  None, NodeCreated, NodeDeleted, NodeDataChanged, NodeChildrenChanged
-}
-
-enum KeeperState {
-  Unknown, Disconnected, NoSyncConnected, SyncConnected, AuthFailed, ConnectedReadOnly, SaslAuthenticated,
Expired
-}
-
-struct id {
-  1: string scheme;
-  2: string id;
-}
-
-struct Stat {
-  1: i64 czxid;
-  2: i64 mzxid;
-  3: i64 ctime;
-  4: i64 mtime;
-  5: i32 version;
-  6: i32 cversion;
-  7: i32 aversion;
-  8: i64 ephemeralOwner;
-  9: i32 dataLength;
-  10: i32 numChildren;
-  11: i64 pzxid;
-}
-
-struct WatchedEvent {
-  1: KeeperState keeperState;
-  2: EventType eventType;
-  3: string path;
-}
-
-struct Acl {
-  1: i32 perms;
-  2: id id;
-}
-
-struct CuratorEvent {
-  1: curator.CuratorProjection projection;
-  2: CuratorEventType type;
-  3: i32 resultCode;
-  4: string path;
-  5: string context;
-  6: Stat stat;
-  7: binary data;
-  8: string name;
-  9: list<string> children;
-  10: list<Acl> aCLList;
-  11: WatchedEvent watchedEvent;
-}
-
-service CuratorEventService {
-  CuratorEvent getNextEvent();
-}

http://git-wip-us.apache.org/repos/asf/curator/blob/cd3dbdcb/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 7973580..8b7ffc3 100644
--- a/curator-x-rpc/src/main/thrift/curator.thrift
+++ b/curator-x-rpc/src/main/thrift/curator.thrift
@@ -1,4 +1,4 @@
-namespace java.swift org.apache.curator.x.rpc.idl.projection
+namespace java.swift org.apache.curator
 namespace cpp org.apache.curator
 
 
@@ -6,6 +6,18 @@ enum CreateMode {
   PERSISTENT, PERSISTENT_SEQUENTIAL, EPHEMERAL, EPHEMERAL_SEQUENTIAL
 }
 
+enum CuratorEventType {
+  CREATE, DELETE, EXISTS, GET_DATA, SET_DATA, CHILDREN, SYNC, GET_ACL, SET_ACL, WATCHED,
CLOSING
+}
+
+enum EventType {
+  None, NodeCreated, NodeDeleted, NodeDataChanged, NodeChildrenChanged
+}
+
+enum KeeperState {
+  Unknown, Disconnected, NoSyncConnected, SyncConnected, AuthFailed, ConnectedReadOnly, SaslAuthenticated,
Expired
+}
+
 struct CreateSpec {
   1: string path;
   2: string asyncId;
@@ -24,8 +36,53 @@ struct CuratorProjection {
 struct CuratorProjectionSpec {
 }
 
+struct id {
+  1: string scheme;
+  2: string id;
+}
+
+struct Stat {
+  1: i64 czxid;
+  2: i64 mzxid;
+  3: i64 ctime;
+  4: i64 mtime;
+  5: i32 version;
+  6: i32 cversion;
+  7: i32 aversion;
+  8: i64 ephemeralOwner;
+  9: i32 dataLength;
+  10: i32 numChildren;
+  11: i64 pzxid;
+}
+
+struct WatchedEvent {
+  1: KeeperState keeperState;
+  2: EventType eventType;
+  3: string path;
+}
+
+struct Acl {
+  1: i32 perms;
+  2: id id;
+}
+
+struct CuratorEvent {
+  1: CuratorProjection projection;
+  2: CuratorEventType type;
+  3: i32 resultCode;
+  4: string path;
+  5: string context;
+  6: Stat stat;
+  7: binary data;
+  8: string name;
+  9: list<string> children;
+  10: list<Acl> aCLList;
+  11: WatchedEvent watchedEvent;
+}
+
 service CuratorService {
   void closeCuratorProjection(1: CuratorProjection projection);
   string create(1: CuratorProjection projection, 2: CreateSpec createSpec);
+  CuratorEvent getNextEvent();
   CuratorProjection newCuratorProjection(1: CuratorProjectionSpec spec);
 }


Mime
View raw message