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 4A17E17BDD for ; Tue, 21 Apr 2015 23:06:59 +0000 (UTC) Received: (qmail 85046 invoked by uid 500); 21 Apr 2015 23:06:59 -0000 Delivered-To: apmail-curator-commits-archive@curator.apache.org Received: (qmail 84977 invoked by uid 500); 21 Apr 2015 23:06:59 -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 83917 invoked by uid 99); 21 Apr 2015 23:06:58 -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; Tue, 21 Apr 2015 23:06:58 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A2EA6E0D5B; Tue, 21 Apr 2015 23:06:58 +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: Tue, 21 Apr 2015 23:07:31 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [34/50] curator git commit: Replacing LockSchema with simple Set Replacing LockSchema with simple Set Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/aa3dff70 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/aa3dff70 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/aa3dff70 Branch: refs/heads/CURATOR-154 Commit: aa3dff70b2c895cd69a490d426afbdb7e6a9ae67 Parents: 72aea4a Author: David Kesler Authored: Mon Mar 9 14:29:52 2015 -0400 Committer: David Kesler Committed: Mon Mar 9 14:29:52 2015 -0400 ---------------------------------------------------------------------- .../framework/recipes/locks/ChildReaper.java | 10 +++++---- .../recipes/locks/InterProcessSemaphoreV2.java | 9 ++++---- .../framework/recipes/locks/LockSchema.java | 22 -------------------- 3 files changed, 10 insertions(+), 31 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/aa3dff70/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/ChildReaper.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/ChildReaper.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/ChildReaper.java index 7935f0b..6a2c05a 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/ChildReaper.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/ChildReaper.java @@ -33,7 +33,9 @@ import org.slf4j.LoggerFactory; import java.io.Closeable; import java.io.IOException; import java.util.Collection; +import java.util.Collections; import java.util.List; +import java.util.Set; import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -55,7 +57,7 @@ public class ChildReaper implements Closeable private final CloseableScheduledExecutorService executor; private final int reapingThresholdMs; private final LeaderLatch leaderLatch; - private final LockSchema lockSchema; + private final Set lockSchema; private volatile Future task; @@ -109,7 +111,7 @@ public class ChildReaper implements Closeable */ public ChildReaper(CuratorFramework client, String path, Reaper.Mode mode, ScheduledExecutorService executor, int reapingThresholdMs, String leaderPath) { - this(client, path, mode, executor, reapingThresholdMs, leaderPath, new LockSchema()); + this(client, path, mode, executor, reapingThresholdMs, leaderPath, Collections.emptySet()); } @@ -122,7 +124,7 @@ public class ChildReaper implements Closeable * @param leaderPath if not null, uses a leader selection so that only 1 reaper is active in the cluster * @param lockSchema a set of the possible subnodes of the children of path that must be reaped in addition to the child nodes */ - public ChildReaper(CuratorFramework client, String path, Reaper.Mode mode, ScheduledExecutorService executor, int reapingThresholdMs, String leaderPath, LockSchema lockSchema) + public ChildReaper(CuratorFramework client, String path, Reaper.Mode mode, ScheduledExecutorService executor, int reapingThresholdMs, String leaderPath, Set lockSchema) { this.client = client; this.mode = mode; @@ -226,7 +228,7 @@ public class ChildReaper implements Closeable { String childPath = ZKPaths.makePath(path, name); addPathToReaperIfEmpty(childPath); - for ( String subNode : lockSchema.getPaths() ) + for ( String subNode : lockSchema ) { addPathToReaperIfEmpty(ZKPaths.makePath(childPath, subNode)); } http://git-wip-us.apache.org/repos/asf/curator/blob/aa3dff70/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessSemaphoreV2.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessSemaphoreV2.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessSemaphoreV2.java index 55647ad..b6d5ca2 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessSemaphoreV2.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessSemaphoreV2.java @@ -42,6 +42,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.Collection; import java.util.List; +import java.util.Set; import java.util.concurrent.TimeUnit; import org.apache.curator.utils.PathUtils; @@ -94,11 +95,9 @@ public class InterProcessSemaphoreV2 private static final String LOCK_PARENT = "locks"; private static final String LEASE_PARENT = "leases"; private static final String LEASE_BASE_NAME = "lease-"; - public static final LockSchema LOCK_SCHEMA = new LockSchema( - Sets.newHashSet( - LOCK_PARENT, - LEASE_PARENT - ) + public static final Set LOCK_SCHEMA = Sets.newHashSet( + LOCK_PARENT, + LEASE_PARENT ); /** http://git-wip-us.apache.org/repos/asf/curator/blob/aa3dff70/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockSchema.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockSchema.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockSchema.java deleted file mode 100644 index 5794705..0000000 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockSchema.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.apache.curator.framework.recipes.locks; - -import java.util.HashSet; -import java.util.Set; - -import com.google.common.collect.Sets; - -public class LockSchema { - private final Set paths; - - public LockSchema() { - paths = new HashSet(); - } - - public LockSchema(Set paths) { - this.paths = Sets.newHashSet(paths); - } - - public Set getPaths() { - return Sets.newHashSet(paths); - } -}