Github user aledsage commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/375#discussion_r21529738
--- Diff:
software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
---
@@ -547,40 +563,53 @@ public void stop() {
return "Stop at machine completed with no errors.";
}});
- // Release this machine (even if error trying to stop process - we
rethrow that after)
- Task<StopMachineDetails<Integer>> stoppingMachine =
DynamicTasks.queue("stopping (machine)", new
Callable<StopMachineDetails<Integer>>() { public StopMachineDetails<Integer>
call() {
- if
(entity().getAttribute(SoftwareProcess.SERVICE_STATE_ACTUAL)==Lifecycle.STOPPED)
{
- log.debug("Skipping stop of entity "+entity()+" when
already stopped");
- return new StopMachineDetails<Integer>("Already stopped",
0);
- }
- return stopAnyProvisionedMachines();
- }});
-
- DynamicTasks.drain(entity().getConfig(STOP_PROCESS_TIMEOUT),
false);
- // shutdown the machine if stopping process fails or takes too long
- synchronized (stoppingMachine) {
- // task also used as mutex by DST when it submits it; ensure
it only submits once!
- if (!stoppingMachine.isSubmitted()) {
- // force the stoppingMachine task to run by submitting it
here
- log.warn("Submitting machine stop early in background for
"+entity()+" because process stop has "+
- (stoppingProcess.isDone() ? "finished abnormally"
: "not finished"));
- Entities.submit(entity(), stoppingMachine);
+ Task<StopMachineDetails<Integer>> stoppingMachine = null;
+ if (isStopMachine == StopSoftwareParameters.StopMachineMode.TRUE) {
+ // Release this machine (even if error trying to stop process
- we rethrow that after)
+ stoppingMachine = DynamicTasks.queue("stopping (machine)", new
Callable<StopMachineDetails<Integer>>() {
+ public StopMachineDetails<Integer> call() {
+ if
(entity().getAttribute(SoftwareProcess.SERVICE_STATE_ACTUAL) ==
Lifecycle.STOPPED) {
+ log.debug("Skipping stop of entity " + entity() +
" when already stopped");
+ return new StopMachineDetails<Integer>("Already
stopped", 0);
+ }
+ return stopAnyProvisionedMachines();
+ }
+ });
+
+ DynamicTasks.drain(entity().getConfig(STOP_PROCESS_TIMEOUT),
false);
+
+ // shutdown the machine if stopping process fails or takes too
long
+ synchronized (stoppingMachine) {
+ // task also used as mutex by DST when it submits it;
ensure it only submits once!
+ if (!stoppingMachine.isSubmitted()) {
+ // force the stoppingMachine task to run by submitting
it here
+ log.warn("Submitting machine stop early in background
for "+entity()+" because process stop has "+
+ (stoppingProcess.isDone() ? "finished
abnormally" : "not finished"));
+ Entities.submit(entity(), stoppingMachine);
+ }
}
}
try {
- if (stoppingMachine.get().value == 0) {
+ boolean checkStopProcesses = true;
+ // This maintains previous behaviour of silently squashing any
errors on the stoppingProcess task if the
+ // stoppingMachine exits with a nonzero value
+ if (stoppingMachine != null) {
--- End diff --
I'd go for `boolean checkStopProcesses = (stoppingMachine == null ||
stoppingMachine.get().value == 0);`
But no strong feelings.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---