You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by neykov <gi...@git.apache.org> on 2017/01/03 15:59:35 UTC

[GitHub] brooklyn-server pull request #497: Add findOpenSocketsOnNode to ReachableSoc...

Github user neykov commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/497#discussion_r94429072
  
    --- Diff: locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsUtil.java ---
    @@ -354,30 +355,60 @@ public static String getFirstReachableAddress(ComputeServiceContext context, Nod
             return getFirstReachableAddress(node, Duration.FIVE_MINUTES);
         }
         
    +    /**
    +     * Uses {@link Networking#isReachablePredicate()} to determine reachability.
    +     * @see #getReachableAddresses(NodeMetadata, Duration, Predicate)
    +     */
         public static String getFirstReachableAddress(NodeMetadata node, Duration timeout) {
    -        return getFirstReachableAddress(node, timeout, new Networking.IsReachablePredicate());
    +        return getFirstReachableAddress(node, timeout, Networking.isReachablePredicate());
         }
     
    +    /** @see #getReachableAddresses(NodeMetadata, Duration, Predicate) */
         public static String getFirstReachableAddress(NodeMetadata node, Duration timeout, Predicate<? super HostAndPort> socketTester) {
    +        Iterable<HostAndPort> addresses = getReachableAddresses(node, timeout, socketTester);
    +        HostAndPort address = Iterables.getFirst(addresses, null);
    +        if (address != null) {
    +            return address.getHostText();
    +        } else {
    +            throw new IllegalStateException("No reachable IPs for " + node + "; check whether the node is " +
    +                    "reachable and whether it meets the requirements of the HostAndPort tester: " + socketTester);
    +        }
    +    }
    +
    +    /**
    +     * @return The public and private addresses of node that are reachable.
    +     * @see #getReachableAddresses(Iterable, Duration, Predicate)
    +     */
    +    public static Iterable<HostAndPort> getReachableAddresses(NodeMetadata node, Duration timeout, Predicate<? super HostAndPort> socketTester) {
             final int port = node.getLoginPort();
    --- End diff --
    
    I acknowledge that this is existing code, but shouldn't we get the port from the port forwarder? External ports could be different from the actual listening port on the machine.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---