jiajunwang commented on a change in pull request #1124:
URL: https://github.com/apache/helix/pull/1124#discussion_r454596383
##########
File path:
helix-core/src/main/java/org/apache/helix/controller/stages/MessageGenerationPhase.java
##########
@@ -344,6 +367,13 @@ private void schedulePendingMessageCleanUp(
if (accessor.removeProperty(msg.getKey(accessor.keyBuilder(),
instanceName))) {
LogUtil.logInfo(logger, _eventId, String
.format("Deleted message %s from instance %s",
msg.getMsgId(), instanceName));
+ if (staleMessageMap != null &&
staleMessageMap.containsKey(msg.getTgtName())
+ &&
staleMessageMap.get(msg.getTgtName()).containsKey(msg.getMsgId())) {
Review comment:
nit, could be simpler by
if (staleMessageMap != null &&
staleMessageMap.getOrDefault(msg.getTgtName(),
EmptyMap()).remove(msg.getMsgId())) {
if (staleMessageMap.get(msg.getTgtName()).size() == 0) {
staleMessageMap.remove(msg.getTgtName());
}
}
##########
File path:
helix-core/src/main/java/org/apache/helix/controller/stages/MessageGenerationPhase.java
##########
@@ -371,6 +401,14 @@ private boolean shouldCleanUpPendingMessage(Message
pendingMsg, String currentSt
}
}
+ private boolean shouldCleanUpStaleMessage(Message staleMsg, Long
currentStateTransitionEndTime) {
+ if (staleMsg == null) {
Review comment:
Can staleMsg be null?
##########
File path:
helix-core/src/main/java/org/apache/helix/controller/stages/MessageGenerationPhase.java
##########
@@ -344,6 +367,13 @@ private void schedulePendingMessageCleanUp(
if (accessor.removeProperty(msg.getKey(accessor.keyBuilder(),
instanceName))) {
LogUtil.logInfo(logger, _eventId, String
.format("Deleted message %s from instance %s",
msg.getMsgId(), instanceName));
+ if (staleMessageMap != null &&
staleMessageMap.containsKey(msg.getTgtName())
Review comment:
I think staleMessageMap won't be null.
##########
File path:
helix-core/src/main/java/org/apache/helix/controller/stages/MessageGenerationPhase.java
##########
@@ -188,14 +192,24 @@ private void generateMessage(final Resource resource,
final BaseControllerDataPr
if (pendingMessage != null &&
shouldCleanUpPendingMessage(pendingMessage, currentState,
currentStateOutput.getEndTime(resourceName, partition,
instanceName))) {
- LogUtil.logInfo(logger, _eventId, String.format(
- "Adding pending message %s on instance %s to clean up. Msg:
%s->%s, current state of resource %s:%s is %s",
- pendingMessage.getMsgId(), instanceName,
pendingMessage.getFromState(),
- pendingMessage.getToState(), resourceName, partition,
currentState));
- if (!pendingMessagesToCleanUp.containsKey(instanceName)) {
- pendingMessagesToCleanUp.put(instanceName, new HashMap<String,
Message>());
+ String logMsg = String.format(
Review comment:
This also helps to reduce the duplicate code that logs the stale
messages.
##########
File path:
helix-core/src/main/java/org/apache/helix/controller/stages/MessageGenerationPhase.java
##########
@@ -188,14 +192,24 @@ private void generateMessage(final Resource resource,
final BaseControllerDataPr
if (pendingMessage != null &&
shouldCleanUpPendingMessage(pendingMessage, currentState,
currentStateOutput.getEndTime(resourceName, partition,
instanceName))) {
- LogUtil.logInfo(logger, _eventId, String.format(
- "Adding pending message %s on instance %s to clean up. Msg:
%s->%s, current state of resource %s:%s is %s",
- pendingMessage.getMsgId(), instanceName,
pendingMessage.getFromState(),
- pendingMessage.getToState(), resourceName, partition,
currentState));
- if (!pendingMessagesToCleanUp.containsKey(instanceName)) {
- pendingMessagesToCleanUp.put(instanceName, new HashMap<String,
Message>());
+ String logMsg = String.format(
Review comment:
Better to move this logic into the logAndAddToCleanUp() method too.
This will increase the parameters, but the code here would be much simpler.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]