brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grk...@apache.org
Subject git commit: Fix memory display in MachineEntity by multiplying by 1000
Date Mon, 30 Jun 2014 14:32:43 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master 8373992b5 -> 1809b3605


Fix memory display in MachineEntity by multiplying by 1000


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

Branch: refs/heads/master
Commit: 1809b36058a084794c8005e39380fdc8455104a7
Parents: 8373992
Author: Andrew Kennedy <grkvlt@apache.org>
Authored: Mon Jun 30 15:28:12 2014 +0100
Committer: Andrew Kennedy <grkvlt@apache.org>
Committed: Mon Jun 30 15:28:12 2014 +0100

----------------------------------------------------------------------
 .../entity/machine/MachineAttributes.java         |  6 +++---
 .../java/brooklyn/util/math/MathFunctions.java    | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1809b360/software/base/src/main/java/brooklyn/entity/machine/MachineAttributes.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/machine/MachineAttributes.java b/software/base/src/main/java/brooklyn/entity/machine/MachineAttributes.java
index 8af01b4..74de3f3 100644
--- a/software/base/src/main/java/brooklyn/entity/machine/MachineAttributes.java
+++ b/software/base/src/main/java/brooklyn/entity/machine/MachineAttributes.java
@@ -74,9 +74,9 @@ public class MachineAttributes {
         RendererHints.register(CPU_USAGE, RendererHints.displayValue(MathFunctions.percent(2)));
         RendererHints.register(AVERAGE_CPU_USAGE, RendererHints.displayValue(MathFunctions.percent(2)));
 
-        RendererHints.register(FREE_MEMORY, RendererHints.displayValue(ByteSizeStrings.metric()));
-        RendererHints.register(TOTAL_MEMORY, RendererHints.displayValue(ByteSizeStrings.metric()));
-        RendererHints.register(USED_MEMORY, RendererHints.displayValue(ByteSizeStrings.metric()));
+        RendererHints.register(FREE_MEMORY, RendererHints.displayValue(Functionals.chain(MathFunctions.times(1000L),
ByteSizeStrings.metric())));
+        RendererHints.register(TOTAL_MEMORY, RendererHints.displayValue(Functionals.chain(MathFunctions.times(1000L),
ByteSizeStrings.metric())));
+        RendererHints.register(USED_MEMORY, RendererHints.displayValue(Functionals.chain(MathFunctions.times(1000L),
ByteSizeStrings.metric())));
         RendererHints.register(USED_MEMORY_DELTA_PER_SECOND_LAST, RendererHints.displayValue(Functionals.chain(longValue,
ByteSizeStrings.metric())));
         RendererHints.register(USED_MEMORY_DELTA_PER_SECOND_IN_WINDOW, RendererHints.displayValue(Functionals.chain(longValue,
ByteSizeStrings.metric())));
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1809b360/utils/common/src/main/java/brooklyn/util/math/MathFunctions.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/brooklyn/util/math/MathFunctions.java b/utils/common/src/main/java/brooklyn/util/math/MathFunctions.java
index dbf5604..2285257 100644
--- a/utils/common/src/main/java/brooklyn/util/math/MathFunctions.java
+++ b/utils/common/src/main/java/brooklyn/util/math/MathFunctions.java
@@ -17,6 +17,15 @@ public class MathFunctions {
         };
     }
 
+    public static Function<Number, Long> plus(final long addend) {
+        return new Function<Number, Long>() {
+            public Long apply(@Nullable Number input) {
+                if (input==null) return null;
+                return input.longValue() + addend;
+            }
+        };
+    }
+
     public static Function<Number, Double> plus(final double addend) {
         return new Function<Number, Double>() {
             public Double apply(@Nullable Number input) {
@@ -35,6 +44,15 @@ public class MathFunctions {
         };
     }
 
+    public static Function<Number, Long> times(final long multiplicand) {
+        return new Function<Number, Long>() {
+            public Long apply(@Nullable Number input) {
+                if (input==null) return null;
+                return input.longValue() * multiplicand;
+            }
+        };
+    }
+
     public static Function<Number, Double> times(final double multiplicand) {
         return new Function<Number, Double>() {
             public Double apply(@Nullable Number input) {


Mime
View raw message