Github user aledsage commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/91#discussion_r15523211
--- Diff:
core/src/main/java/brooklyn/management/ha/HighAvailabilityManagerImpl.java ---
@@ -516,10 +522,41 @@ protected void demoteToStandby() {
}
nodeState = ManagementNodeState.STANDBY;
+ onDemotion();
+ publishDemotionFromMaster(false);
+ }
+
+ protected void onDemotion() {
managementContext.getRebindManager().stop();
for (Application app: managementContext.getApplications())
Entities.unmanage(app);
- publishDemotionFromMaster(false);
+ // let's try forcibly interrupting tasks on managed entities
+ Collection<Exception> exceptions = MutableSet.of();
+ int tasks = 0;
+ LOG.debug("Cancelling tasks on demotion");
+ try {
+ for (Entity entity:
managementContext.getEntityManager().getEntities()) {
+ for (Task<?> t:
managementContext.getExecutionContext(entity).getTasks()) {
+ if (!t.isDone()) {
+ tasks++;
+ try {
+ LOG.debug("Cancelling "+t+" on "+entity);
+ t.cancel(true);
+ } catch (Exception e) {
--- End diff --
What exception could `t.cancel(true)` throw - is it just being cautious? No
harm having the try-catch I guess.
---
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.
---