-
Notifications
You must be signed in to change notification settings - Fork 619
HDDS-11350. NullPointerException thrown on checking container balancer status #7134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -341,6 +341,16 @@ public List<ContainerBalancerTaskIterationStatusInfo> getCurrentIterationsStatis | |
| .max() | ||
| .orElse(0); | ||
|
|
||
| // the balancing thread could go to sleep without having initialized findTargetStrategy, so we check for null here | ||
| Map<DatanodeDetails, Long> sizeEnteringNodes = Collections.emptyMap(); | ||
| if (findTargetStrategy != null) { | ||
| sizeEnteringNodes = findTargetStrategy.getSizeEnteringNodes(); | ||
| } | ||
| Map<DatanodeDetails, Long> sizeLeavingNodes = Collections.emptyMap(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it will be better to create empty map only if findSourceStrategy == null?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure - we can come back to this after we've resolved your first review comment above. |
||
| if (findSourceStrategy != null) { | ||
| sizeLeavingNodes = findSourceStrategy.getSizeLeavingNodes(); | ||
| } | ||
|
|
||
| ContainerBalancerTaskIterationStatusInfo currentIterationStatistic = new ContainerBalancerTaskIterationStatusInfo( | ||
| lastIterationNumber + 1, | ||
| null, | ||
|
|
@@ -350,8 +360,7 @@ public List<ContainerBalancerTaskIterationStatusInfo> getCurrentIterationsStatis | |
| metrics.getNumContainerMovesCompletedInLatestIteration(), | ||
| metrics.getNumContainerMovesFailedInLatestIteration(), | ||
| metrics.getNumContainerMovesTimeoutInLatestIteration(), | ||
| findTargetStrategy.getSizeEnteringNodes() | ||
| .entrySet() | ||
| sizeEnteringNodes.entrySet() | ||
| .stream() | ||
| .filter(Objects::nonNull) | ||
| .filter(datanodeDetailsLongEntry -> datanodeDetailsLongEntry.getValue() > 0) | ||
|
|
@@ -360,8 +369,7 @@ public List<ContainerBalancerTaskIterationStatusInfo> getCurrentIterationsStatis | |
| entry -> entry.getValue() / OzoneConsts.GB | ||
| ) | ||
| ), | ||
| findSourceStrategy.getSizeLeavingNodes() | ||
| .entrySet() | ||
| sizeLeavingNodes.entrySet() | ||
| .stream() | ||
| .filter(Objects::nonNull) | ||
| .filter(datanodeDetailsLongEntry -> datanodeDetailsLongEntry.getValue() > 0) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is non-obvious, that findTarget(Source)Strategy can be null. Maybe it will be better to use some default realisation with empty map, if org.apache.hadoop.hdds.scm.container.balancer.ContainerBalancerTask#initializeIteration was not executed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you mean here. Are you suggesting initialising
findTargetStrategyin the constructor ofContainerBalancerTask(likefindSourceStrategy)? That should work as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! Yes, you are right. That's what I mean)