brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rich...@apache.org
Subject [3/4] git commit: use render hints to show file/mem sizes nicely
Date Tue, 17 Jun 2014 07:15:16 GMT
use render hints to show file/mem sizes nicely


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

Branch: refs/heads/master
Commit: df84668392c765b4b61d4e38f786195701004e56
Parents: 4b563d7
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Thu Jun 12 23:39:56 2014 -0700
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Sat Jun 14 20:13:02 2014 -0700

----------------------------------------------------------------------
 .../entity/nosql/couchbase/CouchbaseNode.java   | 26 +++++++++++++-------
 .../entity/webapp/DynamicWebAppCluster.java     | 13 ++++++++--
 .../entity/webapp/DynamicWebAppFabric.java      | 10 +++-----
 .../entity/webapp/WebAppServiceConstants.java   |  6 +++++
 4 files changed, 37 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/df846683/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 dd6979c..46b49f5 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
@@ -8,12 +8,14 @@ import brooklyn.entity.basic.ConfigKeys;
 import brooklyn.entity.basic.MethodEffector;
 import brooklyn.entity.basic.SoftwareProcess;
 import brooklyn.entity.proxying.ImplementedBy;
+import brooklyn.entity.webapp.WebAppService;
 import brooklyn.entity.webapp.WebAppServiceConstants;
 import brooklyn.event.AttributeSensor;
 import brooklyn.event.basic.BasicAttributeSensorAndConfigKey;
 import brooklyn.event.basic.PortAttributeSensorAndConfigKey;
 import brooklyn.event.basic.Sensors;
 import brooklyn.util.flags.SetFromFlag;
