You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2016/10/04 14:43:51 UTC

[3/5] brooklyn-server git commit: JcloudsLocation.reachableAddressPredicate: improve generics

JcloudsLocation.reachableAddressPredicate: improve generics

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

Branch: refs/heads/master
Commit: 47193927249e4f49ef0a96e6dab557e6e2510936
Parents: b9dfdaa
Author: Aled Sage <al...@gmail.com>
Authored: Fri Sep 30 12:33:51 2016 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Oct 4 09:12:07 2016 +0100

----------------------------------------------------------------------
 .../core/location/cloud/CloudLocationConfig.java        | 12 +++++++++---
 .../brooklyn/location/jclouds/JcloudsLocation.java      |  4 ++--
 .../apache/brooklyn/location/jclouds/JcloudsUtil.java   |  2 +-
 .../apache/brooklyn/util/net/ReachableSocketFinder.java |  5 ++---
 4 files changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/47193927/core/src/main/java/org/apache/brooklyn/core/location/cloud/CloudLocationConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/location/cloud/CloudLocationConfig.java b/core/src/main/java/org/apache/brooklyn/core/location/cloud/CloudLocationConfig.java
index 21cd132..cc3e222 100644
--- a/core/src/main/java/org/apache/brooklyn/core/location/cloud/CloudLocationConfig.java
+++ b/core/src/main/java/org/apache/brooklyn/core/location/cloud/CloudLocationConfig.java
@@ -82,12 +82,18 @@ public interface CloudLocationConfig {
             + "if 'false', will default to the node's first public IP (or privae if no public IPs); "
             + "if 'true' uses default duration; otherwise accepts a time string e.g. '5m' (the default) or a number of milliseconds", "5m");
 
