brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [09/11] git commit: comment tidy and remove some warnings
Date Thu, 26 Jun 2014 10:39:46 GMT
comment tidy and remove some warnings


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

Branch: refs/heads/master
Commit: 6605118c5b23aa5274fc5dfc41e7453e4cc091e0
Parents: 380eff6
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Mon Jun 9 08:23:00 2014 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Tue Jun 24 21:59:55 2014 +0100

----------------------------------------------------------------------
 .../brooklyn/entity/effector/AddSensor.java     |  2 +-
 .../event/feed/function/FunctionFeed.java       |  3 +-
 .../brooklyn/event/feed/shell/ShellFeed.java    |  5 +--
 .../java/brooklyn/event/feed/ssh/SshFeed.java   |  2 +-
 .../brooklyn/event/feed/ssh/SshPollConfig.java  | 35 ++++++++++----------
 .../defining-applications/yaml-reference.md     |  2 +-
 .../entity/software/ssh/SshCommandSensor.java   |  6 ----
 .../java/brooklyn/event/feed/jmx/JmxFeed.java   | 14 ++++----
 .../event/feed/jmx/JmxOperationPollConfig.java  |  1 +
 9 files changed, 35 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6605118c/core/src/main/java/brooklyn/entity/effector/AddSensor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/effector/AddSensor.java b/core/src/main/java/brooklyn/entity/effector/AddSensor.java
