curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From randg...@apache.org
Subject [4/4] git commit: doc continues
Date Tue, 18 Feb 2014 09:48:45 GMT
doc continues


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

Branch: refs/heads/CURATOR-88
Commit: b4c76c79bcc3f2e1ffcb0dcf32854255ffa9d126
Parents: 3267285
Author: randgalt <randgalt@apache.org>
Authored: Tue Feb 18 10:48:30 2014 +0100
Committer: randgalt <randgalt@apache.org>
Committed: Tue Feb 18 10:48:30 2014 +0100

----------------------------------------------------------------------
 .../curator/x/rest/api/ClientResource.java      |  40 +++++--
 .../apache/curator/x/rest/api/Constants.java    |   1 -
 .../curator/x/rest/api/LeaderResource.java      |  36 ++++++-
 .../x/rest/api/PathChildrenCacheResource.java   |   2 +-
 .../x/rest/api/RestBackgroundCallback.java      |   8 +-
 .../org/apache/curator/x/rest/api/Session.java  |   2 +-
 .../curator/x/rest/entities/LeaderSpec.java     |  14 +--
 .../x/rest/entities/ParticipantSpec.java        |  60 +++++++++++
 curator-x-rest/src/site/assets/client.png       | Bin 100105 -> 0 bytes
 .../src/site/confluence/apis.confluence         |  56 ++++++++++
 .../src/site/confluence/entities.confluence     |  86 +++++++++++++++
 .../src/site/confluence/index.confluence        | 108 ++-----------------
 .../src/site/confluence/status.confluence       |  75 +++++++++++++
 .../src/site/resources/images/client.png        | Bin 0 -> 100105 bytes
 14 files changed, 365 insertions(+), 123 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/b4c76c79/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/ClientResource.java
----------------------------------------------------------------------
diff --git a/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/ClientResource.java
b/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/ClientResource.java
index d866a21..49e3789 100644
--- a/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/ClientResource.java
+++ b/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/ClientResource.java
@@ -75,7 +75,7 @@ public class ClientResource
     public Response getStatusWithTouch(List<String> ids) throws IOException
     {
         ObjectNode node = context.getMapper().createObjectNode();
-        node.put("state", context.getConnectionState().name());
+        node.put("state", context.getConnectionState().name().toLowerCase());
         node.putPOJO("messages", context.getSession().drainMessages());
 
         for ( String id : ids )
@@ -213,11 +213,16 @@ public class ClientResource
                 @Override
                 protected String getMessage(CuratorEvent event)
                 {
-                    if ( event.getResultCode() != 0 )
+                    PathAndId pathAndId = new PathAndId(String.valueOf(event.getName()),
id);
+                    try
+                    {
+                        return context.getWriter().writeValueAsString(pathAndId);
+                    }
+                    catch ( IOException e )
                     {
-                        return Constants.ERROR;
+                        log.error("Could not serialize PathAndId", e);
                     }
-                    return event.getName();
+                    return "{}";
                 }
 
                 @Override
@@ -261,7 +266,11 @@ public class ClientResource
                 @Override
                 protected String getMessage(CuratorEvent event)
                 {
-                    return (event.getData() != null) ? new String(event.getData()) : "";
+                    if ( event.getResultCode() == 0 )
+                    {
+                        return (event.getData() != null) ? new String(event.getData()) :
"";
+                    }
+                    return "";
                 }
             };
             castBuilder(builder, Backgroundable.class).inBackground(backgroundCallback);
@@ -297,7 +306,26 @@ public class ClientResource
 
         if ( existsSpec.isAsync() )
         {
-            BackgroundCallback backgroundCallback = new RestBackgroundCallback(context, Constants.CLIENT_EXISTS_ASYNC,
existsSpec.getAsyncId());
+            BackgroundCallback backgroundCallback = new RestBackgroundCallback(context, Constants.CLIENT_EXISTS_ASYNC,
existsSpec.getAsyncId())
+            {
+                @Override
+                protected String getMessage(CuratorEvent event)
+                {
+                    Stat stat = event.getStat();
+                    if ( stat != null )
+                    {
+                        try
+                        {
+                            return context.getWriter().writeValueAsString(stat);
+                        }
+                        catch ( IOException e )
+                        {
+                            log.error("Could not serialize stat object", e);
+                        }
+                    }
+                    return "{}";
+                }
+            };
             castBuilder(builder, Backgroundable.class).inBackground(backgroundCallback);
         }
 

