You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by Graeme-Miller <gi...@git.apache.org> on 2016/06/03 14:53:08 UTC

[GitHub] brooklyn-server pull request #181: Added a default PortForwardManager

GitHub user Graeme-Miller opened a pull request:

    https://github.com/apache/brooklyn-server/pull/181

    Added a default PortForwardManager

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/Graeme-Miller/brooklyn-server default_pf_manager_2

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/brooklyn-server/pull/181.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #181
    
----
commit a166122426600ecbc0846ab9065ae4772bbcd196
Author: graeme.miller <gr...@cloudsoftcorp.com>
Date:   2016-06-03T11:14:09Z

    Added a default PortForwardManager

----


---
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.
---

[GitHub] brooklyn-server pull request #181: Added a default PortForwardManager

Posted by grkvlt <gi...@git.apache.org>.
Github user grkvlt commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/181#discussion_r65801404
  
    --- Diff: locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java ---
    @@ -2582,10 +2576,15 @@ protected void releasePortForwarding(final JcloudsMachineLocation machine) {
     
             boolean usePortForwarding = Boolean.TRUE.equals(machine.getConfig(USE_PORT_FORWARDING));
             final JcloudsPortForwarderExtension portForwarder = machine.getConfig(PORT_FORWARDER);
    -        PortForwardManager portForwardManager = machine.getConfig(PORT_FORWARDING_MANAGER);
             final String nodeId = machine.getJcloudsId();
             final Map<String, Runnable> subtasks = Maps.newLinkedHashMap();
     
    +        PortForwardManager portForwardManager = machine.getConfig(PORT_FORWARDING_MANAGER);
    +        if (portForwardManager == null) {
    +            LOG.debug("No PortForwardManager, using default");
    +            portForwardManager = (PortForwardManager) getManagementContext().getLocationRegistry().getLocationManaged("portForwardManager(scope=global)");
    --- End diff --
    
    Again, use constant.


---
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.
---

[GitHub] brooklyn-server pull request #181: Added a default PortForwardManager

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/brooklyn-server/pull/181


---
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.
---

[GitHub] brooklyn-server pull request #181: Added a default PortForwardManager

Posted by grkvlt <gi...@git.apache.org>.
Github user grkvlt commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/181#discussion_r65897294
  
    --- Diff: locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java ---
    @@ -2617,15 +2616,10 @@ public void run() {
                 }
     
                 // Get all the other port-forwarding mappings for this VM, and release all of those
    -            Set<PortMapping> mappings;
    -            if (portForwardManager != null) {
    -                mappings = Sets.newLinkedHashSet();
    -                mappings.addAll(portForwardManager.getLocationPublicIpIds(machine));
    -                if (nodeId != null) {
    -                    mappings.addAll(portForwardManager.getPortMappingWithPublicIpId(nodeId));
    -                }
    -            } else {
    -                mappings = ImmutableSet.of();
    +            Set<PortMapping> mappings = Sets.newLinkedHashSet();
    --- End diff --
    
    ```Java
    Set<PortMapping> mappings = MutableMap.copyOf(portForwardManager.getLocationPublicIpIds(machine));
    if (nodeId != null) {
        mappings.addAll(portForwardManager.getPortMappingWithPublicIpId(nodeId));
    }
    ```
    Yeah, it's pointless. Forget it...


---
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.
---

[GitHub] brooklyn-server pull request #181: Added a default PortForwardManager

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/181#discussion_r65896243
  
    --- Diff: locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java ---
    @@ -2617,15 +2616,10 @@ public void run() {
                 }
     
                 // Get all the other port-forwarding mappings for this VM, and release all of those
    -            Set<PortMapping> mappings;
    -            if (portForwardManager != null) {
    -                mappings = Sets.newLinkedHashSet();
    -                mappings.addAll(portForwardManager.getLocationPublicIpIds(machine));
    -                if (nodeId != null) {
    -                    mappings.addAll(portForwardManager.getPortMappingWithPublicIpId(nodeId));
    -                }
    -            } else {
    -                mappings = ImmutableSet.of();
    +            Set<PortMapping> mappings = Sets.newLinkedHashSet();
    --- End diff --
    
    @grkvlt I don't follow - it's a `Set<PortMapping>`. What would you copy?


---
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.
---

[GitHub] brooklyn-server issue #181: Added a default PortForwardManager

Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on the issue:

    https://github.com/apache/brooklyn-server/pull/181
  
    LGTM


---
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.
---

[GitHub] brooklyn-server pull request #181: Added a default PortForwardManager

Posted by grkvlt <gi...@git.apache.org>.
Github user grkvlt commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/181#discussion_r65801396
  
    --- Diff: core/src/main/java/org/apache/brooklyn/core/location/access/BrooklynAccessUtils.java ---
    @@ -59,46 +60,52 @@
     
         public static HostAndPort getBrooklynAccessibleAddress(Entity entity, int port) {
             String host;
    -        
    +
    +        EntityInternal entityInternal = (EntityInternal) entity;
    +
             // look up port forwarding
             PortForwardManager pfw = entity.getConfig(PORT_FORWARDING_MANAGER);
    -        if (pfw!=null) {
    -            Collection<Location> ll = entity.getLocations();
    -            
    -            synchronized (BrooklynAccessUtils.class) {
    -                // TODO finer-grained synchronization
    -                
    -                for (MachineLocation machine : Iterables.filter(ll, MachineLocation.class)) {
    -                    HostAndPort hp = pfw.lookup(machine, port);
    +        if (pfw == null) {
    +            log.debug("No PortForwardManager, using default");
    +            pfw = (PortForwardManager) entityInternal.getManagementContext().getLocationRegistry().getLocationManaged("portForwardManager(scope=global)");
    +        }
    +
    +        Collection<Location> ll = entity.getLocations();
    +
    +        synchronized (BrooklynAccessUtils.class) {
    +            // TODO finer-grained synchronization
    +
    +            for (MachineLocation machine : Iterables.filter(ll, MachineLocation.class)) {
    +                HostAndPort hp = pfw.lookup(machine, port);
    +                if (hp!=null) {
    +                    log.debug("BrooklynAccessUtils found port-forwarded address {} for entity {}, port {}, using machine {}",
    +                            new Object[] {hp, entity, port, machine});
    +                    return hp;
    +                }
    +            }
    +
    +            Maybe<SupportsPortForwarding> supportPortForwardingLoc = Machines.findUniqueElement(ll, SupportsPortForwarding.class);
    +            if (supportPortForwardingLoc.isPresent()) {
    +                Cidr source = entity.getConfig(MANAGEMENT_ACCESS_CIDR);
    --- End diff --
    
    Also `config().get(...)`


---
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.
---

[GitHub] brooklyn-server pull request #181: Added a default PortForwardManager

Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/181#discussion_r65891907
  
    --- Diff: core/src/main/java/org/apache/brooklyn/core/location/access/BrooklynAccessUtils.java ---
    @@ -59,46 +60,52 @@
     
         public static HostAndPort getBrooklynAccessibleAddress(Entity entity, int port) {
             String host;
    -        
    +
    +        EntityInternal entityInternal = (EntityInternal) entity;
    +
             // look up port forwarding
             PortForwardManager pfw = entity.getConfig(PORT_FORWARDING_MANAGER);
    -        if (pfw!=null) {
    -            Collection<Location> ll = entity.getLocations();
    -            
    -            synchronized (BrooklynAccessUtils.class) {
    -                // TODO finer-grained synchronization
    -                
    -                for (MachineLocation machine : Iterables.filter(ll, MachineLocation.class)) {
    -                    HostAndPort hp = pfw.lookup(machine, port);
    +        if (pfw == null) {
    +            log.debug("No PortForwardManager, using default");
    +            pfw = (PortForwardManager) entityInternal.getManagementContext().getLocationRegistry().getLocationManaged("portForwardManager(scope=global)");
    +        }
    +
    +        Collection<Location> ll = entity.getLocations();
    +
    +        synchronized (BrooklynAccessUtils.class) {
    --- End diff --
    
    Do we need to check for null `pfw` here? Is it always there? What about non-jclouds locations?


---
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.
---

[GitHub] brooklyn-server pull request #181: Added a default PortForwardManager

Posted by grkvlt <gi...@git.apache.org>.
Github user grkvlt commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/181#discussion_r65801410
  
    --- Diff: locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java ---
    @@ -2617,15 +2616,10 @@ public void run() {
                 }
     
                 // Get all the other port-forwarding mappings for this VM, and release all of those
    -            Set<PortMapping> mappings;
    -            if (portForwardManager != null) {
    -                mappings = Sets.newLinkedHashSet();
    -                mappings.addAll(portForwardManager.getLocationPublicIpIds(machine));
    -                if (nodeId != null) {
    -                    mappings.addAll(portForwardManager.getPortMappingWithPublicIpId(nodeId));
    -                }
    -            } else {
    -                mappings = ImmutableSet.of();
    +            Set<PortMapping> mappings = Sets.newLinkedHashSet();
    --- End diff --
    
    Maybe use `ImmutableMap.copyOf()` here?


---
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.
---

[GitHub] brooklyn-server pull request #181: Added a default PortForwardManager

Posted by grkvlt <gi...@git.apache.org>.
Github user grkvlt commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/181#discussion_r65801373
  
    --- Diff: core/src/main/java/org/apache/brooklyn/core/location/access/BrooklynAccessUtils.java ---
    @@ -59,46 +60,52 @@
     
         public static HostAndPort getBrooklynAccessibleAddress(Entity entity, int port) {
             String host;
    -        
    +
    +        EntityInternal entityInternal = (EntityInternal) entity;
    +
             // look up port forwarding
             PortForwardManager pfw = entity.getConfig(PORT_FORWARDING_MANAGER);
    --- End diff --
    
    Not you, but why not change this to `pfm` instead?


---
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.
---

[GitHub] brooklyn-server issue #181: Added a default PortForwardManager

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on the issue:

    https://github.com/apache/brooklyn-server/pull/181
  
    LGTM.
    Build failure is an unrelated test, which we should mark as "Broken" in a separate PR.
    Happy for Andrew's rename comments to be addressed in a separate PR in the future.


---
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.
---

[GitHub] brooklyn-server pull request #181: Added a default PortForwardManager

Posted by grkvlt <gi...@git.apache.org>.
Github user grkvlt commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/181#discussion_r65801402
  
    --- Diff: locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java ---
    @@ -820,32 +820,26 @@ protected MachineLocation obtainOnce(ConfigBag setup) throws NoMachinesAvailable
                     machineLocation = registerJcloudsSshMachineLocation(computeService, node, Optional.fromNullable(template), userCredentials, sshHostAndPortOverride, setup);
                 }
     
    +            PortForwardManager portForwardManager = setup.get(PORT_FORWARDING_MANAGER);
    +            if (portForwardManager == null) {
    +                LOG.debug("No PortForwardManager, using default");
    +                portForwardManager = (PortForwardManager) getManagementContext().getLocationRegistry().getLocationManaged("portForwardManager(scope=global)");
    --- End diff --
    
    Use constant declared earlier


---
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.
---

[GitHub] brooklyn-server pull request #181: Added a default PortForwardManager

Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/181#discussion_r65893833
  
    --- Diff: core/src/main/java/org/apache/brooklyn/core/location/access/BrooklynAccessUtils.java ---
    @@ -59,46 +60,52 @@
     
         public static HostAndPort getBrooklynAccessibleAddress(Entity entity, int port) {
             String host;
    -        
    +
    +        EntityInternal entityInternal = (EntityInternal) entity;
    +
             // look up port forwarding
             PortForwardManager pfw = entity.getConfig(PORT_FORWARDING_MANAGER);
    -        if (pfw!=null) {
    -            Collection<Location> ll = entity.getLocations();
    -            
    -            synchronized (BrooklynAccessUtils.class) {
    -                // TODO finer-grained synchronization
    -                
    -                for (MachineLocation machine : Iterables.filter(ll, MachineLocation.class)) {
    -                    HostAndPort hp = pfw.lookup(machine, port);
    +        if (pfw == null) {
    +            log.debug("No PortForwardManager, using default");
    +            pfw = (PortForwardManager) entityInternal.getManagementContext().getLocationRegistry().getLocationManaged("portForwardManager(scope=global)");
    +        }
    +
    +        Collection<Location> ll = entity.getLocations();
    +
    +        synchronized (BrooklynAccessUtils.class) {
    --- End diff --
    
    Looking at the sources shouldn't be ever null, ignore.


---
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.
---

[GitHub] brooklyn-server issue #181: Added a default PortForwardManager

Posted by Graeme-Miller <gi...@git.apache.org>.
Github user Graeme-Miller commented on the issue:

    https://github.com/apache/brooklyn-server/pull/181
  
    @duncangrant @Graeme-Miller how does this interact with #171


---
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.
---

[GitHub] brooklyn-server pull request #181: Added a default PortForwardManager

Posted by grkvlt <gi...@git.apache.org>.
Github user grkvlt commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/181#discussion_r65801388
  
    --- Diff: core/src/main/java/org/apache/brooklyn/core/location/access/BrooklynAccessUtils.java ---
    @@ -59,46 +60,52 @@
     
         public static HostAndPort getBrooklynAccessibleAddress(Entity entity, int port) {
             String host;
    -        
    +
    +        EntityInternal entityInternal = (EntityInternal) entity;
    +
             // look up port forwarding
             PortForwardManager pfw = entity.getConfig(PORT_FORWARDING_MANAGER);
    -        if (pfw!=null) {
    -            Collection<Location> ll = entity.getLocations();
    -            
    -            synchronized (BrooklynAccessUtils.class) {
    -                // TODO finer-grained synchronization
    -                
    -                for (MachineLocation machine : Iterables.filter(ll, MachineLocation.class)) {
    -                    HostAndPort hp = pfw.lookup(machine, port);
    +        if (pfw == null) {
    +            log.debug("No PortForwardManager, using default");
    +            pfw = (PortForwardManager) entityInternal.getManagementContext().getLocationRegistry().getLocationManaged("portForwardManager(scope=global)");
    --- End diff --
    
    Make `"portForwardManager(scope=global)"` a constant in the `PortForwardManager` interface.


---
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.
---