+import brooklyn.util.text.ByteSizeStrings;
 
 @ImplementedBy(CouchbaseNodeImpl.class)
 public interface CouchbaseNode extends SoftwareProcess {
@@ -78,21 +80,28 @@ public interface CouchbaseNode extends SoftwareProcess {
             "Retrieved from pools/nodes/<current node>/interestingStats/cmd_get");
     AttributeSensor<Integer> CURR_ITEMS_TOT = Sensors.newIntegerSensor("couchbase.stats.curr.items.tot",

             "Retrieved from pools/nodes/<current node>/interestingStats/curr_items_tot");
+
     
-    // this class is added because the ROOT_URL relies on a static initialization which unfortunately
-    // can't be added to
-    // an interface.
     class RootUrl {
-        public static final AttributeSensor<String> ROOT_URL = Sensors.newStringSensor("webapp.url",
"URL");
-
+        public static final AttributeSensor<String> ROOT_URL = WebAppService.ROOT_URL;
+        
         static {
-            RendererHints.register(ROOT_URL, new RendererHints.NamedActionWithUrl("Open"));
+            // ROOT_URL does not need init because it refers to something already initialized
             RendererHints.register(COUCHBASE_WEB_ADMIN_URL, new RendererHints.NamedActionWithUrl("Open"));
+
+            RendererHints.register(COUCH_DOCS_DATA_SIZE, RendererHints.displayValue(ByteSizeStrings.metric()));
+            RendererHints.register(COUCH_DOCS_ACTUAL_DISK_SIZE, RendererHints.displayValue(ByteSizeStrings.metric()));
+            RendererHints.register(MEM_USED, RendererHints.displayValue(ByteSizeStrings.metric()));
+            RendererHints.register(COUCH_VIEWS_ACTUAL_DISK_SIZE, RendererHints.displayValue(ByteSizeStrings.metric()));
+            RendererHints.register(COUCH_VIEWS_DATA_SIZE, RendererHints.displayValue(ByteSizeStrings.metric()));
         }
     }
+    
+    // this long-winded reference is done just to trigger the initialization above
+    AttributeSensor<String> ROOT_URL = RootUrl.ROOT_URL;
 
-    public static final MethodEffector<Void> SERVER_ADD = new MethodEffector<Void>(CouchbaseNode.class,
"serverAdd");
-    public static final MethodEffector<Void> REBALANCE = new MethodEffector<Void>(CouchbaseNode.class,
"rebalance");
+    MethodEffector<Void> SERVER_ADD = new MethodEffector<Void>(CouchbaseNode.class,
"serverAdd");
+    MethodEffector<Void> REBALANCE = new MethodEffector<Void>(CouchbaseNode.class,
"rebalance");
 
     @Effector(description = "add a server to a cluster")
     public void serverAdd(@EffectorParam(name = "serverHostname") String serverToAdd, @EffectorParam(name
= "username") String username, @EffectorParam(name = "password") String password);
@@ -100,5 +109,4 @@ public interface CouchbaseNode extends SoftwareProcess {
     @Effector(description = "rebalance the couchbase cluster")
     public void rebalance();
 
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/df846683/software/webapp/src/main/java/brooklyn/entity/webapp/DynamicWebAppCluster.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/DynamicWebAppCluster.java
b/software/webapp/src/main/java/brooklyn/entity/webapp/DynamicWebAppCluster.java
index a757f95..19f320d 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/DynamicWebAppCluster.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/DynamicWebAppCluster.java
@@ -1,9 +1,11 @@
 package brooklyn.entity.webapp;
 
+import brooklyn.config.render.RendererHints;
 import brooklyn.entity.group.DynamicCluster;
 import brooklyn.entity.proxying.ImplementedBy;
 import brooklyn.event.AttributeSensor;
 import brooklyn.event.basic.BasicAttributeSensor;
+import brooklyn.util.time.Duration;
 
 /**
  * DynamicWebAppClusters provide cluster-wide aggregates of entity attributes.  Currently
totals and averages:
@@ -29,10 +31,17 @@ public interface DynamicWebAppCluster extends DynamicCluster, WebAppService
{
     public static final AttributeSensor<Double> REQUESTS_PER_SECOND_IN_WINDOW_PER_NODE
= new BasicAttributeSensor<Double>(
             Double.class, "webapp.reqs.perSec.windowed.perNode", "Reqs/sec (over time window)
averaged over all nodes");
 
-    public static final AttributeSensor<Integer> TOTAL_PROCESSING_TIME_PER_NODE = new
BasicAttributeSensor<Integer>(
-            Integer.class, "webapp.reqs.processingTime.perNode", "Total processing time per
node");
+    public static final AttributeSensor<Integer> TOTAL_PROCESSING_TIME_PER_NODE = ApplyDisplayHints.TOTAL_PROCESSING_TIME_PER_NODE;
 
     public static final AttributeSensor<Double> PROCESSING_TIME_FRACTION_IN_WINDOW_PER_NODE
= new BasicAttributeSensor<Double>(
             Double.class, "webapp.reqs.processingTime.fraction.windowed.perNode", "Fraction
of time spent processing reported by webserver (percentage, over time window) averaged over
all nodes");
 
+    class ApplyDisplayHints {
+        public static final AttributeSensor<Integer> TOTAL_PROCESSING_TIME_PER_NODE
= new BasicAttributeSensor<Integer>(
+            Integer.class, "webapp.reqs.processingTime.perNode", "Total processing time per
node (millis)");
+        static {
+            RendererHints.register(TOTAL_PROCESSING_TIME_PER_NODE, RendererHints.displayValue(Duration.millisToStringRounded()));
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/df846683/software/webapp/src/main/java/brooklyn/entity/webapp/DynamicWebAppFabric.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/DynamicWebAppFabric.java
b/software/webapp/src/main/java/brooklyn/entity/webapp/DynamicWebAppFabric.java
index a464cf2..b1c75cf 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/DynamicWebAppFabric.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/DynamicWebAppFabric.java
@@ -23,12 +23,8 @@ public interface DynamicWebAppFabric extends DynamicFabric, WebAppService
{
     public static final AttributeSensor<Integer> ERROR_COUNT_PER_NODE = new BasicAttributeSensor<Integer>(
             Integer.class, "webapp.reqs.errors.perNode", "Fabric entity request error average");
 
-    public static final AttributeSensor<Double> REQUESTS_PER_SECOND_LAST_PER_NODE =
new BasicAttributeSensor<Double>(
-            Double.class, "webapp.reqs.perSec.last.perNode", "Reqs/sec (last datapoint) averaged
over all nodes");
+    public static final AttributeSensor<Double> REQUESTS_PER_SECOND_LAST_PER_NODE =
DynamicWebAppCluster.REQUESTS_PER_SECOND_LAST_PER_NODE;
+    public static final AttributeSensor<Double> REQUESTS_PER_SECOND_IN_WINDOW_PER_NODE
= DynamicWebAppCluster.REQUESTS_PER_SECOND_IN_WINDOW_PER_NODE;
+    public static final AttributeSensor<Integer> TOTAL_PROCESSING_TIME_PER_NODE = DynamicWebAppCluster.TOTAL_PROCESSING_TIME_PER_NODE;
 
-    public static final AttributeSensor<Double> REQUESTS_PER_SECOND_IN_WINDOW_PER_NODE
= new BasicAttributeSensor<Double>(
-            Double.class, "webapp.reqs.perSec.windowed.perNode", "Reqs/sec (over time window)
averaged over all nodes");
-
-    public static final AttributeSensor<Integer> TOTAL_PROCESSING_TIME_PER_NODE = new
BasicAttributeSensor<Integer>(
-            Integer.class, "webapp.reqs.processingTime.perNode", "Total processing time per
node");
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/df846683/software/webapp/src/main/java/brooklyn/entity/webapp/WebAppServiceConstants.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/WebAppServiceConstants.java
b/software/webapp/src/main/java/brooklyn/entity/webapp/WebAppServiceConstants.java
index 3dfc89d..91a46e2 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/WebAppServiceConstants.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/WebAppServiceConstants.java
@@ -10,6 +10,8 @@ import brooklyn.event.basic.BasicAttributeSensorAndConfigKey;
 import brooklyn.event.basic.PortAttributeSensorAndConfigKey;
 import brooklyn.event.basic.Sensors;
 import brooklyn.util.flags.SetFromFlag;
+import brooklyn.util.text.ByteSizeStrings;
+import brooklyn.util.time.Duration;
 
 import com.google.common.collect.ImmutableList;
 
@@ -71,5 +73,9 @@ class RootUrl {
 
     static {
         RendererHints.register(ROOT_URL, new RendererHints.NamedActionWithUrl("Open"));
+        RendererHints.register(WebAppServiceConstants.TOTAL_PROCESSING_TIME, RendererHints.displayValue(Duration.millisToStringRounded()));
+        RendererHints.register(WebAppServiceConstants.MAX_PROCESSING_TIME, RendererHints.displayValue(Duration.millisToStringRounded()));
+        RendererHints.register(WebAppServiceConstants.BYTES_RECEIVED, RendererHints.displayValue(ByteSizeStrings.metric()));
+        RendererHints.register(WebAppServiceConstants.BYTES_SENT, RendererHints.displayValue(ByteSizeStrings.metric()));
     }
 }


Mime
View raw message