http://git-wip-us.apache.org/repos/asf/curator/blob/b4c76c79/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/Constants.java
----------------------------------------------------------------------
diff --git a/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/Constants.java b/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/Constants.java
index a516322..5ee1982 100644
--- a/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/Constants.java
+++ b/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/Constants.java
@@ -34,7 +34,6 @@ class Constants
     static final String CLIENT_SET_DATA_ASYNC = "client-set-data-async";
     static final String CLIENT_EXISTS_ASYNC = "client-exists-async";
     static final String CLIENT_DELETE_ASYNC = "client-delete-async";
-    static final String ERROR = "error";
     static final String WATCH = "watch";
     static final String PATH_CACHE = "path-cache";
     static final String NODE_CACHE = "node-cache";

http://git-wip-us.apache.org/repos/asf/curator/blob/b4c76c79/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/LeaderResource.java
----------------------------------------------------------------------
diff --git a/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/LeaderResource.java
b/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/LeaderResource.java
index 2590597..43316a1 100644
--- a/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/LeaderResource.java
+++ b/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/LeaderResource.java
@@ -18,24 +18,33 @@
  */
 package org.apache.curator.x.rest.api;
 
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
 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.x.rest.CuratorRestContext;
 import org.apache.curator.x.rest.entities.LeaderSpec;
+import org.apache.curator.x.rest.entities.ParticipantSpec;
 import org.apache.curator.x.rest.entities.StatusMessage;
 import org.codehaus.jackson.node.ObjectNode;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import javax.annotation.Nullable;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.Context;
+import javax.ws.rs.core.GenericEntity;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
 
 @Path("/curator/v1/recipes/leader")
 public class LeaderResource
@@ -53,7 +62,7 @@ public class LeaderResource
     @Produces(MediaType.APPLICATION_JSON)
     public Response startLeaderSelection(final LeaderSpec leaderSpec) throws Exception
     {
-        LeaderLatch leaderLatch = new LeaderLatch(context.getClient(), leaderSpec.getPath(),
leaderSpec.getId());
+        LeaderLatch leaderLatch = new LeaderLatch(context.getClient(), leaderSpec.getPath(),
leaderSpec.getParticipantId());
         leaderLatch.start();
 
         Closer<LeaderLatch> closer = new Closer<LeaderLatch>()
@@ -101,4 +110,29 @@ public class LeaderResource
         leaderLatch.close();
         return Response.ok().build();
     }
+
+    @GET
+    @Path("{leader-id}")
+    public Response getParticipants(@PathParam("leader-id") String leaderId) throws Exception
+    {
+        LeaderLatch leaderLatch = Constants.getThing(context.getSession(), leaderId, LeaderLatch.class);
+        Collection<Participant> participants = leaderLatch.getParticipants();
+
+        List<ParticipantSpec> transformed = Lists.transform
+        (
+            Lists.newArrayList(participants),
+            new Function<Participant, ParticipantSpec>()
+            {
+                @Nullable
+                @Override
+                public ParticipantSpec apply(Participant participant)
+                {
+                    return new ParticipantSpec(participant.getId(), participant.isLeader());
+                }
+            }
+        );
+
+        GenericEntity<List<ParticipantSpec>> entity = new GenericEntity<List<ParticipantSpec>>(transformed){};
+        return Response.ok(entity).build();
+    }
 }

