[
https://issues.apache.org/jira/browse/BROOKLYN-325?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15532634#comment-15532634
]
ASF GitHub Bot commented on BROOKLYN-325:
-----------------------------------------
Github user aledsage commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/356#discussion_r81123434
--- Diff:
core/src/main/java/org/apache/brooklyn/core/entity/lifecycle/ServiceStateLogic.java
---
@@ -153,6 +153,26 @@ private ServiceStateLogic() {}
}
public static void setExpectedState(Entity entity, Lifecycle state) {
+ waitForServiceUpIfStateIsRunning(entity, state);
+
((EntityInternal)entity).sensors().set(Attributes.SERVICE_STATE_EXPECTED, new
Lifecycle.Transition(state, new Date()));
+
+ Maybe<Enricher> enricher =
EntityAdjuncts.tryFindWithUniqueTag(entity.enrichers(),
ComputeServiceState.DEFAULT_ENRICHER_UNIQUE_TAG);
+ if (enricher.isPresent() && enricher.get() instanceof
ComputeServiceState) {
+ ((ComputeServiceState)enricher.get()).onEvent(null);
+ }
+ }
+ public static Lifecycle getExpectedState(Entity entity) {
+ Transition expected =
entity.getAttribute(Attributes.SERVICE_STATE_EXPECTED);
+ if (expected==null) return null;
+ return expected.getState();
+ }
+
+ public static void setActualState(Entity entity, Lifecycle state) {
--- End diff --
Let's delete `setActualState`: it's not used. The pattern used is to set
the expected state, and then for the actual state to be inferred by an enricher.
> Restarting Brooklyn while entity deploying: entity shown as deploying
> indefinitely
> ----------------------------------------------------------------------------------
>
> Key: BROOKLYN-325
> URL: https://issues.apache.org/jira/browse/BROOKLYN-325
> Project: Brooklyn
> Issue Type: Bug
> Affects Versions: 0.9.0
> Reporter: Aled Sage
>
> When the Brooklyn server restarts while an entity is halfway through starting
> or stopping, on rebind that entity continues to report its sensor as
> starting/stopping. However, the task does not resume so it stays in this
> state indefinitely.
> To reproduce, run Brooklyn with persistence enabled, and try deploying a
> blueprint like that below:
> {noformat}
> location: localhost
> services:
> - type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess
> brooklyn.config:
> launch.command: sleep 20
> stop.command: sleep 20
> checkRunning.command: true
> {noformat}
> While the app is starting, terminate the Brooklyn server and then restart it.
> In the UI, the spinning icon shows that the app is still deploying. The
> entity has the following sensor values:
> {noformat}
> service.isUp: false
> service.notUp.indicators: {"service.process.isRunning":"No information on
> whether this service is running"}
> service.state: STARTING
> service.state.expected: starting @ 1470658910966 / Mon Aug 08 13:21:50 BST
> 2016
> {noformat}
> Alternatively, deploy the app normally and then invoke stop. While the app is
> stopping, terminate the Brooklyn server and then restart it. The entity has
> the following sensor values:
> {noformat}
> service.process.isRunning: false
> service.state: STOPPING
> service.state.expected: stopping @ 1470658816662 / Mon Aug 08 13:20:16 BST
> 2016
> {noformat}
> Given that the task won't resume, I'd expect the entity to be marked as
> having some kind of error. For example, the service.state as on-fire (but
> ideally without losing the fact that it was previously stopping).
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)