[
https://issues.apache.org/jira/browse/BROOKLYN-345?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15673631#comment-15673631
]
ASF GitHub Bot commented on BROOKLYN-345:
-----------------------------------------
Github user aledsage commented on the issue:
https://github.com/apache/brooklyn-server/pull/440
Thanks @neykov -
`ConfigNestedYamlTest.testCatalogParameterFromSuperYamlTypeAsSoftware` is a
very annoying and valid failure!
There is a `MapConfigKey` defined on the java type
(`SoftwareProcess.TEMPLATE_SUBSTITUTIONS`). In the yaml
(`config-nested-tests,bom`), the super-type declares a brooklyn.parameters for
this: brooklyn.parameters: [ {name: template.substitutions, type:
java.util.Map} ]`.
Note the difference in type for the config keys: the first is a
`MapConfigKey` and the latter is a `BasicConfigKey<java.util.Map>`.
When the config values are written into the entity's spec, it uses the
`MapConfigKey` so the value of `{field: val}` is actually written as
`{template.substitutions.field: val}`.
When the config value is later read, it uses the
`BasicConfigKey<java.util.Map>`, so it just looks up `template.substitutions`
and thus returns an empty map.
---
A few things spring to mind:
1. don't try to change the type of a config key when you're overriding it
in brooklyn.parameters. (However, the user doesn't think they've done this -
it's of type map!)
2. write creating the spec, use the same config key as will subsequently be
used for reading the value back out again.
3. I really don't like the `MapConfigKey` stuff. Particularly now that we
have capabilities for defining the merge-semantics of map config keys, the need
for the `MapConfigKey` is greatly reduced.
Let's not try to tackle (3) right now, but that is one for the mailing list!
(2) feels like the right thing to do. But it's fiddly. We're in the middle
of the stacktrace below for (one of the places?) where we're writing the config
value using the `MapConfigKey`:
```
"main" prio=5 tid=0x00007fdbab000000 nid=0x1703 at
breakpoint[0x0000700000217000]
java.lang.Thread.State: RUNNABLE
at
org.apache.brooklyn.api.internal.AbstractBrooklynObjectSpec.configure(AbstractBrooklynObjectSpec.java:293)
at
org.apache.brooklyn.camp.brooklyn.spi.creation.BrooklynComponentTemplateResolver.configureEntityConfig(BrooklynComponentTemplateResolver.java:337)
at
org.apache.brooklyn.camp.brooklyn.spi.creation.BrooklynComponentTemplateResolver.decorateSpec(BrooklynComponentTemplateResolver.java:259)
at
org.apache.brooklyn.camp.brooklyn.spi.creation.BrooklynComponentTemplateResolver.populateSpec(BrooklynComponentTemplateResolver.java:250)
at
org.apache.brooklyn.camp.brooklyn.spi.creation.BrooklynComponentTemplateResolver.resolveSpec(BrooklynComponentTemplateResolver.java:189)
at
org.apache.brooklyn.camp.brooklyn.spi.creation.BrooklynAssemblyTemplateInstantiator.buildTemplateServicesAsSpecs(BrooklynAssemblyTemplateInstantiator.java:114)
at
org.apache.brooklyn.camp.brooklyn.spi.creation.BrooklynAssemblyTemplateInstantiator.createServiceSpecs(BrooklynAssemblyTemplateInstantiator.java:73)
at
org.apache.brooklyn.camp.brooklyn.spi.creation.BrooklynAssemblyTemplateInstantiator.createApplicationSpec(BrooklynAssemblyTemplateInstantiator.java:90)
at
org.apache.brooklyn.camp.brooklyn.spi.creation.CampResolver.createEntitySpecFromServicesBlock(CampResolver.java:145)
at
org.apache.brooklyn.camp.brooklyn.spi.creation.CampResolver.createSpecFromFull(CampResolver.java:111)
at
org.apache.brooklyn.camp.brooklyn.spi.creation.CampToSpecTransformer.createCatalogSpec(CampToSpecTransformer.java:102)
at
org.apache.brooklyn.core.catalog.internal.BasicBrooklynCatalog$1.apply(BasicBrooklynCatalog.java:331)
at
org.apache.brooklyn.core.catalog.internal.BasicBrooklynCatalog$1.apply(BasicBrooklynCatalog.java:1)
at
org.apache.brooklyn.core.plan.PlanToSpecFactory.attemptWithLoaders(PlanToSpecFactory.java:126)
at
org.apache.brooklyn.core.plan.PlanToSpecFactory.attemptWithLoaders(PlanToSpecFactory.java:118)
at
org.apache.brooklyn.core.catalog.internal.BasicBrooklynCatalog.internalCreateSpecLegacy(BasicBrooklynCatalog.java:328)
at
org.apache.brooklyn.core.catalog.internal.BasicBrooklynCatalog$PlanInterpreterGuessingType.attemptType(BasicBrooklynCatalog.java:808)
at
org.apache.brooklyn.core.catalog.internal.BasicBrooklynCatalog$PlanInterpreterGuessingType.reconstruct(BasicBrooklynCatalog.java:735)
at
org.apache.brooklyn.core.catalog.internal.BasicBrooklynCatalog.collectCatalogItems(BasicBrooklynCatalog.java:508)
at
org.apache.brooklyn.core.catalog.internal.BasicBrooklynCatalog.collectCatalogItems(BasicBrooklynCatalog.java:476)
at
org.apache.brooklyn.core.catalog.internal.BasicBrooklynCatalog.collectCatalogItems(BasicBrooklynCatalog.java:383)
at
org.apache.brooklyn.core.catalog.internal.BasicBrooklynCatalog.collectCatalogItems(BasicBrooklynCatalog.java:372)
at
org.apache.brooklyn.core.catalog.internal.BasicBrooklynCatalog.addItems(BasicBrooklynCatalog.java:929)
at
org.apache.brooklyn.core.catalog.internal.BasicBrooklynCatalog.addItems(BasicBrooklynCatalog.java:1)
at
org.apache.brooklyn.camp.brooklyn.AbstractYamlTest.addCatalogItems(AbstractYamlTest.java:199)
at
org.apache.brooklyn.camp.brooklyn.ConfigNestedYamlTest.testCatalogParameterFromSuperYamlTypeAsSoftware(ConfigNestedYamlTest.java:89)
```
Maybe this is one to document and defer? Thoughts?
> NPE on rebind of enricher ServiceStateLogic$ComputeServiceState
> ---------------------------------------------------------------
>
> Key: BROOKLYN-345
> URL: https://issues.apache.org/jira/browse/BROOKLYN-345
> 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(ServiceFailureDetector.java:188)
> ~[brooklyn-policy-0.10.0-20160907.0931.jar:0.10.0-20160907.0931]
> at
> org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic$ComputeServiceState.onEvent(ServiceStateLogic.java:288)
> ~[brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931]
> at
> org.apache.brooklyn.policy.ha.ServiceFailureDetector.onEvent(ServiceFailureDetector.java:159)
> ~[brooklyn-policy-0.10.0-20160907.0931.jar:0.10.0-20160907.0931]
> at
> org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic$ComputeServiceState.setEntity(ServiceStateLogic.java:274)
> ~[brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931]
> at
> org.apache.brooklyn.core.entity.AbstractEntity$BasicEnricherSupport.add(AbstractEntity.java:1788)
> ~[brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931]
> at
> org.apache.brooklyn.core.mgmt.rebind.BasicEntityRebindSupport.addEnrichers(BasicEntityRebindSupport.java:145)
> [brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931]
> at
> org.apache.brooklyn.core.mgmt.rebind.BasicEntityRebindSupport.addEnrichers(BasicEntityRebindSupport.java:47)
> [brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931]
> at
> org.apache.brooklyn.core.mgmt.rebind.RebindIteration.associateAdjunctsWithEntities(RebindIteration.java:650)
> [brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931]
> at
> org.apache.brooklyn.core.mgmt.rebind.RebindIteration.doRun(RebindIteration.java:244)
> [brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931]
> at
> org.apache.brooklyn.core.mgmt.rebind.InitialFullRebindIteration.doRun(InitialFullRebindIteration.java:69)
> [brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931]
> at
> org.apache.brooklyn.core.mgmt.rebind.RebindIteration.run(RebindIteration.java:266)
> [brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931]
> at
> org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl.rebindImpl(RebindManagerImpl.java:558)
> [brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931]
> at
> org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl$3.call(RebindManagerImpl.java:508)
> [brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931]
> at
> org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl$3.call(RebindManagerImpl.java:506)
> [brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931]
> at
> org.apache.brooklyn.util.core.task.BasicExecutionManager$SubmissionCallable.call(BasicExecutionManager.java:519)
> [brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931]
> at java.util.concurrent.FutureTask.run(FutureTask.java:262)
> [na:1.7.0_95]
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> [na:1.7.0_95]
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> [na:1.7.0_95]
> at java.lang.Thread.run(Thread.java:745) [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>
>
> <org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent_-DslConfigSupplier>
> <component>
> <componentId></componentId>
> <scope>THIS</scope>
> </component>
> <keyName>swarm.recovery.stabilizationDelay</keyName>
>
> </org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent_-DslConfigSupplier>
> </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'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
(v6.3.4#6332)