[ https://issues.apache.org/jira/browse/BROOKLYN-345?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15670339#comment-15670339 ]
ASF GitHub Bot commented on BROOKLYN-345: ----------------------------------------- GitHub user aledsage opened a pull request: https://github.com/apache/brooklyn-server/pull/440 BROOKLYN-345: persist brooklyn.parameters (fixes ServiceFailureDetector rebind) You can merge this pull request into a Git repository by running: $ git pull https://github.com/aledsage/brooklyn-server BROOKLYN-345 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/brooklyn-server/pull/440.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #440 ---- commit 31d84a69cdc66efef7a0f064789a0d4d1693e8e4 Author: Aled Sage <aled.s...@gmail.com> Date: 2016-11-16T09:47:27Z Time.makeTimeString: avoid NPE if arg is null commit 53f6b1379ac8d50250564b17d9ada2a6c1b661d2 Author: Aled Sage <aled.s...@gmail.com> Date: 2016-11-16T09:51:43Z ServiceFailureDetector yaml tests, and fix commit 6e8b7b4d927fc3d152753fe673957c7854705589 Author: Aled Sage <aled.s...@gmail.com> Date: 2016-11-16T09:58:08Z BROOKLYN-345: add (failing) tests for rebind commit f7026a792c6b7007ea38971cd51b599334abc56c Author: Aled Sage <aled.s...@gmail.com> Date: 2016-11-16T09:59:46Z ServiceFailureDetector: persist lastPublished commit b530cd670883bb7a901c72ecfa79692670b5fb08 Author: Aled Sage <aled.s...@gmail.com> Date: 2016-11-16T12:34:07Z BROOKLYN-345: Persist entity’s dynamic config keys ---- > 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)