index 165e1a6..ccb82c2 100644
--- a/core/src/main/java/brooklyn/entity/effector/AddSensor.java
+++ b/core/src/main/java/brooklyn/entity/effector/AddSensor.java
@@ -15,7 +15,7 @@ import com.google.common.annotations.Beta;
 import com.google.common.base.Preconditions;
 
 /** Entity initializer which adds a sensor to an entity's type definition.
- * TODO this does not add the feed. 
+ * Subclasses must add the feed; this class does not do that. 
  * @since 0.7.0 */
 @Beta
 public class AddSensor<RT,T extends Sensor<RT>> implements EntityInitializer
{

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6605118c/core/src/main/java/brooklyn/event/feed/function/FunctionFeed.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/event/feed/function/FunctionFeed.java b/core/src/main/java/brooklyn/event/feed/function/FunctionFeed.java
index c40a7ba..bb8dbc2 100644
--- a/core/src/main/java/brooklyn/event/feed/function/FunctionFeed.java
+++ b/core/src/main/java/brooklyn/event/feed/function/FunctionFeed.java
@@ -135,6 +135,7 @@ public class FunctionFeed extends AbstractFeed {
         super(builder.entity, builder.onlyIfServiceUp);
         
         for (FunctionPollConfig<?,?> config : builder.polls) {
+            @SuppressWarnings({ "rawtypes", "unchecked" })
             FunctionPollConfig<?,?> configCopy = new FunctionPollConfig(config);
             if (configCopy.getPeriod() < 0) configCopy.period(builder.period, builder.periodUnits);
             Callable<?> job = config.getCallable();
@@ -142,7 +143,7 @@ public class FunctionFeed extends AbstractFeed {
         }
     }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     @Override
     protected void preStart() {
         for (final FunctionPollIdentifier pollInfo : polls.keySet()) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6605118c/core/src/main/java/brooklyn/event/feed/shell/ShellFeed.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/event/feed/shell/ShellFeed.java b/core/src/main/java/brooklyn/event/feed/shell/ShellFeed.java
index 1f2b37a..9619fbd 100644
--- a/core/src/main/java/brooklyn/event/feed/shell/ShellFeed.java
+++ b/core/src/main/java/brooklyn/event/feed/shell/ShellFeed.java
@@ -160,6 +160,7 @@ public class ShellFeed extends AbstractFeed {
         super(builder.entity);
         
         for (ShellPollConfig<?> config : builder.polls) {
+            @SuppressWarnings({ "unchecked", "rawtypes" })
             ShellPollConfig<?> configCopy = new ShellPollConfig(config);
             if (configCopy.getPeriod() < 0) configCopy.period(builder.period, builder.periodUnits);
             String command = config.getCommand();
@@ -178,7 +179,7 @@ public class ShellFeed extends AbstractFeed {
         for (final ShellPollIdentifier pollInfo : polls.keySet()) {
             Set<ShellPollConfig<?>> configs = polls.get(pollInfo);
             long minPeriod = Integer.MAX_VALUE;
-            Set<AttributePollHandler<SshPollValue>> handlers = Sets.newLinkedHashSet();
+            Set<AttributePollHandler<? super SshPollValue>> handlers = Sets.newLinkedHashSet();
 
             for (ShellPollConfig<?> config : configs) {
                 handlers.add(new AttributePollHandler<SshPollValue>(config, entity,
this));
@@ -198,7 +199,7 @@ public class ShellFeed extends AbstractFeed {
                             Optional<Integer> exitCode = Optional.fromNullable(taskWrapper.getExitCode());
                             return new SshPollValue(null, exitCode.or(-1), taskWrapper.getStdout(),
taskWrapper.getStderr());
                         }}, 
-                    new DelegatingPollHandler(handlers), 
+                    new DelegatingPollHandler<SshPollValue>(handlers), 
                     minPeriod);
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6605118c/core/src/main/java/brooklyn/event/feed/ssh/SshFeed.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/event/feed/ssh/SshFeed.java b/core/src/main/java/brooklyn/event/feed/ssh/SshFeed.java
index 8aee368..7492f75 100644
--- a/core/src/main/java/brooklyn/event/feed/ssh/SshFeed.java
+++ b/core/src/main/java/brooklyn/event/feed/ssh/SshFeed.java
@@ -211,7 +211,7 @@ public class SshFeed extends AbstractFeed {
                         public SshPollValue call() throws Exception {
                             return exec(pollInfo.command.get(), pollInfo.env.get());
                         }}, 
-                    new DelegatingPollHandler<SshPollValue>(handlers), 
+                    new DelegatingPollHandler<SshPollValue>(handlers),
                     minPeriod);
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6605118c/core/src/main/java/brooklyn/event/feed/ssh/SshPollConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/event/feed/ssh/SshPollConfig.java b/core/src/main/java/brooklyn/event/feed/ssh/SshPollConfig.java
index 9e86f5b..58acbbb 100644
--- a/core/src/main/java/brooklyn/event/feed/ssh/SshPollConfig.java
+++ b/core/src/main/java/brooklyn/event/feed/ssh/SshPollConfig.java
@@ -1,7 +1,6 @@
 package brooklyn.event.feed.ssh;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
@@ -15,13 +14,11 @@ import brooklyn.util.collections.MutableMap;
 import com.google.common.base.Predicate;
 import com.google.common.base.Supplier;
 import com.google.common.base.Suppliers;
-import com.google.common.collect.Maps;
 
 public class SshPollConfig<T> extends PollConfig<SshPollValue, T, SshPollConfig<T>>
{
 
     private Supplier<String> commandSupplier;
     private List<Supplier<Map<String,String>>> dynamicEnvironmentSupplier
= MutableList.of();
-    private Map<String,String> fixedEnvironment = Maps.newLinkedHashMap();
 
     public static final Predicate<SshPollValue> DEFAULT_SUCCESS = new Predicate<SshPollValue>()
{
         @Override
@@ -37,7 +34,6 @@ public class SshPollConfig<T> extends PollConfig<SshPollValue,
T, SshPollConfig<
     public SshPollConfig(SshPollConfig<T> other) {
         super(other);
         commandSupplier = other.commandSupplier;
-        fixedEnvironment = other.fixedEnvironment;
     }
     
     /** @deprecated since 0.7.0; use {@link #getCommandSupplier()} and resolve just-in-time
*/
@@ -57,13 +53,11 @@ public class SshPollConfig<T> extends PollConfig<SshPollValue,
T, SshPollConfig<
             @Override
             public Map<String, String> get() {
                 Map<String,String> result = MutableMap.of();
-                result.putAll(fixedEnvironment);
                 for (Supplier<Map<String, String>> envS: dynamicEnvironmentSupplier)
{
                     if (envS!=null) {
                         Map<String, String> envM = envS.get();
                         if (envM!=null) {
-                            // TODO deeply additive?
-                            result.putAll(envM);
+                            mergeEnvMaps(envM, result);
                         }
                     }
                 }
@@ -72,6 +66,11 @@ public class SshPollConfig<T> extends PollConfig<SshPollValue,
T, SshPollConfig<
         };
     }
     
+    protected void mergeEnvMaps(Map<String,String> supplied, Map<String,String>
target) {
+        if (supplied==null) return;
+        // as the value is a string there is no need to look at deep merge behaviour
+        target.putAll(supplied);
+    }
 
     public SshPollConfig<T> command(String val) { return command(Suppliers.ofInstance(val));
}
     public SshPollConfig<T> command(Supplier<String> val) {
@@ -79,10 +78,9 @@ public class SshPollConfig<T> extends PollConfig<SshPollValue,
T, SshPollConfig<
         return this;
     }
 
-    /** add the given env param */
+    /** add the given env param; sequence is as per {@link #env(Supplier)} */
     public SshPollConfig<T> env(String key, String val) {
-        fixedEnvironment.put(checkNotNull(key, "key"), checkNotNull(val, "val"));
-        return this;
+        return env(Collections.singletonMap(key, val));
     }
     
     /** add the given env params; sequence is as per {@link #env(Supplier)} */
@@ -90,13 +88,16 @@ public class SshPollConfig<T> extends PollConfig<SshPollValue,
T, SshPollConfig<
         return env(Suppliers.ofInstance(val));
     }
 
-    /** adds the given dynamic env supplier. 
-     * these are put into the result in the order they are applied, with fixed values
-     * set via {@link #env(String, String)} preceding all these.
+    /** 
+     * adds the given dynamic supplier of environment variables.
+     * <p>
+     * use of a supplier allows env vars to be computed on each execution,
+     * for example to take the most recent sensor values.
      * <p>
-     * currently addition is not deep, in the case of two identical top-level keys 
-     * the latter one kills anything from the former. 
-     * this behaviour may change in future. */
+     * in the case of multiple map suppliers, static maps, or static {@link #env(String,
String)} 
+     * key value pairs, the order in which they are specified here is the order
+     * in which they are computed and applied. 
+     **/
     public SshPollConfig<T> env(Supplier<Map<String,String>> val) {
         dynamicEnvironmentSupplier.add(val);
         return this;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6605118c/docs/use/guide/defining-applications/yaml-reference.md
----------------------------------------------------------------------
diff --git a/docs/use/guide/defining-applications/yaml-reference.md b/docs/use/guide/defining-applications/yaml-reference.md
index 3ca1157..49dde18 100644
--- a/docs/use/guide/defining-applications/yaml-reference.md
+++ b/docs/use/guide/defining-applications/yaml-reference.md
@@ -22,7 +22,7 @@ defining types:
 
 * `io.brooklyn.package.JavaEntityClass`
 * `java:io.brooklyn.package.JavaEntityClass`
-* *OSGi and YAML references are coming soon!*
+* *OSGi and YAML references are coming soon!* <!-- TODO -->
 
 A reference of some of the common service `type` instances used is included in a section
below.
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6605118c/software/base/src/main/java/brooklyn/entity/software/ssh/SshCommandSensor.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/software/ssh/SshCommandSensor.java
b/software/base/src/main/java/brooklyn/entity/software/ssh/SshCommandSensor.java
index 8fe42a1..5a8323b 100644
--- a/software/base/src/main/java/brooklyn/entity/software/ssh/SshCommandSensor.java
+++ b/software/base/src/main/java/brooklyn/entity/software/ssh/SshCommandSensor.java
@@ -42,12 +42,6 @@ public final class SshCommandSensor<T extends String> extends AddSensor<String,A
     public void apply(final EntityLocal entity) {
         super.apply(entity);
 
-//        TODO:
-//        parameters for effectors <- test 
-//        text for new example, 
-//        and test for new example
-//        javadoc for this class
-        
         Supplier<Map<String,String>> envSupplier = new Supplier<Map<String,String>>()
{
             @Override
             public Map<String, String> get() {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6605118c/software/base/src/main/java/brooklyn/event/feed/jmx/JmxFeed.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/event/feed/jmx/JmxFeed.java b/software/base/src/main/java/brooklyn/event/feed/jmx/JmxFeed.java
index f591bb9..17ff762 100644
--- a/software/base/src/main/java/brooklyn/event/feed/jmx/JmxFeed.java
+++ b/software/base/src/main/java/brooklyn/event/feed/jmx/JmxFeed.java
@@ -149,11 +149,13 @@ public class JmxFeed extends AbstractFeed {
         this.jmxConnectionTimeout = builder.jmxConnectionTimeout;
         
         for (JmxAttributePollConfig<?> config : builder.attributePolls) {
+            @SuppressWarnings({ "rawtypes", "unchecked" })
             JmxAttributePollConfig<?> configCopy = new JmxAttributePollConfig(config);
             if (configCopy.getPeriod() < 0) configCopy.period(builder.period, builder.periodUnits);
             attributePolls.put(configCopy.getObjectName().getCanonicalName() + configCopy.getAttributeName(),
configCopy);
         }
         for (JmxOperationPollConfig<?> config : builder.operationPolls) {
+            @SuppressWarnings({ "rawtypes", "unchecked" })
             JmxOperationPollConfig<?> configCopy = new JmxOperationPollConfig(config);
             if (configCopy.getPeriod() < 0) configCopy.period(builder.period, builder.periodUnits);
             operationPolls.put(configCopy.buildOperationIdentity(), configCopy);
@@ -252,7 +254,7 @@ public class JmxFeed extends AbstractFeed {
      * Registers to poll a jmx-operation for an ObjectName, where all the given configs are
for the same ObjectName + operation + parameters.
      */
     private void registerOperationPoller(Set<JmxOperationPollConfig<?>> configs)
{
-        Set<AttributePollHandler<Object>> handlers = Sets.newLinkedHashSet();
+        Set<AttributePollHandler<? super Object>> handlers = Sets.newLinkedHashSet();
         long minPeriod = Integer.MAX_VALUE;
         
         final ObjectName objectName = Iterables.get(configs, 0).getObjectName();
@@ -276,14 +278,14 @@ public class JmxFeed extends AbstractFeed {
                         }
                     }
                 }, 
-                new DelegatingPollHandler(handlers), minPeriod);
+                new DelegatingPollHandler<Object>(handlers), minPeriod);
     }
 
     /**
      * Registers to poll a jmx-attribute for an ObjectName, where all the given configs are
for that same ObjectName + attribute.
      */
     private void registerAttributePoller(Set<JmxAttributePollConfig<?>> configs)
{
-        Set<AttributePollHandler<Object>> handlers = Sets.newLinkedHashSet();
+        Set<AttributePollHandler<? super Object>> handlers = Sets.newLinkedHashSet();
         long minPeriod = Integer.MAX_VALUE;
         
         final ObjectName objectName = Iterables.get(configs, 0).getObjectName();
@@ -302,14 +304,14 @@ public class JmxFeed extends AbstractFeed {
                         return helper.getAttribute(objectName, jmxAttributeName);
                     }
                 }, 
-                new DelegatingPollHandler(handlers), minPeriod);
+                new DelegatingPollHandler<Object>(handlers), minPeriod);
     }
 
     /**
      * Registers to subscribe to notifications for an ObjectName, where all the given configs
are for that same ObjectName + filter.
      */
     private NotificationListener registerNotificationListener(Set<JmxNotificationSubscriptionConfig<?>>
configs) {
-        final List<AttributePollHandler<javax.management.Notification>> handlers
= Lists.newArrayList();
+        final List<AttributePollHandler<? super javax.management.Notification>>
handlers = Lists.newArrayList();
 
         final ObjectName objectName = Iterables.get(configs, 0).getObjectName();
         final NotificationFilter filter = Iterables.get(configs, 0).getNotificationFilter();
@@ -329,7 +331,7 @@ public class JmxFeed extends AbstractFeed {
             };
             handlers.add(handler);
         }
-        final PollHandler<javax.management.Notification> compoundHandler = new DelegatingPollHandler(handlers);
+        final PollHandler<javax.management.Notification> compoundHandler = new DelegatingPollHandler<javax.management.Notification>(handlers);
         
         NotificationListener listener = new NotificationListener() {
             @Override public void handleNotification(Notification notification, Object handback)
{

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6605118c/software/base/src/main/java/brooklyn/event/feed/jmx/JmxOperationPollConfig.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/event/feed/jmx/JmxOperationPollConfig.java
b/software/base/src/main/java/brooklyn/event/feed/jmx/JmxOperationPollConfig.java
index 1dc60ca..4220455 100644
--- a/software/base/src/main/java/brooklyn/event/feed/jmx/JmxOperationPollConfig.java
+++ b/software/base/src/main/java/brooklyn/event/feed/jmx/JmxOperationPollConfig.java
@@ -21,6 +21,7 @@ public class JmxOperationPollConfig<T> extends PollConfig<Object,
T, JmxOperatio
     private List<String> signature = Collections.emptyList();
     private List<?> params = Collections.emptyList();
 
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     public JmxOperationPollConfig(AttributeSensor<T> sensor) {
         super(sensor);
         onSuccess((Function)Functions.identity());


Mime
View raw message