You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by sv...@apache.org on 2016/07/14 15:39:22 UTC

[1/2] brooklyn-library git commit: Fix NodeJsWebAppSshDriver to obtain properly MAIN_URL

Repository: brooklyn-library
Updated Branches:
  refs/heads/master 512f720dc -> cc058d8c5


Fix NodeJsWebAppSshDriver to obtain properly MAIN_URL

- make NodeJsWebAppSshDriver and JavaWebAppSshDriver to use a single method
  for obtaining the MAIN_URL

This should be a standardized for all entities which has to have
an option for exposing http MAIN_URL


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

Branch: refs/heads/master
Commit: 47fa774a7f8bb76efe2c2e1226234d7406a1aca5
Parents: 512f720
Author: Valentin Aitken <bo...@gmail.com>
Authored: Thu Jul 7 20:20:25 2016 +0300
Committer: Valentin Aitken <bo...@gmail.com>
Committed: Thu Jul 14 11:01:23 2016 +0300

----------------------------------------------------------------------
 .../entity/webapp/JavaWebAppSshDriver.java      | 22 +++++++-------------
 .../webapp/nodejs/NodeJsWebAppSshDriver.java    |  5 ++---
 2 files changed, 9 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/47fa774a/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/JavaWebAppSshDriver.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/JavaWebAppSshDriver.java b/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/JavaWebAppSshDriver.java
index e1e30c3..b2b8620 100644
--- a/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/JavaWebAppSshDriver.java
+++ b/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/JavaWebAppSshDriver.java
@@ -91,25 +91,17 @@ public abstract class JavaWebAppSshDriver extends JavaSoftwareProcessSshDriver i
         return (ssl == null) ? null : ssl.getKeyAlias();
     }
 
+    /**
+     * @deprecated since 0.10.0; please use {@link WebAppServiceMethods#inferBrooklynAccessibleRootUrl(org.apache.brooklyn.api.entity.Entity)}
+     */
+    @Deprecated
     protected String inferRootUrl() {
-        if (isProtocolEnabled("https")) {
-            Integer port = getHttpsPort();
-            checkNotNull(port, "HTTPS_PORT sensors not set; is an acceptable port available?");
-            HostAndPort accessibleAddress = BrooklynAccessUtils.getBrooklynAccessibleAddress(getEntity(), port);
-            return String.format("https://%s:%s/", accessibleAddress.getHostText(), accessibleAddress.getPort());
-        } else if (isProtocolEnabled("http")) {
-            Integer port = getHttpPort();
-            checkNotNull(port, "HTTP_PORT sensors not set; is an acceptable port available?");
-            HostAndPort accessibleAddress = BrooklynAccessUtils.getBrooklynAccessibleAddress(getEntity(), port);
-            return String.format("http://%s:%s/", accessibleAddress.getHostText(), accessibleAddress.getPort());
-        } else {
-            throw new IllegalStateException("HTTP and HTTPS protocols not enabled for "+entity+"; enabled protocols are "+getEnabledProtocols());
-        }
+        return WebAppServiceMethods.inferBrooklynAccessibleRootUrl(entity);
     }
-    
+
     @Override
     public void postLaunch() {
-        String rootUrl = inferRootUrl();
+        String rootUrl = WebAppServiceMethods.inferBrooklynAccessibleRootUrl(entity);
         entity.sensors().set(Attributes.MAIN_URI, URI.create(rootUrl));
         entity.sensors().set(WebAppService.ROOT_URL, rootUrl);
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/47fa774a/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java b/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
index 1040963..b632e71 100644
--- a/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
+++ b/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
@@ -23,6 +23,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.brooklyn.entity.webapp.WebAppServiceMethods;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -31,9 +32,7 @@ import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
 
 import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.entity.software.base.AbstractSoftwareProcessSshDriver;
-import org.apache.brooklyn.entity.software.base.SoftwareProcess;
 import org.apache.brooklyn.entity.webapp.WebAppService;
 import org.apache.brooklyn.location.ssh.SshMachineLocation;
 import org.apache.brooklyn.util.collections.MutableList;
@@ -68,7 +67,7 @@ public class NodeJsWebAppSshDriver extends AbstractSoftwareProcessSshDriver impl
 
     @Override
     public void postLaunch() {
-        String rootUrl = String.format("http://%s:%d/", getHostname(), getHttpPort());
+        String rootUrl = WebAppServiceMethods.inferBrooklynAccessibleRootUrl(entity);
         entity.sensors().set(Attributes.MAIN_URI, URI.create(rootUrl));
         entity.sensors().set(WebAppService.ROOT_URL, rootUrl);
     }


[2/2] brooklyn-library git commit: Closes #48

Posted by sv...@apache.org.
Closes #48

Fix NodeJsWebAppSshDriver to obtain properly MAIN_URL

- make NodeJsWebAppSshDriver and JavaWebAppSshDriver to use a single method
  for obtaining the MAIN_URL

This should be a standardized for all entities which has to have
an option for exposing http MAIN_URL


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

Branch: refs/heads/master
Commit: cc058d8c5ba9665b903dbacfbef5c8ef7c35c1c2
Parents: 512f720 47fa774
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Thu Jul 14 18:39:12 2016 +0300
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Thu Jul 14 18:39:12 2016 +0300

----------------------------------------------------------------------
 .../entity/webapp/JavaWebAppSshDriver.java      | 22 +++++++-------------
 .../webapp/nodejs/NodeJsWebAppSshDriver.java    |  5 ++---
 2 files changed, 9 insertions(+), 18 deletions(-)
----------------------------------------------------------------------