brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grk...@apache.org
Subject [3/5] brooklyn-server git commit: Add static helper method to PollConfig objects
Date Wed, 22 Jun 2016 21:14:24 GMT
Add static helper method to PollConfig objects


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

Branch: refs/heads/master
Commit: 7e54dfdaf1647acd1d4e518cc4cb1978f7c23ac8
Parents: 99d073f
Author: Andrew Donald Kennedy <andrew.kennedy@cloudsoftcorp.com>
Authored: Thu Jun 16 08:08:39 2016 +0100
Committer: Andrew Donald Kennedy <andrew.kennedy@cloudsoftcorp.com>
Committed: Wed Jun 22 12:56:36 2016 -0700

----------------------------------------------------------------------
 .../feed/function/FunctionPollConfig.java         |  8 ++++++--
 .../brooklyn/feed/shell/ShellPollConfig.java      | 14 +++++++++++---
 .../apache/brooklyn/feed/ssh/SshPollConfig.java   | 18 +++++++++++++-----
 .../WindowsPerformanceCounterPollConfig.java      | 14 +++++++++++---
 .../entity/chef/ChefAttributePollConfig.java      | 14 +++++++++++---
 .../brooklyn/feed/jmx/JmxAttributePollConfig.java | 14 +++++++++++---
 .../brooklyn/feed/jmx/JmxOperationPollConfig.java |  8 ++++++++
 7 files changed, 71 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7e54dfda/core/src/main/java/org/apache/brooklyn/feed/function/FunctionPollConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/feed/function/FunctionPollConfig.java
b/core/src/main/java/org/apache/brooklyn/feed/function/FunctionPollConfig.java
index 4951868..f9320a7 100644
--- a/core/src/main/java/org/apache/brooklyn/feed/function/FunctionPollConfig.java
+++ b/core/src/main/java/org/apache/brooklyn/feed/function/FunctionPollConfig.java
@@ -23,6 +23,8 @@ import groovy.lang.Closure;
 
 import java.util.concurrent.Callable;
 
+import com.google.common.base.Supplier;
+
 import org.apache.brooklyn.api.sensor.AttributeSensor;
 import org.apache.brooklyn.core.feed.FeedConfig;
 import org.apache.brooklyn.core.feed.PollConfig;
@@ -30,8 +32,6 @@ import org.apache.brooklyn.util.groovy.GroovyJavaMethods;
 import org.apache.brooklyn.util.guava.Functionals;
 import org.apache.brooklyn.util.javalang.JavaClassNames;
 
-import com.google.common.base.Supplier;
-
 public class FunctionPollConfig<S, T> extends PollConfig<S, T, FunctionPollConfig<S,
