From a08b91af73fa0df3179e44b64aedf834dcfa33e2 Mon Sep 17 00:00:00 2001 From: Noorul Islam K M Date: Fri, 1 Nov 2013 08:20:37 +0530 Subject: [PATCH] JCLOUDS-368: Remove methods which are not exposed to public and hence not used. --- .../jclouds/chef/strategy/ListClients.java | 10 ----- .../chef/strategy/ListCookbookVersions.java | 10 ----- .../chef/strategy/ListEnvironments.java | 9 ----- .../org/jclouds/chef/strategy/ListNodes.java | 10 ----- .../chef/strategy/ListNodesInEnvironment.java | 10 ----- .../CleanupStaleNodesAndClientsImpl.java | 37 +++++++++---------- .../strategy/internal/ListClientsImpl.java | 21 +---------- .../internal/ListCookbookVersionsImpl.java | 24 +----------- .../internal/ListEnvironmentsImpl.java | 21 +---------- .../chef/strategy/internal/ListNodesImpl.java | 21 +---------- .../internal/ListNodesInEnvironmentImpl.java | 21 +---------- .../internal/ListNodesImplLiveTest.java | 20 ---------- .../ListNodesInEnvironmentImplLiveTest.java | 20 ---------- 13 files changed, 24 insertions(+), 210 deletions(-) diff --git a/apis/chef/src/main/java/org/jclouds/chef/strategy/ListClients.java b/apis/chef/src/main/java/org/jclouds/chef/strategy/ListClients.java index 18b7c13bcf..5d6b8a0d66 100644 --- a/apis/chef/src/main/java/org/jclouds/chef/strategy/ListClients.java +++ b/apis/chef/src/main/java/org/jclouds/chef/strategy/ListClients.java @@ -19,12 +19,10 @@ package org.jclouds.chef.strategy; import org.jclouds.chef.domain.Client; import org.jclouds.chef.strategy.internal.ListClientsImpl; -import com.google.common.base.Predicate; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.inject.ImplementedBy; /** - * * * @author Adrian Cole */ @@ -33,13 +31,5 @@ public interface ListClients { Iterable execute(); - Iterable execute(Predicate clientNameSelector); - - Iterable execute(Iterable toGet); - Iterable execute(ListeningExecutorService executor); - - Iterable execute(ListeningExecutorService executor, Predicate clientNameSelector); - - Iterable execute(ListeningExecutorService executor, Iterable toGet); } diff --git a/apis/chef/src/main/java/org/jclouds/chef/strategy/ListCookbookVersions.java b/apis/chef/src/main/java/org/jclouds/chef/strategy/ListCookbookVersions.java index 5987de0fa4..01bcd336d7 100644 --- a/apis/chef/src/main/java/org/jclouds/chef/strategy/ListCookbookVersions.java +++ b/apis/chef/src/main/java/org/jclouds/chef/strategy/ListCookbookVersions.java @@ -19,12 +19,10 @@ package org.jclouds.chef.strategy; import org.jclouds.chef.domain.CookbookVersion; import org.jclouds.chef.strategy.internal.ListCookbookVersionsImpl; -import com.google.common.base.Predicate; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.inject.ImplementedBy; /** - * * * @author Adrian Cole */ @@ -33,13 +31,5 @@ public interface ListCookbookVersions { Iterable execute(); - Iterable execute(Predicate cookbookNameSelector); - - Iterable execute(Iterable cookbookNames); - Iterable execute(ListeningExecutorService executor); - - Iterable execute(ListeningExecutorService executor, Predicate cookbookNameSelector); - - Iterable execute(ListeningExecutorService executor, Iterable cookbookNames); } diff --git a/apis/chef/src/main/java/org/jclouds/chef/strategy/ListEnvironments.java b/apis/chef/src/main/java/org/jclouds/chef/strategy/ListEnvironments.java index 6dc4aa319b..3e5b11f17c 100644 --- a/apis/chef/src/main/java/org/jclouds/chef/strategy/ListEnvironments.java +++ b/apis/chef/src/main/java/org/jclouds/chef/strategy/ListEnvironments.java @@ -19,7 +19,6 @@ package org.jclouds.chef.strategy; import org.jclouds.chef.domain.Environment; import org.jclouds.chef.strategy.internal.ListEnvironmentsImpl; -import com.google.common.base.Predicate; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.inject.ImplementedBy; @@ -28,13 +27,5 @@ public interface ListEnvironments { Iterable execute(); - Iterable execute(Predicate environmentNameSelector); - - Iterable execute(Iterable toGet); - Iterable execute(ListeningExecutorService executor); - - Iterable execute(ListeningExecutorService executor, Predicate environmentNameSelector); - - Iterable execute(ListeningExecutorService executor, Iterable toGet); } diff --git a/apis/chef/src/main/java/org/jclouds/chef/strategy/ListNodes.java b/apis/chef/src/main/java/org/jclouds/chef/strategy/ListNodes.java index 879045607e..92b451b11a 100644 --- a/apis/chef/src/main/java/org/jclouds/chef/strategy/ListNodes.java +++ b/apis/chef/src/main/java/org/jclouds/chef/strategy/ListNodes.java @@ -19,12 +19,10 @@ package org.jclouds.chef.strategy; import org.jclouds.chef.domain.Node; import org.jclouds.chef.strategy.internal.ListNodesImpl; -import com.google.common.base.Predicate; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.inject.ImplementedBy; /** - * * * @author Adrian Cole */ @@ -33,13 +31,5 @@ public interface ListNodes { Iterable execute(); - Iterable execute(Predicate nodeNameSelector); - - Iterable execute(Iterable toGet); - Iterable execute(ListeningExecutorService executor); - - Iterable execute(ListeningExecutorService executor, Predicate nodeNameSelector); - - Iterable execute(ListeningExecutorService executor, Iterable toGet); } diff --git a/apis/chef/src/main/java/org/jclouds/chef/strategy/ListNodesInEnvironment.java b/apis/chef/src/main/java/org/jclouds/chef/strategy/ListNodesInEnvironment.java index 9f6b324b8c..6308747ce1 100644 --- a/apis/chef/src/main/java/org/jclouds/chef/strategy/ListNodesInEnvironment.java +++ b/apis/chef/src/main/java/org/jclouds/chef/strategy/ListNodesInEnvironment.java @@ -19,12 +19,10 @@ package org.jclouds.chef.strategy; import org.jclouds.chef.domain.Node; import org.jclouds.chef.strategy.internal.ListNodesInEnvironmentImpl; -import com.google.common.base.Predicate; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.inject.ImplementedBy; /** - * * * @author Noorul Islam K M */ @@ -33,13 +31,5 @@ public interface ListNodesInEnvironment { Iterable execute(String environmentName); - Iterable execute(String environmentName, Predicate nodeNameSelector); - - Iterable execute(String environmentName, Iterable toGet); - Iterable execute(ListeningExecutorService executor, String environmentName); - - Iterable execute(ListeningExecutorService executor, String environmentName, Predicate nodeNameSelector); - - Iterable execute(ListeningExecutorService executor, String environmentName, Iterable toGet); } diff --git a/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/CleanupStaleNodesAndClientsImpl.java b/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/CleanupStaleNodesAndClientsImpl.java index a3ef7c25bc..a9dbaa8110 100644 --- a/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/CleanupStaleNodesAndClientsImpl.java +++ b/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/CleanupStaleNodesAndClientsImpl.java @@ -72,25 +72,24 @@ public class CleanupStaleNodesAndClientsImpl implements CleanupStaleNodesAndClie final Calendar expired = Calendar.getInstance(); expired.setTime(new Date()); expired.add(Calendar.SECOND, -secondsStale); - Iterable staleNodes = filter(nodeLister.execute(new Predicate() { - - @Override - public boolean apply(String input) { - return input.startsWith(prefix); - } - - }), and(notNull(), new Predicate() { - @Override - public boolean apply(Node input) { - JsonBall dateLong = input.getAutomaticAttributes().get("ohai_time"); - if (dateLong == null) - return true; - Calendar nodeUpdate = Calendar.getInstance(); - nodeUpdate.setTime(fromOhaiTime(dateLong)); - return expired.after(nodeUpdate); - } - - })); + Iterable staleNodes = filter( + nodeLister.execute(), and(notNull(), new Predicate() { + @Override + public boolean apply(Node input) { + return input.getName().startsWith(prefix); + } + }, + new Predicate() { + @Override + public boolean apply(Node input) { + JsonBall dateLong = input.getAutomaticAttributes().get("ohai_time"); + if (dateLong == null) + return true; + Calendar nodeUpdate = Calendar.getInstance(); + nodeUpdate.setTime(fromOhaiTime(dateLong)); + return expired.after(nodeUpdate); + } + })); Iterable nodeNames = transform(staleNodes, new Function() { @Override diff --git a/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/ListClientsImpl.java b/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/ListClientsImpl.java index 70e6a2aff5..63c2484a95 100644 --- a/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/ListClientsImpl.java +++ b/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/ListClientsImpl.java @@ -17,7 +17,6 @@ package org.jclouds.chef.strategy.internal; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.transform; import static com.google.common.util.concurrent.Futures.allAsList; import static com.google.common.util.concurrent.Futures.getUnchecked; @@ -38,13 +37,11 @@ import org.jclouds.logging.Logger; import com.google.common.base.Function; import com.google.common.base.Joiner; -import com.google.common.base.Predicate; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.inject.Inject; /** - * * * @author Adrian Cole */ @@ -68,28 +65,12 @@ public class ListClientsImpl implements ListClients { return execute(userExecutor); } - @Override - public Iterable execute(Predicate clientNameSelector) { - return execute(userExecutor, clientNameSelector); - } - - @Override - public Iterable execute(Iterable toGet) { - return execute(userExecutor, toGet); - } - @Override public Iterable execute(ListeningExecutorService executor) { return execute(executor, api.listClients()); } - @Override - public Iterable execute(ListeningExecutorService executor, Predicate clientNameSelector) { - return execute(executor, filter(api.listClients(), clientNameSelector)); - } - - @Override - public Iterable execute(final ListeningExecutorService executor, Iterable toGet) { + private Iterable execute(final ListeningExecutorService executor, Iterable toGet) { ListenableFuture> futures = allAsList(transform(toGet, new Function>() { @Override diff --git a/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/ListCookbookVersionsImpl.java b/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/ListCookbookVersionsImpl.java index 3bf77a6961..cdd71c4530 100644 --- a/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/ListCookbookVersionsImpl.java +++ b/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/ListCookbookVersionsImpl.java @@ -18,7 +18,6 @@ package org.jclouds.chef.strategy.internal; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.collect.Iterables.concat; -import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.transform; import static com.google.common.util.concurrent.Futures.allAsList; import static com.google.common.util.concurrent.Futures.getUnchecked; @@ -39,13 +38,11 @@ import org.jclouds.chef.strategy.ListCookbookVersions; import org.jclouds.logging.Logger; import com.google.common.base.Function; -import com.google.common.base.Predicate; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.inject.Inject; /** - * * * @author Adrian Cole */ @@ -69,29 +66,12 @@ public class ListCookbookVersionsImpl implements ListCookbookVersions { return execute(userExecutor); } - @Override - public Iterable execute(Predicate cookbookNameSelector) { - return execute(userExecutor, cookbookNameSelector); - } - - @Override - public Iterable execute(Iterable toGet) { - return execute(userExecutor, toGet); - } - @Override public Iterable execute(ListeningExecutorService executor) { return execute(executor, api.listCookbooks()); } - @Override - public Iterable execute(ListeningExecutorService executor, - Predicate cookbookNameSelector) { - return execute(executor, filter(api.listCookbooks(), cookbookNameSelector)); - } - - @Override - public Iterable execute(final ListeningExecutorService executor, + private Iterable execute(final ListeningExecutorService executor, Iterable cookbookNames) { return concat(transform(cookbookNames, new Function>() { @@ -112,7 +92,7 @@ public class ListCookbookVersionsImpl implements ListCookbookVersions { } })); - logger.trace(String.format("getting versions of cookbook: " + cookbook)); + logger.trace(String.format("getting versions of cookbook: %s", cookbook)); return getUnchecked(futures); } })); diff --git a/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/ListEnvironmentsImpl.java b/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/ListEnvironmentsImpl.java index 6429b72f31..9b79de23af 100644 --- a/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/ListEnvironmentsImpl.java +++ b/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/ListEnvironmentsImpl.java @@ -17,7 +17,6 @@ package org.jclouds.chef.strategy.internal; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.transform; import static com.google.common.util.concurrent.Futures.allAsList; import static com.google.common.util.concurrent.Futures.getUnchecked; @@ -38,7 +37,6 @@ import org.jclouds.logging.Logger; import com.google.common.base.Function; import com.google.common.base.Joiner; -import com.google.common.base.Predicate; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.inject.Inject; @@ -63,29 +61,12 @@ public class ListEnvironmentsImpl implements ListEnvironments { return execute(userExecutor); } - @Override - public Iterable execute(Predicate environmentNameSelector) { - return execute(userExecutor, environmentNameSelector); - } - - @Override - public Iterable execute(Iterable toGet) { - return execute(userExecutor, toGet); - } - @Override public Iterable execute(ListeningExecutorService executor) { return execute(executor, api.listEnvironments()); } - @Override - public Iterable execute(ListeningExecutorService executor, - Predicate environmentNameSelector) { - return execute(executor, filter(api.listEnvironments(), environmentNameSelector)); - } - - @Override - public Iterable execute(final ListeningExecutorService executor, Iterable toGet) { + private Iterable execute(final ListeningExecutorService executor, Iterable toGet) { ListenableFuture> futures = allAsList(transform(toGet, new Function>() { @Override diff --git a/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/ListNodesImpl.java b/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/ListNodesImpl.java index 7547f6b422..3af264b8f8 100644 --- a/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/ListNodesImpl.java +++ b/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/ListNodesImpl.java @@ -17,7 +17,6 @@ package org.jclouds.chef.strategy.internal; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.transform; import static com.google.common.util.concurrent.Futures.allAsList; import static com.google.common.util.concurrent.Futures.getUnchecked; @@ -38,13 +37,11 @@ import org.jclouds.logging.Logger; import com.google.common.base.Function; import com.google.common.base.Joiner; -import com.google.common.base.Predicate; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.inject.Inject; /** - * * * @author Adrian Cole */ @@ -68,28 +65,12 @@ public class ListNodesImpl implements ListNodes { return execute(userExecutor); } - @Override - public Iterable execute(Predicate nodeNameSelector) { - return execute(userExecutor, nodeNameSelector); - } - - @Override - public Iterable execute(Iterable toGet) { - return execute(userExecutor, toGet); - } - @Override public Iterable execute(ListeningExecutorService executor) { return execute(executor, api.listNodes()); } - @Override - public Iterable execute(ListeningExecutorService executor, Predicate nodeNameSelector) { - return execute(executor, filter(api.listNodes(), nodeNameSelector)); - } - - @Override - public Iterable execute(final ListeningExecutorService executor, Iterable toGet) { + private Iterable execute(final ListeningExecutorService executor, Iterable toGet) { ListenableFuture> futures = allAsList(transform(toGet, new Function>() { @Override public ListenableFuture apply(final String input) { diff --git a/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/ListNodesInEnvironmentImpl.java b/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/ListNodesInEnvironmentImpl.java index c430b95ce4..a2b22442bd 100644 --- a/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/ListNodesInEnvironmentImpl.java +++ b/apis/chef/src/main/java/org/jclouds/chef/strategy/internal/ListNodesInEnvironmentImpl.java @@ -17,7 +17,6 @@ package org.jclouds.chef.strategy.internal; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.transform; import static com.google.common.util.concurrent.Futures.allAsList; import static com.google.common.util.concurrent.Futures.getUnchecked; @@ -38,13 +37,11 @@ import org.jclouds.logging.Logger; import com.google.common.base.Function; import com.google.common.base.Joiner; -import com.google.common.base.Predicate; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.inject.Inject; /** - * * * @author Noorul Islam K M */ @@ -68,28 +65,12 @@ public class ListNodesInEnvironmentImpl implements ListNodesInEnvironment { return execute(userExecutor, environmentName); } - @Override - public Iterable execute(String environmentName, Predicate nodeNameSelector) { - return execute(userExecutor, environmentName, nodeNameSelector); - } - - @Override - public Iterable execute(String environmentName, Iterable toGet) { - return execute(userExecutor, environmentName, toGet); - } - @Override public Iterable execute(ListeningExecutorService executor, String environmentName) { return execute(executor, environmentName, api.listNodesInEnvironment(environmentName)); } - @Override - public Iterable execute(ListeningExecutorService executor, String environmentName, Predicate nodeNameSelector) { - return execute(executor, environmentName, filter(api.listNodesInEnvironment(environmentName), nodeNameSelector)); - } - - @Override - public Iterable execute(final ListeningExecutorService executor, String environmentName, Iterable toGet) { + private Iterable execute(final ListeningExecutorService executor, String environmentName, Iterable toGet) { ListenableFuture> futures = allAsList(transform(toGet, new Function>() { @Override public ListenableFuture apply(final String input) { diff --git a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/ListNodesImplLiveTest.java b/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/ListNodesImplLiveTest.java index 80b9678e9b..f4c7ed1a24 100644 --- a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/ListNodesImplLiveTest.java +++ b/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/ListNodesImplLiveTest.java @@ -17,7 +17,6 @@ package org.jclouds.chef.strategy.internal; import static com.google.common.collect.Iterables.size; -import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import org.jclouds.chef.ChefApi; @@ -25,7 +24,6 @@ import org.jclouds.chef.internal.BaseChefLiveTest; import org.testng.annotations.AfterClass; import org.testng.annotations.Test; -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableSet; /** @@ -60,22 +58,4 @@ public class ListNodesImplLiveTest extends BaseChefLiveTest { public void testExecute() { assertTrue(size(strategy.execute()) > 0, "Expected one or more elements"); } - - @Test - public void testExecutePredicateOfString() { - assertEquals(size(strategy.execute(new Predicate() { - - @Override - public boolean apply(String input) { - return input.startsWith(prefix); - } - - })), 2); - } - - @Test - public void testExecuteIterableOfString() { - assertEquals(size(strategy.execute(ImmutableSet.of(prefix, prefix + 1))), 2); - } - } diff --git a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/ListNodesInEnvironmentImplLiveTest.java b/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/ListNodesInEnvironmentImplLiveTest.java index 0d19c12c63..25863d9f29 100644 --- a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/ListNodesInEnvironmentImplLiveTest.java +++ b/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/ListNodesInEnvironmentImplLiveTest.java @@ -17,7 +17,6 @@ package org.jclouds.chef.strategy.internal; import static com.google.common.collect.Iterables.size; -import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import org.jclouds.chef.ChefApi; @@ -25,7 +24,6 @@ import org.jclouds.chef.internal.BaseChefLiveTest; import org.testng.annotations.AfterClass; import org.testng.annotations.Test; -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableSet; /** @@ -60,22 +58,4 @@ public class ListNodesInEnvironmentImplLiveTest extends BaseChefLiveTest 0, "Expected one or more elements"); } - - @Test - public void testExecutePredicateOfString() { - assertEquals(size(strategy.execute("_default", new Predicate() { - - @Override - public boolean apply(String input) { - return input.startsWith(prefix); - } - - })), 2); - } - - @Test - public void testExecuteIterableOfString() { - assertEquals(size(strategy.execute("_default", ImmutableSet.of(prefix, prefix + 1))), 2); - } - }