http://git-wip-us.apache.org/repos/asf/curator/blob/b4c76c79/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/PathChildrenCacheResource.java
----------------------------------------------------------------------
diff --git a/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/PathChildrenCacheResource.java
b/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/PathChildrenCacheResource.java
index 76fae7d..4622ac1 100644
--- a/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/PathChildrenCacheResource.java
+++ b/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/PathChildrenCacheResource.java
@@ -84,7 +84,7 @@ public class PathChildrenCacheResource
             @Override
             public void childEvent(CuratorFramework client, PathChildrenCacheEvent event)
throws Exception
             {
-                context.getSession().pushMessage(new StatusMessage(Constants.PATH_CACHE,
id, event.getType().name(), ""));
+                context.getSession().pushMessage(new StatusMessage(Constants.PATH_CACHE,
id, event.getType().name().toLowerCase(), event.getData().getPath()));
             }
         };
         cache.getListenable().addListener(listener);

http://git-wip-us.apache.org/repos/asf/curator/blob/b4c76c79/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/RestBackgroundCallback.java
----------------------------------------------------------------------
diff --git a/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/RestBackgroundCallback.java
b/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/RestBackgroundCallback.java
index a5e2284..a8231bb 100644
--- a/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/RestBackgroundCallback.java
+++ b/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/RestBackgroundCallback.java
@@ -43,13 +43,13 @@ class RestBackgroundCallback implements BackgroundCallback
         context.getSession().pushMessage(new StatusMessage(type, asyncId, getMessage(event),
getDetails(event)));
     }
 
-    protected String getDetails(CuratorEvent event)
+    protected String getMessage(CuratorEvent event)
     {
-        return Integer.toString(event.getResultCode());
+        return String.valueOf(event.getPath());
     }
 
-    protected String getMessage(CuratorEvent event)
+    protected String getDetails(CuratorEvent event)
     {
-        return String.valueOf(event.getName());
+        return Integer.toString(event.getResultCode());
     }
 }

