brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From geom...@apache.org
Subject [3/5] brooklyn-server git commit: Miscellany
Date Fri, 20 Jan 2017 15:27:23 GMT
Miscellany

* Relax the generics on BasicJcloudsLocationCustomizer's constructor
* Typos
* SshCommandSensor calls entity.addFeed with itself
* Delete unused test class
* Better toString in WebAppContextProvider
* JcloudsLocation temporary ssh locations respect configured ssh tools


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

Branch: refs/heads/master
Commit: b6d0ab22a1996174f5e8aac4cd81f59aa86b59a4
Parents: e631ffa
Author: Sam Corbett <sam.corbett@cloudsoftcorp.com>
Authored: Thu Dec 22 19:32:51 2016 +0000
Committer: Sam Corbett <sam.corbett@cloudsoftcorp.com>
Committed: Fri Jan 20 10:25:14 2017 +0000

----------------------------------------------------------------------
 .../org/apache/brooklyn/api/entity/EntitySpec.java   |  2 +-
 .../core/mgmt/internal/BasicSubscriptionContext.java |  2 +-
 .../brooklyn/core/sensor/ssh/SshCommandSensor.java   |  6 ++++--
 .../brooklyn/launcher/WebAppContextProvider.java     |  7 ++++---
 .../brooklyn/launcher/BrooklynLauncherTest.java      |  2 +-
 .../jclouds/BasicJcloudsLocationCustomizer.java      |  6 ++++--
 .../brooklyn/location/jclouds/JcloudsLocation.java   |  9 +++++++++
 ...cationReachabilityPredicateInstantiationTest.java | 15 ++++-----------
 .../filter/BrooklynPropertiesSecurityFilter.java     |  9 +++++++--
 9 files changed, 35 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b6d0ab22/api/src/main/java/org/apache/brooklyn/api/entity/EntitySpec.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/api/entity/EntitySpec.java b/api/src/main/java/org/apache/brooklyn/api/entity/EntitySpec.java