-    ConfigKey<Predicate<HostAndPort>> POLL_FOR_FIRST_REACHABLE_ADDRESS_PREDICATE = ConfigKeys.newConfigKey(new TypeToken<Predicate<HostAndPort>>(){}, "pollForFirstReachableAddress.predicate",
+    @SuppressWarnings("serial")
+    ConfigKey<Predicate<? super HostAndPort>> POLL_FOR_FIRST_REACHABLE_ADDRESS_PREDICATE = ConfigKeys.newConfigKey(
+            new TypeToken<Predicate<? super HostAndPort>>(){}, 
+            "pollForFirstReachableAddress.predicate",
             "Predicate<HostAndPort> implementation which checks whether machine is up or not.");
 
-    ConfigKey<Class<? extends Predicate<HostAndPort>>> POLL_FOR_FIRST_REACHABLE_ADDRESS_PREDICATE_TYPE = ConfigKeys.newConfigKey(new TypeToken<Class<? extends Predicate<HostAndPort>>>(){}, "pollForFirstReachableAddress.predicate.type",
+    @SuppressWarnings("serial")
+    ConfigKey<Class<? extends Predicate<? super HostAndPort>>> POLL_FOR_FIRST_REACHABLE_ADDRESS_PREDICATE_TYPE = ConfigKeys.newConfigKey(
+            new TypeToken<Class<? extends Predicate<? super HostAndPort>>>() {}, 
+            "pollForFirstReachableAddress.predicate.type",
             "Predicate<HostAndPort> class. " +
-            "Other keys prefixed with pollForFirstReachableAddress.predicate.<property> will be passed to the Map constructor of the Predicate<HostAndPort> implementation.",
+                    "Other keys prefixed with pollForFirstReachableAddress.predicate.<property> will be passed to the Map constructor of the Predicate<HostAndPort> implementation.",
             Networking.IsReachablePredicate.class);
 
     public static final ConfigKey<String> WAIT_FOR_SSHABLE = ConfigKeys.newStringConfigKey("waitForSshable",

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/47193927/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java
index 64e43b0..0fd1697 100644
--- a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java
+++ b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java
@@ -2892,7 +2892,7 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation im
         if (enabled) {
             Duration timeout = "true".equals(pollForFirstReachable) ? Duration.FIVE_MINUTES : Duration.of(pollForFirstReachable);
 
-            Predicate<HostAndPort> pollForFirstReachableHostAndPortPredicate;
+            Predicate<? super HostAndPort> pollForFirstReachableHostAndPortPredicate;
             if (setup.get(POLL_FOR_FIRST_REACHABLE_ADDRESS_PREDICATE) != null) {
                 LOG.debug("Using pollForFirstReachableAddress.predicate supplied from config for location " + this + " "
                         + POLL_FOR_FIRST_REACHABLE_ADDRESS_PREDICATE.getName() + " : " + setup.get(POLL_FOR_FIRST_REACHABLE_ADDRESS_PREDICATE));
@@ -2901,7 +2901,7 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation im
                 LOG.debug("Using pollForFirstReachableAddress.predicate.type supplied from config for location " + this + " " + POLL_FOR_FIRST_REACHABLE_ADDRESS_PREDICATE_TYPE.getName()
                         + " : " + setup.get(POLL_FOR_FIRST_REACHABLE_ADDRESS_PREDICATE_TYPE));
 
-                Class<? extends Predicate<HostAndPort>> predicateType = setup.get(POLL_FOR_FIRST_REACHABLE_ADDRESS_PREDICATE_TYPE);
+                Class<? extends Predicate<? super HostAndPort>> predicateType = setup.get(POLL_FOR_FIRST_REACHABLE_ADDRESS_PREDICATE_TYPE);
 
                 Map<String, Object> args = MutableMap.of();
                 ConfigUtils.addUnprefixedConfigKeyInConfigBack(POLL_FOR_FIRST_REACHABLE_ADDRESS_PREDICATE.getName() + ".", setup, args);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/47193927/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsUtil.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsUtil.java b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsUtil.java
index 0ba9b29..9d7d2e3 100644
--- a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsUtil.java
+++ b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsUtil.java
@@ -358,7 +358,7 @@ public class JcloudsUtil implements JcloudsLocationConfig {
         return getFirstReachableAddress(node, timeout, new Networking.IsReachablePredicate());
     }
 
-    public static String getFirstReachableAddress(NodeMetadata node, Duration timeout, Predicate<HostAndPort> socketTester) {
+    public static String getFirstReachableAddress(NodeMetadata node, Duration timeout, Predicate<? super HostAndPort> socketTester) {
         final int port = node.getLoginPort();
         List<HostAndPort> sockets = FluentIterable
                 .from(Iterables.concat(node.getPublicAddresses(), node.getPrivateAddresses()))

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/47193927/utils/common/src/main/java/org/apache/brooklyn/util/net/ReachableSocketFinder.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/org/apache/brooklyn/util/net/ReachableSocketFinder.java b/utils/common/src/main/java/org/apache/brooklyn/util/net/ReachableSocketFinder.java
index 72fb71c..5302c3e 100644
--- a/utils/common/src/main/java/org/apache/brooklyn/util/net/ReachableSocketFinder.java
+++ b/utils/common/src/main/java/org/apache/brooklyn/util/net/ReachableSocketFinder.java
@@ -18,7 +18,6 @@ package org.apache.brooklyn.util.net;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.util.concurrent.MoreExecutors.listeningDecorator;
 
 import java.util.Collection;
 import java.util.List;
@@ -52,7 +51,7 @@ public class ReachableSocketFinder {
 
     private static final Logger LOG = LoggerFactory.getLogger(ReachableSocketFinder.class);
 
-    private final Predicate<HostAndPort> socketTester;
+    private final Predicate<? super HostAndPort> socketTester;
     private final ListeningExecutorService userExecutor;
 
     public ReachableSocketFinder(ListeningExecutorService userExecutor) {
@@ -64,7 +63,7 @@ public class ReachableSocketFinder {
                 userExecutor);
     }
 
-    public ReachableSocketFinder(Predicate<HostAndPort> socketTester, ListeningExecutorService userExecutor) {
+    public ReachableSocketFinder(Predicate<? super HostAndPort> socketTester, ListeningExecutorService userExecutor) {
         this.socketTester = checkNotNull(socketTester, "socketTester");
         this.userExecutor = checkNotNull(userExecutor, "userExecutor");
     }