http://git-wip-us.apache.org/repos/asf/curator/blob/b4c76c79/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/Session.java
----------------------------------------------------------------------
diff --git a/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/Session.java b/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/Session.java
index 36a2654..1a487f8 100644
--- a/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/Session.java
+++ b/curator-x-rest/src/main/java/org/apache/curator/x/rest/api/Session.java
@@ -75,7 +75,7 @@ public class Session implements Closeable
             if ( elapsedSinceLastUse > sessionLengthMs )
             {
                 String id = mapEntry.getKey();
-                pushMessage(new StatusMessage(Constants.EXPIRED, id, "expired", entry.thing.getClass().getName()));
+                pushMessage(new StatusMessage(Constants.EXPIRED, id, entry.thing.getClass().getSimpleName(),
""));
                 log.warn(String.format("Expiring object. Elapsed time: %d, id: %s, Class:
%s", elapsedSinceLastUse, id, entry.thing.getClass().getName()));
 
                 things.remove(id);

http://git-wip-us.apache.org/repos/asf/curator/blob/b4c76c79/curator-x-rest/src/main/java/org/apache/curator/x/rest/entities/LeaderSpec.java
----------------------------------------------------------------------
diff --git a/curator-x-rest/src/main/java/org/apache/curator/x/rest/entities/LeaderSpec.java
b/curator-x-rest/src/main/java/org/apache/curator/x/rest/entities/LeaderSpec.java
index fde9701..0af2a89 100644
--- a/curator-x-rest/src/main/java/org/apache/curator/x/rest/entities/LeaderSpec.java
+++ b/curator-x-rest/src/main/java/org/apache/curator/x/rest/entities/LeaderSpec.java
@@ -24,17 +24,17 @@ import javax.xml.bind.annotation.XmlRootElement;
 public class LeaderSpec
 {
     private String path;
-    private String id;
+    private String participantId;
 
     public LeaderSpec()
     {
         this("/", "");
     }
 
-    public LeaderSpec(String path, String id)
+    public LeaderSpec(String path, String participantId)
     {
         this.path = path;
-        this.id = id;
+        this.participantId = participantId;
     }
 
     public String getPath()
@@ -47,13 +47,13 @@ public class LeaderSpec
         this.path = path;
     }
 
-    public String getId()
+    public String getParticipantId()
     {
-        return id;
+        return participantId;
     }
 
-    public void setId(String id)
+    public void setParticipantId(String participantId)
     {
-        this.id = id;
+        this.participantId = participantId;
     }
 }

http://git-wip-us.apache.org/repos/asf/curator/blob/b4c76c79/curator-x-rest/src/main/java/org/apache/curator/x/rest/entities/ParticipantSpec.java
----------------------------------------------------------------------
diff --git a/curator-x-rest/src/main/java/org/apache/curator/x/rest/entities/ParticipantSpec.java
b/curator-x-rest/src/main/java/org/apache/curator/x/rest/entities/ParticipantSpec.java
new file mode 100644
index 0000000..b695e59
--- /dev/null
+++ b/curator-x-rest/src/main/java/org/apache/curator/x/rest/entities/ParticipantSpec.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.curator.x.rest.entities;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class ParticipantSpec
+{
+    private String participantId;
+    private boolean isLeader;
+
+    public ParticipantSpec()
+    {
+        this("", false);
+    }
+
+    public ParticipantSpec(String participantId, boolean isLeader)
+    {
+        this.participantId = participantId;
+        this.isLeader = isLeader;
+    }
+
+    public String getParticipantId()
+    {
+        return participantId;
+    }
+
+    public void setParticipantId(String participantId)
+    {
+        this.participantId = participantId;
+    }
+
+    public boolean isLeader()
+    {
+        return isLeader;
+    }
+
+    public void setLeader(boolean isLeader)
+    {
+        this.isLeader = isLeader;
+    }
+}

http://git-wip-us.apache.org/repos/asf/curator/blob/b4c76c79/curator-x-rest/src/site/assets/client.png
----------------------------------------------------------------------
diff --git a/curator-x-rest/src/site/assets/client.png b/curator-x-rest/src/site/assets/client.png
deleted file mode 100644
index 27d10c2..0000000
Binary files a/curator-x-rest/src/site/assets/client.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/curator/blob/b4c76c79/curator-x-rest/src/site/confluence/apis.confluence
----------------------------------------------------------------------
diff --git a/curator-x-rest/src/site/confluence/apis.confluence b/curator-x-rest/src/site/confluence/apis.confluence
new file mode 100644
index 0000000..abde4ca
--- /dev/null
+++ b/curator-x-rest/src/site/confluence/apis.confluence
@@ -0,0 +1,56 @@
+[[Curator REST Proxy|index.html]] / APIs
+
+h1. APIs
+
+Here are the available APIs:
+
+h2. Status APIs
+
+||URL||Method||Request Entity||Response Entity||Description||
+|/curator/v1/client/status|GET|n/a|Status|Call to get the status of the Curator connection
as well as any pending messages.|
+|/curator/v1/client/status|POST|List of string ids|Status|Call to get the status of the Curator
connection as well as any pending messages. Additionally, stateful instances with the specified
IDs are "touched" thus preventing timeout expiration.|
+
+h2. Client APIs
+
+NOTE: Not all combinations are valid *TBD*
+
+||URL||Method||Request Entity||Response Entity||Description||
+|/get-children|POST|GetChildrenSpec|Array of strings|This is the equivalent of CuratorFramework.getChildren().|
+|/create|POST|CreateSpec|PathAndId|This is the equivalent of CuratorFramework.create().|
+|/delete|POST|DeleteSpec|n/a|This is the equivalent of CuratorFramework.delete().|
+|/set-data|POST|SetDataSpec|n/a|This is the equivalent of CuratorFramework.setData().|
+|/get-data|POST|GetDataSpec|DataAndStat|This is the equivalent of CuratorFramework.setData().|
+|/exists|POST|ExistsSpec|ZK Stat or empty|This is the equivalent of CuratorFramework.exists().|
+
+h3. How Asynchronous APIs Are Handled
+
+*TBD*
+
+h3. How Watchers Are Handled
+
+*TBD*
+
+h3. How Ephemeral Nodes Are Handled
+
+*TBD*
+
+h2. Recipe APIs
+||URL||Method||Request Entity||Response Entity||Description||
+|/curator/v1/recipes/lock|POST|LockSpec|IdSpec|An InterProcessSemaphoreMutex. On successful
return, your client will be holding the specified lock until you delete the lock via the delete
API.|
+|/curator/v1/recipes/lock/{lock-id}|DELETE|n/a|n/a|Release and delete a lock.|
+|/curator/v1/recipes/leader|POST|LeaderSpec|IdSpec|Start a LeaderLatch instance. When you
gain leadership, it will be notified via status.|
+|/curator/v1/recipes/leader/{leader-id}|DELETE|n/a|n/a|Release/delete leadership.|
+|/curator/v1/recipes/leader/{leader-id}|GET|n/a|array of ParticipantSpecs|List of participants
in the leader election.|
+
+h3. Handling Timeouts, Status and Releasing
+
+*TBD - releases must go to same server, etc.
+
+h2. Entities
+
+See the [[Entity Descriptions Page|entities.html]] for details on the Entities used in the
APIs.
+
+h2. Status Message Types
+
+See the [[Status Message Page|status.html]] for details of the status messages for each type.
+

http://git-wip-us.apache.org/repos/asf/curator/blob/b4c76c79/curator-x-rest/src/site/confluence/entities.confluence
----------------------------------------------------------------------
diff --git a/curator-x-rest/src/site/confluence/entities.confluence b/curator-x-rest/src/site/confluence/entities.confluence
new file mode 100644
index 0000000..dcf6bc5
--- /dev/null
+++ b/curator-x-rest/src/site/confluence/entities.confluence
@@ -0,0 +1,86 @@
+[[Curator REST Proxy|index.html]] / Entity Descriptions
+
+h1. Entity Descriptions
+
+Here are the entity descriptions for the entities used in the APIs:
+
+||Field||Type||Description||
+|*Status*| | |
+|state|string|This instance's Curator connection state. One of: "connected", "suspended",
or "lost". If the state is other than "connected" you must assume that any open locks and/or
watchers are no longer valid.|
+|messages|array of StatusMessages|Any pending messages from this instance.|
+| | | |
+|*StatusMessage*| | |
+|type|string|The status message type. See the Managing Status section for details.|
+|message|string|Type-dependent message|
+|details|string|Type-dependent details|
+|sourceId|string|Type-dependent sourceId|
+| | | |
+|*GetChildrenSpec*| | |
+|path|string|The ZK path|
+|async|boolean|If true, perform asynchronously|
+|asyncId|string|for async, a user-defined ID to return in the status message|
+|asyncListSeparator|string|for async, the separator to use for the child names. Usually you'd
set this to ",".|
+|watched|boolean|if true, set a watch|
+|watchId|string|if watched, a user-defined ID to return in the status when the watch triggers|
+| | | |
+|*CreateSpec*| | |
+|path|string|The ZK path|
+|data|string|The data to store in the node|
+|mode|string|The create mode. One of: "persistent", "persistent_sequential", "ephemeral",
or "ephemeral_sequential"|
+| | | |
+| *PathAndId* | | |
+|path|string|The created ZK Path (possibly with a sequence suffix)|
+|id|string|The internally generated id for this node (used for ephemerals)|
+| | | |
+| *DeleteSpec* | | |
+|path|string|The ZK path|
+|async|boolean|If true, perform asynchronously|
+|asyncId|string|for async, a user-defined ID to return in the status message|
+|guaranteed|boolean|if true, use Curator's guaranteed delete mechanism|
+|version|int|the expected version to delete or -1|
+| | | |
+| *SetDataSpec* | | |
+|path|string|The ZK path|
+|data|string|The data to set|
+|async|boolean|If true, perform asynchronously|
+|asyncId|string|for async, a user-defined ID to return in the status message|
+|watched|boolean|if true, set a watch|
+|watchId|string|if watched, a user-defined ID to return in the status when the watch triggers|
+|compressed|boolean|if true, compress the data using Curator's compression mechanism|
+|version|int|the expected version or -1|
+| | | |
+| *GetDataSpec* | | |
+|path|string|The ZK path|
+|async|boolean|If true, perform asynchronously|
+|asyncId|string|for async, a user-defined ID to return in the status message|
+|watched|boolean|if true, set a watch|
+|watchId|string|if watched, a user-defined ID to return in the status when the watch triggers|
+|decompressed|boolean|if true, decompress the data using Curator's compression mechanism|
+| | | |
+| *DataAndStat* | | |
+|data|string|the data from the node|
+|stat|ZK Stat|the ZooKeeper stat for the node|
+| | | |
+| *ExistsSpec* | | |
+|path|string|The ZK path|
+|async|boolean|If true, perform asynchronously|
+|asyncId|string|for async, a user-defined ID to return in the status message|
+|watched|boolean|if true, set a watch|
+|watchId|string|if watched, a user-defined ID to return in the status when the watch triggers|
+| | | |
+| *IdSpec* | | |
+|id|string|The ID of the created recipe, etc. Used for subsequent calls to delete, close,
etc. the instance.|
+| | | |
+| *LockSpec* | | |
+|path|string|The ZK path|
+|maxWaitMs|int|Maximum time to wait to acquire the lock (in milliseconds)|
+| | | |
+| *LeaderSpec* | | |
+|path|string|The ZK path|
+|maxWaitMs|int|Maximum time to wait to acquire the lock (in milliseconds)|
+| | | |
+| *ParticipantSpec* | | |
+|participantId|string|The participant ID|
+|isLeader|boolean|true if this is the leader|
+
+*TBD*

http://git-wip-us.apache.org/repos/asf/curator/blob/b4c76c79/curator-x-rest/src/site/confluence/index.confluence
----------------------------------------------------------------------
diff --git a/curator-x-rest/src/site/confluence/index.confluence b/curator-x-rest/src/site/confluence/index.confluence
index 22755d5..da36433 100644
--- a/curator-x-rest/src/site/confluence/index.confluence
+++ b/curator-x-rest/src/site/confluence/index.confluence
@@ -8,6 +8,8 @@ any language.
 
 *TBD*
 
+!images/client.png!
+
 h2. Building and Packaging
 
 Dropwizard
@@ -32,111 +34,13 @@ h2. Managing Status
 
 *TBD*
 
-h2. Status APIs
-
-||URL||METHOD||Request Entity||Response Entity||Description||
-|/curator/v1/client/status|GET|n/a|Status|Call to get the status of the Curator connection
as well as any pending messages.|
-|/curator/v1/client/status|POST|List of string ids|Status|Call to get the status of the Curator
connection as well as any pending messages. Additionally, stateful instances with the specified
IDs are "touched" thus preventing timeout expiration.|
-
-h2. Client APIs
-
-NOTE: Not all combinations are valid *TBD*
-
-||URL||METHOD||Request Entity||Response Entity||Description||
-|/get-children|POST|GetChildrenSpec|Array of strings|This is the equivalent of CuratorFramework.getChildren().|
-|/create|POST|CreateSpec|PathAndId|This is the equivalent of CuratorFramework.create().|
-|/delete|POST|DeleteSpec|n/a|This is the equivalent of CuratorFramework.delete().|
-|/set-data|POST|SetDataSpec|n/a|This is the equivalent of CuratorFramework.setData().|
-|/get-data|POST|GetDataSpec|DataAndStat|This is the equivalent of CuratorFramework.setData().|
-|/exists|POST|ExistsSpec|ZK Stat or empty|This is the equivalent of CuratorFramework.exists().|
-
-h3. How Asynchronous APIs Are Handled
-
-*TBD*
-
-h3. How Watchers Are Handled
-
-*TBD*
-
-h3. How Ephemeral Nodes Are Handled
+See the [[Status Message Page|status.html]] for details of the status messages for each type.
 
-*TBD*
-
-h2. Recipe APIs
-||URL||METHOD||Request Entity||Response Entity||Description||
-|/curator/v1/recipes/lock|POST|LockSpec|IdSpec|An InterProcessSemaphoreMutex. On successful
return, your client will be holding the specified lock until you delete the lock via the delete
API.|
-|/curator/v1/recipes/lock/{lock-id}|DELETE|n/a|n/a|Release and delete a lock.|
-|/curator/v1/recipes/leader|POST|LeaderSpec|IdSpec|Start a LeaderLatch instance. When you
gain leadership, it will be notified via status.|
-|/curator/v1/recipes/leader/{leader-id}|DELETE|n/a|n/a|Release/delete leadership.|
+h2. APIs
 
-h3. Handling Timeouts, Status and Releasing
-
-*TBD - releases must go to same server, etc.
+See the [[APIs Page|apis.html]] for list of available APIs.
 
 h2. Entities
 
-||Field||Type||Description||
-|*Status*| | |
-|state|string|This instance's Curator connection state. One of: "connected", "suspended",
or "lost". If the state is other than "connected" you must assume that any open locks and/or
watchers are no longer valid.|
-|messages|array of StatusMessages|Any pending messages from this instance.|
-| | | |
-|*StatusMessage*| | |
-|type|string|The status message type. See the Managing Status section for details.|
-|message|string|Type-dependent message|
-|details|string|Type-dependent details|
-|sourceId|string|Type-dependent sourceId|
-| | | |
-|*GetChildrenSpec*| | |
-|path|string|The ZK path|
-|async|boolean|If true, perform asynchronously|
-|asyncId|string|for async, a user-defined ID to return in the status message|
-|asyncListSeparator|string|for async, the separator to use for the child names. Usually you'd
set this to ",".|
-|watched|boolean|if true, set a watch|
-|watchId|string|if watched, a user-defined ID to return in the status when the watch triggers|
-| | | |
-|*CreateSpec*| | |
-|path|string|The ZK path|
-|data|string|The data to store in the node|
-|mode|string|The create mode. One of: "persistent", "persistent_sequential", "ephemeral",
or "ephemeral_sequential"|
-| | | |
-| *PathAndId* | | |
-|path|string|The created ZK Path (possibly with a sequence suffix)|
-|id|string|The internally generated id for this node (used for ephemerals)|
-| | | |
-| *DeleteSpec* | | |
-|path|string|The ZK path|
-|async|boolean|If true, perform asynchronously|
-|asyncId|string|for async, a user-defined ID to return in the status message|
-|guaranteed|boolean|if true, use Curator's guaranteed delete mechanism|
-|version|int|the expected version to delete or -1|
-| | | |
-| *SetDataSpec* | | |
-|path|string|The ZK path|
-|data|string|The data to set|
-|async|boolean|If true, perform asynchronously|
-|asyncId|string|for async, a user-defined ID to return in the status message|
-|watched|boolean|if true, set a watch|
-|watchId|string|if watched, a user-defined ID to return in the status when the watch triggers|
-|compressed|boolean|if true, compress the data using Curator's compression mechanism|
-|version|int|the expected version or -1|
-| | | |
-| *GetDataSpec* | | |
-|path|string|The ZK path|
-|async|boolean|If true, perform asynchronously|
-|asyncId|string|for async, a user-defined ID to return in the status message|
-|watched|boolean|if true, set a watch|
-|watchId|string|if watched, a user-defined ID to return in the status when the watch triggers|
-|decompressed|boolean|if true, decompress the data using Curator's compression mechanism|
-| | | |
-| *DataAndStat* | | |
-|data|string|the data from the node|
-|stat|ZK Stat|the ZooKeeper stat for the node|
-| | | |
-| *ExistsSpec* | | |
-|path|string|The ZK path|
-|async|boolean|If true, perform asynchronously|
-|asyncId|string|for async, a user-defined ID to return in the status message|
-|watched|boolean|if true, set a watch|
-|watchId|string|if watched, a user-defined ID to return in the status when the watch triggers|
+See the [[Entity Descriptions Page|entities.html]] for details on the Entities used in the
APIs.
 
-*TBD*

http://git-wip-us.apache.org/repos/asf/curator/blob/b4c76c79/curator-x-rest/src/site/confluence/status.confluence
----------------------------------------------------------------------
diff --git a/curator-x-rest/src/site/confluence/status.confluence b/curator-x-rest/src/site/confluence/status.confluence
new file mode 100644
index 0000000..5957771
--- /dev/null
+++ b/curator-x-rest/src/site/confluence/status.confluence
@@ -0,0 +1,75 @@
+[[Curator REST Proxy|index.html]] / Status Messages
+
+h1. Status Messages
+
+h2. Status Messages
+
+|*Watchers*| |
+|Type|watch|
+|Source Id|The watchId passed in the original request|
+|Message|Either "NodeCreated", "NodeDeleted", "NodeDataChanged", or "NodeChildrenChanged"|
+|Details|The event path|
+| | |
+|*Expired Instances*| |
+|Type|expired|
+|Source Id|Generated Id of the instance that is expiring|
+|Message|Class name of the expiring instance. Either: "LeaderLatch.class", "InterProcessSemaphoreMutex.class",
"NodeCache.class", "PathChildrenCache.class", "PersistentEphemeralNode.class", "InterProcessMutex.class",
"LeasesHolder.class" (for semaphores)|
+|Details|n/a|
+
+h2. Asynchronous Client APIs
+
+|API: */curator/v1/client/create*| |
+|Type|client-create-async|
+|Source Id|The asyncId passed in the original request|
+|Message|PathAndId as a JSON string|
+|Details|The ZooKeeper "rc" result code|
+| | |
+|API: */curator/v1/client/delete*| |
+|Type|client-delete-async|
+|Source Id|The asyncId passed in the original request|
+|Message|n/a|
+|Details|The ZooKeeper "rc" result code|
+| | |
+|API: */curator/v1/client/get-children*| |
+|Type|client-get-children-async|
+|Source Id|The asyncId passed in the original request|
+|Message|List of children nodes separated by the value passed as asyncListSeparator in the
original request|
+|Details|The ZooKeeper "rc" result code|
+| | |
+|API: */curator/v1/client/set-data*| |
+|Type|client-set-data-async|
+|Source Id|The asyncId passed in the original request|
+|Message|n/a|
+|Details|The ZooKeeper "rc" result code|
+| | |
+|API: */curator/v1/client/get-data*| |
+|Type|client-get-data-async|
+|Source Id|The asyncId passed in the original request|
+|Message|The data|
+|Details|The ZooKeeper "rc" result code|
+| | |
+|API: */curator/v1/client/exists*| |
+|Type|client-exists-async|
+|Source Id|The asyncId passed in the original request|
+|Message|ZK Stat as a JSON string|
+|Details|The ZooKeeper "rc" result code|
+
+h2. Recipe Messages
+
+|API: */curator/v1/recipes/leader*| |
+|Type|leader|
+|Source Id|generated leader Id|
+|Message|"true" if leader, "false" if leadership is lost|
+|Details|n/a|
+| | |
+|API: */curator/v1/recipes/path-cache*| |
+|Type|path-cache|
+|Source Id|generated leader Id|
+|Message|n/a|
+|Details|n/a|
+| | |
+|API: */curator/v1/recipes/node-cache*| |
+|Type|node-cache|
+|Source Id|generated leader Id|
+|Message|Either "child_added", "child_updated", "child_removed", "connection_suspended",
"connection_reconnected", "connection_lost", or "initialized"|
+|Details|Node path|

http://git-wip-us.apache.org/repos/asf/curator/blob/b4c76c79/curator-x-rest/src/site/resources/images/client.png
----------------------------------------------------------------------
diff --git a/curator-x-rest/src/site/resources/images/client.png b/curator-x-rest/src/site/resources/images/client.png
new file mode 100644
index 0000000..27d10c2
Binary files /dev/null and b/curator-x-rest/src/site/resources/images/client.png differ


Mime
View raw message