brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [05/16] git commit: misc tidies and error checks
Date Sun, 19 Oct 2014 00:59:52 GMT
misc tidies and error checks


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

Branch: refs/heads/master
Commit: baee8c5d567e3655d6cd678c3dc35f9c26cab9f8
Parents: 306b027
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Sat Oct 18 01:40:42 2014 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Sat Oct 18 01:41:53 2014 +0100

----------------------------------------------------------------------
 .../entity/basic/ServiceStateLogic.java         |  6 ++--
 .../java/brooklyn/event/feed/http/HttpFeed.java |  3 +-
 .../brooklyn/launcher/BrooklynLauncher.java     |  3 ++
 .../java/brooklyn/util/guava/Functionals.java   |  1 +
 .../main/java/brooklyn/util/javalang/Enums.java | 30 +++++++++++++++++++-
 5 files changed, 39 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/baee8c5d/core/src/main/java/brooklyn/entity/basic/ServiceStateLogic.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/ServiceStateLogic.java b/core/src/main/java/brooklyn/entity/basic/ServiceStateLogic.java
index 049eff1..ac1bfb2 100644
--- a/core/src/main/java/brooklyn/entity/basic/ServiceStateLogic.java
+++ b/core/src/main/java/brooklyn/entity/basic/ServiceStateLogic.java
@@ -252,8 +252,10 @@ public class ServiceStateLogic {
             if (Boolean.TRUE.equals(serviceUp) && (problems==null || problems.isEmpty()))
{
                 return Lifecycle.RUNNING;
             } else {
-                log.warn("Setting "+entity+" "+Lifecycle.ON_FIRE+" due to problems when expected
running, up="+serviceUp+", "+
-                    (problems==null || problems.isEmpty() ? "not-up-indicators: "+entity.getAttribute(SERVICE_NOT_UP_INDICATORS)
: "problems: "+problems));
+                if (!Lifecycle.ON_FIRE.equals(entity.getAttribute(SERVICE_STATE_ACTUAL)))
{
+                    log.warn("Setting "+entity+" "+Lifecycle.ON_FIRE+" due to problems when
expected running, up="+serviceUp+", "+
+                        (problems==null || problems.isEmpty() ? "not-up-indicators: "+entity.getAttribute(SERVICE_NOT_UP_INDICATORS)
: "problems: "+problems));
+                }
                 return Lifecycle.ON_FIRE;
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/baee8c5d/core/src/main/java/brooklyn/event/feed/http/HttpFeed.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/event/feed/http/HttpFeed.java b/core/src/main/java/brooklyn/event/feed/http/HttpFeed.java
index f931d01..9547599 100644
--- a/core/src/main/java/brooklyn/event/feed/http/HttpFeed.java
+++ b/core/src/main/java/brooklyn/event/feed/http/HttpFeed.java
@@ -107,6 +107,7 @@ public class HttpFeed extends AbstractFeed {
 
     public static final Logger log = LoggerFactory.getLogger(HttpFeed.class);
 
+    @SuppressWarnings("serial")
     public static final ConfigKey<SetMultimap<HttpPollIdentifier, HttpPollConfig<?>>>
POLLS = ConfigKeys.newConfigKey(
             new TypeToken<SetMultimap<HttpPollIdentifier, HttpPollConfig<?>>>()
{},
             "polls");
@@ -197,7 +198,7 @@ public class HttpFeed extends AbstractFeed {
             return this;
         }
         public Builder credentialsIfNotNull(String username, String password) {
-            if (username != null) {
+            if (username != null && password != null) {
                 this.credentials = new UsernamePasswordCredentials(username, password);
             }
             return this;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/baee8c5d/usage/launcher/src/main/java/brooklyn/launcher/BrooklynLauncher.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/main/java/brooklyn/launcher/BrooklynLauncher.java b/usage/launcher/src/main/java/brooklyn/launcher/BrooklynLauncher.java
index d6dd8a1..598d176 100644
--- a/usage/launcher/src/main/java/brooklyn/launcher/BrooklynLauncher.java
+++ b/usage/launcher/src/main/java/brooklyn/launcher/BrooklynLauncher.java
@@ -49,6 +49,7 @@ import brooklyn.config.BrooklynProperties;
 import brooklyn.config.BrooklynServerConfig;
 import brooklyn.config.BrooklynServiceAttributes;
 import brooklyn.config.ConfigKey;
+import brooklyn.config.ConfigPredicates;
 import brooklyn.entity.Application;
 import brooklyn.entity.basic.ApplicationBuilder;
 import brooklyn.entity.basic.BrooklynShutdownHooks;
@@ -750,6 +751,8 @@ public class BrooklynLauncher {
             brooklynProperties.put(
                     BrooklynWebConfig.SECURITY_PROVIDER_CLASSNAME,
                     BrooklynUserWithRandomPasswordSecurityProvider.class.getName());
+        } else {
+            LOG.debug("Starting Brooklyn using security properties: "+brooklynProperties.submap(ConfigPredicates.startingWith(BrooklynWebConfig.BASE_NAME_SECURITY)).asMapWithStringKeys());
         }
         if (bindAddress == null) bindAddress = Networking.ANY_NIC;
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/baee8c5d/utils/common/src/main/java/brooklyn/util/guava/Functionals.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/brooklyn/util/guava/Functionals.java b/utils/common/src/main/java/brooklyn/util/guava/Functionals.java
index dcbd9da..e24c475 100644
--- a/utils/common/src/main/java/brooklyn/util/guava/Functionals.java
+++ b/utils/common/src/main/java/brooklyn/util/guava/Functionals.java
@@ -21,6 +21,7 @@ package brooklyn.util.guava;
 import java.util.concurrent.Callable;
 
 import brooklyn.util.guava.IfFunctions.IfFunctionBuilderApplyingFirst;
+import brooklyn.util.javalang.Enums;
 
 import com.google.common.base.Function;
 import com.google.common.base.Functions;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/baee8c5d/utils/common/src/main/java/brooklyn/util/javalang/Enums.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/brooklyn/util/javalang/Enums.java b/utils/common/src/main/java/brooklyn/util/javalang/Enums.java
index 9b18bbe..f79fb6e 100644
--- a/utils/common/src/main/java/brooklyn/util/javalang/Enums.java
+++ b/utils/common/src/main/java/brooklyn/util/javalang/Enums.java
@@ -33,7 +33,9 @@ import com.google.common.collect.Iterables;
 
 public class Enums {
     
-    /** returns a function which given an enum, returns its <code>name()</code>
function */
+    /** returns a function which given an enum, returns its <code>name()</code>
function 
+     * @deprecated since 0.7.0 use {@link #nameFunction()} to avoid inner class */
+    @Deprecated
     public static Function<Enum<?>,String> enumValueNameFunction() {
         return new Function<Enum<?>,String>() {
             @Override
@@ -43,6 +45,32 @@ public class Enums {
         };
     }
 
+    private static final class EnumToNameFunction implements Function<Enum<?>, String>
{
+        @Override
+        public String apply(Enum<?> input) {
+            return input.name();
+        }
+    }
+
+    /** returns a function which given an enum, returns its <code>name()</code>
function */
+    public static Function<Enum<?>,String> nameFunction() {
+        return new EnumToNameFunction();
+    }
+
+    private static final class EnumFromStringFunction<T extends Enum<?>> implements
Function<String,T> {
+        private final Class<T> type;
+        public EnumFromStringFunction(Class<T> type) { this.type = type; }
+        @Override
+        public T apply(String input) {
+            return valueOfIgnoreCase(type, input).orNull();
+        }
+    }
+
+    /** returns a function which given a string, produces an enum of the given type or null
*/
+    public static <T extends Enum<?>> Function<String,T> fromStringFunction(Class<T>
type) {
+        return new EnumFromStringFunction<T>(type);
+    }
+
     @SuppressWarnings("unchecked")
     private static <T extends Enum<?>> T[] values(Class<T> type) {
         try {


Mime
View raw message