You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/01/30 04:45:47 UTC

[01/10] incubator-brooklyn git commit: ensure install-label-salt-inferencing does not block

Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master a6f32193d -> 5b37751dc


ensure install-label-salt-inferencing does not block

otherwise setting a shell env var to include a port will cause it to block prematurely.
also clean up javadoc around `getNonBlocking` behaviour.


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

Branch: refs/heads/master
Commit: 5e9012b23e2bf9ad6423a5e0ef13c7ea8153947d
Parents: b28ba02
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Thu Jan 21 13:22:21 2016 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Thu Jan 21 13:25:36 2016 +0000

----------------------------------------------------------------------
 .../AbstractConfigurationSupportInternal.java   |  5 ++--
 .../core/objs/BrooklynObjectInternal.java       | 11 ++++++++
 .../brooklyn/util/core/flags/TypeCoercions.java |  4 +--
 .../brooklyn/util/core/task/ValueResolver.java  | 12 +++++++++
 ...wareProcessDriverLifecycleEffectorTasks.java |  3 ++-
 .../base/VanillaSoftwareProcessSshDriver.java   | 28 +++++++++++++++-----
 6 files changed, 51 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5e9012b2/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/objs/AbstractConfigurationSupportInternal.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/objs/AbstractConfigurationSupportInternal.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/objs/AbstractConfigurationSupportInternal.java
index 6cb8bb4..1d4cfea 100644
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/objs/AbstractConfigurationSupportInternal.java
+++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/objs/AbstractConfigurationSupportInternal.java
@@ -19,7 +19,6 @@
 
 package org.apache.brooklyn.core.objs;
 
-import java.util.concurrent.TimeUnit;
 import javax.annotation.Nullable;
 
 import org.apache.brooklyn.api.mgmt.ExecutionContext;
@@ -28,8 +27,8 @@ import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.config.ConfigKey.HasConfigKey;
 import org.apache.brooklyn.util.core.flags.TypeCoercions;
 import org.apache.brooklyn.util.core.task.Tasks;
+import org.apache.brooklyn.util.core.task.ValueResolver;
 import org.apache.brooklyn.util.guava.Maybe;
