Github user tbouron commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/821#discussion_r141590729
  
    --- Diff: core/src/main/java/org/apache/brooklyn/core/policy/Policies.java 
---
    @@ -81,11 +85,27 @@ public void setEntity(EntityLocal entity) {
         }
     
         public static Lifecycle getPolicyStatus(Policy p) {
    -        if (p.isRunning()) return Lifecycle.RUNNING;
    -        if (p.isDestroyed()) return Lifecycle.DESTROYED;
    -        if (p.isSuspended()) return Lifecycle.STOPPED;
    -        // TODO could policy be in an error state?
    -        return Lifecycle.CREATED;        
    +        return inferAdjunctStatus(p);
    +    }
    +    
    +    @Beta
    +    public static Lifecycle inferAdjunctStatus(EntityAdjunct a) {
    +        if (a.isRunning()) return Lifecycle.RUNNING;
    +        if (a.isDestroyed()) return Lifecycle.DESTROYED;
    +        
    +        // adjuncts don't currently support an "error" state; though that 
would be useful!
    +        
    +        if (a instanceof Policy) {
    +            if (((Policy)a).isSuspended()) return Lifecycle.STOPPED;
    +            return Lifecycle.CREATED;
    +        }
    +        if (a instanceof Feed) {
    +            if (((Feed)a).isSuspended()) return Lifecycle.STOPPED;
    +            if (((Feed)a).isActivated()) return Lifecycle.STARTING;
    +            return Lifecycle.CREATED;
    +        }
    +        
    +        return Lifecycle.STOPPED;
    --- End diff --
    
    What other adjunct this case be to arrive here? Enrichers for example? In 
this case, is an enricher `STOPPED` really instead of `CREATED`?


---

Reply via email to