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 2014/11/03 16:52:08 UTC

[24/29] git commit: don't ignore explicit --port if https selected

don't ignore explicit --port if https selected


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

Branch: refs/heads/master
Commit: 4de0dc91e2021d97c0d21cc4b0b03b8b647ace53
Parents: 6dfd178
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Thu Oct 30 22:30:32 2014 -0500
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Fri Oct 31 09:39:51 2014 -0500

----------------------------------------------------------------------
 .../java/brooklyn/launcher/BrooklynLauncher.java  | 10 ++++------
 .../java/brooklyn/launcher/BrooklynWebServer.java | 18 +++++++++++++-----
 2 files changed, 17 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4de0dc91/usage/launcher/src/main/java/brooklyn/launcher/BrooklynLauncher.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/main/java/brooklyn/launcher/BrooklynLauncher.java b/usage/launcher/src/main/java/brooklyn/launcher/BrooklynLauncher.java
index 158c7c4..d9cde0c 100644
--- a/usage/launcher/src/main/java/brooklyn/launcher/BrooklynLauncher.java
+++ b/usage/launcher/src/main/java/brooklyn/launcher/BrooklynLauncher.java
@@ -142,7 +142,7 @@ public class BrooklynLauncher {
     
     private boolean startWebApps = true;
     private boolean startBrooklynNode = false;
-    private PortRange port = PortRanges.fromString("8081+");
+    private PortRange port = null;
     private InetAddress bindAddress = null;
     private InetAddress publicAddress = null;
     private Map<String,String> webApps = new LinkedHashMap<String,String>();
@@ -321,16 +321,14 @@ public class BrooklynLauncher {
     }
 
     /** 
-     * Specifies the port where the web console (and any additional webapps specified) will listen; 
-     * default "8081+" being the first available >= 8081.
+     * As {@link #webconsolePort(PortRange)} taking a single port
      */ 
     public BrooklynLauncher webconsolePort(int port) {
         return webconsolePort(PortRanges.fromInteger(port));
     }
 
     /**
-     * Specifies the port where the web console (and any additional webapps specified) will listen;
-     * default "8081+" being the first available >= 8081.
+     * As {@link #webconsolePort(PortRange)} taking a string range
      */
     public BrooklynLauncher webconsolePort(String port) {
         return webconsolePort(PortRanges.fromString(port));
@@ -338,7 +336,7 @@ public class BrooklynLauncher {
 
     /**
      * Specifies the port where the web console (and any additional webapps specified) will listen;
-     * default "8081+" being the first available >= 8081.
+     * default "8081+" (or "8443+" for https) being the first available >= 8081.
      */ 
     public BrooklynLauncher webconsolePort(PortRange port) {
         this.port = port;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4de0dc91/usage/launcher/src/main/java/brooklyn/launcher/BrooklynWebServer.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/main/java/brooklyn/launcher/BrooklynWebServer.java b/usage/launcher/src/main/java/brooklyn/launcher/BrooklynWebServer.java
index 1d62fad..2561272 100644
--- a/usage/launcher/src/main/java/brooklyn/launcher/BrooklynWebServer.java
+++ b/usage/launcher/src/main/java/brooklyn/launcher/BrooklynWebServer.java
@@ -109,8 +109,12 @@ public class BrooklynWebServer {
 
     private WebAppContext rootContext;
     
+    /** base port to use, for http if enabled or else https; if not set, it uses httpPort or httpsPort */
+    @SetFromFlag("port")
+    protected PortRange requestedPort = null;
+    
     @SetFromFlag
-    protected PortRange port = PortRanges.fromString("8081+");
+    protected PortRange httpPort = PortRanges.fromString("8081+");
     @SetFromFlag
     protected PortRange httpsPort = PortRanges.fromString("8443+");
     
@@ -206,7 +210,7 @@ public class BrooklynWebServer {
     public BrooklynWebServer setPort(Object port) {
         if (getActualPort()>0)
             throw new IllegalStateException("Can't set port after port has been assigned to server (using "+getActualPort()+")");
-        this.port = TypeCoercions.coerce(port, PortRange.class);
+        this.requestedPort = TypeCoercions.coerce(port, PortRange.class);
         return this;
     }
 
@@ -222,7 +226,7 @@ public class BrooklynWebServer {
     }
     
     public PortRange getRequestedPort() {
-        return port;
+        return requestedPort;
     }
     
     /** returns port where this is running, or -1 if not yet known */
@@ -328,9 +332,13 @@ public class BrooklynWebServer {
         if (server != null) throw new IllegalStateException(""+this+" already running");
 
         if (actualPort == -1){
-            actualPort = LocalhostMachineProvisioningLocation.obtainPort(getAddress(), getHttpsEnabled()?httpsPort:port);
+            PortRange portRange = requestedPort;
+            if (portRange==null) {
+                portRange = getHttpsEnabled()? httpsPort : httpPort;
+            }
+            actualPort = LocalhostMachineProvisioningLocation.obtainPort(getAddress(), portRange);
             if (actualPort == -1) 
-                throw new IllegalStateException("Unable to provision port for web console (wanted "+(getHttpsEnabled()?httpsPort:port)+")");
+                throw new IllegalStateException("Unable to provision port for web console (wanted "+portRange+")");
         }
 
         server = new Server(new InetSocketAddress(bindAddress, actualPort));