index 30df4ed..d431c17 100644
--- a/api/src/main/java/org/apache/brooklyn/api/entity/EntitySpec.java
+++ b/api/src/main/java/org/apache/brooklyn/api/entity/EntitySpec.java
@@ -382,7 +382,7 @@ public class EntitySpec<T extends Entity> extends AbstractBrooklynObjectSpec<T,E
     }
     
      /** adds a location to the spec
-      * @deprecated since 0.9.0 pass a spec, using {@link #enricherSpecs(Iterable)} */ 
+      * @deprecated since 0.9.0 pass a spec, using {@link #location(LocationSpec)} */
      @Deprecated
      // there are still many places in tests where we use this;
      // in some we want to force the use of a given location.

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b6d0ab22/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/BasicSubscriptionContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/BasicSubscriptionContext.java
b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/BasicSubscriptionContext.java
index 2c6ab65..3064fc0 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/BasicSubscriptionContext.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/BasicSubscriptionContext.java
@@ -166,7 +166,7 @@ public class BasicSubscriptionContext implements SubscriptionContext {
         for (SubscriptionHandle s : subscriptionsCopy) {
             count++; 
             boolean result = unsubscribe(s); 
-            if (!result) LOG.warn("When unsubscribing from all of {}, unsubscribe of {} return
false", subscriber, s);
+            if (!result) LOG.warn("When unsubscribing from all of {}, unsubscribe of {} returned
false", subscriber, s);
         }
         return count;
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b6d0ab22/core/src/main/java/org/apache/brooklyn/core/sensor/ssh/SshCommandSensor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/sensor/ssh/SshCommandSensor.java
b/core/src/main/java/org/apache/brooklyn/core/sensor/ssh/SshCommandSensor.java
index 24bc2d4..eca50f7 100644
--- a/core/src/main/java/org/apache/brooklyn/core/sensor/ssh/SshCommandSensor.java
+++ b/core/src/main/java/org/apache/brooklyn/core/sensor/ssh/SshCommandSensor.java
@@ -78,7 +78,7 @@ public final class SshCommandSensor<T> extends AddSensor<T>
{
         super(params);
 
         // TODO create a supplier for the command string to support attribute embedding
-        command = Preconditions.checkNotNull(params.get(SENSOR_COMMAND), "SSH command must
be dupplied when defining this sensor");
+        command = Preconditions.checkNotNull(params.get(SENSOR_COMMAND), "SSH command must
be supplied when defining this sensor");
         executionDir = params.get(SENSOR_EXECUTION_DIR);
         sensorEnv = params.get(SENSOR_SHELL_ENVIRONMENT);
     }
@@ -131,11 +131,13 @@ public final class SshCommandSensor<T> extends AddSensor<T>
{
                             return TypeCoercions.coerce(Strings.trimEnd(input), (Class<T>)
sensor.getType());
                         }}, SshValueFunctions.stdout()));
 
-        SshFeed.builder()
+        SshFeed feed = SshFeed.builder()
                 .entity(entity)
                 .onlyIfServiceUp()
                 .poll(pollConfig)
                 .build();
+
+        entity.addFeed(feed);
     }
 
     @Beta

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b6d0ab22/launcher/src/main/java/org/apache/brooklyn/launcher/WebAppContextProvider.java
----------------------------------------------------------------------
diff --git a/launcher/src/main/java/org/apache/brooklyn/launcher/WebAppContextProvider.java
b/launcher/src/main/java/org/apache/brooklyn/launcher/WebAppContextProvider.java
index fc8b89f..840e541 100644
--- a/launcher/src/main/java/org/apache/brooklyn/launcher/WebAppContextProvider.java
+++ b/launcher/src/main/java/org/apache/brooklyn/launcher/WebAppContextProvider.java
@@ -52,8 +52,8 @@ public class WebAppContextProvider {
      * @param warUrl The url from which the war should be obtained.
      */
     public WebAppContextProvider(String pathSpec, String warUrl) {
-        this.warUrl = warUrl;
-        String cleanPathSpec = pathSpec;
+        this.warUrl = checkNotNull(warUrl, "warUrl");
+        String cleanPathSpec = checkNotNull(pathSpec, "pathSpec");
         while (cleanPathSpec.startsWith("/")) {
             cleanPathSpec = cleanPathSpec.substring(1);
         }
@@ -116,7 +116,8 @@ public class WebAppContextProvider {
 
     @Override
     public String toString() {
-        return warUrl + "@" + pathSpec;
+        final String path = this.pathSpec.isEmpty() ? "/" : this.pathSpec;
+        return warUrl + "@" + path;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b6d0ab22/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherTest.java
----------------------------------------------------------------------
diff --git a/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherTest.java
b/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherTest.java
index fe5eda6..c3db7ad 100644
--- a/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherTest.java
+++ b/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherTest.java
@@ -73,7 +73,7 @@ public class BrooklynLauncherTest {
         if (launcher != null) launcher.terminate();
         launcher = null;
     }
-    
+
     // Integration because takes a few seconds to start web-console
     @Test(groups="Integration")
     public void testStartsWebServerOnExpectectedPort() throws Exception {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b6d0ab22/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/BasicJcloudsLocationCustomizer.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/BasicJcloudsLocationCustomizer.java
b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/BasicJcloudsLocationCustomizer.java
index dc03447..93f53c0 100644
--- a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/BasicJcloudsLocationCustomizer.java
+++ b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/BasicJcloudsLocationCustomizer.java
@@ -29,8 +29,10 @@ import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.core.config.ConfigKeys;
 import org.apache.brooklyn.core.entity.BrooklynConfigKeys;
 import org.apache.brooklyn.core.location.LocationConfigKeys;
+import org.apache.brooklyn.core.mgmt.BrooklynTaskTags;
 import org.apache.brooklyn.core.objs.BasicConfigurableObject;
 import org.apache.brooklyn.util.core.config.ConfigBag;
+import org.apache.brooklyn.util.core.task.Tasks;
 import org.jclouds.compute.ComputeService;
 import org.jclouds.compute.domain.Template;
 import org.jclouds.compute.domain.TemplateBuilder;
@@ -55,10 +57,10 @@ public class BasicJcloudsLocationCustomizer extends BasicConfigurableObject
impl
     private static final Logger LOG = LoggerFactory.getLogger(BasicJcloudsLocationCustomizer.class);
 
     public BasicJcloudsLocationCustomizer() {
-        this(ImmutableMap.<String, String>of());
+        this(ImmutableMap.of());
     }
 
-    public BasicJcloudsLocationCustomizer(Map<String, String> params) {
+    public BasicJcloudsLocationCustomizer(Map<?, ?> params) {
         this(ConfigBag.newInstance(params));
     }
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b6d0ab22/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java
b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java
index d7ff9e8..cb6a8e8 100644
--- a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java
+++ b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java
@@ -1612,6 +1612,11 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation
im
         sshProps.put("port", hostAndPort.getPort());
         sshProps.put(AbstractLocation.TEMPORARY_LOCATION.getName(), true);
         sshProps.put(LocalLocationManager.CREATE_UNMANAGED.getName(), true);
+        String sshClass = config().get(SshMachineLocation.SSH_TOOL_CLASS);
+        if (Strings.isNonBlank(sshClass)) {
+            sshProps.put(SshMachineLocation.SSH_TOOL_CLASS.getName(), sshClass);
+        }
+
         sshProps.remove("id");
         sshProps.remove("password");
         sshProps.remove("privateKeyData");
@@ -1647,6 +1652,10 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation
im
         winrmProps.remove("privateKeyData");
         winrmProps.remove("privateKeyFile");
         winrmProps.remove("privateKeyPassphrase");
+        String winrmClass = config().get(WinRmMachineLocation.WINRM_TOOL_CLASS);
+        if (Strings.isNonBlank(winrmClass)) {
+            winrmProps.put(WinRmMachineLocation.WINRM_TOOL_CLASS.getName(), winrmClass);
+        }
 
         if (initialPassword.isPresent()) winrmProps.put("password", initialPassword.get());
         if (initialPrivateKey.isPresent()) winrmProps.put("privateKeyData", initialPrivateKey.get());

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b6d0ab22/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationReachabilityPredicateInstantiationTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationReachabilityPredicateInstantiationTest.java
b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationReachabilityPredicateInstantiationTest.java
index 8178639..41377d1 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationReachabilityPredicateInstantiationTest.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsLocationReachabilityPredicateInstantiationTest.java
@@ -166,11 +166,14 @@ public class JcloudsLocationReachabilityPredicateInstantiationTest {
     }
 
     public static class RecordingReachabilityCheckProtectedMapConstructor implements Predicate<HostAndPort>
{
+        @SuppressWarnings("unused")
         public RecordingReachabilityCheckProtectedMapConstructor() {
             TEST_INIT_MAP_AND_EMPTY_CONSTRUCTOR_COUNTER.getAndIncrement();
         }
 
-        protected RecordingReachabilityCheckProtectedMapConstructor(Map<String, Object>
flags) {}
+        @SuppressWarnings("unused")
+        protected RecordingReachabilityCheckProtectedMapConstructor(Map<String, Object>
flags) {
+        }
 
         @Override
         public boolean apply(@Nullable HostAndPort input) {
@@ -178,14 +181,4 @@ public class JcloudsLocationReachabilityPredicateInstantiationTest {
         }
     }
 
-    public static class BailOutJcloudsLocation extends JcloudsLocation {
-        public BailOutJcloudsLocation() {
-            super();
-        }
-
-        @Override
-        public String getFirstReachableAddress(NodeMetadata nodeMetada, ConfigBag setup)
{
-            return super.getFirstReachableAddress(nodeMetada, setup);
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b6d0ab22/rest/rest-server/src/main/java/org/apache/brooklyn/rest/filter/BrooklynPropertiesSecurityFilter.java
----------------------------------------------------------------------
diff --git a/rest/rest-server/src/main/java/org/apache/brooklyn/rest/filter/BrooklynPropertiesSecurityFilter.java
b/rest/rest-server/src/main/java/org/apache/brooklyn/rest/filter/BrooklynPropertiesSecurityFilter.java
index c1d2d9f..8b3a04b 100644
--- a/rest/rest-server/src/main/java/org/apache/brooklyn/rest/filter/BrooklynPropertiesSecurityFilter.java
+++ b/rest/rest-server/src/main/java/org/apache/brooklyn/rest/filter/BrooklynPropertiesSecurityFilter.java
@@ -148,8 +148,13 @@ public class BrooklynPropertiesSecurityFilter implements Filter {
         String authorization = request.getHeader("Authorization");
         if (authorization != null) {
             String userpass = new String(Base64.decodeBase64(authorization.substring(6)));
-            user = userpass.substring(0, userpass.indexOf(":"));
-            pass = userpass.substring(userpass.indexOf(":") + 1);
+            int idxColon = userpass.indexOf(":");
+            if (idxColon >= 0) {
+                user = userpass.substring(0, idxColon);
+                pass = userpass.substring(idxColon + 1);
+            } else {
+                return false;
+            }
         }
         if (provider.authenticate(session, user, pass)) {
             if (user != null) {


Mime
View raw message