brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From neykov <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #300: Location DSL Updates
Date Wed, 21 Sep 2016 13:31:20 GMT
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<Entity> newTask() {
    -        return TaskBuilder.<Entity>builder().displayName(toString()).tag(BrooklynTaskTags.TRANSIENT_TASK_TAG)
    -            .body(new EntityInScopeFinder(scopeComponent, scope, componentId)).build();
    +    public Task<O> newTask() {
    +        return TaskBuilder.<O>builder()
    +                .displayName(toString())
    +                .tag(BrooklynTaskTags.TRANSIENT_TASK_TAG)
    +                .body(new ObjectInScopeFinder(scopeComponent, scope, componentId))
    +                .build();
         }
    -    
    -    protected static class EntityInScopeFinder implements Callable<Entity> {
    +
    +    protected static class ObjectInScopeFinder<O> implements Callable<O>
{
             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<Entity> entitiesToSearch = null;
    +        public O call() throws Exception {
                 EntityInternal entity = getEntity();
    +
    +            if (scope == Scope.LOCATION) {
    +                Maybe<SshMachineLocation> 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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message