sodonnel commented on code in PR #5184:
URL: https://github.com/apache/ozone/pull/5184#discussion_r1293466204
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/SCMCommonPlacementPolicy.java:
##########
@@ -481,16 +486,20 @@ public boolean isValidNode(DatanodeDetails
datanodeDetails,
if (datanodeInfo == null) {
LOG.error("Failed to find the DatanodeInfo for datanode {}",
datanodeDetails);
- } else {
- if (datanodeInfo.getNodeStatus().isNodeWritable() &&
- (hasEnoughSpace(datanodeInfo, metadataSizeRequired,
- dataSizeRequired))) {
- LOG.debug("Datanode {} is chosen. Required metadata size is {} and " +
- "required data size is {}",
- datanodeDetails, metadataSizeRequired, dataSizeRequired);
- return true;
- }
+ return false;
+ }
+ NodeStatus nodeStatus = datanodeInfo.getNodeStatus();
+ if (nodeStatus.isNodeWritable() &&
+ (hasEnoughSpace(datanodeInfo, metadataSizeRequired,
+ dataSizeRequired))) {
+ LOG.debug("Datanode {} is chosen. Required metadata size is {} and " +
+ "required data size is {} and NodeStatus is {}",
+ datanodeDetails, metadataSizeRequired, dataSizeRequired, nodeStatus);
+ return true;
}
+ LOG.debug("Datanode {} is not chosen. Required metadata size is {} and " +
Review Comment:
Inside the LOG.debug method, it will only call the toString() method if the
log is going to be produced. At parameter passing time, just the reference to
the object is passed, and it should be passed as type Object, so no toString
conversion gets done:
``` public void debug(String format, Object arg1, Object arg2) {
if (this.logger.isDebugEnabled()) {
FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
this.logger.log(FQCN, Level.DEBUG, ft.getMessage(), ft.getThrowable());
}
}
```
The place you need to use `LOG.isDebugEnabled()` is when you need to build
the string and pass that built string into the logger, eg:
```
String s = some_concatenations_or_logic_to_construct
LOG.debug("some log {}", s);
```
This is better written as:
```
if (LOG.isDebugEnabled()) {
String s = some_concatenations_or_logic_to_construct
LOG.debug("some log {}", s);
}
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]