brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdowner <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: allow parameters for restart effe...
Date Fri, 24 Oct 2014 12:52:23 GMT
Github user rdowner commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/260#discussion_r19336618
  
    --- Diff: core/src/main/java/brooklyn/entity/trait/Startable.java ---
    @@ -51,30 +56,68 @@
                 parameters.put(LOCATIONS, entity().getManagementContext().getLocationRegistry().resolveList(parameters.get(LOCATIONS)));
                 return new MethodEffector<Void>(Startable.class, "start").call(entity(),
parameters.getAllConfig());
             }
    -    };
    -    
    +    }
    +
    +    public static class StopEffectorBody extends EffectorBody<Void> {
    +        private static final Logger log = LoggerFactory.getLogger(Startable.class);
    +        
    +        @Override public Void call(ConfigBag parameters) {
    +            if (!parameters.isEmpty()) {
    +                log.warn("Parameters "+parameters+" not supported for call to "+entity()+"
- "+Tasks.current());
    +            }
    +            
    +            return new MethodEffector<Void>(Startable.class, "stop").call(entity(),
parameters.getAllConfig());
    +        }
    +    }
    +
    +    public static class RestartEffectorBody extends EffectorBody<Void> {
    +        private static final Logger log = LoggerFactory.getLogger(Startable.class);
    +
    +        @Override public Void call(ConfigBag parameters) {
    +            if (!parameters.isEmpty()) {
    +                log.warn("Parameters "+parameters+" not supported for call to "+entity()+"
- "+Tasks.current());
    +            }
    +            return new MethodEffector<Void>(Startable.class, "restart").call(entity(),
parameters.getAllConfig());
    +        }
    +    }
    +
         brooklyn.entity.Effector<Void> START = Effectors.effector(new MethodEffector<Void>(Startable.class,
"start"))
             // override start to take strings etc
             .parameter(StartEffectorBody.LOCATIONS)
             .impl(new StartEffectorBody())
             .build();
    -    brooklyn.entity.Effector<Void> STOP = new MethodEffector<Void>(Startable.class,
"stop");
    -    brooklyn.entity.Effector<Void> RESTART = new MethodEffector<Void>(Startable.class,"restart");
    +    
    +    brooklyn.entity.Effector<Void> STOP = Effectors.effector(new MethodEffector<Void>(Startable.class,
"stop"))
    +        .impl(new StopEffectorBody())
    +        .build();
    +    
    +    brooklyn.entity.Effector<Void> RESTART = Effectors.effector(new MethodEffector<Void>(Startable.class,
"restart"))
    +        .impl(new RestartEffectorBody())
    +        .build();
     
         /**
          * Start the entity in the given collection of locations.
    +     * <p>
    +     * Some entities may define custom {@link Effector} implementations which support
    +     * a richer set of parameters.  See the entity-specific {@link #START} effector declaration.
          */
         @brooklyn.entity.annotation.Effector(description="Start the process/service represented
by an entity")
         void start(@EffectorParam(name="locations") Collection<? extends Location>
locations);
     
         /**
          * Stop the entity.
    +     * <p>
    +     * Some entities may define custom {@link Effector} implementations which support
    +     * a richer set of parameters.  See the entity-specific {@link #START} effector declaration.
          */
    --- End diff --
    
    Should `{@link #START}` actually be `STOP`? Likewise for `RESTART` below?


---
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