[GitHub] brooklyn-server pull request #300: Location DSL Updates

2017-04-11 Thread grkvlt
Github user grkvlt closed the pull request at:

https://github.com/apache/brooklyn-server/pull/300


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-server pull request #300: Location DSL Updates

2016-09-21 Thread neykov
Github user neykov commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/300#discussion_r79842987
  
--- Diff: 
core/src/main/java/org/apache/brooklyn/entity/group/DynamicFabric.java ---
@@ -67,9 +69,7 @@
 public static final AttributeSensor SERVICE_STATE_ACTUAL = 
Attributes.SERVICE_STATE_ACTUAL;
 
 public void setMemberSpec(EntitySpec memberSpec);
-
-public void setFactory(EntityFactory factory);
-
--- End diff --

Should we go through a deprecation cycle here?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-server pull request #300: Location DSL Updates

2016-09-21 Thread neykov
Github user neykov commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/300#discussion_r79842886
  
--- Diff: 
core/src/main/java/org/apache/brooklyn/entity/group/DynamicFabric.java ---
@@ -18,39 +18,41 @@
  */
 package org.apache.brooklyn.entity.group;
 
+import java.util.List;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.reflect.TypeToken;
+
 import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.entity.ImplementedBy;
+import org.apache.brooklyn.api.location.LocationSpec;
 import org.apache.brooklyn.api.sensor.AttributeSensor;
 import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.core.config.ConfigKeys;
 import org.apache.brooklyn.core.config.MapConfigKey;
 import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.entity.factory.EntityFactory;
 import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
 import org.apache.brooklyn.core.entity.trait.Startable;
 import org.apache.brooklyn.core.sensor.Sensors;
 import org.apache.brooklyn.util.core.flags.SetFromFlag;
 
