This is an automated email from the ASF dual-hosted git repository. heneveld pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git
commit 37c331ea43f85e7958d9f03e8de3e3fc5e1b1743 Author: Alex Heneveld <[email protected]> AuthorDate: Mon Sep 13 23:17:08 2021 +0100 tidy rebind, skip duplicate hot-standby activation --- .../brooklyn/core/mgmt/ha/HighAvailabilityManagerImpl.java | 12 ++++++++++-- .../brooklyn/util/core/task/BasicExecutionManager.java | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/HighAvailabilityManagerImpl.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/HighAvailabilityManagerImpl.java index 2bd080d..fab4ffc 100644 --- a/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/HighAvailabilityManagerImpl.java +++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/HighAvailabilityManagerImpl.java @@ -314,7 +314,8 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager { // catch error in some tests where mgmt context has a different HA manager if (managementContext.getHighAvailabilityManager()!=this) throw new IllegalStateException("Cannot start an HA manager on a management context with a different HA manager!"); - + + boolean newModeApplied = false; if (weAreMasterLocally) { // demotion may be required; do this before triggering an election switch (startMode) { @@ -326,13 +327,20 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager { case HOT_STANDBY: case HOT_BACKUP: case STANDBY: - demoteTo(ManagementNodeState.of(startMode).get()); break; + demoteTo(ManagementNodeState.of(startMode).get()); + newModeApplied = true; + break; default: throw new IllegalStateException("Unexpected high availability mode "+startMode+" requested for "+this); } } ManagementNodeState oldState = getInternalNodeState(); + if (newModeApplied && Objects.equal(oldState, startMode)) { + // successfully applied new mode, as part of demoteTo call above; + // skip the duplicate logic below which re-applies it + return; + } // now do election switch (startMode) { diff --git a/core/src/main/java/org/apache/brooklyn/util/core/task/BasicExecutionManager.java b/core/src/main/java/org/apache/brooklyn/util/core/task/BasicExecutionManager.java index 8b44490..793c5ca 100644 --- a/core/src/main/java/org/apache/brooklyn/util/core/task/BasicExecutionManager.java +++ b/core/src/main/java/org/apache/brooklyn/util/core/task/BasicExecutionManager.java @@ -390,7 +390,7 @@ public class BasicExecutionManager implements ExecutionManager { if (context!=null && !Entities.isManaged(context)) { log.debug("Forgetting about active task on unmanagement of "+context+": "+removed); } else { - log.warn("Deleting submitted task before completion: "+removed+"; this task will continue to run in the background outwith "+this+", but perhaps it should have been cancelled?"); + log.warn("Deleting submitted task before completion: "+removed+" (tags "+removed.getTags()+"); this task will continue to run in the background outwith "+this+", but perhaps it should have been cancelled?"); } } task.getTags().forEach(t -> {
