[2/4] curator git commit: Fix TreeCache duplicate ADD events in rare cases.

2016-05-19 Thread randgalt
Fix TreeCache duplicate ADD events in rare cases.


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

Branch: refs/heads/CURATOR-3.0
Commit: 56525235cc63b9c74b6286a44ef89f3ffca94a1a
Parents: ee34e2b
Author: Scott Blum 
Authored: Thu May 19 20:18:01 2016 -0400
Committer: Scott Blum 
Committed: Thu May 19 20:18:01 2016 -0400

--
 .../org/apache/curator/framework/recipes/cache/TreeCache.java| 4 ++--
 .../curator/framework/recipes/cache/TestEventOrdering.java   | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/56525235/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
--
diff --git 
a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
 
b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
index f762324..2dbe699 100644
--- 
a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
+++ 
b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
@@ -447,11 +447,11 @@ public class TreeCache implements Closeable
 }
 
 NodeState oldState = nodeState.getAndSet(NodeState.LIVE);
-if ( oldState != NodeState.LIVE )
+if ( oldState == NodeState.PENDING || (oldState == 
NodeState.DEAD && parent == null))
 {
 publishEvent(TreeCacheEvent.Type.NODE_ADDED, 
toPublish);
 }
-else
+else if ( oldState == NodeState.LIVE )
 {
 if ( oldChildData == null || 
oldChildData.getStat().getMzxid() != newStat.getMzxid() )
 {

http://git-wip-us.apache.org/repos/asf/curator/blob/56525235/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java
--
diff --git 
a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java
 
b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java
index 28a1655..8f332af 100644
--- 
a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java
+++ 
b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java
@@ -12,7 +12,6 @@ import org.apache.zookeeper.KeeperException;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 import java.io.Closeable;
-import java.util.Date;
 import java.util.List;
 import java.util.Random;
 import java.util.concurrent.BlockingQueue;



[1/4] curator git commit: test for event ordering in both caches

2016-05-19 Thread randgalt
Repository: curator
Updated Branches:
  refs/heads/CURATOR-3.0 2180d0550 -> 48e2c15b8


test for event ordering in both caches


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

Branch: refs/heads/CURATOR-3.0
Commit: ee34e2b77225b62432d73d47d648763747c165d3
Parents: 168dfd7
Author: randgalt 
Authored: Thu May 19 15:25:57 2016 -0500
Committer: randgalt 
Committed: Thu May 19 15:25:57 2016 -0500

--
 .../recipes/cache/TestEventOrdering.java| 160 +++
 .../TestPathChildrenCacheEventOrdering.java |  37 +
 .../cache/TestTreeCacheEventOrdering.java   |  40 +
 3 files changed, 237 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/ee34e2b7/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java
--
diff --git 
a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java
 
b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java
new file mode 100644
index 000..28a1655
--- /dev/null
+++ 
b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java
@@ -0,0 +1,160 @@
+package org.apache.curator.framework.recipes.cache;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Queues;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.retry.RetryOneTime;
+import org.apache.curator.test.BaseClassForTests;
+import org.apache.curator.test.Timing;
+import org.apache.curator.utils.CloseableUtils;
+import org.apache.zookeeper.KeeperException;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+import java.io.Closeable;
+import java.util.Date;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+public abstract class TestEventOrdering extends 
BaseClassForTests
+{
+private final Timing timing = new Timing();
+private final long start = System.currentTimeMillis();
+private static final int THREAD_QTY = 100;
+private static final int ITERATIONS = 100;
+private static final int NODE_QTY = 10;
+
+public enum EventType
+{
+ADDED,
+DELETED
+}
+
+public static class Event
+{
+public final EventType eventType;
+public final String path;
+public final long time = System.currentTimeMillis();
+
+public Event(EventType eventType, String path)
+{
+this.eventType = eventType;
+this.path = path;
+}
+}
+
+@Test
+public void testEventOrdering() throws Exception
+{
+ExecutorService executorService = 
Executors.newFixedThreadPool(THREAD_QTY);
+BlockingQueue events = Queues.newLinkedBlockingQueue();
+final CuratorFramework client = 
CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), 
timing.connection(), new RetryOneTime(1));
+T cache = null;
+try
+{
+client.start();
+client.create().forPath("/root");
+cache = newCache(client, "/root", events);
+
+final Random random = new Random();
+final Callable task = new Callable()
+{
+@Override
+public Void call() throws Exception
+{
+for ( int i = 0; i < ITERATIONS; ++i )
+{
+String node = "/root/" + random.nextInt(NODE_QTY);
+try
+{
+switch ( random.nextInt(3) )
+{
+default:
+case 0:
+client.create().forPath(node);
+break;
+
+case 1:
+client.setData().forPath(node, 
"new".getBytes());
+break;
+
+case 2:
+client.delete().forPath(node);
+break;
+}
+}
+catch ( KeeperException ignore )
+   

[4/4] curator git commit: Merge branch 'master' into CURATOR-3.0

2016-05-19 Thread randgalt
Merge branch 'master' into CURATOR-3.0


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

Branch: refs/heads/CURATOR-3.0
Commit: 48e2c15b8c3e3e6e5de97858898aa757e213fb02
Parents: 2180d05 3424fc1
Author: randgalt 
Authored: Thu May 19 21:38:15 2016 -0500
Committer: randgalt 
Committed: Thu May 19 21:38:15 2016 -0500

--
 .../framework/recipes/cache/TreeCache.java  |   4 +-
 .../recipes/cache/TestEventOrdering.java| 177 +++
 .../TestPathChildrenCacheEventOrdering.java |  55 ++
 .../cache/TestTreeCacheEventOrdering.java   |  58 ++
 4 files changed, 292 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/48e2c15b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
--



[1/2] curator git commit: test for event ordering in both caches

2016-05-19 Thread randgalt
Repository: curator
Updated Branches:
  refs/heads/master 168dfd734 -> 56525235c


test for event ordering in both caches


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

Branch: refs/heads/master
Commit: ee34e2b77225b62432d73d47d648763747c165d3
Parents: 168dfd7
Author: randgalt 
Authored: Thu May 19 15:25:57 2016 -0500
Committer: randgalt 
Committed: Thu May 19 15:25:57 2016 -0500

--
 .../recipes/cache/TestEventOrdering.java| 160 +++
 .../TestPathChildrenCacheEventOrdering.java |  37 +
 .../cache/TestTreeCacheEventOrdering.java   |  40 +
 3 files changed, 237 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/ee34e2b7/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java
--
diff --git 
a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java
 
b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java
new file mode 100644
index 000..28a1655
--- /dev/null
+++ 
b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java
@@ -0,0 +1,160 @@
+package org.apache.curator.framework.recipes.cache;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Queues;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.retry.RetryOneTime;
+import org.apache.curator.test.BaseClassForTests;
+import org.apache.curator.test.Timing;
+import org.apache.curator.utils.CloseableUtils;
+import org.apache.zookeeper.KeeperException;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+import java.io.Closeable;
+import java.util.Date;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+public abstract class TestEventOrdering extends 
BaseClassForTests
+{
+private final Timing timing = new Timing();
+private final long start = System.currentTimeMillis();
+private static final int THREAD_QTY = 100;
+private static final int ITERATIONS = 100;
+private static final int NODE_QTY = 10;
+
+public enum EventType
+{
+ADDED,
+DELETED
+}
+
+public static class Event
+{
+public final EventType eventType;
+public final String path;
+public final long time = System.currentTimeMillis();
+
+public Event(EventType eventType, String path)
+{
+this.eventType = eventType;
+this.path = path;
+}
+}
+
+@Test
+public void testEventOrdering() throws Exception
+{
+ExecutorService executorService = 
Executors.newFixedThreadPool(THREAD_QTY);
+BlockingQueue events = Queues.newLinkedBlockingQueue();
+final CuratorFramework client = 
CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), 
timing.connection(), new RetryOneTime(1));
+T cache = null;
+try
+{
+client.start();
+client.create().forPath("/root");
+cache = newCache(client, "/root", events);
+
+final Random random = new Random();
+final Callable task = new Callable()
+{
+@Override
+public Void call() throws Exception
+{
+for ( int i = 0; i < ITERATIONS; ++i )
+{
+String node = "/root/" + random.nextInt(NODE_QTY);
+try
+{
+switch ( random.nextInt(3) )
+{
+default:
+case 0:
+client.create().forPath(node);
+break;
+
+case 1:
+client.setData().forPath(node, 
"new".getBytes());
+break;
+
+case 2:
+client.delete().forPath(node);
+break;
+}
+}
+catch ( KeeperException ignore )
+ 

curator git commit: test for event ordering in both caches

2016-05-19 Thread randgalt
Repository: curator
Updated Branches:
  refs/heads/CURATOR-324 [created] ee34e2b77


test for event ordering in both caches


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

Branch: refs/heads/CURATOR-324
Commit: ee34e2b77225b62432d73d47d648763747c165d3
Parents: 168dfd7
Author: randgalt 
Authored: Thu May 19 15:25:57 2016 -0500
Committer: randgalt 
Committed: Thu May 19 15:25:57 2016 -0500

--
 .../recipes/cache/TestEventOrdering.java| 160 +++
 .../TestPathChildrenCacheEventOrdering.java |  37 +
 .../cache/TestTreeCacheEventOrdering.java   |  40 +
 3 files changed, 237 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/ee34e2b7/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java
--
diff --git 
a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java
 
b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java
new file mode 100644
index 000..28a1655
--- /dev/null
+++ 
b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java
@@ -0,0 +1,160 @@
+package org.apache.curator.framework.recipes.cache;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Queues;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.retry.RetryOneTime;
+import org.apache.curator.test.BaseClassForTests;
+import org.apache.curator.test.Timing;
+import org.apache.curator.utils.CloseableUtils;
+import org.apache.zookeeper.KeeperException;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+import java.io.Closeable;
+import java.util.Date;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+public abstract class TestEventOrdering extends 
BaseClassForTests
+{
+private final Timing timing = new Timing();
+private final long start = System.currentTimeMillis();
+private static final int THREAD_QTY = 100;
+private static final int ITERATIONS = 100;
+private static final int NODE_QTY = 10;
+
+public enum EventType
+{
+ADDED,
+DELETED
+}
+
+public static class Event
+{
+public final EventType eventType;
+public final String path;
+public final long time = System.currentTimeMillis();
+
+public Event(EventType eventType, String path)
+{
+this.eventType = eventType;
+this.path = path;
+}
+}
+
+@Test
+public void testEventOrdering() throws Exception
+{
+ExecutorService executorService = 
Executors.newFixedThreadPool(THREAD_QTY);
+BlockingQueue events = Queues.newLinkedBlockingQueue();
+final CuratorFramework client = 
CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), 
timing.connection(), new RetryOneTime(1));
+T cache = null;
+try
+{
+client.start();
+client.create().forPath("/root");
+cache = newCache(client, "/root", events);
+
+final Random random = new Random();
+final Callable task = new Callable()
+{
+@Override
+public Void call() throws Exception
+{
+for ( int i = 0; i < ITERATIONS; ++i )
+{
+String node = "/root/" + random.nextInt(NODE_QTY);
+try
+{
+switch ( random.nextInt(3) )
+{
+default:
+case 0:
+client.create().forPath(node);
+break;
+
+case 1:
+client.setData().forPath(node, 
"new".getBytes());
+break;
+
+case 2:
+client.delete().forPath(node);
+break;
+}
+}
+catch ( KeeperException ignore )
+  

curator git commit: oops - typo

2016-05-19 Thread randgalt
Repository: curator
Updated Branches:
  refs/heads/CURATOR-3.0 fdbbbaa6b -> 2180d0550


oops - typo


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

Branch: refs/heads/CURATOR-3.0
Commit: 2180d05500c04e0a8a5300d602ea1323316bcb28
Parents: fdbbbaa
Author: randgalt 
Authored: Thu May 19 14:26:36 2016 -0500
Committer: randgalt 
Committed: Thu May 19 14:26:36 2016 -0500

--
 curator-framework/src/site/confluence/schema.confluence | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/2180d055/curator-framework/src/site/confluence/schema.confluence
--
diff --git a/curator-framework/src/site/confluence/schema.confluence 
b/curator-framework/src/site/confluence/schema.confluence
index 1a9923c..0a033e0 100644
--- a/curator-framework/src/site/confluence/schema.confluence
+++ b/curator-framework/src/site/confluence/schema.confluence
@@ -11,7 +11,7 @@ Curator provides a mechanism to:
 * Validate operations on ZooKeeper paths
 * Map a simple string to a ZooKeeper path
 
-When a Curator operation violates a schema, {{SchemaViolationException}} is 
thrown.
+When a Curator operation violates a schema, {{SchemaViolation}} is thrown.
 
 h2. Schema and SchemaSet
 



[19/35] curator git commit: move name into schema - better definition of search order

2016-05-19 Thread randgalt
move name into schema - better definition of search order


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

Branch: refs/heads/CURATOR-3.0
Commit: 8d4a94683e9231ec762aa2e2c6ff78c072510cc2
Parents: f2ef8b3
Author: randgalt 
Authored: Tue May 3 11:28:30 2016 -0500
Committer: randgalt 
Committed: Tue May 3 11:28:30 2016 -0500

--
 .../apache/curator/framework/schema/Schema.java | 22 ++--
 .../curator/framework/schema/SchemaBuilder.java | 14 -
 .../curator/framework/schema/SchemaSet.java | 58 +++-
 .../framework/schema/SchemaSetLoader.java   | 17 +++---
 4 files changed, 82 insertions(+), 29 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/8d4a9468/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
index fc4919e..86732e0 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
@@ -27,6 +27,7 @@ import java.util.regex.Pattern;
  */
 public class Schema
 {
+private final String name;
 private final Pattern pathRegex;
 private final String path;
 private final String documentation;
@@ -44,7 +45,7 @@ public class Schema
 }
 
 /**
- * Start a builder for the given path pattern. Note: full path schemas
+ * Start a builder for the given full path. Note: full path schemas
  * take precedence over regex path schemas.
  *
  * @param path full ZNode path. This schema only applies to an exact match
@@ -66,11 +67,12 @@ public class Schema
 return new SchemaBuilder(pathRegex, null);
 }
 
-Schema(Pattern pathRegex, String path, String documentation, DataValidator 
dataValidator, Allowance ephemeral, Allowance sequential, Allowance watched, 
boolean canBeDeleted)
+Schema(String name, Pattern pathRegex, String path, String documentation, 
DataValidator dataValidator, Allowance ephemeral, Allowance sequential, 
Allowance watched, boolean canBeDeleted)
 {
 Preconditions.checkNotNull((pathRegex != null) || (path != null), 
"pathRegex and path cannot both be null");
 this.pathRegex = pathRegex;
 this.path = path;
+this.name = Preconditions.checkNotNull(name, "name cannot be null");
 this.documentation = Preconditions.checkNotNull(documentation, 
"documentation cannot be null");
 this.dataValidator = Preconditions.checkNotNull(dataValidator, 
"dataValidator cannot be null");
 this.ephemeral = Preconditions.checkNotNull(ephemeral, "ephemeral 
cannot be null");
@@ -159,6 +161,11 @@ public class Schema
 }
 }
 
+public String getName()
+{
+return name;
+}
+
 /**
  * Return the raw path for this schema. If a full path was used, it is 
returned.
  * If a regex was used, it is returned
@@ -217,11 +224,13 @@ public class Schema
 public String toString()
 {
 return "Schema{" +
-"path=" + pathRegex +
+"name='" + name + '\'' +
+", pathRegex=" + pathRegex +
+", path='" + path + '\'' +
 ", documentation='" + documentation + '\'' +
 ", dataValidator=" + dataValidator +
-", isEphemeral=" + ephemeral +
-", isSequential=" + sequential +
+", ephemeral=" + ephemeral +
+", sequential=" + sequential +
 ", watched=" + watched +
 ", canBeDeleted=" + canBeDeleted +
 '}';
@@ -229,7 +238,8 @@ public class Schema
 
 public String toDocumentation()
 {
-return "Path: " + getRawPath() + '\n'
+return "Name: " + name + '\n'
++ "Path: " + getRawPath() + '\n'
 + "Documentation: " + documentation + '\n'
 + "Validator: " + dataValidator.getClass().getSimpleName() + '\n'
 + String.format("ephemeral: %s | sequential: %s | watched: %s | 
canBeDeleted: %s", ephemeral, sequential, watched, canBeDeleted) + '\n'

http://git-wip-us.apache.org/repos/asf/curator/blob/8d4a9468/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaBuilder.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaBuilder.java
 

[02/35] curator git commit: forgot sequential

2016-05-19 Thread randgalt
forgot sequential


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

Branch: refs/heads/CURATOR-3.0
Commit: da760f96cc5e553e7475505f282bce60a5da3056
Parents: ef1658c
Author: randgalt 
Authored: Mon May 2 14:16:48 2016 -0500
Committer: randgalt 
Committed: Mon May 2 14:16:48 2016 -0500

--
 .../java/org/apache/curator/framework/schema/Schema.java  | 10 ++
 1 file changed, 10 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/da760f96/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
index f10542d..7b8f1d5 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
@@ -49,6 +49,16 @@ public class Schema
 throw new SchemaViolation(this, "Must be ephemeral");
 }
 
+if ( mode.isSequential() && (sequential == Allowance.CANNOT) )
+{
+throw new SchemaViolation(this, "Cannot be sequential");
+}
+
+if ( !mode.isSequential() && (sequential == Allowance.MUST) )
+{
+throw new SchemaViolation(this, "Must be sequential");
+}
+
 validateData(data);
 }
 



[29/35] curator git commit: updated docs

2016-05-19 Thread randgalt
updated docs


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

Branch: refs/heads/CURATOR-3.0
Commit: b77b7eeb03b37d5db690647cff105a46b9f3b1a1
Parents: 726b03c
Author: randgalt 
Authored: Wed May 4 13:22:55 2016 -0500
Committer: randgalt 
Committed: Wed May 4 13:22:55 2016 -0500

--
 .../src/site/confluence/schema.confluence | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/b77b7eeb/curator-framework/src/site/confluence/schema.confluence
--
diff --git a/curator-framework/src/site/confluence/schema.confluence 
b/curator-framework/src/site/confluence/schema.confluence
index 1b59fe7..12b40f2 100644
--- a/curator-framework/src/site/confluence/schema.confluence
+++ b/curator-framework/src/site/confluence/schema.confluence
@@ -24,7 +24,7 @@ The basic specification is the Schema class:
 | sequential | can/must/cannot | N | Whether the schema allows for sequentials 
at the path |
 | watched | can/must/cannot | N | Whether the schema allows for watchers at 
the path |
 | canBeDeleted | true/false | N | Whether the schema allows the path to be 
deleted |
-| metadata | map | N | Any fields-to-values you want |
+| metadata | map | N | Any fields\-to\-values you want |
 
 All the Schema instances are combined into a SchemaSet and this can be set in 
the CuratorFrameworkFactory
 when creating a CuratorFramework instance. Schemas in a SchemaSet are applied 
in the following order:
@@ -35,7 +35,7 @@ when creating a CuratorFramework instance. Schemas in a 
SchemaSet are applied in
 h3. SchemaValidator
 
 SchemaValidators are used to optionally validate a ZNode operation when the 
node is created or
-data is being set. It is a functor of the form:
+modified. It is a functor of the form:
 
 {code}
 boolean isValid(Schema schema, String path, byte[] data, List acl);
@@ -54,9 +54,9 @@ h2. Loading JSON Schema from a file/stream
 
 An optional utility is provided to load SchemaSets from a JSON file or stream: 
SchemaSetLoader
 *NOTE:* to avoid adding a new dependency to Curator, the Jackson library has 
been used with "provided" scope.
-You will need to add a dependency to jackson-core and jackson-databind to your 
project.
+You will need to add a dependency to jackson\-core and jackson\-databind to 
your project.
 
-The JSON stream should be an array of named schemas:
+The JSON stream should be an array of schemas:
 
 {code}
 [
@@ -72,7 +72,7 @@ The JSON stream should be an array of named schemas:
"canBeDeleted": true/false,   optional - true if ZNode at path 
can be deleted - default is true
"metadata": { optional - any fields -> values 
that you want
"field1": "value1",
-"field2": "value2"
+   "field2": "value2"
}
}
 ]
@@ -128,5 +128,5 @@ h3. Example 2
 * The ZNode "/a/b/c" must be ephemeral, cannot be sequential, can be watched, 
and can be deleted
 * The second schema is regex and applies to any path that matches the 
expression "/a/.\*"
 * The ZNodes that match "/a/.\*" cannot be ephemeral, can be sequential, can 
be watched, and cannot be deleted
-* The second schema also has a data validator. The data validator named "test" 
(configured when constructing the SchemaSetLoader) will
-be called to validate data for ZNodes that match "/a/.\*" when create() or 
setData() are called.
+* The second schema also has a schema validator. The schema validator named 
"test" (configured when constructing the SchemaSetLoader) will
+be called to validate ZNodes that match "/a/.\*".



[21/35] curator git commit: minor renaming - beginning of site doc

2016-05-19 Thread randgalt
minor renaming - beginning of site doc


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

Branch: refs/heads/CURATOR-3.0
Commit: 3d9eb203b41736b9c314eac2f3a22b7b4034f0bc
Parents: 93a2a74
Author: randgalt 
Authored: Tue May 3 12:35:33 2016 -0500
Committer: randgalt 
Committed: Tue May 3 12:35:33 2016 -0500

--
 .../framework/imps/CuratorMultiTransactionImpl.java   |  2 +-
 .../apache/curator/framework/imps/DeleteBuilderImpl.java  |  2 +-
 .../apache/curator/framework/imps/ExistsBuilderImpl.java  |  2 +-
 .../curator/framework/imps/GetChildrenBuilderImpl.java|  2 +-
 .../apache/curator/framework/imps/GetDataBuilderImpl.java |  2 +-
 .../java/org/apache/curator/framework/schema/Schema.java  |  4 ++--
 curator-framework/src/site/confluence/schema.confluence   | 10 ++
 src/site/site.xml |  1 +
 8 files changed, 18 insertions(+), 7 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/3d9eb203/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorMultiTransactionImpl.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorMultiTransactionImpl.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorMultiTransactionImpl.java
index bfdf40f..a08bd0f 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorMultiTransactionImpl.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorMultiTransactionImpl.java
@@ -133,7 +133,7 @@ public class CuratorMultiTransactionImpl implements
 }
 else if ( (curatorOp.get().getType() == ZooDefs.OpCode.delete) || 
(curatorOp.get().getType() == ZooDefs.OpCode.deleteContainer) )
 {
-schema.validateDeletion();
+schema.validateDelete();
 }
 else if ( curatorOp.get().getType() == ZooDefs.OpCode.setData )
 {

http://git-wip-us.apache.org/repos/asf/curator/blob/3d9eb203/curator-framework/src/main/java/org/apache/curator/framework/imps/DeleteBuilderImpl.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/imps/DeleteBuilderImpl.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/imps/DeleteBuilderImpl.java
index 54aac54..cbd12dd 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/imps/DeleteBuilderImpl.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/imps/DeleteBuilderImpl.java
@@ -213,7 +213,7 @@ class DeleteBuilderImpl implements DeleteBuilder, 
BackgroundOperation, E
 @Override
 public Void forPath(String path) throws Exception
 {
-client.getSchemaSet().getSchema(path).validateDeletion();
+client.getSchemaSet().getSchema(path).validateDelete();
 
 final String unfixedPath = path;
 path = client.fixForNamespace(path);

http://git-wip-us.apache.org/repos/asf/curator/blob/3d9eb203/curator-framework/src/main/java/org/apache/curator/framework/imps/ExistsBuilderImpl.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/imps/ExistsBuilderImpl.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/imps/ExistsBuilderImpl.java
index 11721de..dd50efb 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/imps/ExistsBuilderImpl.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/imps/ExistsBuilderImpl.java
@@ -158,7 +158,7 @@ class ExistsBuilderImpl implements ExistsBuilder, 
BackgroundOperation, E
 {
 path = client.fixForNamespace(path);
 
-
client.getSchemaSet().getSchema(path).validateWatcher(watching.isWatched() || 
watching.hasWatcher());
+
client.getSchemaSet().getSchema(path).validateWatch(watching.isWatched() || 
watching.hasWatcher());
 
 StatreturnStat = null;
 if ( backgrounding.inBackground() )

http://git-wip-us.apache.org/repos/asf/curator/blob/3d9eb203/curator-framework/src/main/java/org/apache/curator/framework/imps/GetChildrenBuilderImpl.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/imps/GetChildrenBuilderImpl.java
 

[33/35] curator git commit: Added getSchemas()

2016-05-19 Thread randgalt
Added getSchemas()


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

Branch: refs/heads/CURATOR-3.0
Commit: b6b9006b79afbb029da08d9319fa1b1986a5f3d6
Parents: 1dbdbdc
Author: randgalt 
Authored: Fri May 6 11:19:33 2016 -0500
Committer: randgalt 
Committed: Fri May 6 11:19:33 2016 -0500

--
 .../org/apache/curator/framework/schema/SchemaSetLoader.java| 5 +
 1 file changed, 5 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/b6b9006b/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSetLoader.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSetLoader.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSetLoader.java
index bf77c7d..16b387e 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSetLoader.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSetLoader.java
@@ -103,6 +103,11 @@ public class SchemaSetLoader
 return new SchemaSet(schemas, useDefaultSchema);
 }
 
+public List getSchemas()
+{
+return schemas;
+}
+
 private void read(ImmutableList.Builder builder, JsonNode node, 
SchemaValidatorMapper schemaValidatorMapper)
 {
 for ( JsonNode child : node )



[25/35] curator git commit: make sure correct menu item is selected

2016-05-19 Thread randgalt
make sure correct menu item is selected


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

Branch: refs/heads/CURATOR-3.0
Commit: 032af453ef2a4b4ce1bfc22e40c8712676c98234
Parents: 5730f21
Author: randgalt 
Authored: Tue May 3 14:00:12 2016 -0500
Committer: randgalt 
Committed: Tue May 3 14:00:12 2016 -0500

--
 curator-framework/src/site/site.xml | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/032af453/curator-framework/src/site/site.xml
--
diff --git a/curator-framework/src/site/site.xml 
b/curator-framework/src/site/site.xml
index 38d877a..4a66e87 100644
--- a/curator-framework/src/site/site.xml
+++ b/curator-framework/src/site/site.xml
@@ -25,7 +25,11 @@
 
 
 $(function(){
-$('a[title="Framework"]').parent().addClass("active");
+if ( location.pathname.endsWith('schema.html') ) {
+$('a[title="Schema 
Support"]').parent().addClass("active");
+} else {
+$('a[title="Framework"]').parent().addClass("active");
+}
 });
 
 



[06/35] curator git commit: documentation and cleanup

2016-05-19 Thread randgalt
documentation and cleanup


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

Branch: refs/heads/CURATOR-3.0
Commit: 33534a099884fc8336c85aaf518e10485de4efe1
Parents: 7f27631
Author: randgalt 
Authored: Mon May 2 16:35:55 2016 -0500
Committer: randgalt 
Committed: Mon May 2 16:35:55 2016 -0500

--
 .../framework/CuratorFrameworkFactory.java  |  9 +---
 .../framework/schema/DefaultDataValidator.java  |  3 ++
 .../apache/curator/framework/schema/Schema.java | 53 +---
 .../curator/framework/schema/SchemaBuilder.java | 48 +-
 .../curator/framework/schema/SchemaSet.java | 35 +++--
 .../framework/schema/SchemaViolation.java   | 18 +++
 6 files changed, 124 insertions(+), 42 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/33534a09/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
index c17534f..915aee1 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
@@ -144,14 +144,7 @@ public class CuratorFrameworkFactory
 private boolean useContainerParentsIfAvailable = true;
 private ConnectionStateErrorPolicy connectionStateErrorPolicy = new 
StandardConnectionStateErrorPolicy();
 private ConnectionHandlingPolicy connectionHandlingPolicy = 
Boolean.getBoolean("curator-use-classic-connection-handling") ? new 
ClassicConnectionHandlingPolicy() : new StandardConnectionHandlingPolicy();
-private SchemaSet schemaSet = new SchemaSet()
-{
-@Override
-public String toDocumentation()
-{
-return "Default schema";
-}
-};
+private SchemaSet schemaSet = SchemaSet.getDefaultSchemaSet();
 
 /**
  * Apply the current values and build a new CuratorFramework

http://git-wip-us.apache.org/repos/asf/curator/blob/33534a09/curator-framework/src/main/java/org/apache/curator/framework/schema/DefaultDataValidator.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/DefaultDataValidator.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/DefaultDataValidator.java
index 05e1f7c..f28db57 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/DefaultDataValidator.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/DefaultDataValidator.java
@@ -1,5 +1,8 @@
 package org.apache.curator.framework.schema;
 
+/**
+ * The default data validator - always returns true
+ */
 public class DefaultDataValidator implements DataValidator
 {
 @Override

http://git-wip-us.apache.org/repos/asf/curator/blob/33534a09/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
index ed8fecb..05aa6f1 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
@@ -4,6 +4,9 @@ import com.google.common.base.Preconditions;
 import org.apache.zookeeper.CreateMode;
 import java.util.regex.Pattern;
 
+/**
+ * Represents and documents operations allowed for a given path pattern
+ */
 public class Schema
 {
 private final Pattern path;
@@ -11,8 +14,7 @@ public class Schema
 private final DataValidator dataValidator;
 private final Allowance ephemeral;
 private final Allowance sequential;
-private final boolean canBeWatched;
-private final boolean canHaveChildren;
+private final Schema.Allowance watched;
 private final boolean canBeDeleted;
 
 public enum Allowance
@@ -22,20 +24,36 @@ public class Schema
 CANNOT
 }
 
-public static SchemaBuilder builder(String path)
+/**
+ * Start a builder for the given path pattern.
+ *
+ * @param pathRegex regex for the path. This schema applies to all 
matching 

curator git commit: doc update

2016-05-19 Thread randgalt
Repository: curator
Updated Branches:
  refs/heads/CURATOR-3.0 63a0d4550 -> fdbbbaa6b


doc update


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

Branch: refs/heads/CURATOR-3.0
Commit: fdbbbaa6b1222866c71ebf41aea691e63d7cad1c
Parents: 63a0d45
Author: randgalt 
Authored: Thu May 19 14:08:34 2016 -0500
Committer: randgalt 
Committed: Thu May 19 14:08:34 2016 -0500

--
 curator-framework/src/site/confluence/schema.confluence | 2 ++
 1 file changed, 2 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/fdbbbaa6/curator-framework/src/site/confluence/schema.confluence
--
diff --git a/curator-framework/src/site/confluence/schema.confluence 
b/curator-framework/src/site/confluence/schema.confluence
index 410d71a..1a9923c 100644
--- a/curator-framework/src/site/confluence/schema.confluence
+++ b/curator-framework/src/site/confluence/schema.confluence
@@ -11,6 +11,8 @@ Curator provides a mechanism to:
 * Validate operations on ZooKeeper paths
 * Map a simple string to a ZooKeeper path
 
+When a Curator operation violates a schema, {{SchemaViolationException}} is 
thrown.
+
 h2. Schema and SchemaSet
 
 The basic specification is the Schema class:



[27/35] curator git commit: Introduce metadata and make the DataValidator more generic

2016-05-19 Thread randgalt
Introduce metadata and make the DataValidator more generic


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

Branch: refs/heads/CURATOR-3.0
Commit: b889e3bce1566d7a5d1e30bf425d555d6ccd8ed0
Parents: fd0f3b0
Author: randgalt 
Authored: Wed May 4 12:36:43 2016 -0500
Committer: randgalt 
Committed: Wed May 4 12:36:43 2016 -0500

--
 .../framework/imps/CreateBuilderImpl.java   | 16 ++---
 .../imps/CuratorMultiTransactionImpl.java   |  4 +-
 .../framework/imps/SetDataBuilderImpl.java  |  3 +-
 .../curator/framework/schema/DataValidator.java | 24 ---
 .../framework/schema/DefaultDataValidator.java  | 31 -
 .../schema/DefaultSchemaValidator.java  | 34 ++
 .../apache/curator/framework/schema/Schema.java | 69 
 .../curator/framework/schema/SchemaBuilder.java | 23 +--
 .../curator/framework/schema/SchemaSet.java |  4 +-
 .../framework/schema/SchemaSetLoader.java   | 54 ++-
 .../framework/schema/SchemaValidator.java   | 27 
 .../src/site/confluence/schema.confluence   | 25 ---
 .../curator/framework/schema/TestSchema.java| 41 +++-
 .../src/test/resources/schema1.json |  6 +-
 .../src/test/resources/schema3.json |  2 +-
 .../src/test/resources/schema4.json |  2 +-
 16 files changed, 237 insertions(+), 128 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/b889e3bc/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java
index facabe7..8096802 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java
@@ -480,14 +480,14 @@ class CreateBuilderImpl implements CreateBuilder, 
BackgroundOperation aclList = acling.getAclList(adjustedPath);
+client.getSchemaSet().getSchema(givenPath).validateCreate(createMode, 
data, aclList);
 
 String returnPath = null;
 if ( backgrounding.inBackground() )
@@ -496,17 +496,17 @@ class CreateBuilderImpl implements CreateBuilder, 
BackgroundOperation aclList) throws Exception
 {
 try
 {
-return pathInForeground(adjustedPath, data);
+return pathInForeground(adjustedPath, data, aclList);
 }
 catch ( Exception e)
 {
@@ -1013,7 +1013,7 @@ class CreateBuilderImpl implements CreateBuilder, 
BackgroundOperation aclList) throws Exception
 {
 TimeTrace trace = 
client.getZookeeperClient().startTracer("CreateBuilderImpl-Foreground");
 
@@ -1053,7 +1053,7 @@ class CreateBuilderImpl implements CreateBuilder, 
BackgroundOperationhttp://git-wip-us.apache.org/repos/asf/curator/blob/b889e3bc/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorMultiTransactionImpl.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorMultiTransactionImpl.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorMultiTransactionImpl.java
index a08bd0f..40d0d2d 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorMultiTransactionImpl.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorMultiTransactionImpl.java
@@ -129,7 +129,7 @@ public class CuratorMultiTransactionImpl implements
 {
 CreateRequest createRequest = 
(CreateRequest)curatorOp.get().toRequestRecord();
 CreateMode createMode = 
CreateMode.fromFlag(createRequest.getFlags(), CreateMode.PERSISTENT);
-schema.validateCreate(createMode, createRequest.getData());
+schema.validateCreate(createMode, createRequest.getData(), 
createRequest.getAcl());
 }
 else if ( (curatorOp.get().getType() == ZooDefs.OpCode.delete) || 
(curatorOp.get().getType() == ZooDefs.OpCode.deleteContainer) )
 {
@@ -138,7 +138,7 @@ public class CuratorMultiTransactionImpl implements
 else if ( curatorOp.get().getType() == ZooDefs.OpCode.setData )
 {
 SetDataRequest setDataRequest = 
(SetDataRequest)curatorOp.get().toRequestRecord();
-  

[16/35] curator git commit: test transactions

2016-05-19 Thread randgalt
test transactions


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

Branch: refs/heads/CURATOR-3.0
Commit: ae6cb4be4ee56215bef26e8d7fb5139d9b81d026
Parents: 923a2d8
Author: randgalt 
Authored: Tue May 3 10:19:46 2016 -0500
Committer: randgalt 
Committed: Tue May 3 10:19:46 2016 -0500

--
 .../curator/framework/schema/TestSchema.java| 83 
 .../src/test/resources/schema4.json | 14 
 2 files changed, 97 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/ae6cb4be/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
--
diff --git 
a/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
 
b/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
index f3754f5..e094c0e 100644
--- 
a/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
+++ 
b/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
@@ -22,6 +22,7 @@ import com.google.common.base.Charsets;
 import com.google.common.io.Resources;
 import org.apache.curator.framework.CuratorFramework;
 import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.framework.api.transaction.CuratorOp;
 import org.apache.curator.retry.RetryOneTime;
 import org.apache.curator.test.BaseClassForTests;
 import org.apache.curator.utils.CloseableUtils;
@@ -139,6 +140,88 @@ public class TestSchema extends BaseClassForTests
 }
 }
 
+@Test
+public void testTransaction() throws Exception
+{
+final DataValidator dataValidator = new DataValidator()
+{
+@Override
+public boolean isValid(String path, byte[] data)
+{
+return data.length > 0;
+}
+};
+SchemaSetLoader.DataValidatorMapper dataValidatorMapper = new 
SchemaSetLoader.DataValidatorMapper()
+{
+@Override
+public DataValidator getDataValidator(String name)
+{
+return dataValidator;
+}
+};
+SchemaSet schemaSet = loadSchemaSet("schema4.json", 
dataValidatorMapper);
+CuratorFramework client = newClient(schemaSet);
+try
+{
+client.start();
+
+CuratorOp createAPersistent = 
client.transactionOp().create().forPath("/a");
+CuratorOp createAEphemeral = 
client.transactionOp().create().withMode(CreateMode.EPHEMERAL).forPath("/a");
+CuratorOp deleteA = client.transactionOp().delete().forPath("/a");
+CuratorOp createBEmptyData = 
client.transactionOp().create().forPath("/b", new byte[0]);
+CuratorOp createBWithData = 
client.transactionOp().create().forPath("/b", new byte[10]);
+CuratorOp setBEmptyData = 
client.transactionOp().setData().forPath("/b", new byte[0]);
+CuratorOp setBWithData = 
client.transactionOp().setData().forPath("/b", new byte[10]);
+
+try
+{
+client.transaction().forOperations(createAPersistent, 
createAEphemeral);
+Assert.fail("Should've violated schema");
+}
+catch ( SchemaViolation dummy )
+{
+// expected
+}
+client.transaction().forOperations(createAEphemeral);
+
+try
+{
+client.transaction().forOperations(deleteA);
+Assert.fail("Should've violated schema");
+}
+catch ( SchemaViolation dummy )
+{
+// expected
+}
+
+try
+{
+client.transaction().forOperations(createBEmptyData);
+Assert.fail("Should've violated schema");
+}
+catch ( SchemaViolation dummy )
+{
+// expected
+}
+client.transaction().forOperations(createBWithData);
+
+try
+{
+client.transaction().forOperations(setBEmptyData);
+Assert.fail("Should've violated schema");
+}
+catch ( SchemaViolation dummy )
+{
+// expected
+}
+client.transaction().forOperations(setBWithData);
+}
+finally
+{
+CloseableUtils.closeQuietly(client);
+}
+}
+
 @Override
 protected boolean 

[11/35] curator git commit: more tests, fixes

2016-05-19 Thread randgalt
more tests, fixes


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

Branch: refs/heads/CURATOR-3.0
Commit: 4e667686332fe43114b7e093569a988a1a85c819
Parents: 734f453
Author: randgalt 
Authored: Mon May 2 23:36:48 2016 -0500
Committer: randgalt 
Committed: Mon May 2 23:36:48 2016 -0500

--
 .../apache/curator/framework/schema/Schema.java |  6 ++--
 .../curator/framework/schema/SchemaSet.java |  2 +-
 .../curator/framework/imps/TestSchema.java  | 38 +++-
 .../src/test/resources/schema2.json | 17 +
 4 files changed, 58 insertions(+), 5 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/4e667686/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
index 7cb9d76..1f91397 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
@@ -200,10 +200,10 @@ public class Schema
 
 public String toDocumentation()
 {
-return pathRegex.pattern() + '\n'
-+ documentation + '\n'
+return "Path: " + getRawPath() + '\n'
++ "Documentation: " + documentation + '\n'
 + "Validator: " + dataValidator.getClass().getSimpleName() + '\n'
-+ String.format("ephemeral: %s | sequential: %s | watched: %s | | 
canBeDeleted: %s", ephemeral, sequential, watched, canBeDeleted) + '\n'
++ String.format("ephemeral: %s | sequential: %s | watched: %s | 
canBeDeleted: %s", ephemeral, sequential, watched, canBeDeleted) + '\n'
 ;
 }
 }

http://git-wip-us.apache.org/repos/asf/curator/blob/4e667686/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
index 768f6c6..ff650f5 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
@@ -136,7 +136,7 @@ public class SchemaSet
 StringBuilder str = new StringBuilder("Curator Schemas:\n\n");
 for ( Map.Entry schemaEntry : schemas.entrySet() )
 {
-
str.append(schemaEntry.getKey()).append('\n').append(schemaEntry.getValue()).append('\n');
+
str.append(schemaEntry.getKey()).append('\n').append(schemaEntry.getValue().toDocumentation()).append('\n');
 }
 return str.toString();
 }

http://git-wip-us.apache.org/repos/asf/curator/blob/4e667686/curator-framework/src/test/java/org/apache/curator/framework/imps/TestSchema.java
--
diff --git 
a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestSchema.java
 
b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestSchema.java
index a55ad8e..9359fff 100644
--- 
a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestSchema.java
+++ 
b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestSchema.java
@@ -4,6 +4,7 @@ import com.google.common.base.Charsets;
 import com.google.common.io.Resources;
 import org.apache.curator.framework.CuratorFramework;
 import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.framework.schema.SchemaKey;
 import org.apache.curator.framework.schema.SchemaSet;
 import org.apache.curator.framework.schema.SchemaSetLoader;
 import org.apache.curator.framework.schema.SchemaViolation;
@@ -28,7 +29,7 @@ public class TestSchema extends BaseClassForTests
 
 try
 {
-client.create().creatingParentsIfNeeded().forPath("/a/b/c");
+
client.create().creatingParentsIfNeeded().forPath(schemaSet.getNamedSchema(SchemaKey.named("test")).getRawPath());
 Assert.fail("Should've violated schema");
 }
 catch ( SchemaViolation dummy )
@@ -44,6 +45,41 @@ public class TestSchema extends BaseClassForTests
 }
 }
 
+@Test
+public void testMulti() throws Exception
+{
+   

[05/35] curator git commit: needs new arg

2016-05-19 Thread randgalt
needs new arg


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

Branch: refs/heads/CURATOR-3.0
Commit: 7f27631cb8d11e7026deca5e6848d9a1e584f0d3
Parents: df3c1c4
Author: randgalt 
Authored: Mon May 2 16:16:52 2016 -0500
Committer: randgalt 
Committed: Mon May 2 16:16:52 2016 -0500

--
 .../main/java/org/apache/curator/framework/schema/SchemaSet.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/7f27631c/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
index 0c3dfd5..8a6e19c 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
@@ -37,7 +37,7 @@ public class SchemaSet
 .softValues()
 .build(cacheLoader);
 
-private static final Schema defaultSchema = new 
Schema(Pattern.compile(".*"), "__default__", new DefaultDataValidator(), 
Schema.Allowance.CAN, Schema.Allowance.CAN, true, true);
+private static final Schema defaultSchema = new 
Schema(Pattern.compile(".*"), "Default schema", new DefaultDataValidator(), 
Schema.Allowance.CAN, Schema.Allowance.CAN, true, true, true);
 
 public SchemaSet()
 {



[35/35] curator git commit: Merge branch 'CURATOR-322' into CURATOR-3.0

2016-05-19 Thread randgalt
Merge branch 'CURATOR-322' into CURATOR-3.0


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

Branch: refs/heads/CURATOR-3.0
Commit: 63a0d4550ebfaa2e29ddf719f8bfe9696cffc5ae
Parents: 29906f1 5533d08
Author: randgalt 
Authored: Thu May 19 14:02:00 2016 -0500
Committer: randgalt 
Committed: Thu May 19 14:02:00 2016 -0500

--
 curator-framework/pom.xml   |  19 ++
 .../curator/framework/CuratorFramework.java |   8 +
 .../framework/CuratorFrameworkFactory.java  |  20 ++
 .../api/ErrorListenerEnsembleable.java  |  18 +
 .../api/ErrorListenerMultiTransactionMain.java  |  18 +
 .../api/ErrorListenerPathAndBytesable.java  |  18 +
 .../framework/api/ErrorListenerPathable.java|  18 +
 .../api/ErrorListenerReconfigBuilderMain.java   |  18 +
 .../framework/imps/CreateBuilderImpl.java   |  17 +-
 .../framework/imps/CuratorFrameworkImpl.java|  12 +
 .../imps/CuratorMultiTransactionImpl.java   |  22 +-
 .../framework/imps/DeleteBuilderImpl.java   |   2 +
 .../framework/imps/ExistsBuilderImpl.java   |   2 +
 .../framework/imps/GetChildrenBuilderImpl.java  |   2 +
 .../framework/imps/GetDataBuilderImpl.java  |   2 +
 .../framework/imps/SetACLBuilderImpl.java   |  12 +-
 .../framework/imps/SetDataBuilderImpl.java  |   3 +
 .../apache/curator/framework/imps/Watching.java |   5 +
 .../schema/DefaultSchemaValidator.java  |  34 ++
 .../apache/curator/framework/schema/Schema.java | 338 +++
 .../curator/framework/schema/SchemaBuilder.java | 135 
 .../curator/framework/schema/SchemaSet.java | 214 
 .../framework/schema/SchemaSetLoader.java   | 217 
 .../framework/schema/SchemaValidator.java   |  34 ++
 .../framework/schema/SchemaViolation.java   |  52 +++
 .../src/site/confluence/schema.confluence   | 133 
 curator-framework/src/site/site.xml |   6 +-
 .../curator/framework/schema/TestSchema.java| 322 ++
 .../src/test/resources/schema.yaml  |  14 +
 .../src/test/resources/schema1.json |  13 +
 .../src/test/resources/schema2.json |  17 +
 .../src/test/resources/schema3.json |   7 +
 .../src/test/resources/schema4.json |  14 +
 .../src/test/resources/schema5.json |  25 ++
 .../recipes/locks/TestInterProcessMutex.java| 117 ---
 pom.xml |  13 +
 src/site/site.xml   |   1 +
 37 files changed, 1864 insertions(+), 58 deletions(-)
--




[26/35] curator git commit: Added getNamedPath() utility

2016-05-19 Thread randgalt
Added getNamedPath() utility


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

Branch: refs/heads/CURATOR-3.0
Commit: fd0f3b0c886a73667d2e4115e6ed83e684fbfef3
Parents: 032af45
Author: randgalt 
Authored: Tue May 3 14:11:43 2016 -0500
Committer: randgalt 
Committed: Tue May 3 14:11:43 2016 -0500

--
 .../org/apache/curator/framework/schema/SchemaSet.java | 13 +
 .../src/site/confluence/schema.confluence  |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/fd0f3b0c/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
index fe27cbd..76dd36b 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
@@ -26,6 +26,7 @@ import com.google.common.cache.LoadingCache;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Maps;
+import org.apache.curator.framework.CuratorFramework;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import java.util.Collections;
@@ -163,6 +164,18 @@ public class SchemaSet
 }
 
 /**
+ * Utility to return a ZNode path for the given name
+ *
+ * @param client Curator client
+ * @param name path/schema name
+ * @return ZNode path
+ */
+public static String getNamedPath(CuratorFramework client, String name)
+{
+return client.getSchemaSet().getNamedSchema(name).getRawPath();
+}
+
+/**
  * Return the schema with the given key/name
  *
  * @param name name

http://git-wip-us.apache.org/repos/asf/curator/blob/fd0f3b0c/curator-framework/src/site/confluence/schema.confluence
--
diff --git a/curator-framework/src/site/confluence/schema.confluence 
b/curator-framework/src/site/confluence/schema.confluence
index 444f9d5..7478763 100644
--- a/curator-framework/src/site/confluence/schema.confluence
+++ b/curator-framework/src/site/confluence/schema.confluence
@@ -46,7 +46,7 @@ Use SchemaSets to access ZNode paths by a simple name. E.g.
 
 {code}
 CuratorFramework client = ...
-String path = client.getSchemaSet().getNamedSchema("locks").getRawPath();
+String path = SchemaSet.getNamedPath(client, "locks");
 {code}
 
 h2. Loading JSON Schema from a file/stream



[22/35] curator git commit: cache loader must return nullSchema if not found

2016-05-19 Thread randgalt
cache loader must return nullSchema if not found


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

Branch: refs/heads/CURATOR-3.0
Commit: d374773545d08bd4fc0f9d2be73d86772dc9cd9f
Parents: 3d9eb20
Author: randgalt 
Authored: Tue May 3 12:40:01 2016 -0500
Committer: randgalt 
Committed: Tue May 3 12:40:01 2016 -0500

--
 .../main/java/org/apache/curator/framework/schema/SchemaSet.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/d3747735/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
index 345d430..fe27cbd 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
@@ -55,7 +55,7 @@ public class SchemaSet
 return schema;
 }
 }
-return defaultSchema;
+return nullSchema;
 }
 };
 private final LoadingCache regexCache = CacheBuilder



[09/35] curator git commit: more doc

2016-05-19 Thread randgalt
more doc


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

Branch: refs/heads/CURATOR-3.0
Commit: 8ccfdebddfd9ce3d23d35f9ae94d5be77fa538a8
Parents: f83c8ef
Author: randgalt 
Authored: Mon May 2 17:09:40 2016 -0500
Committer: randgalt 
Committed: Mon May 2 17:09:40 2016 -0500

--
 .../apache/curator/framework/schema/Schema.java | 39 +++-
 1 file changed, 37 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/8ccfdebd/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
index 16d335a..7cb9d76 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
@@ -61,6 +61,11 @@ public class Schema
 this.canBeDeleted = canBeDeleted;
 }
 
+/**
+ * Validate that this schema allows znode deletion
+ *
+ * @throws SchemaViolation if schema does not allow znode deletion
+ */
 public void validateDeletion()
 {
 if ( !canBeDeleted )
@@ -69,6 +74,12 @@ public class Schema
 }
 }
 
+/**
+ * Validate that this schema's watching setting matches
+ *
+ * @param isWatching true if attempt is being made to watch node
+ * @throws SchemaViolation if schema's watching setting does not match
+ */
 public void validateWatcher(boolean isWatching)
 {
 if ( isWatching && (watched == Allowance.CANNOT) )
@@ -82,6 +93,13 @@ public class Schema
 }
 }
 
+/**
+ * Validate that this schema's create mode setting matches and that the 
data is valid
+ *
+ * @param mode CreateMode being used
+ * @param data data being set
+ * @throws SchemaViolation if schema's create mode setting does not match 
or data is invalid
+ */
 public void validateCreate(CreateMode mode, byte[] data)
 {
 if ( mode.isEphemeral() && (ephemeral == Allowance.CANNOT) )
@@ -107,6 +125,12 @@ public class Schema
 validateData(data);
 }
 
+/**
+ * Validate that this schema validates the data
+ *
+ * @param data data being set
+ * @throws SchemaViolation if data is invalid
+ */
 public void validateData(byte[] data)
 {
 if ( !dataValidator.isValid(data) )
@@ -115,12 +139,23 @@ public class Schema
 }
 }
 
-public Pattern getPathRegex()
+/**
+ * Return the raw path for this schema. If a full path was used, it is 
returned.
+ * If a regex was used, it is returned
+ *
+ * @return path
+ */
+public String getRawPath()
+{
+return (path != null) ? path : pathRegex.pattern();
+}
+
+Pattern getPathRegex()
 {
 return pathRegex;
 }
 
-public String getPath()
+String getPath()
 {
 return path;
 }



[30/35] curator git commit: some refinements and more tests

2016-05-19 Thread randgalt
some refinements and more tests


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

Branch: refs/heads/CURATOR-3.0
Commit: 32965e53b1eee4186e5704f2f23326e6f41d1ee8
Parents: b77b7ee
Author: randgalt 
Authored: Wed May 4 15:09:32 2016 -0500
Committer: randgalt 
Committed: Wed May 4 15:09:32 2016 -0500

--
 .../apache/curator/framework/schema/Schema.java |  46 +++-
 .../curator/framework/schema/TestSchema.java|   2 +
 .../recipes/locks/TestInterProcessMutex.java| 117 ---
 3 files changed, 121 insertions(+), 44 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/32965e53/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
index dff3cfe..6d4d09e 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
@@ -20,6 +20,7 @@ package org.apache.curator.framework.schema;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
+import org.apache.curator.utils.ZKPaths;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.data.ACL;
 import java.util.List;
@@ -72,11 +73,41 @@ public class Schema
 return new SchemaBuilder(pathRegex, null);
 }
 
+/**
+ * Start a schema builder for a typical Curator recipe's parent node
+ *
+ * @param parentPath Path to the parent node
+ * @return builder
+ */
+public static SchemaBuilder builderForRecipeParent(String parentPath)
+{
+return new SchemaBuilder(null, parentPath)
+.sequential(Allowance.CANNOT)
+.ephemeral(Allowance.CANNOT)
+;
+}
+
+/**
+ * Start a schema builder for a typical Curator recipe's children
+ *
+ * @param parentPath Path to the parent node
+ * @return builder
+ */
+public static SchemaBuilder builderForRecipe(String parentPath)
+{
+return new SchemaBuilder(Pattern.compile(ZKPaths.makePath(parentPath, 
".*")), null)
+.sequential(Allowance.MUST)
+.ephemeral(Allowance.MUST)
+.watched(Allowance.MUST)
+.canBeDeleted(true)
+;
+}
+
 Schema(String name, Pattern pathRegex, String path, String documentation, 
SchemaValidator schemaValidator, Allowance ephemeral, Allowance sequential, 
Allowance watched, boolean canBeDeleted, Map metadata)
 {
 Preconditions.checkNotNull((pathRegex != null) || (path != null), 
"pathRegex and path cannot both be null");
 this.pathRegex = pathRegex;
-this.path = path;
+this.path = fixPath(path);
 this.metadata = 
ImmutableMap.copyOf(Preconditions.checkNotNull(metadata, "metadata cannot be 
null"));
 this.name = Preconditions.checkNotNull(name, "name cannot be null");
 this.documentation = Preconditions.checkNotNull(documentation, 
"documentation cannot be null");
@@ -87,6 +118,19 @@ public class Schema
 this.canBeDeleted = canBeDeleted;
 }
 
+private String fixPath(String path)
+{
+if ( path != null )
+{
+if ( path.endsWith(ZKPaths.PATH_SEPARATOR) )
+{
+return (path.length() > 1) ? path.substring(0, path.length() - 
1) : "";
+}
+return path;
+}
+return null;
+}
+
 /**
  * Validate that this schema allows znode deletion
  *

http://git-wip-us.apache.org/repos/asf/curator/blob/32965e53/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
--
diff --git 
a/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
 
b/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
index 78ecdf5..482d17f 100644
--- 
a/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
+++ 
b/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
@@ -19,6 +19,7 @@
 package org.apache.curator.framework.schema;
 
 import com.google.common.base.Charsets;
+import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.io.Resources;
 import 

[18/35] curator git commit: Schema's equals() hashCode() needed updating

2016-05-19 Thread randgalt
Schema's equals() hashCode() needed updating


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

Branch: refs/heads/CURATOR-3.0
Commit: f2ef8b3ac687de9badccfa5f4250f38fe332cb7d
Parents: ea05370
Author: randgalt 
Authored: Tue May 3 10:42:25 2016 -0500
Committer: randgalt 
Committed: Tue May 3 10:42:25 2016 -0500

--
 .../org/apache/curator/framework/schema/Schema.java| 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/f2ef8b3a/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
index 6d08244..fc4919e 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
@@ -180,6 +180,7 @@ public class Schema
 return path;
 }
 
+// intentionally only path and pathRegex
 @Override
 public boolean equals(Object o)
 {
@@ -194,14 +195,22 @@ public class Schema
 
 Schema schema = (Schema)o;
 
-return pathRegex.equals(schema.pathRegex);
+//noinspection SimplifiableIfStatement
+if ( !pathRegex.equals(schema.pathRegex) )
+{
+return false;
+}
+return path.equals(schema.path);
 
 }
 
+// intentionally only path and pathRegex
 @Override
 public int hashCode()
 {
-return pathRegex.hashCode();
+int result = pathRegex.hashCode();
+result = 31 * result + path.hashCode();
+return result;
 }
 
 @Override



[23/35] curator git commit: completed site doc

2016-05-19 Thread randgalt
completed site doc


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

Branch: refs/heads/CURATOR-3.0
Commit: f039be918b8b52fd18f23bb653851cc646b29c87
Parents: d374773
Author: randgalt 
Authored: Tue May 3 13:35:27 2016 -0500
Committer: randgalt 
Committed: Tue May 3 13:35:27 2016 -0500

--
 .../apache/curator/framework/schema/Schema.java |   2 +-
 .../src/site/confluence/schema.confluence   | 104 +++
 2 files changed, 105 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/f039be91/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
index 465085d..3e6d448 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/Schema.java
@@ -34,7 +34,7 @@ public class Schema
 private final DataValidator dataValidator;
 private final Allowance ephemeral;
 private final Allowance sequential;
-private final Schema.Allowance watched;
+private final Allowance watched;
 private final boolean canBeDeleted;
 
 public enum Allowance

http://git-wip-us.apache.org/repos/asf/curator/blob/f039be91/curator-framework/src/site/confluence/schema.confluence
--
diff --git a/curator-framework/src/site/confluence/schema.confluence 
b/curator-framework/src/site/confluence/schema.confluence
index 57420ca..dc79fb0 100644
--- a/curator-framework/src/site/confluence/schema.confluence
+++ b/curator-framework/src/site/confluence/schema.confluence
@@ -1,10 +1,114 @@
 h1. Schema/Documentation Support
 
+In larger ZooKeeper applications you will end with many paths to ZNodes that 
have specific meanings and
+uses. E.g. "/myapp/clients/clusters/instances" or "/myapp/writers/locks". 
These paths can become unwieldy
+and difficult to reason about. Ideally, you should have a simple way to 
commonly refer to these paths,
+a way to validate how they are used, and a way to document what they are used 
for.
+
 Curator provides a mechanism to:
 
 * Document your ZooKeeper paths
 * Validate operations on ZooKeeper paths
 * Map a simple string to a ZooKeeper path
 
+h2. Schema and SchemaSet
+
+The basic specification is the Schema class:
+
+|| Field || Type || Required || Description ||
+| name | String | Y | A unique name for this schema |
+| path | String | Y | A full path to a ZNode or a regex pattern to a ZNode |
+| documentation | String | N | User displayable documentation for this schema |
+| dataValidator | DataValidator | N | _see below_ |
+| ephemeral | can/must/cannot | N | Whether the schema allows for ephemerals 
at the path |
+| sequential | can/must/cannot | N | Whether the schema allows for sequentials 
at the path |
+| watched | can/must/cannot | N | Whether the schema allows for watchers at 
the path |
+| canBeDeleted | true/false | N | Whether the schema allows the path to be 
deleted |
+
+All the Schema instances are combined into a SchemaSet and this can be set in 
the CuratorFrameworkFactory
+when creating a CuratorFramework instance. Schemas in a SchemaSet are applied 
in the following order:
+
+# Exact match on full path (i.e. non-regex)
+# Match on the first regex path, searched in the order given to the SchemaSet 
constructor
+
+h3. DataValidator
+
+DataValidators are used to optionally validate the data of a ZNode when the 
node is created or
+data is being set. It is a functor of the form:
+
+{code}
+boolean isValid(String path, byte[] data);
+{code}
+
+h2. Loading JSON Schema from a file/stream
+
+An optional utility is provided to load SchemaSets from a JSON file or stream: 
SchemaSetLoader
+*NOTE:* to avoid adding a new dependency to Curator, the Jackson library has 
been used with "provided" scope.
+You will need to add a dependency to jackson-core and jackson-databind to your 
project.
+
+The JSON stream should be an array of named schemas:
+
+{code}
+[
+   {
+   "name": "name",   required - name of the schema
+   "path": "path or pattern",required - full path or regex 
pattern
+   "isRegex": true/false,optional - true if path is a 
regular expression - default is false
+   "dataValidator": "name",  optional - name of a data 
validator - 

[17/35] curator git commit: minor optimization

2016-05-19 Thread randgalt
minor optimization


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

Branch: refs/heads/CURATOR-3.0
Commit: ea05370366c271825740499f483f0f0d7c80ee3f
Parents: ae6cb4b
Author: randgalt 
Authored: Tue May 3 10:38:11 2016 -0500
Committer: randgalt 
Committed: Tue May 3 10:38:11 2016 -0500

--
 .../org/apache/curator/framework/schema/SchemaSet.java   | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/ea053703/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
index d33519a..6226f23 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
@@ -106,10 +106,9 @@ public class SchemaSet
  */
 public Schema getSchema(String path)
 {
-Schema schema = null;
 if ( schemas.size() > 0 )
 {
-schema = pathSchemas.get(path);
+Schema schema = pathSchemas.get(path);
 if ( schema == null )
 {
 try
@@ -121,10 +120,10 @@ public class SchemaSet
 throw new RuntimeException(e);
 }
 }
-}
-if ( schema != null )
-{
-return schema;
+if ( schema != null )
+{
+return schema;
+}
 }
 if ( useDefaultSchema )
 {



[24/35] curator git commit: Make getSchemaSet() public

2016-05-19 Thread randgalt
Make getSchemaSet() public


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

Branch: refs/heads/CURATOR-3.0
Commit: 5730f21f999e3056e55d44b2f0b7160c5ab8690b
Parents: f039be9
Author: randgalt 
Authored: Tue May 3 13:47:33 2016 -0500
Committer: randgalt 
Committed: Tue May 3 13:47:33 2016 -0500

--
 .../java/org/apache/curator/framework/CuratorFramework.java | 8 
 .../apache/curator/framework/imps/CuratorFrameworkImpl.java | 3 ++-
 curator-framework/src/site/confluence/schema.confluence | 9 +
 3 files changed, 19 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/5730f21f/curator-framework/src/main/java/org/apache/curator/framework/CuratorFramework.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFramework.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFramework.java
index c8fa4a5..9423631 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFramework.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFramework.java
@@ -27,6 +27,7 @@ import 
org.apache.curator.framework.api.transaction.CuratorTransaction;
 import org.apache.curator.framework.api.transaction.TransactionOp;
 import org.apache.curator.framework.imps.CuratorFrameworkState;
 import org.apache.curator.framework.listen.Listenable;
+import org.apache.curator.framework.schema.SchemaSet;
 import org.apache.curator.framework.state.ConnectionStateListener;
 import org.apache.curator.framework.state.ConnectionStateErrorPolicy;
 import org.apache.curator.utils.EnsurePath;
@@ -315,4 +316,11 @@ public interface CuratorFramework extends Closeable
  * @return the current config
  */
 public QuorumVerifier getCurrentConfig();
+
+/**
+ * Return this instance's schema set
+ *
+ * @return schema set
+ */
+SchemaSet getSchemaSet();
 }

http://git-wip-us.apache.org/repos/asf/curator/blob/5730f21f/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
index f5ae213..51485f2 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
@@ -554,7 +554,8 @@ public class CuratorFrameworkImpl implements 
CuratorFramework
 return namespace.newNamespaceAwareEnsurePath(path);
 }
 
-SchemaSet getSchemaSet()
+@Override
+public SchemaSet getSchemaSet()
 {
 return schemaSet;
 }

http://git-wip-us.apache.org/repos/asf/curator/blob/5730f21f/curator-framework/src/site/confluence/schema.confluence
--
diff --git a/curator-framework/src/site/confluence/schema.confluence 
b/curator-framework/src/site/confluence/schema.confluence
index dc79fb0..444f9d5 100644
--- a/curator-framework/src/site/confluence/schema.confluence
+++ b/curator-framework/src/site/confluence/schema.confluence
@@ -40,6 +40,15 @@ data is being set. It is a functor of the form:
 boolean isValid(String path, byte[] data);
 {code}
 
+h2. Getting ZNode paths/schemas by name
+
+Use SchemaSets to access ZNode paths by a simple name. E.g.
+
+{code}
+CuratorFramework client = ...
+String path = client.getSchemaSet().getNamedSchema("locks").getRawPath();
+{code}
+
 h2. Loading JSON Schema from a file/stream
 
 An optional utility is provided to load SchemaSets from a JSON file or stream: 
SchemaSetLoader



[32/35] curator git commit: wip

2016-05-19 Thread randgalt
wip


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

Branch: refs/heads/CURATOR-3.0
Commit: 1dbdbdc675ebda9246bd6b2437bb4ce83e3bf594
Parents: 7624725
Author: randgalt 
Authored: Wed May 4 20:06:41 2016 -0500
Committer: randgalt 
Committed: Wed May 4 20:06:41 2016 -0500

--
 curator-framework/src/site/confluence/schema.confluence | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/1dbdbdc6/curator-framework/src/site/confluence/schema.confluence
--
diff --git a/curator-framework/src/site/confluence/schema.confluence 
b/curator-framework/src/site/confluence/schema.confluence
index 12b40f2..410d71a 100644
--- a/curator-framework/src/site/confluence/schema.confluence
+++ b/curator-framework/src/site/confluence/schema.confluence
@@ -48,11 +48,12 @@ Use SchemaSets to access ZNode paths by a simple name. E.g.
 {code}
 CuratorFramework client = ...
 String path = SchemaSet.getNamedPath(client, "locks");
+client.create().forPath(path);
 {code}
 
 h2. Loading JSON Schema from a file/stream
 
-An optional utility is provided to load SchemaSets from a JSON file or stream: 
SchemaSetLoader
+An optional utility is provided to load SchemaSets from a JSON file or stream: 
SchemaSetLoader.
 *NOTE:* to avoid adding a new dependency to Curator, the Jackson library has 
been used with "provided" scope.
 You will need to add a dependency to jackson\-core and jackson\-databind to 
your project.
 



[10/35] curator git commit: more doc, some testing, schema set loader

2016-05-19 Thread randgalt
more doc, some testing, schema set loader


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

Branch: refs/heads/CURATOR-3.0
Commit: 734f4533808f1a4b8b8086407476bca8862339ff
Parents: 8ccfdeb
Author: randgalt 
Authored: Mon May 2 21:41:25 2016 -0500
Committer: randgalt 
Committed: Mon May 2 21:41:25 2016 -0500

--
 curator-framework/pom.xml   |  12 ++
 .../curator/framework/schema/SchemaSet.java |  34 +++--
 .../framework/schema/SchemaSetLoader.java   | 148 +++
 .../framework/schema/SchemaViolation.java   |   7 +
 .../curator/framework/imps/TestSchema.java  |  61 
 .../src/test/resources/schema1.json |   9 ++
 pom.xml |  13 ++
 7 files changed, 272 insertions(+), 12 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/734f4533/curator-framework/pom.xml
--
diff --git a/curator-framework/pom.xml b/curator-framework/pom.xml
index 32b2cdb..c47e265 100644
--- a/curator-framework/pom.xml
+++ b/curator-framework/pom.xml
@@ -57,6 +57,18 @@
 
 
 
+com.fasterxml.jackson.core
+jackson-core
+provided
+
+
+
+com.fasterxml.jackson.core
+jackson-databind
+provided
+
+
+
 org.testng
 testng
 test

http://git-wip-us.apache.org/repos/asf/curator/blob/734f4533/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
index 1014dc8..768f6c6 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSet.java
@@ -41,6 +41,7 @@ public class SchemaSet
 .build(cacheLoader);
 
 private static final Schema defaultSchema = new Schema(null, "", "Default 
schema", new DefaultDataValidator(), Schema.Allowance.CAN, 
Schema.Allowance.CAN, Schema.Allowance.CAN, true);
+private final boolean useDefaultSchema;
 
 /**
  * Return the default (empty) schema set
@@ -49,7 +50,7 @@ public class SchemaSet
  */
 public static SchemaSet getDefaultSchemaSet()
 {
-return new SchemaSet(Collections.emptyMap())
+return new SchemaSet(Collections.emptyMap(), true)
 {
 @Override
 public String toDocumentation()
@@ -62,9 +63,11 @@ public class SchemaSet
 /**
  * @param schemas the schemas for the set. The key of the map is a 
key/name for the schema that can be
  *used when calling {@link #getNamedSchema(SchemaKey)}
+ * @param useDefaultSchema if true, return a default schema when there is 
no match. Otherwise, an exception is thrown
  */
-public SchemaSet(Map schemas)
+public SchemaSet(Map schemas, boolean useDefaultSchema)
 {
+this.useDefaultSchema = useDefaultSchema;
 this.schemas = ImmutableMap.copyOf(Preconditions.checkNotNull(schemas, 
"schemas cannot be null"));
 ImmutableMap.Builder builder = ImmutableMap.builder();
 for ( Schema schema : schemas.values() )
@@ -85,24 +88,31 @@ public class SchemaSet
  */
 public Schema getSchema(String path)
 {
-if ( schemas.size() == 0 )
+Schema schema = null;
+if ( schemas.size() > 0 )
 {
-return defaultSchema;
+schema = pathSchemas.get(path);
+if ( schema == null )
+{
+try
+{
+schema = regexCache.get(path);
+}
+catch ( ExecutionException e )
+{
+throw new RuntimeException(e);
+}
+}
 }
-Schema schema = pathSchemas.get(path);
 if ( schema != null )
 {
 return schema;
 }
-
-try
+if ( useDefaultSchema )
 {
-return regexCache.get(path);
-}
-catch ( ExecutionException e )
-{
-throw new RuntimeException(e);
+return defaultSchema;
 }
+throw new 

[04/35] curator git commit: Log the schema at start

2016-05-19 Thread randgalt
Log the schema at start


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

Branch: refs/heads/CURATOR-3.0
Commit: df3c1c4b059fc9c930716f91230dbe8a466fef08
Parents: f25a812
Author: randgalt 
Authored: Mon May 2 16:12:47 2016 -0500
Committer: randgalt 
Committed: Mon May 2 16:12:47 2016 -0500

--
 .../apache/curator/framework/CuratorFrameworkFactory.java   | 9 -
 .../apache/curator/framework/imps/CuratorFrameworkImpl.java | 2 ++
 2 files changed, 10 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/df3c1c4b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
index 5aed199..c17534f 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
@@ -144,7 +144,14 @@ public class CuratorFrameworkFactory
 private boolean useContainerParentsIfAvailable = true;
 private ConnectionStateErrorPolicy connectionStateErrorPolicy = new 
StandardConnectionStateErrorPolicy();
 private ConnectionHandlingPolicy connectionHandlingPolicy = 
Boolean.getBoolean("curator-use-classic-connection-handling") ? new 
ClassicConnectionHandlingPolicy() : new StandardConnectionHandlingPolicy();
-private SchemaSet schemaSet = new SchemaSet();
+private SchemaSet schemaSet = new SchemaSet()
+{
+@Override
+public String toDocumentation()
+{
+return "Default schema";
+}
+};
 
 /**
  * Apply the current values and build a new CuratorFramework

http://git-wip-us.apache.org/repos/asf/curator/blob/df3c1c4b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
index 739f07e..f5ae213 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
@@ -317,6 +317,8 @@ public class CuratorFrameworkImpl implements 
CuratorFramework
 });
 
 ensembleTracker.start();
+
+log.info(schemaSet.toDocumentation());
 }
 catch ( Exception e )
 {



[28/35] curator git commit: must do schema validation on set acl

2016-05-19 Thread randgalt
must do schema validation on set acl


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

Branch: refs/heads/CURATOR-3.0
Commit: 726b03cf986f7ac2fc61f3dd448b18cde40d3501
Parents: b889e3b
Author: randgalt 
Authored: Wed May 4 12:54:46 2016 -0500
Committer: randgalt 
Committed: Wed May 4 12:54:46 2016 -0500

--
 .../curator/framework/imps/SetACLBuilderImpl.java   | 12 +++-
 .../curator/framework/schema/SchemaValidator.java   |  7 +++
 .../org/apache/curator/framework/schema/TestSchema.java |  2 +-
 3 files changed, 15 insertions(+), 6 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/726b03cf/curator-framework/src/main/java/org/apache/curator/framework/imps/SetACLBuilderImpl.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/imps/SetACLBuilderImpl.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/imps/SetACLBuilderImpl.java
index 5ab353a..44adfe2 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/imps/SetACLBuilderImpl.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/imps/SetACLBuilderImpl.java
@@ -114,16 +114,18 @@ class SetACLBuilderImpl implements SetACLBuilder, 
BackgroundPathable, Back
 @Override
 public Stat forPath(String path) throws Exception
 {
-path = client.fixForNamespace(path);
+String fixedPath = client.fixForNamespace(path);
+List aclList = acling.getAclList(fixedPath);
+client.getSchemaSet().getSchema(path).validateGeneral(path, null, 
aclList);
 
 StatresultStat = null;
 if ( backgrounding.inBackground()  )
 {
-client.processBackgroundOperation(new 
OperationAndData(this, path, backgrounding.getCallback(), null, 
backgrounding.getContext(), null), null);
+client.processBackgroundOperation(new 
OperationAndData(this, fixedPath, backgrounding.getCallback(), null, 
backgrounding.getContext(), null), null);
 }
 else
 {
-resultStat = pathInForeground(path);
+resultStat = pathInForeground(fixedPath, aclList);
 }
 return resultStat;
 }
@@ -160,7 +162,7 @@ class SetACLBuilderImpl implements SetACLBuilder, 
BackgroundPathable, Back
 }
 }
 
-private Stat pathInForeground(final String path) throws Exception
+private Stat pathInForeground(final String path, final List aclList) 
throws Exception
 {
 TimeTrace   trace = 
client.getZookeeperClient().startTracer("SetACLBuilderImpl-Foreground");
 StatresultStat = RetryLoop.callWithRetry
@@ -171,7 +173,7 @@ class SetACLBuilderImpl implements SetACLBuilder, 
BackgroundPathable, Back
 @Override
 public Stat call() throws Exception
 {
-return client.getZooKeeper().setACL(path, 
acling.getAclList(path), version);
+return client.getZooKeeper().setACL(path, aclList, 
version);
 }
 }
 );

http://git-wip-us.apache.org/repos/asf/curator/blob/726b03cf/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaValidator.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaValidator.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaValidator.java
index 560b8f8..a92720f 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaValidator.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaValidator.java
@@ -23,5 +23,12 @@ import java.util.List;
 
 public interface SchemaValidator
 {
+/**
+ * @param schema the schema being validated
+ * @param path the path being operated on
+ * @param data data or null
+ * @param acl acls or null
+ * @return true if valid
+ */
 boolean isValid(Schema schema, String path, byte[] data, List acl);
 }

http://git-wip-us.apache.org/repos/asf/curator/blob/726b03cf/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
--
diff --git 
a/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
 
b/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
index e2a581b..78ecdf5 100644
--- 

curator git commit: support alternate file formats for schema. E.g. yaml

2016-05-19 Thread randgalt
Repository: curator
Updated Branches:
  refs/heads/CURATOR-322 b6b9006b7 -> 5533d08aa


support alternate file formats for schema. E.g. yaml


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

Branch: refs/heads/CURATOR-322
Commit: 5533d08aa5c44cafab39bc77e41fc6176db339e7
Parents: b6b9006
Author: randgalt 
Authored: Thu May 19 13:35:05 2016 -0500
Committer: randgalt 
Committed: Thu May 19 13:35:05 2016 -0500

--
 curator-framework/pom.xml   |  7 +++
 .../framework/schema/SchemaSetLoader.java   | 47 +++-
 .../curator/framework/schema/TestSchema.java| 19 +++-
 .../src/test/resources/schema.yaml  | 14 ++
 4 files changed, 74 insertions(+), 13 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/5533d08a/curator-framework/pom.xml
--
diff --git a/curator-framework/pom.xml b/curator-framework/pom.xml
index c47e265..45a90b6 100644
--- a/curator-framework/pom.xml
+++ b/curator-framework/pom.xml
@@ -69,6 +69,13 @@
 
 
 
+com.fasterxml.jackson.dataformat
+jackson-dataformat-yaml
+${jackson-version}
+test
+
+
+
 org.testng
 testng
 test

http://git-wip-us.apache.org/repos/asf/curator/blob/5533d08a/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSetLoader.java
--
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSetLoader.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSetLoader.java
index 16b387e..bab97c6 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSetLoader.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/schema/SchemaSetLoader.java
@@ -78,26 +78,39 @@ public class SchemaSetLoader
 SchemaValidator getSchemaValidator(String name);
 }
 
+/**
+ * @param json the json to parse
+ * @param schemaValidatorMapper mapper from validator name to instance - 
can be null if not needed
+ */
 public SchemaSetLoader(String json, SchemaValidatorMapper 
schemaValidatorMapper)
 {
-this(new StringReader(json), schemaValidatorMapper);
+this(getRoot(new StringReader(json)), schemaValidatorMapper);
+}
+
+/**
+ * @param jsonStream the json stream to parse
+ * @param schemaValidatorMapper mapper from validator name to instance - 
can be null if not needed
+ */
+public SchemaSetLoader(Reader jsonStream, SchemaValidatorMapper 
schemaValidatorMapper)
+{
+this(getRoot(jsonStream), schemaValidatorMapper);
 }
 
-public SchemaSetLoader(Reader in, SchemaValidatorMapper 
schemaValidatorMapper)
+/**
+ * @param root a Jackson root node
+ * @param schemaValidatorMapper mapper from validator name to instance - 
can be null if not needed
+ */
+public SchemaSetLoader(JsonNode root, SchemaValidatorMapper 
schemaValidatorMapper)
 {
 ImmutableList.Builder builder = ImmutableList.builder();
-try
-{
-JsonNode root = new ObjectMapper().readTree(in);
-read(builder, root, schemaValidatorMapper);
-}
-catch ( IOException e )
-{
-throw new RuntimeException(e);
-}
+read(builder, root, schemaValidatorMapper);
 schemas = builder.build();
 }
 
+/**
+ * @param useDefaultSchema if true, return a default schema when there is 
no match. Otherwise, an exception is thrown
+ * @return schema set
+ */
 public SchemaSet toSchemaSet(boolean useDefaultSchema)
 {
 return new SchemaSet(schemas, useDefaultSchema);
@@ -108,6 +121,18 @@ public class SchemaSetLoader
 return schemas;
 }
 
+private static JsonNode getRoot(Reader in)
+{
+try
+{
+return new ObjectMapper().readTree(in);
+}
+catch ( IOException e )
+{
+throw new RuntimeException(e);
+}
+}
+
 private void read(ImmutableList.Builder builder, JsonNode node, 
SchemaValidatorMapper schemaValidatorMapper)
 {
 for ( JsonNode child : node )

http://git-wip-us.apache.org/repos/asf/curator/blob/5533d08a/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
--
diff --git