You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2021/09/14 21:56:34 UTC
[brooklyn-server] 15/27: better logging for HA promotion and for
scheduled tasks
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 49ab36d5138f2cc4637e2f50d4a05f70084c27ad
Author: Alex Heneveld <al...@cloudsoftcorp.com>
AuthorDate: Tue Sep 14 13:52:05 2021 +0100
better logging for HA promotion and for scheduled tasks
---
.../brooklyn/core/mgmt/ha/HighAvailabilityManagerImpl.java | 10 ++++++----
.../apache/brooklyn/util/core/task/BasicExecutionManager.java | 11 ++++++++---
2 files changed, 14 insertions(+), 7 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 fab4ffc..00f511a 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
@@ -567,7 +567,7 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager {
if (ManagementNodeState.isHotProxy(oldState) && !ManagementNodeState.isHotProxy(newState)) {
// could perhaps promote standby items on some transitions; but for now we stop the old read-only and re-load them
// TODO ideally there'd be an incremental rebind as well as an incremental persist
- LOG.debug("Resetting rebind on hot->cold transition, from "+oldState+" to "+newState);
+ LOG.debug("Resetting rebind on transition from hot proxy ("+oldState+") to "+newState);
managementContext.getRebindManager().stopReadOnly();
clearManagedItems(ManagementTransitionMode.transitioning(BrooklynObjectManagementMode.LOADED_READ_ONLY, BrooklynObjectManagementMode.UNMANAGED_PERSISTED));
managementContext.getRebindManager().reset();
@@ -781,7 +781,8 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager {
// if failed or hot backup then we can't promote ourselves, so no point in checking who is master
return;
}
-
+
+ ManagementNodeState ourPrevState = getNodeState();
updateLocalPlaneId(memento);
String currMasterNodeId = memento.getMasterNodeId();
@@ -852,7 +853,8 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager {
});
}
String message = "Management node "+ownNodeId+" detected ";
- String currMasterSummary = currMasterNodeId + " (" + (currMasterNodeRecord==null ? "<none>" : timestampString(currMasterNodeRecord.getRemoteTimestamp())) + ")";
+ String currMasterSummary =
+ (Strings.isNonBlank(currMasterNodeId) ? currMasterNodeId+" " : "") + "(" + (currMasterNodeRecord==null ? "<none>" : timestampString(currMasterNodeRecord.getRemoteTimestamp())) + ")";
if (weAreNewMaster && (ownNodeRecord.getStatus() == ManagementNodeState.MASTER)) {
LOG.warn(message + "we must reassert master status, as we believe we should be master and other master "+
(currMasterNodeRecord==null ? "(a node which has gone away)" : currMasterSummary)+" has failed");
@@ -863,7 +865,7 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager {
if (!initializing) {
if (weAreNewMaster) {
- message += "we should be master, changing from ";
+ message += "we should be master, promoting from "+ourPrevState+"; master changing from ";
}
else if (currMasterNodeRecord==null && newMasterNodeId==null) message += "master change attempted but no candidates ";
else message += "master change, from ";
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 995c49e..41a704e 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
@@ -172,9 +172,15 @@ public class BasicExecutionManager implements ExecutionManager {
entityMdc = MDC.putCloseable(LOGGING_MDC_KEY_ENTITY_IDS, "");
}
+ logEvent("Starting task", task, entity);
+
+ return this;
+ }
+
+ public static void logEvent(String prefix, Task task, Entity entity) {
if (BrooklynLoggingCategories.TASK_LIFECYCLE_LOG.isDebugEnabled() || BrooklynLoggingCategories.TASK_LIFECYCLE_LOG.isTraceEnabled()) {
String taskName = task.getDisplayName();
- String message = "Starting task " + task.getId() +
+ String message = prefix + " " + task.getId() +
(Strings.isNonBlank(taskName) ? " ("+taskName+")" : "") +
(entity == null ? "" : " on entity " + entity.getId()) +
(Strings.isNonBlank(task.getSubmittedByTaskId()) ? " from task " + task.getSubmittedByTaskId() : "") +
@@ -189,8 +195,6 @@ public class BasicExecutionManager implements ExecutionManager {
message);
}
-
- return this;
}
public void finish() {
@@ -557,6 +561,7 @@ public class BasicExecutionManager implements ExecutionManager {
protected Task<?> submitNewScheduledTask(final Map<?,?> flags, final ScheduledTask task) {
boolean result = false;
try {
+ BrooklynTaskLoggingMdc.logEvent("Submitting scheduled task", task, BrooklynTaskTags.getTargetOrContextEntity(Tasks.current()));
result = submitSubsequentScheduledTask(flags, task);
} finally {
if (!result) {