brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [3/8] git commit: add a new main.uri sensor in Attributes, similar idea but wider scope to WebAppService.ROOT_URL
Date Mon, 27 Oct 2014 14:56:08 GMT
add a new main.uri sensor in Attributes, similar idea but wider scope to WebAppService.ROOT_URL


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

Branch: refs/heads/master
Commit: 33858e222598946db3f2cc9a89192be622fcdc2e
Parents: ea41bfa
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Sun Oct 26 21:38:21 2014 +0000
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Mon Oct 27 07:51:41 2014 -0700

----------------------------------------------------------------------
 .../main/java/brooklyn/entity/basic/Attributes.java   | 14 ++++++++++++++
 .../entity/nosql/couchbase/CouchbaseNode.java         | 12 +++++++-----
 .../entity/nosql/couchbase/CouchbaseNodeImpl.java     |  4 ++--
 .../entity/dns/AbstractGeoDnsServiceImpl.java         |  7 ++++---
 .../entity/dns/geoscaling/GeoscalingDnsService.java   |  4 ++++
 .../dns/geoscaling/GeoscalingDnsServiceImpl.java      |  7 ++++++-
 .../brooklyn/entity/proxy/AbstractControllerImpl.java | 10 ++++++++--
 .../main/java/brooklyn/entity/proxy/LoadBalancer.java |  2 ++
 .../java/brooklyn/entity/proxy/nginx/UrlMapping.java  |  2 --
 .../webapp/ControlledDynamicWebAppClusterImpl.java    |  4 ++--
 .../brooklyn/entity/webapp/JavaWebAppSshDriver.java   |  2 ++
 .../entity/webapp/nodejs/NodeJsWebAppSshDriver.java   |  7 ++-----
 .../src/main/webapp/assets/js/view/entity-summary.js  |  2 +-
 .../qa/load/SimulatedNginxControllerImpl.java         |  8 ++++++--
 .../java/brooklyn/qa/load/SimulatedTheeTierApp.java   |  3 ++-
 15 files changed, 62 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/33858e22/core/src/main/java/brooklyn/entity/basic/Attributes.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/Attributes.java b/core/src/main/java/brooklyn/entity/basic/Attributes.java
index e26617e..f8781e3 100644
--- a/core/src/main/java/brooklyn/entity/basic/Attributes.java
+++ b/core/src/main/java/brooklyn/entity/basic/Attributes.java
@@ -18,9 +18,11 @@
  */
 package brooklyn.entity.basic;
 
+import java.net.URI;
 import java.util.List;
 import java.util.Map;
 
+import brooklyn.config.render.RendererHints;
 import brooklyn.event.AttributeSensor;
 import brooklyn.event.Sensor;
 import brooklyn.event.basic.BasicAttributeSensor;
