brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <>
Subject [jira] [Commented] (BROOKLYN-345) NPE on rebind of enricher ServiceStateLogic$ComputeServiceState
Date Tue, 29 Nov 2016 13:39:58 GMT


ASF GitHub Bot commented on BROOKLYN-345:

Github user ahgittin commented on a diff in the pull request:
    --- Diff: camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/
    @@ -374,15 +374,45 @@ protected ConfigInheritance getDefaultConfigInheritance() {
          * Searches for config keys in the type, additional interfaces and the implementation
(if specified)
         private Collection<FlagConfigKeyAndValueRecord> findAllFlagsAndConfigKeyValues(EntitySpec<?>
spec, ConfigBag bagFlags) {
    +        // Matches the bagFlags against the names used in brooklyn.parameters, entity
    +        // and entity fields with `@SetFromFlag`.
    +        //
    +        // Returns all config keys / flags that match things in bagFlags, including duplicates.
    +        // For example, if a configKey in Java is re-declared in YAML `brooklyn.parameters`,
    +        // then we'll get two records.
    +        //
    +        // Make some effort to have these returned in the right order. That is very important
    +        // because they are added to the `EntitySpec.configure(key, val)`. If there is
    +        // a key in `EntitySpec.config`, then the put will replace the value and leave
the key
    +        // as-is (so the default-value and description of the key will remain as whatever
    +        // first put said).
    +        // TODO We should remove duplicates, rather than just doing the `put` multiple
    +        // relying on ordering. We should also respect the ordered returned by 
    +        // EntityDynamicType.getConfigKeys, which is much better (it respects `BasicConfigKeyOverwriting`

    +        // etc).
    +        // 
    +        // However, that is hard/fiddly because of the way a config key can be referenced
    +        // its real name or flag-name.
    +        // 
    +        // I wonder if this is fundamentally broken (and I really do dislike our informal
    +        // of aliases). Consider a configKey with name A and alias B. The bagFlags could
    +        // {A: val1, B: val2}. There is no formal definition of which takes precedence.
We'll add 
    +        // both to the entity's configBag, without any warning - it's up to the `config().get()`

    +        // method to then figure out what to do. It gets worse if there is also a ConfigKey
    +        // name "B" the "val2" then applies to both!
    --- End diff --
    I think things should be de-aliased when writing to the config map, so config map has
canonical config key names _only_ -- ie it should not be up to `config().get()` to figure
out if any aliases are in effect.
    Is this not the case?
    Agree if we have `{A: val1, B: val2 }` as flags where `A` and `B` are names/aliases for
a given config key there is ambiguity -- this is possible even with `{A: val1, A: val2 }`.
 I'm not too worried about either of these, fair enough to say it's not guaranteed which is
    BTW good code change to treat the parameter definitions of config keys as the preferred
ones.  The only tweak I might suggest is that if the parameter fields are incomplete they
might be merged with those defined on the type (eg description, default value) so that it
isn't necessary to re-declare them as parameters.

> NPE on rebind of enricher ServiceStateLogic$ComputeServiceState
> ---------------------------------------------------------------
>                 Key: BROOKLYN-345
>                 URL:
>             Project: Brooklyn
>          Issue Type: Bug
>            Reporter: Aled Sage
> Using Brooklyn 0.10.0-SNAPSHOT (e.g. brooklyn-server commit 66b9b1c)...
> When rebinding to existing persisted state, it failed to create the enricher {{ServiceStateLogic$ComputeServiceState}}
with the NPE shown below (but then continued, so this is otherwise benign):
> {noformat}
> 2016-09-09 09:31:03,850 WARN  o.a.b.c.m.r.RebindExceptionHandlerImpl [brooklyn-execmanager-VtZheMDn-0]:
problem adding enricher cdoy70m1hv (ServiceFailureDetector{name=org.apache.brooklyn.policy.ha.ServiceFailureDetector,
uniqueTag=service.state.actual, running=true, entity=VanillaSoftwareProcessImpl{id=pwz8z4pbyp},
id=cdoy70m1hv}) to entity pwz8z4pbyp (VanillaSoftwareProcessImpl{id=pwz8z4pbyp}); continuing
> java.lang.NullPointerException: null
>         at org.apache.brooklyn.policy.ha.ServiceFailureDetector.setActualState(
>         at org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic$ComputeServiceState.onEvent(
>         at org.apache.brooklyn.policy.ha.ServiceFailureDetector.onEvent(
>         at org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic$ComputeServiceState.setEntity(
>         at org.apache.brooklyn.core.entity.AbstractEntity$BasicEnricherSupport.add(
>         at org.apache.brooklyn.core.mgmt.rebind.BasicEntityRebindSupport.addEnrichers(
>         at org.apache.brooklyn.core.mgmt.rebind.BasicEntityRebindSupport.addEnrichers(
>         at org.apache.brooklyn.core.mgmt.rebind.RebindIteration.associateAdjunctsWithEntities(
>         at org.apache.brooklyn.core.mgmt.rebind.RebindIteration.doRun(
>         at org.apache.brooklyn.core.mgmt.rebind.InitialFullRebindIteration.doRun(
>         at
>         at org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl.rebindImpl(
>         at org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl$
>         at org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl$
>         at org.apache.brooklyn.util.core.task.BasicExecutionManager$
>         at [na:1.7.0_95]
>         at java.util.concurrent.ThreadPoolExecutor.runWorker(
>         at java.util.concurrent.ThreadPoolExecutor$
>         at [na:1.7.0_95]
> {noformat}
> The line throwing the NPE is executing {{setEntityOnFireTime = now + getConfig(SERVICE_ON_FIRE_STABILIZATION_DELAY).toMilliseconds()}}.
That suggests we got null for the config value, even though there is a default value of zero
for it.
> The enricher persisted state contains:
> {noformat}
>     <serviceOnFire.stabilizationDelay>
>       <>
>         <component>
>           <componentId></componentId>
>           <scope>THIS</scope>
>         </component>
>         <keyName>swarm.recovery.stabilizationDelay</keyName>
>       </>
>     </serviceOnFire.stabilizationDelay>
> {noformat}
> And the owning entity has:
> {noformat}
>   brooklyn.parameters:
>     - name: swarm.recovery.stabilizationDelay
>       label: Stabilization Delay
>       description: |
>         Time period for which the service must be consistently in the same state to trigger
an action
>       # A restart shouldn&apos;t trigger failure
>       type: org.apache.brooklyn.util.time.Duration
>       default: 5m
> {noformat}
> There are a few things we should think about fixing:
> 1. guard against the NPE in {{ServiceFailureDetector.setActualState}} (i.e. handle when
the config returns null) - but unclear what value it should then default to.
> 2. avoid calling this code on rebind. for example, instead of {{ComputeServiceState.setEntity}}
immediately calling {{onEvent(null)}}, it could subscribe with "notifyOfInitialValue" so that
it gets a callback (in the right thread, at the right time).
> 3. investigate further why the config lookup returned null - e.g. is it because entity
wasn't fully initialised, or because the DSL didn't find the default value defined in brooklyn.parameters?

This message was sent by Atlassian JIRA

View raw message