brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [1/4] brooklyn-server git commit: Fix classRenames for SshPollConfig anonymous classes
Date Thu, 16 Mar 2017 09:26:03 GMT
Repository: brooklyn-server
Updated Branches:
  refs/heads/master 37c37477b -> b95932a7c


Fix classRenames for SshPollConfig anonymous classes

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

Branch: refs/heads/master
Commit: ad73fcf99676b4c06e30ac6f1ed1093225087f05
Parents: 37c3747
Author: Aled Sage <aled.sage@gmail.com>
Authored: Thu Mar 16 00:04:03 2017 +0000
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Thu Mar 16 00:17:46 2017 +0000

----------------------------------------------------------------------
 .../apache/brooklyn/feed/CommandPollConfig.java | 16 +++++++-
 .../apache/brooklyn/feed/ssh/SshPollConfig.java | 43 ++++++++++++++++++++
 .../deserializingClassRenames.properties        |  4 +-
 3 files changed, 59 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ad73fcf9/core/src/main/java/org/apache/brooklyn/feed/CommandPollConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/feed/CommandPollConfig.java b/core/src/main/java/org/apache/brooklyn/feed/CommandPollConfig.java
index f8c5b81..f3d8cc4 100644
--- a/core/src/main/java/org/apache/brooklyn/feed/CommandPollConfig.java
+++ b/core/src/main/java/org/apache/brooklyn/feed/CommandPollConfig.java
@@ -41,14 +41,26 @@ import org.apache.brooklyn.util.collections.MutableMap;
 public class CommandPollConfig<T> extends PollConfig<SshPollValue, T, CommandPollConfig<T>>
{
 
     private Supplier<String> commandSupplier;
-    private List<Supplier<Map<String,String>>> dynamicEnvironmentSupplier
= MutableList.of();
+    protected List<Supplier<Map<String,String>>> dynamicEnvironmentSupplier
= MutableList.of();
 
-    public static final Predicate<SshPollValue> DEFAULT_SUCCESS = new Predicate<SshPollValue>()
{
+    // TODO Kept in case it's persisted; new code will not use this.
+    // Can't just use deserializingClassRenames.properties, because persistence format
+    // for a static versus anonymous (non-static) inner class is different.
+    private static final Predicate<SshPollValue> unused_DEFAULT_SUCCESS = new Predicate<SshPollValue>()
{
         @Override
         public boolean apply(@Nullable SshPollValue input) {
             return input != null && input.getExitStatus() == 0;
         }};
 
+    public static final Predicate<SshPollValue> DEFAULT_SUCCESS = new DefaultSuccessPredicate();
+
+    private static class DefaultSuccessPredicate implements Predicate<SshPollValue>
{
+        @Override
+        public boolean apply(@Nullable SshPollValue input) {
+            return input != null && input.getExitStatus() == 0;
+        }
+    }
+    
     public static <T> CommandPollConfig<T> forSensor(AttributeSensor<T>
sensor) {
         return new CommandPollConfig<T>(sensor);
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ad73fcf9/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 859d30f..d59a04f 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
@@ -18,8 +18,16 @@
  */
 package org.apache.brooklyn.feed.ssh;
 
+import java.util.Map;
+
+import javax.annotation.Nullable;
+
 import org.apache.brooklyn.api.sensor.AttributeSensor;
 import org.apache.brooklyn.feed.CommandPollConfig;
+import org.apache.brooklyn.util.collections.MutableMap;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
 
 /**
  * @deprecated since 0.11.0. Please use {@link CommandPollConfig}.
@@ -38,4 +46,39 @@ public class SshPollConfig<T> extends CommandPollConfig<T>
{
     public SshPollConfig<T> self() {
         return this;
     }
+    
+    // TODO Kept in case it's persisted; new code will not use this.
+    @SuppressWarnings("unused")
+    private static final Predicate<SshPollValue> unused_DEFAULT_SUCCESS = new Predicate<SshPollValue>()
{
+        @Override
+        public boolean apply(@Nullable SshPollValue input) {
+            return input != null && input.getExitStatus() == 0;
+        }};
+        
+    // TODO Kept in case it's persisted; new code will not use this.
+    // Can't just use deserializingClassRenames.properties, because persistence format
+    // for a static versus anonymous (non-static) inner class is different. 
+    @SuppressWarnings("unused")
+    private void unused_getEnvSupplier() {
+        new Supplier<Map<String,String>>() {
+            @Override
+            public Map<String, String> get() {
+                Map<String,String> result = MutableMap.of();
+                for (Supplier<Map<String, String>> envS: dynamicEnvironmentSupplier)
{
+                    if (envS!=null) {
+                        Map<String, String> envM = envS.get();
+                        if (envM!=null) {
+                            mergeEnvMaps(envM, result);
+                        }
+                    }
+                }
+                return result;
+            }
+            private 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);
+            }
+        };
+    }
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ad73fcf9/core/src/main/resources/org/apache/brooklyn/core/mgmt/persist/deserializingClassRenames.properties
----------------------------------------------------------------------
diff --git a/core/src/main/resources/org/apache/brooklyn/core/mgmt/persist/deserializingClassRenames.properties
b/core/src/main/resources/org/apache/brooklyn/core/mgmt/persist/deserializingClassRenames.properties
index 0e664cf..992d9e5 100644
--- a/core/src/main/resources/org/apache/brooklyn/core/mgmt/persist/deserializingClassRenames.properties
+++ b/core/src/main/resources/org/apache/brooklyn/core/mgmt/persist/deserializingClassRenames.properties
@@ -1452,5 +1452,5 @@ brooklyn.networking.vclouddirector.NatPredicates
 brooklyn.networking.vclouddirector.NatService                                    : brooklyn.networking.vclouddirector.nat.NatService
 brooklyn.networking.vclouddirector.PortForwardingConfig                          : brooklyn.networking.vclouddirector.nat.PortForwardingConfig
 
-org.apache.brooklyn.feed.ssh.SshFeed$SshPollIdentifier : org.apache.brooklyn.feed.AbstractCommandFeed$CommandPollIdentifier
-org.apache.brooklyn.feed.ssh.SshPollConfig$2 : org.apache.brooklyn.feed.CommandPollConfig$CombiningEnvSupplier
\ No newline at end of file
+org.apache.brooklyn.feed.ssh.SshFeed$SshPollIdentifier                           : org.apache.brooklyn.feed.AbstractCommandFeed$CommandPollIdentifier
+org.apache.brooklyn.feed.ssh.SshPollConfig$CombiningEnvSupplier                  : org.apache.brooklyn.feed.CommandPollConfig$CombiningEnvSupplier


Mime
View raw message