T>> {
 
     private Callable<?> callable;
@@ -39,6 +39,10 @@ public class FunctionPollConfig<S, T> extends PollConfig<S, T,
FunctionPollConfi
     public static <T> FunctionPollConfig<?, T> forSensor(AttributeSensor<T>
sensor) {
         return new FunctionPollConfig<Object, T>(sensor);
     }
+
+    public static FunctionPollConfig<?, Void> forMultiple() {
+        return new FunctionPollConfig<Object, Void>(PollConfig.NO_SENSOR);
+    }
     
     public FunctionPollConfig(AttributeSensor<T> sensor) {
         super(sensor);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7e54dfda/core/src/main/java/org/apache/brooklyn/feed/shell/ShellPollConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/feed/shell/ShellPollConfig.java b/core/src/main/java/org/apache/brooklyn/feed/shell/ShellPollConfig.java
index e1147c3..7e599b5 100644
--- a/core/src/main/java/org/apache/brooklyn/feed/shell/ShellPollConfig.java
+++ b/core/src/main/java/org/apache/brooklyn/feed/shell/ShellPollConfig.java
@@ -26,14 +26,14 @@ import java.util.concurrent.TimeUnit;
 
 import javax.annotation.Nullable;
 
+import com.google.common.base.Predicate;
+import com.google.common.collect.Maps;
+
 import org.apache.brooklyn.api.sensor.AttributeSensor;
 import org.apache.brooklyn.core.feed.PollConfig;
 import org.apache.brooklyn.feed.ssh.SshPollValue;
 import org.apache.brooklyn.util.collections.MutableList;
 
-import com.google.common.base.Predicate;
-import com.google.common.collect.Maps;
-
 public class ShellPollConfig<T> extends PollConfig<SshPollValue, T, ShellPollConfig<T>>
{
 
     private String command;
@@ -48,6 +48,14 @@ public class ShellPollConfig<T> extends PollConfig<SshPollValue,
T, ShellPollCon
             return input != null && input.getExitStatus() == 0;
         }};
 
+    public static <T> ShellPollConfig<T> forSensor(AttributeSensor<T> sensor)
{
+        return new ShellPollConfig<T>(sensor);
+    }
+
+    public static ShellPollConfig<Void> forMultiple() {
+        return new ShellPollConfig<Void>(PollConfig.NO_SENSOR);
+    }
+
     public ShellPollConfig(AttributeSensor<T> sensor) {
         super(sensor);
         super.checkSuccess(DEFAULT_SUCCESS);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7e54dfda/core/src/main/java/org/apache/brooklyn/feed/ssh/SshPollConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/feed/ssh/SshPollConfig.java b/core/src/main/java/org/apache/brooklyn/feed/ssh/SshPollConfig.java
index 7839fde..e75a5d9 100644
--- a/core/src/main/java/org/apache/brooklyn/feed/ssh/SshPollConfig.java
+++ b/core/src/main/java/org/apache/brooklyn/feed/ssh/SshPollConfig.java
@@ -26,17 +26,17 @@ import java.util.Map;
 
 import javax.annotation.Nullable;
 
-import org.apache.brooklyn.api.sensor.AttributeSensor;
-import org.apache.brooklyn.core.feed.PollConfig;
-import org.apache.brooklyn.util.collections.MutableList;
-import org.apache.brooklyn.util.collections.MutableMap;
-
 import com.google.common.base.Objects;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Predicate;
 import com.google.common.base.Supplier;
 import com.google.common.base.Suppliers;
 
+import org.apache.brooklyn.api.sensor.AttributeSensor;
+import org.apache.brooklyn.core.feed.PollConfig;
+import org.apache.brooklyn.util.collections.MutableList;
+import org.apache.brooklyn.util.collections.MutableMap;
+
 public class SshPollConfig<T> extends PollConfig<SshPollValue, T, SshPollConfig<T>>
{
 
     private Supplier<String> commandSupplier;
@@ -48,6 +48,14 @@ public class SshPollConfig<T> extends PollConfig<SshPollValue,
T, SshPollConfig<
             return input != null && input.getExitStatus() == 0;
         }};
 
+    public static <T> SshPollConfig<T> forSensor(AttributeSensor<T> sensor)
{
+        return new SshPollConfig<T>(sensor);
+    }
+
+    public static SshPollConfig<Void> forMultiple() {
+        return new SshPollConfig<Void>(PollConfig.NO_SENSOR);
+    }
+
     public SshPollConfig(AttributeSensor<T> sensor) {
         super(sensor);
         super.checkSuccess(DEFAULT_SUCCESS);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7e54dfda/core/src/main/java/org/apache/brooklyn/feed/windows/WindowsPerformanceCounterPollConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/feed/windows/WindowsPerformanceCounterPollConfig.java
b/core/src/main/java/org/apache/brooklyn/feed/windows/WindowsPerformanceCounterPollConfig.java
index 1391c3e..2dd97b6 100644
--- a/core/src/main/java/org/apache/brooklyn/feed/windows/WindowsPerformanceCounterPollConfig.java
+++ b/core/src/main/java/org/apache/brooklyn/feed/windows/WindowsPerformanceCounterPollConfig.java
@@ -18,16 +18,24 @@
  */
 package org.apache.brooklyn.feed.windows;
 
-import org.apache.brooklyn.api.sensor.AttributeSensor;
-import org.apache.brooklyn.core.feed.PollConfig;
-
 import com.google.common.base.Function;
 import com.google.common.base.Functions;
 
+import org.apache.brooklyn.api.sensor.AttributeSensor;
+import org.apache.brooklyn.core.feed.PollConfig;
+
 public class WindowsPerformanceCounterPollConfig<T> extends PollConfig<Object, T,
WindowsPerformanceCounterPollConfig<T>>{
 
     private String performanceCounterName;
 
+    public static <T> WindowsPerformanceCounterPollConfig<T> forSensor(AttributeSensor<T>
sensor) {
+        return new WindowsPerformanceCounterPollConfig<T>(sensor);
+    }
+
+    public static WindowsPerformanceCounterPollConfig<Void> forMultiple() {
+        return new WindowsPerformanceCounterPollConfig<Void>(PollConfig.NO_SENSOR);
+    }
+
     @SuppressWarnings({ "unchecked", "rawtypes" })
     public WindowsPerformanceCounterPollConfig(AttributeSensor<T> sensor) {
         super(sensor);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7e54dfda/software/base/src/main/java/org/apache/brooklyn/entity/chef/ChefAttributePollConfig.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/org/apache/brooklyn/entity/chef/ChefAttributePollConfig.java
b/software/base/src/main/java/org/apache/brooklyn/entity/chef/ChefAttributePollConfig.java
index badc7e4..c090f34 100644
--- a/software/base/src/main/java/org/apache/brooklyn/entity/chef/ChefAttributePollConfig.java
+++ b/software/base/src/main/java/org/apache/brooklyn/entity/chef/ChefAttributePollConfig.java
@@ -18,16 +18,24 @@
  */
 package org.apache.brooklyn.entity.chef;
 
-import org.apache.brooklyn.api.sensor.AttributeSensor;
-import org.apache.brooklyn.core.feed.PollConfig;
-
 import com.google.common.base.Function;
 import com.google.common.base.Functions;
 
+import org.apache.brooklyn.api.sensor.AttributeSensor;
+import org.apache.brooklyn.core.feed.PollConfig;
+
 public class ChefAttributePollConfig<T> extends PollConfig<Object, T, ChefAttributePollConfig<T>>{
 
     private String chefAttributePath;
 
+    public static <T> ChefAttributePollConfig<T> forSensor(AttributeSensor<T>
sensor) {
+        return new ChefAttributePollConfig<T>(sensor);
+    }
+
+    public static ChefAttributePollConfig<Void> forMultiple() {
+        return new ChefAttributePollConfig<Void>(PollConfig.NO_SENSOR);
+    }
+
     @SuppressWarnings({ "unchecked", "rawtypes" })
     public ChefAttributePollConfig(AttributeSensor<T> sensor) {
         super(sensor);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7e54dfda/software/base/src/main/java/org/apache/brooklyn/feed/jmx/JmxAttributePollConfig.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/org/apache/brooklyn/feed/jmx/JmxAttributePollConfig.java
b/software/base/src/main/java/org/apache/brooklyn/feed/jmx/JmxAttributePollConfig.java
index ae19f45..230c73d 100644
--- a/software/base/src/main/java/org/apache/brooklyn/feed/jmx/JmxAttributePollConfig.java
+++ b/software/base/src/main/java/org/apache/brooklyn/feed/jmx/JmxAttributePollConfig.java
@@ -21,17 +21,25 @@ package org.apache.brooklyn.feed.jmx;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 
-import org.apache.brooklyn.api.sensor.AttributeSensor;
-import org.apache.brooklyn.core.feed.PollConfig;
-
 import com.google.common.base.Function;
 import com.google.common.base.Functions;
 
+import org.apache.brooklyn.api.sensor.AttributeSensor;
+import org.apache.brooklyn.core.feed.PollConfig;
+
 public class JmxAttributePollConfig<T> extends PollConfig<Object, T, JmxAttributePollConfig<T>>{
 
     private ObjectName objectName;
     private String attributeName;
 
+    public static <T> JmxAttributePollConfig<T> forSensor(AttributeSensor<T>
sensor) {
+        return new JmxAttributePollConfig<T>(sensor);
+    }
+
+    public static JmxAttributePollConfig<Void> forMultiple() {
+        return new JmxAttributePollConfig<Void>(PollConfig.NO_SENSOR);
+    }
+
     @SuppressWarnings({ "unchecked", "rawtypes" })
     public JmxAttributePollConfig(AttributeSensor<T> sensor) {
         super(sensor);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7e54dfda/software/base/src/main/java/org/apache/brooklyn/feed/jmx/JmxOperationPollConfig.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/org/apache/brooklyn/feed/jmx/JmxOperationPollConfig.java
b/software/base/src/main/java/org/apache/brooklyn/feed/jmx/JmxOperationPollConfig.java
index 107401d..25acb1b 100644
--- a/software/base/src/main/java/org/apache/brooklyn/feed/jmx/JmxOperationPollConfig.java
+++ b/software/base/src/main/java/org/apache/brooklyn/feed/jmx/JmxOperationPollConfig.java
@@ -39,6 +39,14 @@ public class JmxOperationPollConfig<T> extends PollConfig<Object,
T, JmxOperatio
     private List<String> signature = Collections.emptyList();
     private List<?> params = Collections.emptyList();
 
+    public static <T> JmxOperationPollConfig<T> forSensor(AttributeSensor<T>
sensor) {
+        return new JmxOperationPollConfig<T>(sensor);
+    }
+
+    public static JmxOperationPollConfig<Void> forMultiple() {
+        return new JmxOperationPollConfig<Void>(PollConfig.NO_SENSOR);
+    }
+
     @SuppressWarnings({ "unchecked", "rawtypes" })
     public JmxOperationPollConfig(AttributeSensor<T> sensor) {
         super(sensor);


Mime
View raw message