@@ -122,4 +124,16 @@ public interface Attributes {
     AttributeSensor<Integer> PID = Sensors.newIntegerSensor("pid", "Process ID for
the previously launched instance");
 
     AttributeSensor<String> LOG_FILE_LOCATION = Sensors.newStringSensor("log.location",
"Log file location");
+    
+    AttributeSensor<URI> MAIN_URI = MainUri.MAIN_URI;
+
+ // this class is added because the MAIN_URI relies on a static initialization which unfortunately
can't be added to an interface.
+    class MainUri {
+        private final static AttributeSensor<URI> MAIN_URI = Sensors.newSensor(URI.class,
"main.uri", "Main URI for contacting the service/endpoint offered by this entity");
+
+        static {
+            RendererHints.register(MAIN_URI, RendererHints.namedActionWithUrl());
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/33858e22/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNode.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNode.java
b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNode.java
index a0f2b88..01b9562 100644
--- a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNode.java
+++ b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNode.java
@@ -18,17 +18,19 @@
  */
 package brooklyn.entity.nosql.couchbase;
 
+import java.net.URI;
+
 import brooklyn.catalog.Catalog;
 import brooklyn.config.ConfigKey;
 import brooklyn.config.render.RendererHints;
 import brooklyn.entity.annotation.Effector;
 import brooklyn.entity.annotation.EffectorParam;
+import brooklyn.entity.basic.Attributes;
 import brooklyn.entity.basic.ConfigKeys;
 import brooklyn.entity.basic.MethodEffector;
 import brooklyn.entity.basic.SoftwareProcess;
 import brooklyn.entity.effector.Effectors;
 import brooklyn.entity.proxying.ImplementedBy;
-import brooklyn.entity.webapp.WebAppService;
 import brooklyn.entity.webapp.WebAppServiceConstants;
 import brooklyn.event.AttributeSensor;
 import brooklyn.event.basic.BasicAttributeSensorAndConfigKey;
@@ -80,7 +82,7 @@ public interface CouchbaseNode extends SoftwareProcess {
 
     AttributeSensor<Boolean> IS_PRIMARY_NODE = Sensors.newBooleanSensor("couchbase.isPrimaryNode",
"flag to determine if the current couchbase node is the primary node for the cluster");
     AttributeSensor<Boolean> IS_IN_CLUSTER = Sensors.newBooleanSensor("couchbase.isInCluster",
"flag to determine if the current couchbase node has been added to a cluster");
-    public static final AttributeSensor<String> COUCHBASE_WEB_ADMIN_URL = WebAppServiceConstants.ROOT_URL;
// By using this specific sensor, the value will be shown in the summary tab
+    public static final AttributeSensor<URI> COUCHBASE_WEB_ADMIN_URL = Attributes.MAIN_URI;
     
     // Interesting stats
     AttributeSensor<Double> OPS = Sensors.newDoubleSensor("couchbase.stats.ops", 
@@ -110,8 +112,8 @@ public interface CouchbaseNode extends SoftwareProcess {
     AttributeSensor<String> REBALANCE_STATUS = Sensors.newStringSensor("couchbase.rebalance.status",

             "Displays the current rebalance status from pools/nodes/rebalanceStatus");
     
-    class RootUrl {
-        public static final AttributeSensor<String> ROOT_URL = WebAppService.ROOT_URL;
+    class MainUri {
+        public static final AttributeSensor<URI> MAIN_URI = Attributes.MAIN_URI;
         
         static {
             // ROOT_URL does not need init because it refers to something already initialized
@@ -126,7 +128,7 @@ public interface CouchbaseNode extends SoftwareProcess {
     }
     
     // this long-winded reference is done just to trigger the initialization above
-    AttributeSensor<String> ROOT_URL = RootUrl.ROOT_URL;
+    AttributeSensor<URI> MAIN_URI = MainUri.MAIN_URI;
 
     MethodEffector<Void> SERVER_ADD = new MethodEffector<Void>(CouchbaseNode.class,
"serverAdd");
     MethodEffector<Void> SERVER_ADD_AND_REBALANCE = new MethodEffector<Void>(CouchbaseNode.class,
"serverAddAndRebalance");

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/33858e22/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNodeImpl.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNodeImpl.java
b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNodeImpl.java
index d5a9598..a459637 100644
--- a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNodeImpl.java
+++ b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNodeImpl.java
@@ -93,7 +93,7 @@ public class CouchbaseNodeImpl extends SoftwareProcessImpl implements CouchbaseN
                     Integer webPort = getAttribute(CouchbaseNode.COUCHBASE_WEB_ADMIN_PORT);
                     Preconditions.checkNotNull(webPort, CouchbaseNode.COUCHBASE_WEB_ADMIN_PORT+"
not set for %s; is an acceptable port available?", this);
                     String hostAndPort = BrooklynAccessUtils.getBrooklynAccessibleAddress(CouchbaseNodeImpl.this,
webPort).toString();
-                    setAttribute(CouchbaseNode.COUCHBASE_WEB_ADMIN_URL, format("http://%s",
hostAndPort));
+                    setAttribute(CouchbaseNode.COUCHBASE_WEB_ADMIN_URL, URI.create(format("http://%s",
hostAndPort)));
                 }
             }
         });
@@ -208,7 +208,7 @@ public class CouchbaseNodeImpl extends SoftwareProcessImpl implements
CouchbaseN
         super.connectSensors();
         connectServiceUpIsRunning();
                 
-        String adminUrl = DynamicTasks.submit(DependentConfiguration.attributeWhenReady(this,
CouchbaseNode.COUCHBASE_WEB_ADMIN_URL), this).getUnchecked(Duration.TWO_MINUTES);
+        URI adminUrl = DynamicTasks.submit(DependentConfiguration.attributeWhenReady(this,
CouchbaseNode.COUCHBASE_WEB_ADMIN_URL), this).getUnchecked(Duration.TWO_MINUTES);
         
         httpFeed = HttpFeed.builder()
             .entity(this)

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/33858e22/software/webapp/src/main/java/brooklyn/entity/dns/AbstractGeoDnsServiceImpl.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/dns/AbstractGeoDnsServiceImpl.java
b/software/webapp/src/main/java/brooklyn/entity/dns/AbstractGeoDnsServiceImpl.java
index f931bb1..4c66e5d 100644
--- a/software/webapp/src/main/java/brooklyn/entity/dns/AbstractGeoDnsServiceImpl.java
+++ b/software/webapp/src/main/java/brooklyn/entity/dns/AbstractGeoDnsServiceImpl.java
@@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
 
 import java.net.InetAddress;
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URL;
 import java.net.UnknownHostException;
 import java.util.Collection;
@@ -131,7 +132,7 @@ public abstract class AbstractGeoDnsServiceImpl extends AbstractEntity
implement
         log.debug("Initializing tracker for "+this+", following "+targetEntityProvider);
         tracker = addPolicy(PolicySpec.create(MemberTrackingPolicy.class)
                 .displayName("GeoDNS targets tracker")
-                .configure("sensorsToTrack", ImmutableSet.of(HOSTNAME, ADDRESS, WebAppService.ROOT_URL))
+                .configure("sensorsToTrack", ImmutableSet.of(HOSTNAME, ADDRESS, Attributes.MAIN_URI,
WebAppService.ROOT_URL))
                 .configure("group", targetEntityProvider));
         refreshGroupMembership();
     }
@@ -302,10 +303,10 @@ public abstract class AbstractGeoDnsServiceImpl extends AbstractEntity
implement
     
     protected String inferHostname(Entity entity) {
         String hostname = entity.getAttribute(Attributes.HOSTNAME);
-        String url = entity.getAttribute(WebAppService.ROOT_URL);
+        URI url = entity.getAttribute(Attributes.MAIN_URI);
         if (url!=null) {
             try {
-                URL u = new URL(url);
+                URL u = url.toURL();
                 
                 String hostname2 = u.getHost(); 
                 if (hostname==null) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/33858e22/software/webapp/src/main/java/brooklyn/entity/dns/geoscaling/GeoscalingDnsService.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/dns/geoscaling/GeoscalingDnsService.java
b/software/webapp/src/main/java/brooklyn/entity/dns/geoscaling/GeoscalingDnsService.java
index 48fda9b..c07b4cc 100644
--- a/software/webapp/src/main/java/brooklyn/entity/dns/geoscaling/GeoscalingDnsService.java
+++ b/software/webapp/src/main/java/brooklyn/entity/dns/geoscaling/GeoscalingDnsService.java
@@ -18,7 +18,10 @@
  */
 package brooklyn.entity.dns.geoscaling;
 
+import java.net.URI;
+
 import brooklyn.config.ConfigKey;
+import brooklyn.entity.basic.Attributes;
 import brooklyn.entity.dns.AbstractGeoDnsService;
 import brooklyn.entity.proxying.ImplementedBy;
 import brooklyn.entity.webapp.WebAppServiceConstants;
@@ -48,6 +51,7 @@ public interface GeoscalingDnsService extends AbstractGeoDnsService {
     
     public static final AttributeSensor<String> GEOSCALING_ACCOUNT = new BasicAttributeSensor<String>(
             String.class, "geoscaling.account", "Active user account for the GeoScaling.com
service");
+    public static final AttributeSensor<URI> MAIN_URI = Attributes.MAIN_URI;
     public static final AttributeSensor<String> ROOT_URL = WebAppServiceConstants.ROOT_URL;
     public static final AttributeSensor<String> MANAGED_DOMAIN = new BasicAttributeSensor<String>(
             String.class, "geoscaling.managed.domain", "Fully qualified domain name that
will be geo-redirected; " +

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/33858e22/software/webapp/src/main/java/brooklyn/entity/dns/geoscaling/GeoscalingDnsServiceImpl.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/dns/geoscaling/GeoscalingDnsServiceImpl.java
b/software/webapp/src/main/java/brooklyn/entity/dns/geoscaling/GeoscalingDnsServiceImpl.java
index d22d4c7..28d41b2 100644
--- a/software/webapp/src/main/java/brooklyn/entity/dns/geoscaling/GeoscalingDnsServiceImpl.java
+++ b/software/webapp/src/main/java/brooklyn/entity/dns/geoscaling/GeoscalingDnsServiceImpl.java
@@ -21,6 +21,7 @@ package brooklyn.entity.dns.geoscaling;
 import static brooklyn.entity.dns.geoscaling.GeoscalingWebClient.PROVIDE_CITY_INFO;
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import java.net.URI;
 import java.util.Collection;
 import java.util.Set;
 
@@ -170,10 +171,14 @@ public class GeoscalingDnsServiceImpl extends AbstractGeoDnsServiceImpl
implemen
             if (targetHosts.isEmpty()) {
                 setServiceState(Lifecycle.CREATED);
                 setAttribute(ROOT_URL, null);
+                setAttribute(MAIN_URI, null);
             } else {
                 setServiceState(Lifecycle.RUNNING);
                 String domain = getAttribute(MANAGED_DOMAIN);
-                if (!Strings.isEmpty(domain)) setAttribute(ROOT_URL, "http://"+domain+"/");
+                if (!Strings.isEmpty(domain)) {
+                    setAttribute(ROOT_URL, "http://"+domain+"/");
+                    setAttribute(MAIN_URI, URI.create("http://"+domain+"/"));
+                }
             }
         } else {
             log.warn("Failed to retrieve or create GeoScaling smart subdomain '"+smartSubdomainName+"."+primaryDomainName+

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/33858e22/software/webapp/src/main/java/brooklyn/entity/proxy/AbstractControllerImpl.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/proxy/AbstractControllerImpl.java
b/software/webapp/src/main/java/brooklyn/entity/proxy/AbstractControllerImpl.java
index 76a6922..8bab2fa 100644
--- a/software/webapp/src/main/java/brooklyn/entity/proxy/AbstractControllerImpl.java
+++ b/software/webapp/src/main/java/brooklyn/entity/proxy/AbstractControllerImpl.java
@@ -22,6 +22,7 @@ import static brooklyn.util.JavaGroovyEquivalents.groovyTruth;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
 
+import java.net.URI;
 import java.util.Collection;
 import java.util.Map;
 import java.util.Set;
@@ -49,6 +50,7 @@ import brooklyn.util.collections.MutableMap;
 import brooklyn.util.exceptions.Exceptions;
 import brooklyn.util.guava.Maybe;
 import brooklyn.util.task.Tasks;
+import brooklyn.util.text.Strings;
 
 import com.google.common.base.Objects;
 import com.google.common.base.Predicates;
@@ -230,7 +232,7 @@ public abstract class AbstractControllerImpl extends SoftwareProcessImpl
impleme
     /** primary URL this controller serves, if one can / has been inferred */
     @Override
     public String getUrl() {
-        return getAttribute(ROOT_URL);
+        return Strings.toString( getAttribute(MAIN_URI) );
     }
 
     @Override
@@ -301,6 +303,7 @@ public abstract class AbstractControllerImpl extends SoftwareProcessImpl
impleme
         ConfigToAttributes.apply(this);
 
         setAttribute(PROTOCOL, inferProtocol());
+        setAttribute(MAIN_URI, URI.create(inferUrl()));
         setAttribute(ROOT_URL, inferUrl());
  
         checkNotNull(getPortNumberSensor(), "no sensor configured to infer port number");
@@ -309,7 +312,10 @@ public abstract class AbstractControllerImpl extends SoftwareProcessImpl
impleme
     @Override
     protected void connectSensors() {
         super.connectSensors();
-        if (getUrl()==null) setAttribute(ROOT_URL, inferUrl());
+        if (getUrl()==null) {
+            setAttribute(MAIN_URI, URI.create(inferUrl()));
+            setAttribute(ROOT_URL, inferUrl());
+        }
         
         // TODO when rebind policies, and rebind calls connectSensors, then this will cause
problems.
         // Also relying on addServerPoolMemberTrackingPolicy to set the serverPoolAddresses
and serverPoolTargets.

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/33858e22/software/webapp/src/main/java/brooklyn/entity/proxy/LoadBalancer.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/proxy/LoadBalancer.java b/software/webapp/src/main/java/brooklyn/entity/proxy/LoadBalancer.java
index cf8cbe4..b130e6f 100644
--- a/software/webapp/src/main/java/brooklyn/entity/proxy/LoadBalancer.java
+++ b/software/webapp/src/main/java/brooklyn/entity/proxy/LoadBalancer.java
@@ -18,6 +18,7 @@
  */
 package brooklyn.entity.proxy;
 
+import java.net.URI;
 import java.util.Map;
 
 import brooklyn.config.ConfigKey;
@@ -88,6 +89,7 @@ public interface LoadBalancer extends Entity, Startable {
     
     public static final AttributeSensor<String> HOSTNAME = Attributes.HOSTNAME;
     
+    public static final AttributeSensor<URI> MAIN_URI = Attributes.MAIN_URI;
     public static final AttributeSensor<String> ROOT_URL = WebAppService.ROOT_URL;
 
     public static final AttributeSensor<Map<Entity, String>> SERVER_POOL_TARGETS
= Sensors.newSensor(

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/33858e22/software/webapp/src/main/java/brooklyn/entity/proxy/nginx/UrlMapping.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/proxy/nginx/UrlMapping.java b/software/webapp/src/main/java/brooklyn/entity/proxy/nginx/UrlMapping.java
index c3e8a43..7cd7d87 100644
--- a/software/webapp/src/main/java/brooklyn/entity/proxy/nginx/UrlMapping.java
+++ b/software/webapp/src/main/java/brooklyn/entity/proxy/nginx/UrlMapping.java
@@ -76,8 +76,6 @@ public interface UrlMapping extends AbstractGroup {
     AttributeSensor<Collection<String>> TARGET_ADDRESSES = Sensors.newSensor(new
TypeToken<Collection<String>>() { },
             "urlmapping.target.addresses", "set of addresses which should be forwarded to
by this URL mapping");
 
-    AttributeSensor<String> ROOT_URL = WebAppService.ROOT_URL;
-
     String getUniqueLabel();
 
     /** Adds a rewrite rule, must be called at config time. See {@link UrlRewriteRule} for
more info. */

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/33858e22/software/webapp/src/main/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterImpl.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterImpl.java
b/software/webapp/src/main/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterImpl.java
index e1d8794..1c8b188 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterImpl.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterImpl.java
@@ -251,12 +251,12 @@ public class ControlledDynamicWebAppClusterImpl extends DynamicGroupImpl
impleme
     void connectSensors() {
         // FIXME no longer needed
         addEnricher(Enrichers.builder()
-                .propagatingAllButUsualAnd(ROOT_URL, GROUP_MEMBERS, GROUP_SIZE)
+                .propagatingAllButUsualAnd(Attributes.MAIN_URI, ROOT_URL, GROUP_MEMBERS,
GROUP_SIZE)
                 .from(getCluster())
                 .build());
         addEnricher(Enrichers.builder()
                 // include hostname and address of controller (need both in case hostname
only resolves to internal/private ip)
-                .propagating(LoadBalancer.HOSTNAME, Attributes.ADDRESS, ROOT_URL)
+                .propagating(LoadBalancer.HOSTNAME, Attributes.ADDRESS, Attributes.MAIN_URI,
ROOT_URL)
                 .from(getController())
                 .build());
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/33858e22/software/webapp/src/main/java/brooklyn/entity/webapp/JavaWebAppSshDriver.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/JavaWebAppSshDriver.java
b/software/webapp/src/main/java/brooklyn/entity/webapp/JavaWebAppSshDriver.java
index 44e93eb..9916711 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/JavaWebAppSshDriver.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/JavaWebAppSshDriver.java
@@ -21,6 +21,7 @@ package brooklyn.entity.webapp;
 import static com.google.common.base.Preconditions.checkNotNull;
 
 import java.io.File;
+import java.net.URI;
 import java.util.Set;
 
 import brooklyn.entity.basic.Attributes;
@@ -101,6 +102,7 @@ public abstract class JavaWebAppSshDriver extends JavaSoftwareProcessSshDriver
i
     @Override
     public void postLaunch() {
         String rootUrl = inferRootUrl();
+        entity.setAttribute(Attributes.MAIN_URI, URI.create(rootUrl));
         entity.setAttribute(WebAppService.ROOT_URL, rootUrl);
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/33858e22/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
index 12e06c6..f720c60 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
@@ -18,8 +18,7 @@
  */
 package brooklyn.entity.webapp.nodejs;
 
-import static java.lang.String.format;
-
+import java.net.URI;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -29,9 +28,7 @@ import org.slf4j.LoggerFactory;
 
 import brooklyn.entity.basic.AbstractSoftwareProcessSshDriver;
 import brooklyn.entity.basic.Attributes;
-import brooklyn.entity.basic.Entities;
 import brooklyn.entity.basic.SoftwareProcess;
-import brooklyn.entity.drivers.downloads.DownloadResolver;
 import brooklyn.entity.webapp.WebAppService;
 import brooklyn.location.basic.SshMachineLocation;
 import brooklyn.util.collections.MutableList;
@@ -44,7 +41,6 @@ import brooklyn.util.text.Strings;
 import com.google.common.base.Joiner;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 
 public class NodeJsWebAppSshDriver extends AbstractSoftwareProcessSshDriver implements NodeJsWebAppDriver
{
@@ -72,6 +68,7 @@ public class NodeJsWebAppSshDriver extends AbstractSoftwareProcessSshDriver
impl
     @Override
     public void postLaunch() {
         String rootUrl = String.format("http://%s:%d/", getHostname(), getHttpPort());
+        entity.setAttribute(Attributes.MAIN_URI, URI.create(rootUrl));
         entity.setAttribute(WebAppService.ROOT_URL, rootUrl);
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/33858e22/usage/jsgui/src/main/webapp/assets/js/view/entity-summary.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/view/entity-summary.js b/usage/jsgui/src/main/webapp/assets/js/view/entity-summary.js
index a5e1f6e..3436832 100644
--- a/usage/jsgui/src/main/webapp/assets/js/view/entity-summary.js
+++ b/usage/jsgui/src/main/webapp/assets/js/view/entity-summary.js
@@ -93,7 +93,7 @@ define([
             this.revealIfHasValue("service.isUp", this.$(".serviceUp"), null, data)
             
             var renderAsLink = function(data) { return "<a href='"+_.escape(data)+"'>"+_.escape(data)+"</a>"
};
-            this.revealIfHasValue("webapp.url", this.$(".url"), renderAsLink, data)
+            this.revealIfHasValue("main.uri", this.$(".url"), renderAsLink, data)
 
             var status = this.updateStatusIcon();
             

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/33858e22/usage/qa/src/main/java/brooklyn/qa/load/SimulatedNginxControllerImpl.java
----------------------------------------------------------------------
diff --git a/usage/qa/src/main/java/brooklyn/qa/load/SimulatedNginxControllerImpl.java b/usage/qa/src/main/java/brooklyn/qa/load/SimulatedNginxControllerImpl.java
index d8fe57a..1fc6488 100644
--- a/usage/qa/src/main/java/brooklyn/qa/load/SimulatedNginxControllerImpl.java
+++ b/usage/qa/src/main/java/brooklyn/qa/load/SimulatedNginxControllerImpl.java
@@ -20,6 +20,7 @@ package brooklyn.qa.load;
 
 import static java.lang.String.format;
 
+import java.net.URI;
 import java.util.Collection;
 import java.util.concurrent.Callable;
 
@@ -70,7 +71,10 @@ public class SimulatedNginxControllerImpl extends NginxControllerImpl {
         }
 
         // From AbstractController.connectSensors
-        if (getUrl()==null) setAttribute(ROOT_URL, inferUrl());
+        if (getUrl()==null) {
+            setAttribute(MAIN_URI, URI.create(inferUrl()));
+            setAttribute(ROOT_URL, inferUrl());
+        }
         addServerPoolMemberTrackingPolicy();
 
         // From NginxController.connectSensors
@@ -78,7 +82,7 @@ public class SimulatedNginxControllerImpl extends NginxControllerImpl {
 
         if (!simulateExternalMonitoring) {
             // if simulating entity, then simulate work of periodic HTTP request; TODO but
not parsing JSON response
-            String uriToPoll = (simulateEntity) ? "http://localhost:8081" : getAttribute(ROOT_URL);
+            String uriToPoll = (simulateEntity) ? "http://localhost:8081" : getAttribute(MAIN_URI).toString();
             
             httpFeed = HttpFeed.builder()
                     .entity(this)

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/33858e22/usage/qa/src/main/java/brooklyn/qa/load/SimulatedTheeTierApp.java
----------------------------------------------------------------------
diff --git a/usage/qa/src/main/java/brooklyn/qa/load/SimulatedTheeTierApp.java b/usage/qa/src/main/java/brooklyn/qa/load/SimulatedTheeTierApp.java
index 24c0355..6f95209 100644
--- a/usage/qa/src/main/java/brooklyn/qa/load/SimulatedTheeTierApp.java
+++ b/usage/qa/src/main/java/brooklyn/qa/load/SimulatedTheeTierApp.java
@@ -28,6 +28,7 @@ import brooklyn.config.ConfigKey;
 import brooklyn.enricher.Enrichers;
 import brooklyn.enricher.HttpLatencyDetector;
 import brooklyn.entity.basic.AbstractApplication;
+import brooklyn.entity.basic.Attributes;
 import brooklyn.entity.basic.ConfigKeys;
 import brooklyn.entity.basic.Entities;
 import brooklyn.entity.basic.StartableApplication;
@@ -105,7 +106,7 @@ public class SimulatedTheeTierApp extends AbstractApplication {
                 build());
 
         addEnricher(Enrichers.builder()
-                .propagating(WebAppServiceConstants.ROOT_URL,
+                .propagating(Attributes.MAIN_URI, WebAppServiceConstants.ROOT_URL,
                         DynamicWebAppCluster.REQUESTS_PER_SECOND_IN_WINDOW,
                         HttpLatencyDetector.REQUEST_LATENCY_IN_SECONDS_IN_WINDOW)
                 .from(web)


Mime
View raw message