-import com.google.common.collect.ImmutableMap;
-import com.google.common.reflect.TypeToken;
-
 /**
- * When a dynamic fabric is started, it starts an entity in each of its 
locations. 
- * This entity will be the parent of each of the started entities. 
+ * When a dynamic fabric is started, it starts an entity in each of its 
locations.
+ * This entity will be the parent of each of the started entities.
  */
 @ImplementedBy(DynamicFabricImpl.class)
 @SuppressWarnings("serial")
 public interface DynamicFabric extends AbstractGroup, Startable, Fabric {
 
 public static final AttributeSensor FABRIC_SIZE = 
Sensors.newIntegerSensor("fabric.size", "Fabric size");
-
+
 @SetFromFlag("memberSpec")
 public static final ConfigKey> MEMBER_SPEC = 
ConfigKeys.newConfigKey(
-new TypeToken>() {}, 
"dynamiccfabric.memberspec", "entity spec for creating new cluster members", 
null);
+new TypeToken>() {}, 
"dynamiccfabric.memberspec", "Entity specification for creating new cluster 
members", null);
 
-@SetFromFlag("factory")
-public static final ConfigKey> FACTORY = 
ConfigKeys.newConfigKey(
-new TypeToken>() {}, "dynamicfabric.factory", 
"factory for creating new cluster members", null);
+@SetFromFlag("locationSpecs")
+public static final ConfigKey>> LOCATION_SPECS = 
ConfigKeys.newConfigKey(
+new TypeToken>>() {}, 
"dynamiccfabric.locationspecs", "List of location specifications for starting 
new cluster members", null);
--- End diff --

Persistence/backwards compatibility concerns.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-server pull request #300: Location DSL Updates

2016-09-21 Thread neykov
Github user neykov commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/300#discussion_r79833570
  
--- Diff: 
core/src/main/java/org/apache/brooklyn/entity/group/DynamicFabricImpl.java ---
@@ -134,29 +125,39 @@ public void start(Collection 
locsO) {
 it = locationsToStart.get(locIndex++ % 
locationsToStart.size());
 
((EntityInternal)child).addLocations(Arrays.asList(it));
 }
-
+
 tasks.put(child, Entities.submit(this,
-Effectors.invocation(child, START, 
ImmutableMap.of("locations", 
+Effectors.invocation(child, START, 
ImmutableMap.of("locations",
 it==null ? ImmutableList.of() : 
ImmutableList.of(it))).asTask()));
 }
 }
 // remove all the locations we applied to existing nodes
 while (locIndex-->0 && !locationsToStart.isEmpty())
 locationsToStart.remove(0);
 
-// finally (and usually) we create new entities for locations 
passed in
+// now look at the configured location specs
+List> locationSpecs = 
MutableList.copyOf(config().get(LOCATION_SPECS));
+if (locationSpecs.size() > 0) {
+// use these in addition to locations passed to start 
method
+for (LocationSpec spec : locationSpecs) {
+Location location = 
getManagementContext().getLocationManager().createLocation(spec);
+locationsToStart.add(location);
+}
--- End diff --

Where are these locations unmanaged?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-server pull request #300: Location DSL Updates

2016-09-21 Thread neykov
Github user neykov commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/300#discussion_r79832991
  
--- Diff: 
camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java
 ---
@@ -84,51 +89,72 @@ public DslComponent(DslComponent scopeComponent, Scope 
scope, String componentId
 }
 
 // ---
-
+
 @Override
-public Task newTask() {
-return 
TaskBuilder.builder().displayName(toString()).tag(BrooklynTaskTags.TRANSIENT_TASK_TAG)
-.body(new EntityInScopeFinder(scopeComponent, scope, 
componentId)).build();
+public Task newTask() {
+return TaskBuilder.builder()
+.displayName(toString())
+.tag(BrooklynTaskTags.TRANSIENT_TASK_TAG)
+.body(new ObjectInScopeFinder(scopeComponent, scope, 
componentId))
+.build();
 }
-
-protected static class EntityInScopeFinder implements Callable 
{
+
+protected static class ObjectInScopeFinder implements Callable {
 protected final DslComponent scopeComponent;
 protected final Scope scope;
 protected final String componentId;
 
-public EntityInScopeFinder(DslComponent scopeComponent, Scope 
scope, String componentId) {
+public ObjectInScopeFinder(DslComponent scopeComponent, Scope 
scope, String componentId) {
 this.scopeComponent = scopeComponent;
 this.scope = scope;
 this.componentId = componentId;
 }
 
 protected EntityInternal getEntity() {
 if (scopeComponent!=null) {
-return (EntityInternal)scopeComponent.get();
+return (EntityInternal) scopeComponent.get();
 } else {
 return entity();
 }
 }
-
+
+protected LocationInternal getLocation() {
+if (scopeComponent!=null) {
+return (LocationInternal) scopeComponent.get();
+} else {
+throw new IllegalStateException("Scope component must be 
set");
+}
+}
+
 @Override
-public Entity call() throws Exception {
-Iterable entitiesToSearch = null;
+public O call() throws Exception {
 EntityInternal entity = getEntity();
+
+if (scope == Scope.LOCATION) {
+Maybe machine = 
Machines.findUniqueMachineLocation(entity.getLocations(), 
SshMachineLocation.class);
--- End diff --

It makes sense to expose only machine locations - our hierarchy of parent 
"spec" locations is confusing to users (well me). Better hide them altogether - 
it's the machine locations that are interesting. This has the nice effect for 
spinning up machines that the `$brooklyn:location().locationId()` will return 
only when the VM is provisioned. Instead of returning immediately with the ID 
of the spec location.

Can be improved by:
  * working with `MachineLocation` to accomodate the winrm case
  * looking at parent entities for the location if there's non at this 
level - for the case of nested softwareprocesses/sameserverentity.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-server pull request #300: Location DSL Updates

2016-09-21 Thread neykov
Github user neykov commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/300#discussion_r79810923
  
--- Diff: 
camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/LocationSpecConfiguration.java
 ---
@@ -0,0 +1,58 @@
+/*
+ * 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.spi.creation;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Maps;
+
+import org.apache.brooklyn.api.location.LocationSpec;
+
+/**
+ * Captures the {@link LocationSpec} configuration defined in YAML. 
+ * 
+ * This class does not parse that output; it just stores it.
+ */
+public class LocationSpecConfiguration {
+
+@SuppressWarnings("unused")
+private static final Logger LOG = 
LoggerFactory.getLogger(LocationSpecConfiguration.class);
+
+private Map specConfiguration;
+
+public LocationSpecConfiguration(Map specConfiguration) {
+this.specConfiguration = 
Maps.newHashMap(checkNotNull(specConfiguration, "specConfiguration"));
--- End diff --

+1 for ordered map - snameyaml's maps are already ordered.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-server pull request #300: Location DSL Updates

2016-08-18 Thread aledsage
Github user aledsage commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/300#discussion_r75293363
  
--- Diff: 
camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java
 ---
@@ -84,51 +89,72 @@ public DslComponent(DslComponent scopeComponent, Scope 
scope, String componentId
 }
 
 // ---
-
+
 @Override
-public Task newTask() {
-return 
TaskBuilder.builder().displayName(toString()).tag(BrooklynTaskTags.TRANSIENT_TASK_TAG)
-.body(new EntityInScopeFinder(scopeComponent, scope, 
componentId)).build();
+public Task newTask() {
+return TaskBuilder.builder()
+.displayName(toString())
+.tag(BrooklynTaskTags.TRANSIENT_TASK_TAG)
+.body(new ObjectInScopeFinder(scopeComponent, scope, 
componentId))
+.build();
 }
-
-protected static class EntityInScopeFinder implements Callable 
{
+
+protected static class ObjectInScopeFinder implements Callable {
 protected final DslComponent scopeComponent;
 protected final Scope scope;
 protected final String componentId;
 
-public EntityInScopeFinder(DslComponent scopeComponent, Scope 
scope, String componentId) {
+public ObjectInScopeFinder(DslComponent scopeComponent, Scope 
scope, String componentId) {
 this.scopeComponent = scopeComponent;
 this.scope = scope;
 this.componentId = componentId;
 }
 
 protected EntityInternal getEntity() {
 if (scopeComponent!=null) {
-return (EntityInternal)scopeComponent.get();
+return (EntityInternal) scopeComponent.get();
 } else {
 return entity();
 }
 }
-
+
+protected LocationInternal getLocation() {
+if (scopeComponent!=null) {
+return (LocationInternal) scopeComponent.get();
+} else {
+throw new IllegalStateException("Scope component must be 
set");
+}
+}
+
 @Override
-public Entity call() throws Exception {
-Iterable entitiesToSearch = null;
+public O call() throws Exception {
 EntityInternal entity = getEntity();
+
+if (scope == Scope.LOCATION) {
+Maybe machine = 
Machines.findUniqueMachineLocation(entity.getLocations(), 
SshMachineLocation.class);
--- End diff --

Does this mean it will fail if used for a non-machine location? e.g. if 
called on the top-level app that has a `JcloudsLocation` instance?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-server pull request #300: Location DSL Updates

2016-08-18 Thread aledsage
Github user aledsage commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/300#discussion_r75292379
  
--- Diff: 
camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java
 ---
@@ -145,81 +171,88 @@ public Entity call() throws Exception {
 default:
 throw new IllegalStateException("Unexpected scope 
"+scope);
 }
-
+
 Optional result = Iterables.tryFind(entitiesToSearch, 
EntityPredicates.configEqualTo(BrooklynCampConstants.PLAN_ID, componentId));
-
+
 if (result.isPresent())
-return result.get();
-
+return (O) result.get();
+
 // TODO may want to block and repeat on new entities joining?
 throw new NoSuchElementException("No entity matching id " + 
componentId+
 (scope==Scope.GLOBAL ? "" : ", in scope "+scope+" wrt 
"+entity+
 (scopeComponent!=null ? " ("+scopeComponent+" from 
"+entity()+")" : "")));
-}
+}
 }
-
+
 // ---
 
 // DSL words which move to a new component
-
-public DslComponent entity(String scopeOrId) {
+
+public DslComponent entity(String scopeOrId) {
 return new DslComponent(this, Scope.GLOBAL, scopeOrId);
 }
-public DslComponent child(String scopeOrId) {
+public DslComponent child(String scopeOrId) {
 return new DslComponent(this, Scope.CHILD, scopeOrId);
 }
-public DslComponent sibling(String scopeOrId) {
+public DslComponent sibling(String scopeOrId) {
 return new DslComponent(this, Scope.SIBLING, scopeOrId);
 }
-public DslComponent descendant(String scopeOrId) {
+public DslComponent descendant(String scopeOrId) {
 return new DslComponent(this, Scope.DESCENDANT, scopeOrId);
 }
-public DslComponent ancestor(String scopeOrId) {
+public DslComponent ancestor(String scopeOrId) {
 return new DslComponent(this, Scope.ANCESTOR, scopeOrId);
 }
-public DslComponent root() {
+public DslComponent root() {
 return new DslComponent(this, Scope.ROOT, "");
 }
-public DslComponent scopeRoot() {
+public DslComponent scopeRoot() {
 return new DslComponent(this, Scope.SCOPE_ROOT, "");
 }
-
+
 @Deprecated /** @deprecated since 0.7.0 */
-public DslComponent component(String scopeOrId) {
+public DslComponent component(String scopeOrId) {
 return new DslComponent(this, Scope.GLOBAL, scopeOrId);
 }
-
-public DslComponent self() {
+
+public DslComponent self() {
 return new DslComponent(this, Scope.THIS, null);
 }
-
-public DslComponent parent() {
+
+public DslComponent parent() {
 return new DslComponent(this, Scope.PARENT, "");
 }
-
-public DslComponent component(String scope, String id) {
+
+public DslComponent component(String scope, String id) {
 if (!DslComponent.Scope.isValid(scope)) {
 throw new IllegalArgumentException(scope + " is not a vlaid 
scope");
 }
 return new DslComponent(this, 
DslComponent.Scope.fromString(scope), id);
 }
 
+public DslComponent location() {
+return new DslComponent(this, Scope.LOCATION, null);
+}
+
 // DSL words which return things
 
 public BrooklynDslDeferredSupplier entityId() {
-return new EntityId(this);
+return new Identity(this);
 }
-protected static class EntityId extends 
BrooklynDslDeferredSupplier {
--- End diff --

Is this rename going to be backwards compatible? Could `EntityId` be in 
anyone's persisted state?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-server pull request #300: Location DSL Updates

2016-08-18 Thread aledsage
Github user aledsage commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/300#discussion_r75292142
  
--- Diff: 
camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java
 ---
@@ -84,51 +89,72 @@ public DslComponent(DslComponent scopeComponent, Scope 
scope, String componentId
 }
 
 // ---
-
+
 @Override
-public Task newTask() {
-return 
TaskBuilder.builder().displayName(toString()).tag(BrooklynTaskTags.TRANSIENT_TASK_TAG)
-.body(new EntityInScopeFinder(scopeComponent, scope, 
componentId)).build();
+public Task newTask() {
+return TaskBuilder.builder()
+.displayName(toString())
+.tag(BrooklynTaskTags.TRANSIENT_TASK_TAG)
+.body(new ObjectInScopeFinder(scopeComponent, scope, 
componentId))
+.build();
 }
-
-protected static class EntityInScopeFinder implements Callable 
{
+
+protected static class ObjectInScopeFinder implements Callable {
 protected final DslComponent scopeComponent;
 protected final Scope scope;
 protected final String componentId;
 
-public EntityInScopeFinder(DslComponent scopeComponent, Scope 
scope, String componentId) {
+public ObjectInScopeFinder(DslComponent scopeComponent, Scope 
scope, String componentId) {
 this.scopeComponent = scopeComponent;
 this.scope = scope;
 this.componentId = componentId;
 }
 
 protected EntityInternal getEntity() {
 if (scopeComponent!=null) {
-return (EntityInternal)scopeComponent.get();
+return (EntityInternal) scopeComponent.get();
 } else {
 return entity();
 }
 }
-
+
+protected LocationInternal getLocation() {
+if (scopeComponent!=null) {
+return (LocationInternal) scopeComponent.get();
+} else {
+throw new IllegalStateException("Scope component must be 
set");
+}
+}
+
 @Override
-public Entity call() throws Exception {
-Iterable entitiesToSearch = null;
+public O call() throws Exception {
 EntityInternal entity = getEntity();
--- End diff --

I don't follow what the expectation of this class is now. Do we expect the 
`scopeComponent` to always be an entity? Or sometimes a location? If it calls 
`call()` then it will fail for anything but an entity, I presume.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-server pull request #300: Location DSL Updates

2016-08-18 Thread aledsage
Github user aledsage commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/300#discussion_r75291636
  
--- Diff: 
camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java
 ---
@@ -84,51 +89,72 @@ public DslComponent(DslComponent scopeComponent, Scope 
scope, String componentId
 }
 
 // ---
-
+
 @Override
-public Task newTask() {
-return 
TaskBuilder.builder().displayName(toString()).tag(BrooklynTaskTags.TRANSIENT_TASK_TAG)
-.body(new EntityInScopeFinder(scopeComponent, scope, 
componentId)).build();
+public Task newTask() {
+return TaskBuilder.builder()
+.displayName(toString())
+.tag(BrooklynTaskTags.TRANSIENT_TASK_TAG)
+.body(new ObjectInScopeFinder(scopeComponent, scope, 
componentId))
+.build();
 }
-
-protected static class EntityInScopeFinder implements Callable 
{
+
+protected static class ObjectInScopeFinder implements Callable {
 protected final DslComponent scopeComponent;
 protected final Scope scope;
 protected final String componentId;
 
-public EntityInScopeFinder(DslComponent scopeComponent, Scope 
scope, String componentId) {
+public ObjectInScopeFinder(DslComponent scopeComponent, Scope 
scope, String componentId) {
 this.scopeComponent = scopeComponent;
 this.scope = scope;
 this.componentId = componentId;
 }
 
 protected EntityInternal getEntity() {
 if (scopeComponent!=null) {
-return (EntityInternal)scopeComponent.get();
+return (EntityInternal) scopeComponent.get();
--- End diff --

Seems strange to cast this to `EntityInternal`, now that you've generalised 
it to `ObjectInScopeFinder`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-server pull request #300: Location DSL Updates

2016-08-18 Thread aledsage
Github user aledsage commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/300#discussion_r75291679
  
--- Diff: 
camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java
 ---
@@ -84,51 +89,72 @@ public DslComponent(DslComponent scopeComponent, Scope 
scope, String componentId
 }
 
 // ---
-
+
 @Override
-public Task newTask() {
-return 
TaskBuilder.builder().displayName(toString()).tag(BrooklynTaskTags.TRANSIENT_TASK_TAG)
-.body(new EntityInScopeFinder(scopeComponent, scope, 
componentId)).build();
+public Task newTask() {
+return TaskBuilder.builder()
+.displayName(toString())
+.tag(BrooklynTaskTags.TRANSIENT_TASK_TAG)
+.body(new ObjectInScopeFinder(scopeComponent, scope, 
componentId))
+.build();
 }
-
-protected static class EntityInScopeFinder implements Callable 
{
+
+protected static class ObjectInScopeFinder implements Callable {
 protected final DslComponent scopeComponent;
 protected final Scope scope;
 protected final String componentId;
 
-public EntityInScopeFinder(DslComponent scopeComponent, Scope 
scope, String componentId) {
+public ObjectInScopeFinder(DslComponent scopeComponent, Scope 
scope, String componentId) {
 this.scopeComponent = scopeComponent;
 this.scope = scope;
 this.componentId = componentId;
 }
 
 protected EntityInternal getEntity() {
 if (scopeComponent!=null) {
-return (EntityInternal)scopeComponent.get();
+return (EntityInternal) scopeComponent.get();
--- End diff --

Ah, ignore me - I missed the method name!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-server pull request #300: Location DSL Updates

2016-08-18 Thread aledsage
Github user aledsage commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/300#discussion_r75291309
  
--- Diff: 
camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/LocationSpecConfiguration.java
 ---
@@ -0,0 +1,58 @@
+/*
+ * 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.spi.creation;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Maps;
+
+import org.apache.brooklyn.api.location.LocationSpec;
+
+/**
+ * Captures the {@link LocationSpec} configuration defined in YAML. 
+ * 
+ * This class does not parse that output; it just stores it.
+ */
+public class LocationSpecConfiguration {
+
+@SuppressWarnings("unused")
+private static final Logger LOG = 
LoggerFactory.getLogger(LocationSpecConfiguration.class);
+
+private Map specConfiguration;
+
+public LocationSpecConfiguration(Map specConfiguration) {
+this.specConfiguration = 
Maps.newHashMap(checkNotNull(specConfiguration, "specConfiguration"));
--- End diff --

Personal preference for `newLinkedHashMap` (so that logging/display order 
is consistent) with what the user supplies.

Seems strange to take a copy here, and to assert non-null; but then in 
`setSpecConfiguration` we don't copy it. And if subsequently using the setter, 
then will it really pass non-null to the constructor?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-server pull request #300: Location DSL Updates

2016-08-13 Thread grkvlt
GitHub user grkvlt opened a pull request:

https://github.com/apache/brooklyn-server/pull/300

Location DSL Updates

- Adds a `$brooklyn:location()` command to the DSL to enable retrieval of 
location config keys
- Adds a `$brooklyn:locationSpec:` command to the DSL to enable defining 
`LocationSpec` objects in YAML
- Updates `DynamicFabric` with configuration key that accepts a list of 
`LocationSpec` objects that will be used as extra locations to create 
clusters

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/grkvlt/brooklyn-server location-dsl

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/brooklyn-server/pull/300.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #300


commit ca2d82eea902e22c162a19f131793996b8c08b86
Author: Andrew Donald Kennedy 
Date:   2016-08-12T19:11:59Z

Location YAML DSL additions

commit 31a10941873453622185b95f3e34eca6697c5160
Author: Andrew Donald Kennedy 
Date:   2016-08-13T13:39:36Z

Add locationSpec DSL function

commit b8c81574a0aa9e8f34c64c5126b822070507d6dd
Author: Andrew Donald Kennedy 
Date:   2016-08-13T13:40:04Z

Add configuration for LocationSpec on DynamicFabric entity




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---