Return-Path: X-Original-To: apmail-curator-commits-archive@minotaur.apache.org Delivered-To: apmail-curator-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BEC1818CCA for ; Sun, 17 Jan 2016 23:32:00 +0000 (UTC) Received: (qmail 47025 invoked by uid 500); 17 Jan 2016 23:32:00 -0000 Delivered-To: apmail-curator-commits-archive@curator.apache.org Received: (qmail 46995 invoked by uid 500); 17 Jan 2016 23:32:00 -0000 Mailing-List: contact commits-help@curator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@curator.apache.org Delivered-To: mailing list commits@curator.apache.org Received: (qmail 46986 invoked by uid 99); 17 Jan 2016 23:32:00 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 Jan 2016 23:32:00 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 29C62E058E; Sun, 17 Jan 2016 23:32:00 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: cammckenzie@apache.org To: commits@curator.apache.org Date: Sun, 17 Jan 2016 23:32:00 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/2] curator git commit: CURATOR-278: In transactions compressed option does not work with some fluent api combinations Repository: curator Updated Branches: refs/heads/CURATOR-278 [created] bef5bb9bd CURATOR-278: In transactions compressed option does not work with some fluent api combinations Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/c1e2a308 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/c1e2a308 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/c1e2a308 Branch: refs/heads/CURATOR-278 Commit: c1e2a308d891cba4251adcb18a91d074077979b9 Parents: 31c0465 Author: Grant Henke Authored: Sat Nov 7 13:39:54 2015 -0600 Committer: Grant Henke Committed: Sat Nov 7 13:39:54 2015 -0600 ---------------------------------------------------------------------- .../framework/api/VersionPathAndBytesable.java | 25 +++++++++++ .../transaction/TransactionCreateBuilder.java | 5 ++- .../transaction/TransactionSetDataBuilder.java | 4 +- .../framework/imps/CreateBuilderImpl.java | 12 ++--- .../framework/imps/SetDataBuilderImpl.java | 8 ++-- .../framework/imps/TestTransactions.java | 46 +++++++++++++++++++- 6 files changed, 86 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/c1e2a308/curator-framework/src/main/java/org/apache/curator/framework/api/VersionPathAndBytesable.java ---------------------------------------------------------------------- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/api/VersionPathAndBytesable.java b/curator-framework/src/main/java/org/apache/curator/framework/api/VersionPathAndBytesable.java new file mode 100644 index 0000000..556fc67 --- /dev/null +++ b/curator-framework/src/main/java/org/apache/curator/framework/api/VersionPathAndBytesable.java @@ -0,0 +1,25 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.curator.framework.api; + +public interface VersionPathAndBytesable extends + Versionable>, + PathAndBytesable +{ +} http://git-wip-us.apache.org/repos/asf/curator/blob/c1e2a308/curator-framework/src/main/java/org/apache/curator/framework/api/transaction/TransactionCreateBuilder.java ---------------------------------------------------------------------- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/api/transaction/TransactionCreateBuilder.java b/curator-framework/src/main/java/org/apache/curator/framework/api/transaction/TransactionCreateBuilder.java index 6ac3069..f2ac146 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/api/transaction/TransactionCreateBuilder.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/api/transaction/TransactionCreateBuilder.java @@ -18,6 +18,7 @@ */ package org.apache.curator.framework.api.transaction; +import org.apache.curator.framework.api.ACLCreateModePathAndBytesable; import org.apache.curator.framework.api.ACLPathAndBytesable; import org.apache.curator.framework.api.Compressible; import org.apache.curator.framework.api.CreateModable; @@ -27,6 +28,6 @@ public interface TransactionCreateBuilder extends PathAndBytesable, CreateModable>, ACLPathAndBytesable, - Compressible> -{ + ACLCreateModePathAndBytesable, + Compressible> { } http://git-wip-us.apache.org/repos/asf/curator/blob/c1e2a308/curator-framework/src/main/java/org/apache/curator/framework/api/transaction/TransactionSetDataBuilder.java ---------------------------------------------------------------------- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/api/transaction/TransactionSetDataBuilder.java b/curator-framework/src/main/java/org/apache/curator/framework/api/transaction/TransactionSetDataBuilder.java index 777537a..cc9e01c 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/api/transaction/TransactionSetDataBuilder.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/api/transaction/TransactionSetDataBuilder.java @@ -20,11 +20,13 @@ package org.apache.curator.framework.api.transaction; import org.apache.curator.framework.api.Compressible; import org.apache.curator.framework.api.PathAndBytesable; +import org.apache.curator.framework.api.VersionPathAndBytesable; import org.apache.curator.framework.api.Versionable; public interface TransactionSetDataBuilder extends PathAndBytesable, Versionable>, - Compressible> + VersionPathAndBytesable, + Compressible> { } http://git-wip-us.apache.org/repos/asf/curator/blob/c1e2a308/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 b72b7b6..39dd871 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 @@ -89,14 +89,14 @@ class CreateBuilderImpl implements CreateBuilder, BackgroundOperation compressed() + public ACLCreateModePathAndBytesable compressed() { CreateBuilderImpl.this.compressed(); return this; } - + @Override public CuratorTransactionBridge forPath(String path) throws Exception { @@ -105,12 +105,12 @@ class CreateBuilderImpl implements CreateBuilder, BackgroundOperation compressed() { + public VersionPathAndBytesable compressed() { compress = true; - + return this; } }; http://git-wip-us.apache.org/repos/asf/curator/blob/c1e2a308/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTransactions.java ---------------------------------------------------------------------- diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTransactions.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTransactions.java index ae2cf1d..fedc779 100644 --- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTransactions.java +++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTransactions.java @@ -27,6 +27,7 @@ import org.apache.curator.retry.RetryOneTime; import org.apache.curator.test.BaseClassForTests; import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.KeeperException; +import org.apache.zookeeper.ZooDefs; import org.apache.zookeeper.data.Stat; import org.testng.Assert; import org.testng.annotations.Test; @@ -59,7 +60,7 @@ public class TestTransactions extends BaseClassForTests { // correct } - + Assert.assertNull(client.checkExists().forPath("/bar")); } finally @@ -106,6 +107,49 @@ public class TestTransactions extends BaseClassForTests } @Test + public void testWithCompression() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.builder().connectString(server.getConnectString()).retryPolicy(new RetryOneTime(1)).namespace("galt").build(); + client.start(); + try + { + Collection results = + client.inTransaction() + .create().compressed().forPath("/foo", "one".getBytes()) + .and() + .create().compressed().withACL(ZooDefs.Ids.READ_ACL_UNSAFE).forPath("/bar", "two".getBytes()) + .and() + .create().compressed().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath("/test-", "three".getBytes()) + .and() + .create().compressed().withMode(CreateMode.PERSISTENT).withACL(ZooDefs.Ids.READ_ACL_UNSAFE).forPath("/baz", "four".getBytes()) + .and() + .setData().compressed().withVersion(0).forPath("/foo", "five".getBytes()) + .and() + .commit(); + + Assert.assertTrue(client.checkExists().forPath("/foo") != null); + Assert.assertEquals(client.getData().decompressed().forPath("/foo"), "five".getBytes()); + + Assert.assertTrue(client.checkExists().forPath("/bar") != null); + Assert.assertEquals(client.getData().decompressed().forPath("/bar"), "two".getBytes()); + Assert.assertEquals(client.getACL().forPath("/bar"), ZooDefs.Ids.READ_ACL_UNSAFE); + + CuratorTransactionResult ephemeralResult = Iterables.find(results, CuratorTransactionResult.ofTypeAndPath(OperationType.CREATE, "/test-")); + Assert.assertNotNull(ephemeralResult); + Assert.assertNotEquals(ephemeralResult.getResultPath(), "/test-"); + Assert.assertTrue(ephemeralResult.getResultPath().startsWith("/test-")); + + Assert.assertTrue(client.checkExists().forPath("/baz") != null); + Assert.assertEquals(client.getData().decompressed().forPath("/baz"), "four".getBytes()); + Assert.assertEquals(client.getACL().forPath("/baz"), ZooDefs.Ids.READ_ACL_UNSAFE); + } + finally + { + client.close(); + } + } + + @Test public void testBasic() throws Exception { CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));