-import org.apache.brooklyn.util.time.Duration;
 
 public abstract class AbstractConfigurationSupportInternal implements BrooklynObjectInternal.ConfigurationSupportInternal {
 
@@ -63,7 +62,7 @@ public abstract class AbstractConfigurationSupportInternal implements BrooklynOb
         Object resolved = Tasks.resolving(unresolved)
                 .as(Object.class)
                 .defaultValue(marker)
-                .timeout(Duration.of(5, TimeUnit.MILLISECONDS))
+                .timeout(ValueResolver.REAL_REAL_QUICK_WAIT)
                 .context(getContext())
                 .swallowExceptions()
                 .get();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5e9012b2/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/objs/BrooklynObjectInternal.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/objs/BrooklynObjectInternal.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/objs/BrooklynObjectInternal.java
index 2da7463..89c4e32 100644
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/objs/BrooklynObjectInternal.java
+++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/objs/BrooklynObjectInternal.java
@@ -69,6 +69,9 @@ public interface BrooklynObjectInternal extends BrooklynObject, Rebindable {
         /**
          * Returns the uncoerced value for this config key, if available, not taking any default.
          * If there is no local value and there is an explicit inherited value, will return the inherited.
+         * Returns {@link Maybe#absent()} if the key is not explicitly set on this object or an ancestor.
+         * <p>
+         * See also {@link #getLocalRaw(ConfigKey).
          */
         @Beta
         Maybe<Object> getRaw(ConfigKey<?> key);
@@ -82,6 +85,9 @@ public interface BrooklynObjectInternal extends BrooklynObject, Rebindable {
         /**
          * Returns the uncoerced value for this config key, if available,
          * not following any inheritance chains and not taking any default.
+         * Returns {@link Maybe#absent()} if the key is not explicitly set on this object.
+         * <p>
+         * See also {@link #getRaw(ConfigKey).
          */
         @Beta
         Maybe<Object> getLocalRaw(ConfigKey<?> key);
@@ -96,6 +102,11 @@ public interface BrooklynObjectInternal extends BrooklynObject, Rebindable {
          * Attempts to coerce the value for this config key, if available,
          * taking a default and {@link Maybe#absent absent} if the uncoerced
          * cannot be resolved within a short timeframe.
+         * <p>
+         * Note: if no value for the key is available, not even as a default,
+         * this returns a {@link Maybe#isPresent()} containing <code>null</code>
+         * (following the semantics of {@link #get(ConfigKey)} 
+         * rather than {@link #getRaw(ConfigKey)}).
          */
         @Beta
         <T> Maybe<T> getNonBlocking(ConfigKey<T> key);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5e9012b2/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/flags/TypeCoercions.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/flags/TypeCoercions.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/flags/TypeCoercions.java
index f850fbd..872e713 100644
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/flags/TypeCoercions.java
+++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/flags/TypeCoercions.java
@@ -122,10 +122,10 @@ public class TypeCoercions {
         return coerce(value, TypeToken.of(targetType));
     }
 
-    /** @see #coerce(Object, Class) */
+    /** @see #coerce(Object, Class); allows a null value in the contents of the Maybe */
     public static <T> Maybe<T> tryCoerce(Object value, TypeToken<T> targetTypeToken) {
         try {
-            return Maybe.of( coerce(value, targetTypeToken) );
+            return Maybe.ofAllowingNull( coerce(value, targetTypeToken) );
         } catch (Throwable t) {
             Exceptions.propagateIfFatal(t);
             return Maybe.absent(t); 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5e9012b2/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/task/ValueResolver.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/task/ValueResolver.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/task/ValueResolver.java
index 2809482..0f85c3f 100644
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/task/ValueResolver.java
+++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/task/ValueResolver.java
@@ -42,6 +42,7 @@ import org.apache.brooklyn.util.time.Durations;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.annotations.Beta;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
@@ -57,14 +58,25 @@ import com.google.common.reflect.TypeToken;
  */
 public class ValueResolver<T> implements DeferredSupplier<T> {
 
+    // TODO most of these usages should be removed when we have
+    // an ability to run resolution in a non-blocking mode
+    // (i.e. running resolution tasks in the same thread,
+    // or in a context where they can only wait on subtasks
+    // which are guaranteed to have the same constraint)
     /** 
      * Period to wait if we're expected to return real quick 
      * but we want fast things to have time to finish.
      * <p>
      * Timings are always somewhat arbitrary but this at least
      * allows some intention to be captured in code rather than arbitrary values. */
+    @Beta
     public static Duration REAL_QUICK_WAIT = Duration.millis(50);
     /** 
+     * Like {@link #REAL_QUICK_WAIT} but even smaller, for use when potentially
+     * resolving multiple items in sequence. */
+    @Beta
+    public static Duration REAL_REAL_QUICK_WAIT = Duration.millis(5);
+    /** 
      * Period to wait if we're expected to return quickly 
      * but we want to be a bit more generous for things to finish,
      * without letting a caller get annoyed. 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5e9012b2/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcessDriverLifecycleEffectorTasks.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcessDriverLifecycleEffectorTasks.java b/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcessDriverLifecycleEffectorTasks.java
index 91aa294..cb4149a 100644
--- a/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcessDriverLifecycleEffectorTasks.java
+++ b/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcessDriverLifecycleEffectorTasks.java
@@ -118,7 +118,8 @@ public class SoftwareProcessDriverLifecycleEffectorTasks extends MachineLifecycl
         entity().initDriver(machine);
 
         // Note: must only apply config-sensors after adding to locations and creating driver; 
-        // otherwise can't do things like acquire free port from location, or allowing driver to set up ports
+        // otherwise can't do things like acquire free port from location
+        // or allowing driver to set up ports; but must be careful in init not to block on these!
         super.preStartCustom(machine);
         
         entity().preStart();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5e9012b2/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/VanillaSoftwareProcessSshDriver.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/VanillaSoftwareProcessSshDriver.java b/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/VanillaSoftwareProcessSshDriver.java
index dd01a69..9c955ed 100644
--- a/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/VanillaSoftwareProcessSshDriver.java
+++ b/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/VanillaSoftwareProcessSshDriver.java
@@ -21,11 +21,12 @@ package org.apache.brooklyn.entity.software.base;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.Objects;
 
 import org.apache.brooklyn.api.entity.EntityLocal;
 import org.apache.brooklyn.api.entity.drivers.downloads.DownloadResolver;
+import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.objs.BrooklynObjectInternal.ConfigurationSupportInternal;
 import org.apache.brooklyn.entity.software.base.lifecycle.ScriptHelper;
 import org.apache.brooklyn.location.ssh.SshMachineLocation;
 import org.apache.brooklyn.util.collections.MutableMap;
@@ -54,15 +55,30 @@ public class VanillaSoftwareProcessSshDriver extends AbstractSoftwareProcessSshD
      */
     @Override
     protected String getInstallLabelExtraSalt() {
+        // run non-blocking in case a value set later is used (e.g. a port)
+        Integer hash = hashCodeIfResolved(SoftwareProcess.DOWNLOAD_URL.getConfigKey(), 
+            VanillaSoftwareProcess.INSTALL_COMMAND, SoftwareProcess.SHELL_ENVIRONMENT);
         
-        Maybe<Object> url = getEntity().getConfigRaw(SoftwareProcess.DOWNLOAD_URL, true);
-        String installCommand = getEntity().getConfig(VanillaSoftwareProcess.INSTALL_COMMAND);
-        Map<String, Object> shellEnv = getEntity().getConfig(VanillaSoftwareProcess.SHELL_ENVIRONMENT);
+        // if any of the above blocked then we must make a unique install label,
+        // as other yet-unknown config is involved 
+        if (hash==null) return Identifiers.makeRandomId(8);
         
-        // TODO a user-friendly hash would be nice, but tricky since we don't want it to be too long or contain path chars
-        return Identifiers.makeIdFromHash(Objects.hash(url.or(null), installCommand, shellEnv));
+        // a user-friendly hash is nice, but tricky since it would have to be short; 
+        // go with a random one unless it's totally blank
+        if (hash==0) return "default";
+        return Identifiers.makeIdFromHash(hash);
     }
     
+    private Integer hashCodeIfResolved(ConfigKey<?> ...keys) {
+        int hash = 0;
+        for (ConfigKey<?> k: keys) {
+            Maybe<?> value = ((ConfigurationSupportInternal)getEntity().config()).getNonBlocking(k);
+            if (value.isAbsent()) return null;
+            hash = hash*31 + (value.get()==null ? 0 : value.get().hashCode());
+        }
+        return hash;
+    }
+
     @Override
     public void install() {
         Maybe<Object> url = getEntity().getConfigRaw(SoftwareProcess.DOWNLOAD_URL, true);


[08/10] incubator-brooklyn git commit: Changes re code review

Posted by he...@apache.org.
Changes re code review

Reorder password so "required chars" not at beginning
More default symbols
yaml test
concatenate all characters to use as available characters once required
chars added
Minor other changes


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

Branch: refs/heads/master
Commit: f10ed3a0f5369369cc42c44ab94147075b324aef
Parents: 50f70fe
Author: Duncan Grant <du...@cloudsoftcorp.com>
Authored: Fri Jan 29 11:00:26 2016 +0000
Committer: Duncan Grant <du...@cloudsoftcorp.com>
Committed: Fri Jan 29 11:00:26 2016 +0000

----------------------------------------------------------------------
 .../CreatePasswordSensorIntegrationTest.java    | 67 ++++++++++++++++++++
 .../EmptySoftwareProcessWithPassword.yaml       | 17 +++++
 .../sensor/password/CreatePasswordSensor.java   |  8 +--
 .../password/CreatePasswordSensorTest.java      | 16 ++---
 .../apache/brooklyn/util/text/Identifiers.java  | 30 +++++++--
 .../brooklyn/util/text/IdentifiersTest.java     | 14 ++--
 6 files changed, 126 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f10ed3a0/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/policy/CreatePasswordSensorIntegrationTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/policy/CreatePasswordSensorIntegrationTest.java b/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/policy/CreatePasswordSensorIntegrationTest.java
new file mode 100644
index 0000000..360b705
--- /dev/null
+++ b/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/policy/CreatePasswordSensorIntegrationTest.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.camp.brooklyn.policy;
+
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.sensor.AttributeSensor;
+import org.apache.brooklyn.camp.brooklyn.AbstractYamlTest;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.sensor.Sensors;
+import org.apache.brooklyn.entity.software.base.EmptySoftwareProcess;
+import org.apache.brooklyn.test.Asserts;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Iterables;
+
+public class CreatePasswordSensorIntegrationTest extends AbstractYamlTest {
+
+    private static final Logger LOG = LoggerFactory.getLogger(CreatePasswordSensorIntegrationTest.class);
+    AttributeSensor<String> PASSWORD_1 = Sensors.newStringSensor("test.password.1", "Host name as known internally in " +
+            "the subnet where it is running (if different to host.name)");
+    AttributeSensor<String> PASSWORD_2 = Sensors.newStringSensor("test.password.2", "Host name as known internally in " +
+            "the subnet where it is running (if different to host.name)");
+
+    @Test(groups = "Integration")
+    public void testProvisioningProperties() throws Exception {
+        final Entity app = createAndStartApplication(loadYaml("EmptySoftwareProcessWithPassword.yaml"));
+
+        waitForApplicationTasks(app);
+        EmptySoftwareProcess entity = Iterables.getOnlyElement(Entities.descendants(app, EmptySoftwareProcess.class));
+
+        assertPasswordLength(entity, PASSWORD_1, 15);
+
+        assertPasswordOnlyContains(entity, PASSWORD_2, "abc");
+
+    }
+
+    private void assertPasswordOnlyContains(EmptySoftwareProcess entity, AttributeSensor<String> password, String acceptableChars) {
+        String attribute_2 = entity.getAttribute(password);
+        for (char c : attribute_2.toCharArray()) {
+            Asserts.assertTrue(acceptableChars.indexOf(c) != -1);
+        }
+    }
+
+    private void assertPasswordLength(EmptySoftwareProcess entity, AttributeSensor<String> password, int expectedLength) {
+        String attribute_1 = entity.getAttribute(password);
+        Asserts.assertEquals(attribute_1.length(), expectedLength);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f10ed3a0/brooklyn-server/camp/camp-brooklyn/src/test/resources/EmptySoftwareProcessWithPassword.yaml
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-brooklyn/src/test/resources/EmptySoftwareProcessWithPassword.yaml b/brooklyn-server/camp/camp-brooklyn/src/test/resources/EmptySoftwareProcessWithPassword.yaml
new file mode 100644
index 0000000..2b6acb2
--- /dev/null
+++ b/brooklyn-server/camp/camp-brooklyn/src/test/resources/EmptySoftwareProcessWithPassword.yaml
@@ -0,0 +1,17 @@
+name: example-with-CreatePasswordSensor
+description: |
+  Creates an emptyService and then attaches a password to it
+origin: https://github.com/apache/incubator-brooklyn
+location: localhost
+services:
+- type: org.apache.brooklyn.entity.software.base.EmptySoftwareProcess
+  brooklyn.initializers:
+  - type: org.apache.brooklyn.core.sensor.password.CreatePasswordSensor
+    brooklyn.config:
+      name: test.password.1
+      password.length: 15
+  - type: org.apache.brooklyn.core.sensor.password.CreatePasswordSensor
+    brooklyn.config:
+      name: test.password.2
+      password.chars: abc
+

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f10ed3a0/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/sensor/password/CreatePasswordSensor.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/sensor/password/CreatePasswordSensor.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/sensor/password/CreatePasswordSensor.java
index 0352071..7b7a908 100644
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/sensor/password/CreatePasswordSensor.java
+++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/sensor/password/CreatePasswordSensor.java
@@ -34,7 +34,7 @@ public class CreatePasswordSensor extends AddSensor<String> {
     public static final ConfigKey<String> ACCEPTABLE_CHARS = ConfigKeys.newStringConfigKey("password.chars", "The characters allowed in password");
 
     private Integer passwordLength;
-    private String accecptableChars;
+    private String acceptableChars;
 
     public CreatePasswordSensor(Map<String, String> params) {
         this(ConfigBag.newInstance(params));
@@ -43,16 +43,16 @@ public class CreatePasswordSensor extends AddSensor<String> {
     public CreatePasswordSensor(ConfigBag params) {
         super(params);
         passwordLength = params.get(PASSWORD_LENGTH);
-        accecptableChars = params.get(ACCEPTABLE_CHARS);
+        acceptableChars = params.get(ACCEPTABLE_CHARS);
     }
 
     @Override
     public void apply(EntityLocal entity) {
         super.apply(entity);
 
-        String password = accecptableChars == null
+        String password = acceptableChars == null
                 ? Identifiers.makeRandomPassword(passwordLength)
-                : Identifiers.makeRandomPassword(passwordLength, accecptableChars);
+                : Identifiers.makeRandomPassword(passwordLength, acceptableChars);
         
         entity.sensors().set(sensor, password);
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f10ed3a0/brooklyn-server/core/src/test/java/org/apache/brooklyn/core/sensor/password/CreatePasswordSensorTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/test/java/org/apache/brooklyn/core/sensor/password/CreatePasswordSensorTest.java b/brooklyn-server/core/src/test/java/org/apache/brooklyn/core/sensor/password/CreatePasswordSensorTest.java
index 5223ce5..0dc1126 100644
--- a/brooklyn-server/core/src/test/java/org/apache/brooklyn/core/sensor/password/CreatePasswordSensorTest.java
+++ b/brooklyn-server/core/src/test/java/org/apache/brooklyn/core/sensor/password/CreatePasswordSensorTest.java
@@ -21,39 +21,31 @@ package org.apache.brooklyn.core.sensor.password;
 import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.api.sensor.AttributeSensor;
-import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.entity.EntityInternal;
 import org.apache.brooklyn.core.sensor.Sensors;
-import org.apache.brooklyn.core.test.entity.TestApplication;
+import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
 import org.apache.brooklyn.core.test.entity.TestEntity;
 import org.apache.brooklyn.test.Asserts;
 import org.apache.brooklyn.util.core.config.ConfigBag;
-import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import com.google.common.collect.ImmutableList;
 
-public class CreatePasswordSensorTest {
+public class CreatePasswordSensorTest extends BrooklynAppUnitTestSupport{
 
     final static AttributeSensor<String> SENSOR_STRING = Sensors.newStringSensor("aString");
     private EntityInternal entity;
-    private TestApplication app;
 
-    @BeforeMethod
+    @BeforeMethod(alwaysRun = true)
     public void setup() throws Exception {
-        app = TestApplication.Factory.newManagedInstanceForTests();
+        super.setUp();
 
         entity = app.createAndManageChild(EntitySpec.create(TestEntity.class)
                 .location(app.newLocalhostProvisioningLocation().obtain()));
         app.start(ImmutableList.<Location>of());
     }
 
-    @AfterMethod(alwaysRun = true)
-    public void tearDown() throws Exception {
-        if (app != null) Entities.destroyAll(app.getManagementContext());
-    }
-
     @Test
     public void testCreatePasswordCreatesAPasswordOfDefaultLength() {
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f10ed3a0/brooklyn-server/utils/common/src/main/java/org/apache/brooklyn/util/text/Identifiers.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/utils/common/src/main/java/org/apache/brooklyn/util/text/Identifiers.java b/brooklyn-server/utils/common/src/main/java/org/apache/brooklyn/util/text/Identifiers.java
index 25fb588..bea6208 100644
--- a/brooklyn-server/utils/common/src/main/java/org/apache/brooklyn/util/text/Identifiers.java
+++ b/brooklyn-server/utils/common/src/main/java/org/apache/brooklyn/util/text/Identifiers.java
@@ -19,8 +19,14 @@
 package org.apache.brooklyn.util.text;
 
 import java.security.SecureRandom;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
 import java.util.Random;
+import java.util.Set;
 
+import com.google.common.base.Joiner;
 import com.google.common.base.Preconditions;
 
 public class Identifiers {
@@ -30,7 +36,7 @@ public class Identifiers {
     public static final String UPPER_CASE_ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
     public static final String LOWER_CASE_ALPHA = "abcdefghijklmnopqrstuvwxyz";
     public static final String NUMERIC = "1234567890";
-    public static final String NON_ALPHA_NUMERIC = "!$%@#";
+    public static final String NON_ALPHA_NUMERIC = "!@$%^&*()-_=+[]{};:\\|/?,.<>~";
 
     /** @see #JAVA_GOOD_PACKAGE_OR_CLASS_REGEX */
     public static final String JAVA_GOOD_START_CHARS = UPPER_CASE_ALPHA + LOWER_CASE_ALPHA +"_";
@@ -129,18 +135,30 @@ public class Identifiers {
         Preconditions.checkState(length >= passwordValidCharsPool.length);
         int l = 0;
 
-        char[] id = new char[length];
+        Character[] password = new Character[length];
 
         for(int i = 0; i < passwordValidCharsPool.length; i++){
-            id[l++] = pickRandomCharFrom(passwordValidCharsPool[i]);
+            password[l++] = pickRandomCharFrom(passwordValidCharsPool[i]);
         }
 
-        String remainingValidChars = passwordValidCharsPool[passwordValidCharsPool.length - 1];
+        String remainingValidChars = mergeCharacterSets(passwordValidCharsPool);
 
         while(l < length) {
-            id[l++] = pickRandomCharFrom(remainingValidChars);
+            password[l++] = pickRandomCharFrom(remainingValidChars);
         }
-        return new String(id);
+
+        List<Character> list = Arrays.asList(password);
+        Collections.shuffle(list);
+        return Joiner.on("").join(list);
+    }
+
+    protected static String mergeCharacterSets(String... s) {
+        Set characters = new HashSet<Character>();
+        for (String characterSet : s) {
+            characters.addAll(Arrays.asList(characterSet.split("")));
+        }
+
+        return Joiner.on("").join(characters);
     }
 
     /** creates a short identifier comfortable in java and OS's, given an input hash code

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f10ed3a0/brooklyn-server/utils/common/src/test/java/org/apache/brooklyn/util/text/IdentifiersTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/utils/common/src/test/java/org/apache/brooklyn/util/text/IdentifiersTest.java b/brooklyn-server/utils/common/src/test/java/org/apache/brooklyn/util/text/IdentifiersTest.java
index 37c6443..e21bb81 100644
--- a/brooklyn-server/utils/common/src/test/java/org/apache/brooklyn/util/text/IdentifiersTest.java
+++ b/brooklyn-server/utils/common/src/test/java/org/apache/brooklyn/util/text/IdentifiersTest.java
@@ -102,11 +102,17 @@ public class IdentifiersTest {
         String upper = "ABC";
         String numbers = "123";
         String symbols = "!£$";
-        String id1 = Identifiers.makeRandomPassword(4, upper, numbers, symbols, Identifiers.PASSWORD_VALID_CHARS);
+        String password = Identifiers.makeRandomPassword(4, upper, numbers, symbols, Identifiers.PASSWORD_VALID_CHARS);
 
-        Assert.assertTrue(upper.contains(id1.substring(0,1)));
-        Assert.assertTrue(numbers.contains(id1.substring(1,2)));
-        Assert.assertTrue(symbols.contains(id1.substring(2,3)));
+        Assert.assertTrue(password.matches(".*[" + upper + "].*"));
+        Assert.assertTrue(password.matches(".*[" + numbers + "].*"));
+        Assert.assertTrue(password.matches(".*[" + symbols + "].*"));
+    }
+
+    @Test
+    public void testCharMerge() {
+        String characters = Identifiers.mergeCharacterSets("abc", "bcd", "ghjj");
+        Assert.assertEquals(characters.indexOf('b'), characters.lastIndexOf('b'));
     }
     
 }


[10/10] incubator-brooklyn git commit: This closes #1169

Posted by he...@apache.org.
This closes #1169


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

Branch: refs/heads/master
Commit: 5b37751dcf8a0ea567d639f4a85fc6f932cd3a14
Parents: 73839fa f10ed3a
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Sat Jan 30 03:45:34 2016 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Sat Jan 30 03:45:34 2016 +0000

----------------------------------------------------------------------
 .../CreatePasswordSensorIntegrationTest.java    |  67 ++++++++++
 .../EmptySoftwareProcessWithPassword.yaml       |  17 +++
 .../sensor/password/CreatePasswordSensor.java   |  59 +++++++++
 .../password/CreatePasswordSensorTest.java      |  59 +++++++++
 .../apache/brooklyn/util/text/Identifiers.java  | 125 +++++++++++++++----
 .../brooklyn/util/text/IdentifiersTest.java     |  20 ++-
 6 files changed, 323 insertions(+), 24 deletions(-)
----------------------------------------------------------------------



[05/10] incubator-brooklyn git commit: support dynamic cluster restart

Posted by he...@apache.org.
support dynamic cluster restart


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

Branch: refs/heads/master
Commit: ecbd90e22c989c7d24983942b7426c8a17c29463
Parents: 9141c99
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Thu Jan 21 13:55:30 2016 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Thu Jan 21 13:55:53 2016 +0000

----------------------------------------------------------------------
 .../brooklyn/core/effector/Effectors.java       | 16 +++++++++++--
 .../brooklyn/entity/group/DynamicCluster.java   |  8 +++++++
 .../entity/group/DynamicClusterImpl.java        | 24 +++++++++++++++++++-
 3 files changed, 45 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ecbd90e2/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/effector/Effectors.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/effector/Effectors.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/effector/Effectors.java
index 63ea52d..9b10d1d 100644
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/effector/Effectors.java
+++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/effector/Effectors.java
@@ -173,14 +173,26 @@ public class Effectors {
         return ConfigKeys.newConfigKey(paramType.getParameterClass(), paramType.getName(), paramType.getDescription(), paramType.getDefaultValue());
     }
 
-    /** returns an unsubmitted task which will invoke the given effector on the given entities;
-     * return type is Task<List<T>> (but haven't put in the blood sweat toil and tears to make the generics work) */
+    /** convenience for {@link #invocationParallel(Effector, Map, Iterable)} */
     public static TaskAdaptable<List<?>> invocation(Effector<?> eff, Map<?,?> params, Iterable<? extends Entity> entities) {
+        return invocationParallel(eff, params, entities);
+    }
+    
+    /** returns an unsubmitted task which will invoke the given effector on the given entities in parallel;
+     * return type is Task<List<T>> (but haven't put in the blood sweat toil and tears to make the generics work) */
+    public static TaskAdaptable<List<?>> invocationParallel(Effector<?> eff, Map<?,?> params, Iterable<? extends Entity> entities) {
         List<TaskAdaptable<?>> tasks = new ArrayList<TaskAdaptable<?>>();
         for (Entity e: entities) tasks.add(invocation(e, eff, params));
         return Tasks.parallel("invoking "+eff+" on "+tasks.size()+" node"+(Strings.s(tasks.size())), tasks.toArray(new TaskAdaptable[tasks.size()]));
     }
 
+    /** as {@link #invocationParallel(Effector, Map, Iterable)} but executing sequentially */
+    public static TaskAdaptable<List<?>> invocationSequential(Effector<?> eff, Map<?,?> params, Iterable<? extends Entity> entities) {
+        List<TaskAdaptable<?>> tasks = new ArrayList<TaskAdaptable<?>>();
+        for (Entity e: entities) tasks.add(invocation(e, eff, params));
+        return Tasks.sequential("invoking "+eff+" on "+tasks.size()+" node"+(Strings.s(tasks.size())), tasks.toArray(new TaskAdaptable[tasks.size()]));
+    }
+
     /** returns an unsubmitted task which will invoke the given effector on the given entities
      * (this form of method is a convenience for {@link #invocation(Effector, Map, Iterable)}) */
     public static TaskAdaptable<List<?>> invocation(Effector<?> eff, MutableMap<?, ?> params, Entity ...entities) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ecbd90e2/brooklyn-server/core/src/main/java/org/apache/brooklyn/entity/group/DynamicCluster.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/entity/group/DynamicCluster.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/entity/group/DynamicCluster.java
index 781cb0c..f09e72f 100644
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/entity/group/DynamicCluster.java
+++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/entity/group/DynamicCluster.java
@@ -98,6 +98,14 @@ public interface DynamicCluster extends AbstractGroup, Cluster, MemberReplaceabl
 
     MethodEffector<Collection<Entity>> RESIZE_BY_DELTA = new MethodEffector<Collection<Entity>>(DynamicCluster.class, "resizeByDelta");
 
+    @SetFromFlag("restartMode")
+    ConfigKey<String> RESTART_MODE = ConfigKeys.newStringConfigKey(
+            "dynamiccluster.restartMode", 
+            "How this cluster should handle restarts; "
+            + "by default it is disallowed, but this key can specify a different mode. "
+            + "Modes supported by dynamic cluster are 'off', 'sequqential', or 'parallel'. "
+            + "However subclasses can define their own modes or may ignore this.", null);
+
     @SetFromFlag("quarantineFailedEntities")
     ConfigKey<Boolean> QUARANTINE_FAILED_ENTITIES = ConfigKeys.newBooleanConfigKey(
             "dynamiccluster.quarantineFailedEntities", "If true, will quarantine entities that fail to start; if false, will get rid of them (i.e. delete them)", true);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ecbd90e2/brooklyn-server/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java
index f434fcf..aaf06c5 100644
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java
+++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java
@@ -47,6 +47,7 @@ import org.apache.brooklyn.core.config.Sanitizer;
 import org.apache.brooklyn.core.config.render.RendererHints;
 import org.apache.brooklyn.core.effector.Effectors;
 import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.entity.EntityPredicates;
 import org.apache.brooklyn.core.entity.factory.EntityFactory;
 import org.apache.brooklyn.core.entity.factory.EntityFactoryForLocation;
 import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
@@ -522,7 +523,28 @@ public class DynamicClusterImpl extends AbstractGroupImpl implements DynamicClus
 
     @Override
     public void restart() {
-        throw new UnsupportedOperationException();
+        String mode = getConfig(RESTART_MODE);
+        if (mode==null) {
+            throw new UnsupportedOperationException("Restart not supported for this cluster: "+RESTART_MODE.getName()+" is not configured.");
+        }
+        if ("off".equalsIgnoreCase(mode)) {
+            throw new UnsupportedOperationException("Restart not supported for this cluster.");
+        }
+        
+        if ("sequential".equalsIgnoreCase(mode)) {
+            ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING);
+            DynamicTasks.queue(Effectors.invocationSequential(Startable.RESTART, null, 
+                Iterables.filter(getChildren(), Predicates.and(Predicates.instanceOf(Startable.class), EntityPredicates.isManaged()))));
+        } else if ("parallel".equalsIgnoreCase(mode)) {
+            ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING);
+            DynamicTasks.queue(Effectors.invocationParallel(Startable.RESTART, null, 
+                Iterables.filter(getChildren(), Predicates.and(Predicates.instanceOf(Startable.class), EntityPredicates.isManaged()))));
+        } else {
+            throw new IllegalArgumentException("Unknown "+RESTART_MODE.getName()+" '"+mode+"'");
+        }
+        
+        DynamicTasks.waitForLast();
+        ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING);
     }
 
     @Override


[02/10] incubator-brooklyn git commit: allow spec parameters to imply sensors as well as config keys; mainly intended for AttributeSensorAndConfigKey -- especially ports.

Posted by he...@apache.org.
allow spec parameters to imply sensors as well as config keys;
mainly intended for AttributeSensorAndConfigKey -- especially ports.

this means param of type `port` given a range causes a sensor to be published with the actual value.


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

Branch: refs/heads/master
Commit: 9141c99f4c0f295a3a39b75bf06b42f85650d3f4
Parents: 5e9012b
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Thu Jan 21 13:24:15 2016 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Thu Jan 21 13:25:37 2016 +0000

----------------------------------------------------------------------
 .../apache/brooklyn/api/objs/SpecParameter.java | 16 ++++-
 .../catalog/SpecParameterParsingTest.java       | 18 +++---
 .../brooklyn/core/config/BasicConfigKey.java    | 10 ++-
 .../brooklyn/core/config/ConfigConstraints.java |  3 +-
 .../brooklyn/core/objs/BasicSpecParameter.java  | 68 +++++++++++++++-----
 .../core/objs/proxy/InternalEntityFactory.java  | 14 ++--
 .../sensor/AttributeSensorAndConfigKey.java     |  9 ++-
 .../sensor/PortAttributeSensorAndConfigKey.java |  6 ++
 .../brooklyn/util/core/flags/FlagUtils.java     |  2 +-
 .../objs/BasicSpecParameterFromClassTest.java   |  2 +-
 .../objs/BasicSpecParameterFromListTest.java    | 14 ++--
 .../rest/transform/CatalogTransformer.java      |  8 ++-
 .../rest/transform/EntityTransformer.java       |  2 +-
 13 files changed, 117 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/9141c99f/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/objs/SpecParameter.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/objs/SpecParameter.java b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/objs/SpecParameter.java
index 4e9dc62..fd7047e 100644
--- a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/objs/SpecParameter.java
+++ b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/objs/SpecParameter.java
@@ -20,13 +20,23 @@ package org.apache.brooklyn.api.objs;
 
 import java.io.Serializable;
 
+import javax.annotation.Nullable;
+
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.sensor.AttributeSensor;
 import org.apache.brooklyn.config.ConfigKey;
 
+/** A wrapper around a {@link ConfigKey} which will be added to an {@link Entity},
+ * providing additional information for rendering in a UI */
 public interface SpecParameter<T> extends Serializable {
     /** Short name, to be used in UI */
     String getLabel();
-    /** Visible by default in UI, not all inputs may be visible at once */
+    /** Whether visible by default in UI, not all inputs may be visible at once */
     boolean isPinned();
-    /** Type information for the input */
-    ConfigKey<T> getType();
+    /** All config key info for this spec parameter;
+     * this is the config key which is added to the defined type */
+    ConfigKey<T> getConfigKey();
+    /** An optional sensor which may also be added to the defined type */
+    @Nullable AttributeSensor<?> getSensor();
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/9141c99f/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/SpecParameterParsingTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/SpecParameterParsingTest.java b/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/SpecParameterParsingTest.java
index fdf5807..869ebc0 100644
--- a/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/SpecParameterParsingTest.java
+++ b/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/SpecParameterParsingTest.java
@@ -62,20 +62,20 @@ public class SpecParameterParsingTest  extends AbstractYamlTest {
         SpecParameter<?> firstInput = inputs.get(0);
         assertEquals(firstInput.getLabel(), "simple");
         assertEquals(firstInput.isPinned(), true);
-        assertEquals(firstInput.getType().getName(), "simple");
-        assertEquals(firstInput.getType().getTypeToken(), TypeToken.of(String.class));
+        assertEquals(firstInput.getConfigKey().getName(), "simple");
+        assertEquals(firstInput.getConfigKey().getTypeToken(), TypeToken.of(String.class));
         
         SpecParameter<?> secondInput = inputs.get(1);
         assertEquals(secondInput.getLabel(), "explicit_name");
         assertEquals(secondInput.isPinned(), true);
-        assertEquals(secondInput.getType().getName(), "explicit_name");
-        assertEquals(secondInput.getType().getTypeToken(), TypeToken.of(String.class));
+        assertEquals(secondInput.getConfigKey().getName(), "explicit_name");
+        assertEquals(secondInput.getConfigKey().getTypeToken(), TypeToken.of(String.class));
         
         SpecParameter<?> thirdInput = inputs.get(2);
         assertEquals(thirdInput.getLabel(), "third_input");
         assertEquals(thirdInput.isPinned(), true);
-        assertEquals(thirdInput.getType().getName(), "third_input");
-        assertEquals(thirdInput.getType().getTypeToken(), TypeToken.of(Integer.class));
+        assertEquals(thirdInput.getConfigKey().getName(), "third_input");
+        assertEquals(thirdInput.getConfigKey().getTypeToken(), TypeToken.of(Integer.class));
     }
 
     @Test
@@ -99,8 +99,8 @@ public class SpecParameterParsingTest  extends AbstractYamlTest {
         SpecParameter<?> firstInput = inputs.get(0);
         assertEquals(firstInput.getLabel(), "simple");
         assertTrue(firstInput.isPinned());
-        assertEquals(firstInput.getType().getName(), "simple");
-        assertEquals(firstInput.getType().getTypeToken().getRawType().getName(), OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_SIMPLE_ENTITY);
+        assertEquals(firstInput.getConfigKey().getName(), "simple");
+        assertEquals(firstInput.getConfigKey().getTypeToken().getRawType().getName(), OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_SIMPLE_ENTITY);
     }
 
     @Test
@@ -126,7 +126,7 @@ public class SpecParameterParsingTest  extends AbstractYamlTest {
         SpecParameter<?> input = inputs.get(0);
         assertEquals(input.getLabel(), "more_config");
         assertFalse(input.isPinned());
-        assertEquals(input.getType().getName(), "more_config");
+        assertEquals(input.getConfigKey().getName(), "more_config");
     }
 
     private String add(String... def) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/9141c99f/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/BasicConfigKey.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/BasicConfigKey.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/BasicConfigKey.java
index 2e59185..f158c2c 100644
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/BasicConfigKey.java
+++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/BasicConfigKey.java
@@ -49,7 +49,6 @@ import com.google.common.reflect.TypeToken;
 
 public class BasicConfigKey<T> implements ConfigKeySelfExtracting<T>, Serializable {
     
-    @SuppressWarnings("unused")
     private static final Logger log = LoggerFactory.getLogger(BasicConfigKey.class);
     private static final long serialVersionUID = -1762014059150215376L;
     
@@ -119,6 +118,13 @@ public class BasicConfigKey<T> implements ConfigKeySelfExtracting<T>, Serializab
         public BasicConfigKey<T> build() {
             return new BasicConfigKey<T>(this);
         }
+        
+        public String getName() {
+            return name;
+        }
+        public String getDescription() {
+            return description;
+        }
     }
     
     private String name;
@@ -165,7 +171,7 @@ public class BasicConfigKey<T> implements ConfigKeySelfExtracting<T>, Serializab
         this.constraint = Predicates.alwaysTrue();
     }
 
-    protected BasicConfigKey(Builder<T> builder) {
+    public BasicConfigKey(Builder<T> builder) {
         this.name = checkNotNull(builder.name, "name");
         this.type = TypeTokens.getRawTypeIfRaw(checkNotNull(builder.type, "type"));
         this.typeToken = TypeTokens.getTypeTokenIfNotRaw(builder.type);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/9141c99f/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/ConfigConstraints.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/ConfigConstraints.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/ConfigConstraints.java
index 1a273f6..c508349 100644
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/ConfigConstraints.java
+++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/ConfigConstraints.java
@@ -28,10 +28,9 @@ import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.api.objs.BrooklynObject;
 import org.apache.brooklyn.api.objs.EntityAdjunct;
 import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.core.location.AbstractLocation;
 import org.apache.brooklyn.core.objs.AbstractEntityAdjunct;
-import org.apache.brooklyn.core.objs.BrooklynObjectPredicate;
 import org.apache.brooklyn.core.objs.BrooklynObjectInternal;
+import org.apache.brooklyn.core.objs.BrooklynObjectPredicate;
 import org.apache.brooklyn.util.guava.Maybe;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/9141c99f/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/objs/BasicSpecParameter.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/objs/BasicSpecParameter.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/objs/BasicSpecParameter.java
index dfbe1c1..2bc2346 100644
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/objs/BasicSpecParameter.java
+++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/objs/BasicSpecParameter.java
@@ -36,12 +36,18 @@ import org.apache.brooklyn.api.mgmt.classloading.BrooklynClassLoadingContext;
 import org.apache.brooklyn.api.objs.BrooklynObject;
 import org.apache.brooklyn.api.objs.BrooklynType;
 import org.apache.brooklyn.api.objs.SpecParameter;
+import org.apache.brooklyn.api.sensor.AttributeSensor;
 import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.config.ConfigKey.HasConfigKey;
 import org.apache.brooklyn.core.config.BasicConfigKey;
+import org.apache.brooklyn.core.config.BasicConfigKey.Builder;
+import org.apache.brooklyn.core.sensor.PortAttributeSensorAndConfigKey;
 import org.apache.brooklyn.util.collections.MutableList;
 import org.apache.brooklyn.util.guava.Maybe;
 import org.apache.brooklyn.util.text.StringPredicates;
+import org.apache.brooklyn.util.time.Duration;
 
+import com.google.common.annotations.Beta;
 import com.google.common.base.Function;
 import com.google.common.base.Objects;
 import com.google.common.base.Predicate;
@@ -54,14 +60,26 @@ import com.google.common.reflect.TypeToken;
 public class BasicSpecParameter<T> implements SpecParameter<T>{
     private static final long serialVersionUID = -4728186276307619778L;
 
-    private String label;
-    private boolean pinned;
-    private ConfigKey<T> type;
+    private final String label;
+    
+    /** pinning may become a priority or other more expansive indicator */
+    @Beta
+    private final boolean pinned;
+    
+    private final ConfigKey<T> configKey;
+    private final AttributeSensor<?> sensor;
 
-    public BasicSpecParameter(String label, boolean pinned, ConfigKey<T> type) {
+    @Beta // TBD whether "pinned" stays
+    public BasicSpecParameter(String label, boolean pinned, ConfigKey<T> config) {
+        this(label, pinned, config, null);
+    }
+
+    @Beta // TBD whether "pinned" and "sensor" stay
+    public <SensorType> BasicSpecParameter(String label, boolean pinned, ConfigKey<T> config, AttributeSensor<SensorType> sensor) {
         this.label = label;
         this.pinned = pinned;
-        this.type = type;
+        this.configKey = config;
+        this.sensor = sensor;
     }
 
     @Override
@@ -73,15 +91,20 @@ public class BasicSpecParameter<T> implements SpecParameter<T>{
     public boolean isPinned() {
         return pinned;
     }
+    
+    @Override
+    public ConfigKey<T> getConfigKey() {
+        return configKey;
+    }
 
     @Override
-    public ConfigKey<T> getType() {
-        return type;
+    public AttributeSensor<?> getSensor() {
+        return sensor;
     }
 
     @Override
     public int hashCode() {
-        return Objects.hashCode(label, pinned, type);
+        return Objects.hashCode(label, pinned, configKey);
     }
 
     @Override
@@ -95,7 +118,7 @@ public class BasicSpecParameter<T> implements SpecParameter<T>{
         BasicSpecParameter<?> other = (BasicSpecParameter<?>) obj;
         return Objects.equal(label,  other.label) &&
                 pinned == other.pinned &&
-                Objects.equal(type, other.type);
+                Objects.equal(configKey, other.configKey);
     }
 
     @Override
@@ -103,7 +126,7 @@ public class BasicSpecParameter<T> implements SpecParameter<T>{
         return Objects.toStringHelper(this)
                 .add("label", label)
                 .add("pinned", pinned)
-                .add("type", type)
+                .add("type", configKey)
                 .toString();
     }
 
@@ -154,6 +177,7 @@ public class BasicSpecParameter<T> implements SpecParameter<T>{
                 .put("long", Long.class)
                 .put("float", Float.class)
                 .put("double", Double.class)
+                .put("duration", Duration.class)
                 .put("timestamp", Date.class)
                 .put("port", PortRange.class)
                 .build();
@@ -191,13 +215,23 @@ public class BasicSpecParameter<T> implements SpecParameter<T>{
                 throw new IllegalArgumentException("'name' value missing from input definition " + obj + " but is required. Check for typos.");
             }
 
-            ConfigKey inputType = BasicConfigKey.builder(inferType(type, loader))
-                    .name(name)
-                    .description(description)
-                    .defaultValue(defaultValue)
-                    .constraint(constraints)
-                    .build();
-            return new BasicSpecParameter(Objects.firstNonNull(label, name), true, inputType);
+            ConfigKey configType;
+            AttributeSensor sensorType = null;
+            
+            TypeToken typeToken = inferType(type, loader);
+            Builder builder = BasicConfigKey.builder(typeToken)
+                .name(name)
+                .description(description)
+                .defaultValue(defaultValue)
+                .constraint(constraints);
+            
+            if (PortRange.class.equals(typeToken.getRawType())) {
+                sensorType = new PortAttributeSensorAndConfigKey(builder);
+                configType = ((HasConfigKey)sensorType).getConfigKey();
+            } else {
+                configType = builder.build();
+            }
+            return new BasicSpecParameter(Objects.firstNonNull(label, name), true, configType, sensorType);
         }
 
         @SuppressWarnings({ "rawtypes" })

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/9141c99f/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalEntityFactory.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalEntityFactory.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalEntityFactory.java
index eb4ff10..e55d6d9 100644
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalEntityFactory.java
+++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalEntityFactory.java
@@ -44,6 +44,7 @@ import org.apache.brooklyn.core.config.ConfigConstraints;
 import org.apache.brooklyn.core.entity.AbstractApplication;
 import org.apache.brooklyn.core.entity.AbstractEntity;
 import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.entity.EntityDynamicType;
 import org.apache.brooklyn.core.entity.EntityInternal;
 import org.apache.brooklyn.core.mgmt.BrooklynTaskTags;
 import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
@@ -248,13 +249,13 @@ public class InternalEntityFactory extends InternalFactory {
             }
             
             entity.tags().addTags(spec.getTags());
-            ((AbstractEntity)entity).configure(getConfigKeysFromSpecParameters(spec));
-            ((AbstractEntity)entity).configure(MutableMap.copyOf(spec.getFlags()));
+            addSpecParameters(spec, ((AbstractEntity)entity).getMutableEntityType());
             
+            ((AbstractEntity)entity).configure(MutableMap.copyOf(spec.getFlags()));
             for (Map.Entry<ConfigKey<?>, Object> entry : spec.getConfig().entrySet()) {
                 entity.config().set((ConfigKey)entry.getKey(), entry.getValue());
             }
-
+            
             Entity parent = spec.getParent();
             if (parent != null) {
                 parent = (parent instanceof AbstractEntity) ? ((AbstractEntity)parent).getProxyIfAvailable() : parent;
@@ -268,12 +269,11 @@ public class InternalEntityFactory extends InternalFactory {
         }
     }
 
-    private <T extends Entity> List<ConfigKey<?>> getConfigKeysFromSpecParameters(EntitySpec<T> spec) {
-        List<ConfigKey<?>> configKeys = MutableList.of();
+    private void addSpecParameters(EntitySpec<?> spec, EntityDynamicType edType) {
         for (SpecParameter<?> param : spec.getParameters()) {
-            configKeys.add(param.getType());
+            edType.addConfigKey(param.getConfigKey());
+            if (param.getSensor()!=null) edType.addSensor(param.getSensor());
         }
-        return configKeys;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/9141c99f/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/sensor/AttributeSensorAndConfigKey.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/sensor/AttributeSensorAndConfigKey.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/sensor/AttributeSensorAndConfigKey.java
index f76baaa..2a26fa7 100644
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/sensor/AttributeSensorAndConfigKey.java
+++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/sensor/AttributeSensorAndConfigKey.java
@@ -19,11 +19,11 @@
 package org.apache.brooklyn.core.sensor;
 
 import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntityLocal;
 import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.api.sensor.Sensor;
 import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.core.config.BasicConfigKey;
+import org.apache.brooklyn.core.config.BasicConfigKey.Builder;
 import org.apache.brooklyn.core.config.ConfigKeys;
 import org.apache.brooklyn.core.entity.AbstractEntity;
 import org.apache.brooklyn.core.entity.BrooklynConfigKeys;
@@ -45,6 +45,7 @@ import com.google.common.reflect.TypeToken;
 */
 public abstract class AttributeSensorAndConfigKey<ConfigType,SensorType> extends BasicAttributeSensor<SensorType> 
         implements ConfigKey.HasConfigKey<ConfigType> {
+    
     private static final long serialVersionUID = -3103809215973264600L;
     private static final Logger log = LoggerFactory.getLogger(AttributeSensorAndConfigKey.class);
 
@@ -87,6 +88,10 @@ public abstract class AttributeSensorAndConfigKey<ConfigType,SensorType> extends
         configKey = ConfigKeys.newConfigKeyWithDefault(orig.configKey, 
                 TypeCoercions.coerce(defaultValue, orig.configKey.getTypeToken()));
     }
+    public AttributeSensorAndConfigKey(Builder<ConfigType> configKeyBuilder, TypeToken<SensorType> sensorType) {
+        super(sensorType, configKeyBuilder.getName(), configKeyBuilder.getDescription());
+        configKey = new BasicConfigKey<ConfigType>(configKeyBuilder);
+    }
 
     public ConfigKey<ConfigType> getConfigKey() { return configKey; }
     
@@ -106,7 +111,7 @@ public abstract class AttributeSensorAndConfigKey<ConfigType,SensorType> extends
         SensorType sensorValue = e.getAttribute(this);
         if (sensorValue!=null) return sensorValue;
         
-        ConfigType v = ((EntityLocal)e).getConfig(this);
+        ConfigType v = e.config().get(this);
         try {
             return convertConfigToSensor(v, e);
         } catch (Throwable t) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/9141c99f/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/sensor/PortAttributeSensorAndConfigKey.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/sensor/PortAttributeSensorAndConfigKey.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/sensor/PortAttributeSensorAndConfigKey.java
index 3de0de6..aa396d2 100644
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/sensor/PortAttributeSensorAndConfigKey.java
+++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/sensor/PortAttributeSensorAndConfigKey.java
@@ -29,6 +29,7 @@ import org.apache.brooklyn.api.location.PortSupplier;
 import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.api.sensor.Sensor;
 import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.core.config.BasicConfigKey;
 import org.apache.brooklyn.core.entity.BrooklynConfigKeys;
 import org.apache.brooklyn.core.internal.BrooklynInitialization;
 import org.apache.brooklyn.core.location.Locations;
@@ -40,6 +41,7 @@ import org.slf4j.LoggerFactory;
 import com.google.common.base.Optional;
 import com.google.common.base.Predicates;
 import com.google.common.collect.Iterables;
+import com.google.common.reflect.TypeToken;
 
 /**
  * A {@link Sensor} describing a port on a system,
@@ -68,6 +70,10 @@ public class PortAttributeSensorAndConfigKey extends AttributeSensorAndConfigKey
     public PortAttributeSensorAndConfigKey(PortAttributeSensorAndConfigKey orig, Object defaultValue) {
         super(orig, TypeCoercions.coerce(defaultValue, PortRange.class));
     }
+    public PortAttributeSensorAndConfigKey(BasicConfigKey.Builder<PortRange> builder) {
+        super(builder, TypeToken.of(Integer.class));
+    }
+    
     @Override
     protected Integer convertConfigToSensor(PortRange value, Entity entity) {
         if (value==null) return null;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/9141c99f/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/flags/FlagUtils.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/flags/FlagUtils.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/flags/FlagUtils.java
index 85c9537..3bc22e0 100644
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/flags/FlagUtils.java
+++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/flags/FlagUtils.java
@@ -234,7 +234,7 @@ public class FlagUtils {
     public static List<FlagConfigKeyAndValueRecord> findAllParameterConfigKeys(List<SpecParameter<?>> parameters, ConfigBag input) {
         List<FlagConfigKeyAndValueRecord> output = new ArrayList<FlagUtils.FlagConfigKeyAndValueRecord>();
         for (SpecParameter<?> param : parameters) {
-            FlagConfigKeyAndValueRecord record = getFlagConfigKeyRecord(null, param.getType(), input);
+            FlagConfigKeyAndValueRecord record = getFlagConfigKeyRecord(null, param.getConfigKey(), input);
             if (record.isValuePresent())
                 output.add(record);
         }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/9141c99f/brooklyn-server/core/src/test/java/org/apache/brooklyn/core/objs/BasicSpecParameterFromClassTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/test/java/org/apache/brooklyn/core/objs/BasicSpecParameterFromClassTest.java b/brooklyn-server/core/src/test/java/org/apache/brooklyn/core/objs/BasicSpecParameterFromClassTest.java
index 49cb2d6..30745f0 100644
--- a/brooklyn-server/core/src/test/java/org/apache/brooklyn/core/objs/BasicSpecParameterFromClassTest.java
+++ b/brooklyn-server/core/src/test/java/org/apache/brooklyn/core/objs/BasicSpecParameterFromClassTest.java
@@ -103,7 +103,7 @@ public class BasicSpecParameterFromClassTest {
     private void assertInput(SpecParameter<?> input, String label, boolean pinned, ConfigKey<?> type) {
         assertEquals(input.getLabel(), label);
         assertEquals(input.isPinned(), pinned);
-        assertEquals(input.getType(), type);
+        assertEquals(input.getConfigKey(), type);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/9141c99f/brooklyn-server/core/src/test/java/org/apache/brooklyn/core/objs/BasicSpecParameterFromListTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/test/java/org/apache/brooklyn/core/objs/BasicSpecParameterFromListTest.java b/brooklyn-server/core/src/test/java/org/apache/brooklyn/core/objs/BasicSpecParameterFromListTest.java
index 9f2eaaf..07ad81a 100644
--- a/brooklyn-server/core/src/test/java/org/apache/brooklyn/core/objs/BasicSpecParameterFromListTest.java
+++ b/brooklyn-server/core/src/test/java/org/apache/brooklyn/core/objs/BasicSpecParameterFromListTest.java
@@ -56,7 +56,7 @@ public class BasicSpecParameterFromListTest {
         SpecParameter<?> input = parse(name);
         assertEquals(input.getLabel(), name);
         assertTrue(input.isPinned());
-        ConfigKey<?> type = input.getType();
+        ConfigKey<?> type = input.getConfigKey();
         assertEquals(type.getName(), name);
         assertEquals(type.getTypeToken(), TypeToken.of(String.class));
         assertNull(type.getDefaultValue());
@@ -70,8 +70,8 @@ public class BasicSpecParameterFromListTest {
         String name = "minRam";
         SpecParameter<?> input = parse(ImmutableMap.of("name", name));
         assertEquals(input.getLabel(), name);
-        assertEquals(input.getType().getName(), name);
-        assertEquals(input.getType().getTypeToken(), TypeToken.of(String.class));
+        assertEquals(input.getConfigKey().getName(), name);
+        assertEquals(input.getConfigKey().getTypeToken(), TypeToken.of(String.class));
     }
 
     @Test
@@ -99,7 +99,7 @@ public class BasicSpecParameterFromListTest {
         assertEquals(input.getLabel(), label);
         assertTrue(input.isPinned());
 
-        ConfigKey<?> type = input.getType();
+        ConfigKey<?> type = input.getConfigKey();
         assertEquals(type.getName(), name);
         assertEquals(type.getTypeToken(), TypeToken.of(String.class));
         assertEquals(type.getDefaultValue(), defaultValue);
@@ -123,7 +123,7 @@ public class BasicSpecParameterFromListTest {
         assertEquals(input.getLabel(), name);
         assertTrue(input.isPinned());
 
-        ConfigKey<?> type = input.getType();
+        ConfigKey<?> type = input.getConfigKey();
         assertEquals(type.getName(), name);
         assertEquals(type.getDefaultValue(), defaultValue);
         assertEquals(type.getDescription(), description);
@@ -137,7 +137,7 @@ public class BasicSpecParameterFromListTest {
         SpecParameter<?> input = parse(ImmutableMap.of(
                 "name", name,
                 "constraints", ImmutableList.of(constraint)));
-        ConfigKey<?> type = input.getType();
+        ConfigKey<?> type = input.getConfigKey();
         assertConstraint(type.getConstraint(), StringPredicates.isNonBlank());
     }
 
@@ -153,7 +153,7 @@ public class BasicSpecParameterFromListTest {
         SpecParameter<?> input = parse(ImmutableMap.of(
                 "name", name,
                 "type", BasicSpecParameterFromListTest.class.getName()));
-        assertEquals(input.getType().getTypeToken(), TypeToken.of(BasicSpecParameterFromListTest.class));
+        assertEquals(input.getConfigKey().getTypeToken(), TypeToken.of(BasicSpecParameterFromListTest.class));
     }
 
     @Test(expectedExceptions = IllegalArgumentException.class)

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/9141c99f/brooklyn-server/rest/rest-server/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/rest/rest-server/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java b/brooklyn-server/rest/rest-server/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java
index 74625fd..3c19625 100644
--- a/brooklyn-server/rest/rest-server/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java
+++ b/brooklyn-server/rest/rest-server/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java
@@ -68,15 +68,17 @@ public class CatalogTransformer {
         Set<EffectorSummary> effectors = Sets.newTreeSet(SummaryComparators.nameComparator());
 
         EntitySpec<?> spec = null;
-
         try {
-            spec = (EntitySpec<?>) b.getCatalog().createSpec((CatalogItem) item);
+            spec = (EntitySpec<?>) b.getCatalog().createSpec(item);
             EntityDynamicType typeMap = BrooklynTypes.getDefinedEntityType(spec.getType());
             EntityType type = typeMap.getSnapshot();
 
             AtomicInteger paramPriorityCnt = new AtomicInteger();
-            for (SpecParameter<?> input: spec.getParameters())
+            for (SpecParameter<?> input: spec.getParameters()) {
                 config.add(EntityTransformer.entityConfigSummary(input, paramPriorityCnt));
+                if (input.getSensor()!=null)
+                    sensors.add(SensorTransformer.sensorSummaryForCatalog(input.getSensor()));
+            }
             for (Sensor<?> x: type.getSensors())
                 sensors.add(SensorTransformer.sensorSummaryForCatalog(x));
             for (Effector<?> x: type.getEffectors())

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/9141c99f/brooklyn-server/rest/rest-server/src/main/java/org/apache/brooklyn/rest/transform/EntityTransformer.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/rest/rest-server/src/main/java/org/apache/brooklyn/rest/transform/EntityTransformer.java b/brooklyn-server/rest/rest-server/src/main/java/org/apache/brooklyn/rest/transform/EntityTransformer.java
index 2d9f8a0..f5079b9 100644
--- a/brooklyn-server/rest/rest-server/src/main/java/org/apache/brooklyn/rest/transform/EntityTransformer.java
+++ b/brooklyn-server/rest/rest-server/src/main/java/org/apache/brooklyn/rest/transform/EntityTransformer.java
@@ -159,7 +159,7 @@ public class EntityTransformer {
         // which results in correctly ordered items on the wire (as a list). Clients which use the java bindings
         // though will push the items in an unordered set - so give them means to recover the correct order.
         Double priority = input.isPinned() ? Double.valueOf(paramPriorityCnt.incrementAndGet()) : null;
-        return entityConfigSummary(input.getType(), input.getLabel(), priority, null);
+        return entityConfigSummary(input.getConfigKey(), input.getLabel(), priority, null);
     }
 
 }


[06/10] incubator-brooklyn git commit: Create Password Sensor

Posted by he...@apache.org.
Create Password Sensor

A simple initialiser for creating passwords in yaml as a sensor

Added a password generating function in the Identifiers class which uses
secure random


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

Branch: refs/heads/master
Commit: 50f70fe5be5bdac65f446e8309fcf703f36c08ba
Parents: b28ba02
Author: Duncan Grant <du...@cloudsoftcorp.com>
Authored: Thu Jan 21 16:14:25 2016 +0000
Committer: Duncan Grant <du...@cloudsoftcorp.com>
Committed: Thu Jan 21 17:42:19 2016 +0000

----------------------------------------------------------------------
 .../sensor/password/CreatePasswordSensor.java   |  59 ++++++++++
 .../password/CreatePasswordSensorTest.java      |  67 ++++++++++++
 .../apache/brooklyn/util/text/Identifiers.java  | 107 +++++++++++++++----
 .../brooklyn/util/text/IdentifiersTest.java     |  14 ++-
 4 files changed, 223 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50f70fe5/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/sensor/password/CreatePasswordSensor.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/sensor/password/CreatePasswordSensor.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/sensor/password/CreatePasswordSensor.java
new file mode 100644
index 0000000..0352071
--- /dev/null
+++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/sensor/password/CreatePasswordSensor.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.core.sensor.password;
+
+import java.util.Map;
+
+import org.apache.brooklyn.api.entity.EntityLocal;
+import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.core.effector.AddSensor;
+import org.apache.brooklyn.util.core.config.ConfigBag;
+import org.apache.brooklyn.util.text.Identifiers;
+
+public class CreatePasswordSensor extends AddSensor<String> {
+
+    public static final ConfigKey<Integer> PASSWORD_LENGTH = ConfigKeys.newIntegerConfigKey("password.length", "The length of the password to be created", 12);
+
+    public static final ConfigKey<String> ACCEPTABLE_CHARS = ConfigKeys.newStringConfigKey("password.chars", "The characters allowed in password");
+
+    private Integer passwordLength;
+    private String accecptableChars;
+
+    public CreatePasswordSensor(Map<String, String> params) {
+        this(ConfigBag.newInstance(params));
+    }
+
+    public CreatePasswordSensor(ConfigBag params) {
+        super(params);
+        passwordLength = params.get(PASSWORD_LENGTH);
+        accecptableChars = params.get(ACCEPTABLE_CHARS);
+    }
+
+    @Override
+    public void apply(EntityLocal entity) {
+        super.apply(entity);
+
+        String password = accecptableChars == null
+                ? Identifiers.makeRandomPassword(passwordLength)
+                : Identifiers.makeRandomPassword(passwordLength, accecptableChars);
+        
+        entity.sensors().set(sensor, password);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50f70fe5/brooklyn-server/core/src/test/java/org/apache/brooklyn/core/sensor/password/CreatePasswordSensorTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/test/java/org/apache/brooklyn/core/sensor/password/CreatePasswordSensorTest.java b/brooklyn-server/core/src/test/java/org/apache/brooklyn/core/sensor/password/CreatePasswordSensorTest.java
new file mode 100644
index 0000000..5223ce5
--- /dev/null
+++ b/brooklyn-server/core/src/test/java/org/apache/brooklyn/core/sensor/password/CreatePasswordSensorTest.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.core.sensor.password;
+
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.api.sensor.AttributeSensor;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.entity.EntityInternal;
+import org.apache.brooklyn.core.sensor.Sensors;
+import org.apache.brooklyn.core.test.entity.TestApplication;
+import org.apache.brooklyn.core.test.entity.TestEntity;
+import org.apache.brooklyn.test.Asserts;
+import org.apache.brooklyn.util.core.config.ConfigBag;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+public class CreatePasswordSensorTest {
+
+    final static AttributeSensor<String> SENSOR_STRING = Sensors.newStringSensor("aString");
+    private EntityInternal entity;
+    private TestApplication app;
+
+    @BeforeMethod
+    public void setup() throws Exception {
+        app = TestApplication.Factory.newManagedInstanceForTests();
+
+        entity = app.createAndManageChild(EntitySpec.create(TestEntity.class)
+                .location(app.newLocalhostProvisioningLocation().obtain()));
+        app.start(ImmutableList.<Location>of());
+    }
+
+    @AfterMethod(alwaysRun = true)
+    public void tearDown() throws Exception {
+        if (app != null) Entities.destroyAll(app.getManagementContext());
+    }
+
+    @Test
+    public void testCreatePasswordCreatesAPasswordOfDefaultLength() {
+
+        final CreatePasswordSensor sensor = new CreatePasswordSensor(ConfigBag.newInstance()
+                .configure(CreatePasswordSensor.SENSOR_NAME, SENSOR_STRING.getName()));
+        sensor.apply(entity);
+
+        String password = entity.getAttribute(SENSOR_STRING);
+        Asserts.assertEquals(password.length(), 12);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50f70fe5/brooklyn-server/utils/common/src/main/java/org/apache/brooklyn/util/text/Identifiers.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/utils/common/src/main/java/org/apache/brooklyn/util/text/Identifiers.java b/brooklyn-server/utils/common/src/main/java/org/apache/brooklyn/util/text/Identifiers.java
index c2ec4a5..25fb588 100644
--- a/brooklyn-server/utils/common/src/main/java/org/apache/brooklyn/util/text/Identifiers.java
+++ b/brooklyn-server/utils/common/src/main/java/org/apache/brooklyn/util/text/Identifiers.java
@@ -18,16 +18,24 @@
  */
 package org.apache.brooklyn.util.text;
 
+import java.security.SecureRandom;
 import java.util.Random;
 
+import com.google.common.base.Preconditions;
+
 public class Identifiers {
     
     private static Random random = new Random();
 
-    /** @see #JAVA_GOOD_PACKAGE_OR_CLASS_REGEX */ 
-    public static final String JAVA_GOOD_START_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_";
-    /** @see #JAVA_GOOD_PACKAGE_OR_CLASS_REGEX */ 
-    public static final String JAVA_GOOD_NONSTART_CHARS = JAVA_GOOD_START_CHARS+"1234567890";
+    public static final String UPPER_CASE_ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+    public static final String LOWER_CASE_ALPHA = "abcdefghijklmnopqrstuvwxyz";
+    public static final String NUMERIC = "1234567890";
+    public static final String NON_ALPHA_NUMERIC = "!$%@#";
+
+    /** @see #JAVA_GOOD_PACKAGE_OR_CLASS_REGEX */
+    public static final String JAVA_GOOD_START_CHARS = UPPER_CASE_ALPHA + LOWER_CASE_ALPHA +"_";
+    /** @see #JAVA_GOOD_PACKAGE_OR_CLASS_REGEX */
+    public static final String JAVA_GOOD_NONSTART_CHARS = JAVA_GOOD_START_CHARS+NUMERIC;
     /** @see #JAVA_GOOD_PACKAGE_OR_CLASS_REGEX */ 
     public static final String JAVA_GOOD_SEGMENT_REGEX = "["+JAVA_GOOD_START_CHARS+"]"+"["+JAVA_GOOD_NONSTART_CHARS+"]*";
     /** regex for a java package or class name using "good" chars, that is no accents or funny unicodes.
@@ -37,15 +45,21 @@ public class Identifiers {
     public static final String JAVA_GOOD_PACKAGE_OR_CLASS_REGEX = "("+JAVA_GOOD_SEGMENT_REGEX+"\\."+")*"+JAVA_GOOD_SEGMENT_REGEX;
     /** as {@link #JAVA_GOOD_PACKAGE_OR_CLASS_REGEX} but allowing a dollar sign inside a class name (e.g. Foo$1) */
     public static final String JAVA_GOOD_BINARY_REGEX = JAVA_GOOD_PACKAGE_OR_CLASS_REGEX+"(\\$["+JAVA_GOOD_NONSTART_CHARS+"]+)*";
-    
-    public static final String JAVA_GENERATED_IDENTIFIER_START_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-    public static final String JAVA_GENERATED_IDENTIFIERNONSTART_CHARS = JAVA_GENERATED_IDENTIFIER_START_CHARS+"1234567890";
+
+    public static final String JAVA_GENERATED_IDENTIFIER_START_CHARS = UPPER_CASE_ALPHA + LOWER_CASE_ALPHA;
+
+    public static final String JAVA_GENERATED_IDENTIFIERNONSTART_CHARS = JAVA_GENERATED_IDENTIFIER_START_CHARS+NUMERIC;
 
     public static final String BASE64_VALID_CHARS = JAVA_GENERATED_IDENTIFIERNONSTART_CHARS+"+=";
-    
-    public static final String ID_VALID_START_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-    public static final String ID_VALID_NONSTART_CHARS = ID_VALID_START_CHARS+"1234567890";
-    
+
+    public static final String ID_VALID_START_CHARS = UPPER_CASE_ALPHA + LOWER_CASE_ALPHA;
+    public static final String ID_VALID_NONSTART_CHARS = ID_VALID_START_CHARS+ NUMERIC;
+
+    public static final String PASSWORD_VALID_CHARS = NON_ALPHA_NUMERIC + ID_VALID_NONSTART_CHARS;
+
+    // We only create a secure random when it is first used
+    private static Random secureRandom = null;
+
     /** makes a random id string (letters and numbers) of the given length;
      * starts with letter (upper or lower) so can be used as java-id;
      * tests ensure random distribution, so random ID of length 5 
@@ -91,15 +105,53 @@ public class Identifiers {
         return new String(id);
     }
 
+    /**
+     *
+     * @param length of password to be returned
+     * @return randomly generated password containing at least one of each upper case,
+     * lower case, numeric, and non alpha-numeric characters.  Hopefully this is acceptible
+     * for most password schemes.
+     */
+    public static String makeRandomPassword(final int length) {
+        return makeRandomPassword(length, UPPER_CASE_ALPHA, LOWER_CASE_ALPHA, NUMERIC, NON_ALPHA_NUMERIC, PASSWORD_VALID_CHARS);
+    }
+
+    /**
+     * A fairly slow but hopefully secure way to randomly select characters for a password
+     * Takes a pool of acceptible characters using the first set in the pool for the first character,
+     * second set for the second character, ..., nth set for all remaining character.
+     *
+     * @param length length of password
+     * @param passwordValidCharsPool pool of acceptable character sets
+     * @return a randomly generated password
+     */
+    public static String makeRandomPassword(final int length, String... passwordValidCharsPool) {
+        Preconditions.checkState(length >= passwordValidCharsPool.length);
+        int l = 0;
+
+        char[] id = new char[length];
+
+        for(int i = 0; i < passwordValidCharsPool.length; i++){
+            id[l++] = pickRandomCharFrom(passwordValidCharsPool[i]);
+        }
+
+        String remainingValidChars = passwordValidCharsPool[passwordValidCharsPool.length - 1];
+
+        while(l < length) {
+            id[l++] = pickRandomCharFrom(remainingValidChars);
+        }
+        return new String(id);
+    }
+
     /** creates a short identifier comfortable in java and OS's, given an input hash code
      * <p>
-     * result is always at least of length 1, shorter if the hash is smaller */ 
+     * result is always at least of length 1, shorter if the hash is smaller */
     public static String makeIdFromHash(long d) {
         StringBuffer result = new StringBuffer();
         if (d<0) d=-d;
         // correction for Long.MIN_VALUE
         if (d<0) d=-(d+1000);
-        
+
         result.append(ID_VALID_START_CHARS.charAt((int)(d % (26+26))));
         d /= (26+26);
         while (d!=0) {
@@ -108,31 +160,31 @@ public class Identifiers {
         }
         return result.toString();
     }
-    
+
     /** makes a random id string (letters and numbers) of the given length;
      * starts with letter (upper or lower) so can be used as java-id;
-     * tests ensure random distribution, so random ID of length 5 
-     * is about 2^29 possibilities 
+     * tests ensure random distribution, so random ID of length 5
+     * is about 2^29 possibilities
      * <p>
-     * implementation is efficient, uses char array, and 
+     * implementation is efficient, uses char array, and
      * makes one call to random per 5 chars; makeRandomId(5)
      * takes about 4 times as long as a simple Math.random call,
      * or about 50 times more than a simple x++ instruction;
      * in other words, it's appropriate for contexts where random id's are needed,
-     * but use efficiently (ie cache it per object), and 
+     * but use efficiently (ie cache it per object), and
      * prefer to use a counter where feasible
      **/
     public static String makeRandomJavaId(int l) {
             // copied from Monterey util's com.cloudsoftcorp.util.StringUtils.
             // TODO should share code with makeRandomId, just supplying different char sets (though the char sets in fact are the same..)
 
-            //this version is 30-50% faster than the old double-based one, 
+            //this version is 30-50% faster than the old double-based one,
             //which computed a random every 3 turns --
             //takes about 600 ns to do id of len 10, compared to 10000 ns for old version [on 1.6ghz machine]
             if (l<=0) return "";
             char[] id = new char[l];
             int d = random.nextInt( (26+26) * (26+26+10) * (26+26+10) * (26+26+10) * (26+26+10));
-            int i = 0;    
+            int i = 0;
             id[i] = JAVA_GENERATED_IDENTIFIER_START_CHARS.charAt(d % (26+26));
             d /= (26+26);
             if (++i<l) do {
@@ -151,6 +203,7 @@ public class Identifiers {
     public static double randomDouble() {
         return random.nextDouble();
     }
+
     public static long randomLong() {
         return random.nextLong();
     }
@@ -173,7 +226,6 @@ public class Identifiers {
         byte[] buf = new byte[length];
         return randomBytes(buf);
     }
-
     public static String makeRandomBase64Id(int length) {
         StringBuilder s = new StringBuilder();
         while (length>0) {
@@ -182,6 +234,7 @@ public class Identifiers {
         }
         return s.toString();
     }
+
     public static String getBase64IdFromValue(long value) {
         return getBase64IdFromValue(value, 10);
     }
@@ -210,7 +263,6 @@ public class Identifiers {
             idx = idx >> 6;
         }
     }
-    
     public static boolean isValidToken(String token, String validStartChars, String validSubsequentChars) {
         if (token==null || token.length()==0) return false;
         if (validStartChars.indexOf(token.charAt(0))==-1) return false;
@@ -218,4 +270,15 @@ public class Identifiers {
             if (validSubsequentChars.indexOf(token.charAt(i))==-1) return false;
         return true;
     }
+
+    private static char pickRandomCharFrom(String validChars) {
+        return validChars.charAt(getSecureRandom().nextInt(validChars.length()));
+    }
+
+    private static Random getSecureRandom() {
+        if(secureRandom == null) {
+            secureRandom = new SecureRandom();
+        }
+        return secureRandom;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50f70fe5/brooklyn-server/utils/common/src/test/java/org/apache/brooklyn/util/text/IdentifiersTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/utils/common/src/test/java/org/apache/brooklyn/util/text/IdentifiersTest.java b/brooklyn-server/utils/common/src/test/java/org/apache/brooklyn/util/text/IdentifiersTest.java
index 7b4f999..37c6443 100644
--- a/brooklyn-server/utils/common/src/test/java/org/apache/brooklyn/util/text/IdentifiersTest.java
+++ b/brooklyn-server/utils/common/src/test/java/org/apache/brooklyn/util/text/IdentifiersTest.java
@@ -21,8 +21,6 @@ package org.apache.brooklyn.util.text;
 import java.util.HashSet;
 import java.util.Set;
 
-import org.apache.brooklyn.util.text.Identifiers;
-import org.apache.brooklyn.util.text.Strings;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.Assert;
@@ -98,5 +96,17 @@ public class IdentifiersTest {
         Assert.assertTrue("foo".matches(Identifiers.JAVA_GOOD_BINARY_REGEX));
         Assert.assertTrue("foo.bar.Baz$1".matches(Identifiers.JAVA_GOOD_BINARY_REGEX));
     }
+
+    @Test
+    public void testPassword() {
+        String upper = "ABC";
+        String numbers = "123";
+        String symbols = "!£$";
+        String id1 = Identifiers.makeRandomPassword(4, upper, numbers, symbols, Identifiers.PASSWORD_VALID_CHARS);
+
+        Assert.assertTrue(upper.contains(id1.substring(0,1)));
+        Assert.assertTrue(numbers.contains(id1.substring(1,2)));
+        Assert.assertTrue(symbols.contains(id1.substring(2,3)));
+    }
     
 }


[03/10] incubator-brooklyn git commit: add more examples to `netcat` illustration, showing port inference, parameters, catalog, and more.

Posted by he...@apache.org.
add more examples to `netcat` illustration,
showing port inference, parameters, catalog, and more.


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

Branch: refs/heads/master
Commit: 411d3f8a3536de6e321dea14d72cdffeb9938310
Parents: ecbd90e
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Thu Jan 21 13:17:08 2016 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Thu Jan 21 13:55:53 2016 +0000

----------------------------------------------------------------------
 brooklyn-docs/guide/yaml/custom-entities.md     | 154 +++++++++++++++++--
 .../vanilla-bash-netcat-catalog.bom             |  35 +++++
 .../vanilla-bash-netcat-cluster.yaml            |  11 ++
 .../vanilla-bash-netcat-more-commands.yaml      |  16 ++
 .../vanilla-bash-netcat-port-parameter.yaml     |  21 +++
 .../example_yaml/vanilla-bash-netcat-port.yaml  |  13 ++
 .../vanilla-bash-netcat-reference.yaml          |   5 +
 .../vanilla-bash-netcat-restarter.yaml          |   2 +-
 .../vanilla-bash-netcat-w-client.yaml           |   2 +-
 .../yaml/example_yaml/vanilla-bash-netcat.yaml  |  10 --
 brooklyn-docs/guide/yaml/yaml-reference.md      |  32 ++--
 11 files changed, 266 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/411d3f8a/brooklyn-docs/guide/yaml/custom-entities.md
----------------------------------------------------------------------
diff --git a/brooklyn-docs/guide/yaml/custom-entities.md b/brooklyn-docs/guide/yaml/custom-entities.md
index 6f21c14..9698aa8 100644
--- a/brooklyn-docs/guide/yaml/custom-entities.md
+++ b/brooklyn-docs/guide/yaml/custom-entities.md
@@ -24,15 +24,26 @@ The following blueprint shows how a simple script can be embedded in the YAML
 {% endhighlight %}
 
 This starts a simple `nc` listener on port 4321 which will respond `hello` to the first
-session which connects to it. Test it by running `telnet localhost 4321`.  
+session which connects to it. Test it by running `telnet localhost 4321`
+or opening `http://localhost:4321` in a browser.
+
+Note that it only allows you connect once, and after that it fails.
+This is deliberate! We'll repair this later in this example.
+Until then however, in the *Applications* view you can click the server,
+go to the `Effectors` tab, and click `restart` to bring if back to life.  
 
 This is just a simple script, but it shows how any script can be easily embedded here,
 including a script to download and run other artifacts.
 Many artifacts are already packaged such that they can be downloaded and launched 
 with a simple script, and `VanillaSoftwareProcess` can also be used for them. 
-We can specify a `download.url` which downloads artifacts (unpacking TAR, TGZ, and ZIP archives)
+
+
+#### Downloading Files
+
+We can specify a `download.url` which downloads an artifact 
+(and automatically unpacking TAR, TGZ, and ZIP archives)
 before running `launch.command` relative to where that file is installed (or unpacked),
-with `./start.sh` being the default `launch.command`.
+with the default `launch.command` being `./start.sh`.
 
 So if we create a file `/tmp/netcat-server.tgz` containing just `start.sh` in the root
 which consists of the two lines in the previous example,
@@ -42,17 +53,130 @@ we can instead write our example as:
 {% readj example_yaml/vanilla-bash-netcat-file.yaml %}
 {% endhighlight %}
 
-The one requirement of the script is that it store the process ID (PID) in the file
+
+#### Port Inferencing
+
+If you're deploying to a cloud machine, a firewall might block the port 4321.
+We can tell Brooklyn to open this port explicitly by specifying `inboundPorts: [ 4321 ]`;
+however a more idiomatic way is to specify a config ending with `.port`,
+such as:
+
+{% highlight yaml %}
+{% readj example_yaml/vanilla-bash-netcat-port.yaml %}
+{% endhighlight %}
+
+The regex for ports to be opened can be configured using
+the config `inboundPorts.configRegex` (which has `.*\.port` as the default value).
+
+Config keys of type `org.apache.brooklyn.api.location.PortRange` (aka `port`)
+have special behaviour: when configuring, you can use range notation `8000-8100` or `8000+` to tell Brooklyn
+to find **one** port matching; this is useful when ports might be in use.
+In addition, any such config key will be opened, 
+irrespective of whether it matches the `inboundPorts.configRegex`. 
+To prevent any inferencing of ports to open, you can set the config `inboundPorts.autoInfer` to `false`.
+
+Note that in the example above, `netcat.port` must be specified in a `brooklyn.config` block.
+This block can be used to hold any config (including for example the `launch.command`),
+but for convenience Brooklyn allows config keys declared on the underlying type
+to be specified up one level, alongside the type.
+However config keys which are *not* declared on the type *must* be declared in the `brooklyn.config` block. 
+
+
+#### Declaring New Config Keys
+
+We can define config keys to be presented to the user 
+using the `brooklyn.parameters` block:
+
+{% highlight yaml %}
+{% readj example_yaml/vanilla-bash-netcat-port-parameter.yaml %}
+{% endhighlight %}
+
+The example above will allow a user to specify a message to send back
+and the port where netcat will listen.
+The metadata on these parameters is available at runtime in the UI
+and through the API, and is used when populating a catalog.
+
+The example also shows how these values can be passed as environment variables to the launch command.
+The `$brooklyn:config(...)` function returns the config value supplied or default.
+For the type `port`, an attribute sensor is also created to report the *actual* port used after port inference,
+and so the `$brooklyn:attributeWhenReady(...)` function is used.
+(If `$brooklyn:config("netcat.port")` had been used, `4321+` would be passed as `NETCAT_PORT`.)
+
+This gives us quite a bit more power in writing our blueprint:
+
+* Multiple instances of the server can be launched simultaneously on the same host, 
+  as the `4321+` syntax enables Brooklyn to assign them different ports
+* If this type is added to the catalog, a user can configure the message and the port;
+  we'll show this in the next section
+
+
+#### Using the Catalog and Clustering
+
+The *Catalog* tab allows you to add blueprints which you can refer to in other blueprints.
+In that tab, click *+* then *YAML*, and enter the following:
+
+{% highlight yaml %}
+{% readj example_yaml/vanilla-bash-netcat-catalog.bom %}
+{% endhighlight %}
+
+This is the same example as in the previous section, wrapped according to the catalog YAML requirements,
+with one new block added defining an enricher. An enricher creates a new sensor from other values;
+in this case it will create a `main.uri` sensor by populating a `printf`-style string `"http://%s:%s"`
+with the sensor values.
+
+With this added to the catalog, we can reference the type `netcat-example` when we deploy an application.
+Return to the *Home* or *Applications* tab, click *+*, and submit this YAML blueprint:
+
+{% highlight yaml %}
+{% readj example_yaml/vanilla-bash-netcat-reference.yaml %}
+{% endhighlight %}
+
+This extends the previous blueprint which we registered in the catalog,
+meaning that we don't need to include it each time.
+Here, we've elected to supply our own message, but we'll use the default port.
+More importantly, we can package it for others to consume -- or take items others have built.
+
+We can go further and use this to deploy a cluster,
+this time giving a custom port as well as a custom message: 
+
+{% highlight yaml %}
+{% readj example_yaml/vanilla-bash-netcat-cluster.yaml %}
+{% endhighlight %}
+
+In either of the above examples, if you explore the tree in the *Applications* view
+and look at the *Summary* tab of any of the server instances, you'll now see the URL where netcat is running.
+But remember, netcat will stop after one run, so you'll only be able to use each link once
+before you have to restart it.  You can also run `restart` on the cluster,
+and if you haven't yet experimented with `resize` on the cluster you might want to do that.
+
+
+#### Determining Successful Launch
+
+One requirement of the launch script is that it store the process ID (PID) in the file
 pointed to by `$PID_FILE`, hence the second line of the script.
-This is because Brooklyn wants to monitor the services under management. 
-(There are other options; you can set `checkRunning.command` and `stop.command` instead,
-as documented on the Javadoc of the `VanillaSoftwareProcess` class,
-and those scripts will be used instead of checking and stopping the process whose PID is in `$PID_FILE`.)
+This is because Brooklyn wants to monitor the services under management.
+You'll observe this if you connect to one of the netcat services,
+as the process exits afterwards and Brooklyn sets the entity to an `ON_FIRE` state.
+(You can also test this with a `killall nc` before connecting
+or issueing a `stop` command on the server -- but not on the example,
+as stopping an application root causes it to be removed altogether!) 
+
+There are other options for determining launch: you can set `checkRunning.command` and `stop.command` instead,
+as documented on the javadoc and config keys of the {% include java_link.html class_name="VanillaSoftwareProcess" package_path="org/apache/brooklyn/entity/software/base" project_subpath="software/base" %} class,
+and those scripts will be used instead of checking and stopping the process whose PID is in `$PID_FILE`.
+
+{% highlight yaml %}
+{% readj example_yaml/vanilla-bash-netcat-more-commands.yaml %}
+{% endhighlight %}
 
 And indeed, once you've run one `telnet` to the server, you'll see that the 
-service has gone "on fire" in Brooklyn -- because the `nc` process has stopped. 
+service has gone "on fire" in Brooklyn -- because the `nc` process stops after one run. 
+
+
+#### Attaching Policies
+
 Besides detecting this failure, Brooklyn policies can be added to the YAML to take appropriate 
-action. A simple recovery here might just be to restart the process:
+action. A simple recovery here might just to automatically restart the process:
 
 {% highlight yaml %}
 {% readj example_yaml/vanilla-bash-netcat-restarter.yaml %}
@@ -67,6 +191,9 @@ This makes it easy to configure various aspects, such as to delay to see if the
 Running with this blueprint, you'll see that the service shows as on fire for 15s after a `telnet`,
 before the policy restarts it. 
 
+
+### Sensors and Effectors
+
 For an even more interesting way to test it, look at the blueprint defining
 [a netcat server and client](example_yaml/vanilla-bash-netcat-w-client.yaml).
 This uses `initializers` to define an effector to `sayHiNetcat` on the `Simple Pinger` client,
@@ -100,8 +227,11 @@ so that the `$message` we passed above gets logged and reported back:
           period: 1s
           command: tail -1 server-input
 
-This is still a simple example, but worth going through carefully.
-It shows many of the building blocks used in real-world blueprints,
+
+#### Summary
+
+These examples are relatively simple example, but they
+illustrate many of the building blocks used in real-world blueprints,
 and how they can often be easily described and combined in Brooklyn YAML blueprints.
 Next, if you need to drive off-piste, or you want to write tests against these blueprints,
 have a look at, for example, `VanillaBashNetcatYamlTest.java` in the Brooklyn codebase,

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/411d3f8a/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-catalog.bom
----------------------------------------------------------------------
diff --git a/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-catalog.bom b/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-catalog.bom
new file mode 100644
index 0000000..7551818
--- /dev/null
+++ b/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-catalog.bom
@@ -0,0 +1,35 @@
+brooklyn.catalog:
+  id: netcat-example
+  version: "1.0"
+  item:
+    type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess
+    name: Simple Netcat Server
+
+    launch.command: |
+      echo $MESSAGE | nc -l $NETCAT_PORT &
+      echo $! > $PID_FILE
+        
+    env:
+      MESSAGE: $brooklyn:config("message")
+      NETCAT_PORT: $brooklyn:attributeWhenReady("netcat.port")
+      
+    brooklyn.parameters:
+    - name: message
+      description: a message to send to the caller
+      default: hello
+    - name: netcat.port
+      type: port
+      description: the port netcat should run on
+      default: 4321+
+
+    brooklyn.enrichers:
+    - type: org.apache.brooklyn.enricher.stock.Transformer
+      brooklyn.config:
+        uniqueTag: main-uri-generator
+        enricher.sourceSensor: $brooklyn:sensor("host.address")
+        enricher.targetSensor: $brooklyn:sensor("main.uri")
+        enricher.targetValue:
+          $brooklyn:formatString:
+          - "http://%s:%s/"
+          - $brooklyn:attributeWhenReady("host.address")
+          - $brooklyn:attributeWhenReady("netcat.port")

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/411d3f8a/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-cluster.yaml
----------------------------------------------------------------------
diff --git a/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-cluster.yaml b/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-cluster.yaml
new file mode 100644
index 0000000..70b69af
--- /dev/null
+++ b/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-cluster.yaml
@@ -0,0 +1,11 @@
+name: Netcat Cluster Example
+location: localhost
+services:
+- type: org.apache.brooklyn.entity.group.DynamicCluster
+  memberSpec:
+    $brooklyn:entitySpec:
+      type: netcat-example
+      message: hello from cluster member
+      netcat.port: 8000+
+  initialSize: 3
+  restartMode: parallel

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/411d3f8a/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-more-commands.yaml
----------------------------------------------------------------------
diff --git a/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-more-commands.yaml b/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-more-commands.yaml
new file mode 100644
index 0000000..f4e894f
--- /dev/null
+++ b/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-more-commands.yaml
@@ -0,0 +1,16 @@
+name: Netcat Example with Explicit Check and Stop Commands
+location: localhost
+services:
+- type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess
+  name: Simple Netcat Server
+  launch.command: |
+    echo hello | nc -l 4321 &
+    echo $! > $PID_FILE
+
+  # The following overrides demonstrate the use of a custom shell environment as well as
+  # check-running and stop commands. These are optional; default behavior will "do the
+  # right thing" with the pid file automatically.
+
+  env:                  { CHECK_MARKER: "checkRunning", STOP_MARKER: "stop" }
+  checkRunning.command: echo $CHECK_MARKER >> DATE && test -f "$PID_FILE" && ps -p `cat $PID_FILE` >/dev/null
+  stop.command:         echo $STOP_MARKER  >> DATE && test -f "$PID_FILE" && { kill -9 `cat $PID_FILE`; rm /tmp/vanilla.pid; }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/411d3f8a/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-port-parameter.yaml
----------------------------------------------------------------------
diff --git a/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-port-parameter.yaml b/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-port-parameter.yaml
new file mode 100644
index 0000000..90f83b4
--- /dev/null
+++ b/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-port-parameter.yaml
@@ -0,0 +1,21 @@
+name: Netcat Example with Parameter
+location: localhost
+services:
+- type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess
+  name: Simple Netcat Server
+  launch.command: |
+    echo $MESSAGE | nc -l $NETCAT_PORT &
+    echo $! > $PID_FILE
+    
+  env:
+    MESSAGE: $brooklyn:config("message")
+    NETCAT_PORT: $brooklyn:attributeWhenReady("netcat.port")
+  
+  brooklyn.parameters:
+  - name: message
+    description: a message to send to the caller
+    default: hello
+  - name: netcat.port
+    type: port
+    description: the port netcat should run on
+    default: 4321+

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/411d3f8a/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-port.yaml
----------------------------------------------------------------------
diff --git a/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-port.yaml b/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-port.yaml
new file mode 100644
index 0000000..3ec0212
--- /dev/null
+++ b/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-port.yaml
@@ -0,0 +1,13 @@
+name: Netcat Example with Port Opened
+location: localhost
+services:
+- type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess
+  name: Simple Netcat Server
+  launch.command: |
+    echo hello | nc -l 4321 &
+    echo $! > $PID_FILE
+    
+  brooklyn.config:
+    # matching the regex `.*\.port` will cause the port to be opened
+    # if in a cloud where configurable security groups are available
+    netcat.port: 4321

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/411d3f8a/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-reference.yaml
----------------------------------------------------------------------
diff --git a/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-reference.yaml b/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-reference.yaml
new file mode 100644
index 0000000..0f10c55
--- /dev/null
+++ b/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-reference.yaml
@@ -0,0 +1,5 @@
+name: Netcat Type Reference Example
+location: localhost
+services:
+- type: netcat-example
+  message: hello from netcat using a registered type

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/411d3f8a/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-restarter.yaml
----------------------------------------------------------------------
diff --git a/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-restarter.yaml b/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-restarter.yaml
index adaa933..47e54ab 100644
--- a/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-restarter.yaml
+++ b/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-restarter.yaml
@@ -1,4 +1,4 @@
-name: Simple Netcat Example with Restarter Policy
+name: Netcat Example with Restarter Policy
 location: localhost
 services:
 - type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/411d3f8a/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-w-client.yaml
----------------------------------------------------------------------
diff --git a/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-w-client.yaml b/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-w-client.yaml
index 8290b79..78ed99e 100644
--- a/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-w-client.yaml
+++ b/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat-w-client.yaml
@@ -1,4 +1,4 @@
-name: Simple Netcat with Client
+name: Netcat Example with Client
 
 location: localhost
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/411d3f8a/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat.yaml
----------------------------------------------------------------------
diff --git a/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat.yaml b/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat.yaml
index 3023038..df616af 100644
--- a/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat.yaml
+++ b/brooklyn-docs/guide/yaml/example_yaml/vanilla-bash-netcat.yaml
@@ -6,13 +6,3 @@ services:
   launch.command: |
     echo hello | nc -l 4321 &
     echo $! > $PID_FILE
-
-  # The following overrides demonstrate the use of a custom shell environment as well as
-  # check-running and stop commands. These are optional; default behavior will "do the
-  # right thing" with the pid file automatically.
-
-  env:                  { CHECK_MARKER: "checkRunning", STOP_MARKER: "stop" }
-  checkRunning.command: echo $CHECK_MARKER >> DATE && test -f "$PID_FILE" && ps -p `cat $PID_FILE` >/dev/null
-  stop.command:         echo $STOP_MARKER  >> DATE && test -f "$PID_FILE" && { kill -9 `cat $PID_FILE`; rm /tmp/vanilla.pid; }
-
-# can also define download.url, in which case the launch command defaults to ./start.sh in that (archive) file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/411d3f8a/brooklyn-docs/guide/yaml/yaml-reference.md
----------------------------------------------------------------------
diff --git a/brooklyn-docs/guide/yaml/yaml-reference.md b/brooklyn-docs/guide/yaml/yaml-reference.md
index 36656bb..7a628a0 100644
--- a/brooklyn-docs/guide/yaml/yaml-reference.md
+++ b/brooklyn-docs/guide/yaml/yaml-reference.md
@@ -67,22 +67,32 @@ the entity being defined, with these being the most common:
   * `description`: short text describing the parameter behaviour/usage, presented
     to the user
   * `type`: the type of the parameter, one of `string`, `integer`, `long`, `float`,
-    `double`, `timestamp`, `port`, a fully qualified Java type name. Default is `string`.
-  * `default`: a default value, converted to the type above
-  * `constraints`: a list of constraints the parameter should meet, currently
-    `required` is supported
-
-  A shorthand notation is also supported where the name of the parameter is directly
-  passed as an item in the list. For example:
+    `double`, `timestamp`, `duration`, `port`, or a fully qualified Java type name;
+    the default is `string`;
+    obvious coercion is supported so 
+    `timestamp` accepts most common ISO date formats, `duration` accepts `5m`, and port accepts `8080+`
+  * `default`: a default value; this will be coerced to the declared `type`
+  * `constraints`: a list of constraints the parameter should meet;
+    currently `required` is supported, with the default being not required
+
+  A shorthand notation is also supported where just the name of the parameter is supplied
+  as an item in the list, with the other values being unset or the default.
+  See `displayName` in the following example for an illustration of this:
 
 ~~~ yaml
 brooklyn.parameters:
-- displayName
-- name: user.name
-  constraints:
-  - required
+# user.age parameter is required, and fully specified
 - name: user.age
   type: integer
+  label: Age
+  description: the age of the user
+  constraints:
+  - required
+# user.name is optional, and has a default
+- name: user.name
+  default: You
+# shorthand notation: displayName will be an optional config of type string with no default
+- displayName
 ~~~
 
 Entities, policies, and initializers may accept additional key-value pairs,


[07/10] incubator-brooklyn git commit: revert generics change as it causes inconsistent failures in different JVM's

Posted by he...@apache.org.
revert generics change as it causes inconsistent failures in different JVM's


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

Branch: refs/heads/master
Commit: 03725f4cc582ad5870c34c4437fcd1f4e6f1926c
Parents: 624cf2a
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Fri Jan 22 11:58:16 2016 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Fri Jan 22 11:58:16 2016 +0000

----------------------------------------------------------------------
 .../org/apache/brooklyn/rest/transform/CatalogTransformer.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/03725f4c/brooklyn-server/rest/rest-server/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/rest/rest-server/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java b/brooklyn-server/rest/rest-server/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java
index 3c19625..514d9c9 100644
--- a/brooklyn-server/rest/rest-server/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java
+++ b/brooklyn-server/rest/rest-server/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java
@@ -69,7 +69,11 @@ public class CatalogTransformer {
 
         EntitySpec<?> spec = null;
         try {
-            spec = (EntitySpec<?>) b.getCatalog().createSpec(item);
+            @SuppressWarnings({ "unchecked", "rawtypes" })
+            // the raw type isn't needed according to eclipse IDE, but jenkins maven fails without it;
+            // must be a java version or compiler thing. don't remove even though it looks okay without it!
+            EntitySpec<?> specRaw = (EntitySpec<?>) b.getCatalog().createSpec((CatalogItem) item);
+            spec = specRaw;
             EntityDynamicType typeMap = BrooklynTypes.getDefinedEntityType(spec.getType());
             EntityType type = typeMap.getSnapshot();
 


[04/10] incubator-brooklyn git commit: start fleshing out release notes, including reference to the new parameters example

Posted by he...@apache.org.
start fleshing out release notes, including reference to the new parameters example


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

Branch: refs/heads/master
Commit: 624cf2ac0f7e5353f685bcdba296f329bceeebf2
Parents: 411d3f8
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Thu Jan 21 13:34:02 2016 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Thu Jan 21 13:55:53 2016 +0000

----------------------------------------------------------------------
 brooklyn-docs/guide/misc/release-notes.md | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/624cf2ac/brooklyn-docs/guide/misc/release-notes.md
----------------------------------------------------------------------
diff --git a/brooklyn-docs/guide/misc/release-notes.md b/brooklyn-docs/guide/misc/release-notes.md
index 3661ab1..ef79155 100644
--- a/brooklyn-docs/guide/misc/release-notes.md
+++ b/brooklyn-docs/guide/misc/release-notes.md
@@ -16,7 +16,7 @@ title: Release Notes
 
 ### Introduction
 
-Version 0.8.0 is [TODO add description] 
+Version 0.9.0 is [TODO add description] 
 
 Thanks go to our community for their improvements, feedback and guidance, and
 to Brooklyn's commercial users for funding much of this development.
@@ -24,7 +24,21 @@ to Brooklyn's commercial users for funding much of this development.
 
 ### New Features
 
-[TODO]
+1. Parameters (config keys) can now be defined in YAML, using `brooklyn.parameters`.
+This allows YAML entities to advertise how they should be parameterized,
+for use in the UI and in documentation tools, and do coercion on these values.
+For a good demonstration, see the "Custom Entities" section of the YAML chapter of the user guide. 
+
+[ TODO - 
+restructuring and graduation; 
+the `br` client CLI tool;
+test framework;
+`$brooklyn:external(...)` extension for taking values from other sources is supported in more places;
+better YAML editor in the UI;
+OSGi-native mode using Karaf, to simplify packaging of blueprints;
+a new pure-java WinRM client (winrm4j), hugely reducing the number of dependencies and distro size;
+several version bumps (jclouds) and performance and reliability improvements
+]
  
 
 ### Backwards Compatibility
@@ -49,10 +63,10 @@ parent or application root in YAML. Related to this, tags from referencing specs
 and the referencing catalog item ID also takes priority; this has no effect in most cases, but if you have a chain of
 referenced types blueprint plan source code and the catalog item ID are now set correctly. 
 
-For changes in prior versions, please refer to the release notes for 
-[0.8.0](/v/0.8.0-incubating/misc/release-notes.html).
-
 3. Task cancellation is now propagated to dependent submitted tasks, including backgrounded tasks if they are transient.
 Previously when a task was cancelled the API did not guarantee semantics but the behaviour was to cancel sub-tasks only 
 in very limited cases. Now the semantics are more precise and controllable, and more sub-tasks are cancelled.
 This can prevent some leaked waits on `attributeWhenReady`.
+
+For changes in prior versions, please refer to the release notes for 
+[0.8.0](/v/0.8.0-incubating/misc/release-notes.html).


[09/10] incubator-brooklyn git commit: This closes #1166

Posted by he...@apache.org.
This closes #1166


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

Branch: refs/heads/master
Commit: 73839fa39c291eeeba9ca78e0d0bd2881d8ae986
Parents: a6f3219 03725f4
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Sat Jan 30 03:41:59 2016 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Sat Jan 30 03:41:59 2016 +0000

----------------------------------------------------------------------
 brooklyn-docs/guide/misc/release-notes.md       |  24 ++-
 brooklyn-docs/guide/yaml/custom-entities.md     | 154 +++++++++++++++++--
 .../vanilla-bash-netcat-catalog.bom             |  35 +++++
 .../vanilla-bash-netcat-cluster.yaml            |  11 ++
 .../vanilla-bash-netcat-more-commands.yaml      |  16 ++
 .../vanilla-bash-netcat-port-parameter.yaml     |  21 +++
 .../example_yaml/vanilla-bash-netcat-port.yaml  |  13 ++
 .../vanilla-bash-netcat-reference.yaml          |   5 +
 .../vanilla-bash-netcat-restarter.yaml          |   2 +-
 .../vanilla-bash-netcat-w-client.yaml           |   2 +-
 .../yaml/example_yaml/vanilla-bash-netcat.yaml  |  10 --
 brooklyn-docs/guide/yaml/yaml-reference.md      |  32 ++--
 .../apache/brooklyn/api/objs/SpecParameter.java |  16 +-
 .../catalog/SpecParameterParsingTest.java       |  18 +--
 .../brooklyn/core/config/BasicConfigKey.java    |  10 +-
 .../brooklyn/core/config/ConfigConstraints.java |   3 +-
 .../brooklyn/core/effector/Effectors.java       |  16 +-
 .../AbstractConfigurationSupportInternal.java   |   5 +-
 .../brooklyn/core/objs/BasicSpecParameter.java  |  68 ++++++--
 .../core/objs/BrooklynObjectInternal.java       |  11 ++
 .../core/objs/proxy/InternalEntityFactory.java  |  14 +-
 .../sensor/AttributeSensorAndConfigKey.java     |   9 +-
 .../sensor/PortAttributeSensorAndConfigKey.java |   6 +
 .../brooklyn/entity/group/DynamicCluster.java   |   8 +
 .../entity/group/DynamicClusterImpl.java        |  24 ++-
 .../brooklyn/util/core/flags/FlagUtils.java     |   2 +-
 .../brooklyn/util/core/flags/TypeCoercions.java |   4 +-
 .../brooklyn/util/core/task/ValueResolver.java  |  12 ++
 .../objs/BasicSpecParameterFromClassTest.java   |   2 +-
 .../objs/BasicSpecParameterFromListTest.java    |  14 +-
 .../rest/transform/CatalogTransformer.java      |  12 +-
 .../rest/transform/EntityTransformer.java       |   2 +-
 ...wareProcessDriverLifecycleEffectorTasks.java |   3 +-
 .../base/VanillaSoftwareProcessSshDriver.java   |  28 +++-
 34 files changed, 502 insertions(+), 110 deletions(-)
----------------------------------------------------------------------