guihecheng commented on a change in pull request #2246:
URL: https://github.com/apache/ozone/pull/2246#discussion_r633182776



##########
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/SCMCommonPlacementPolicy.java
##########
@@ -165,9 +166,15 @@ public ConfigurationSource getConf() {
    */
   public boolean hasEnoughSpace(DatanodeDetails datanodeDetails,
       long sizeRequired) {
-    SCMNodeMetric nodeMetric = nodeManager.getNodeStat(datanodeDetails);
-    return (nodeMetric != null) && (nodeMetric.get() != null)
-        && nodeMetric.get().getRemaining().hasResources(sizeRequired);
+    if (datanodeDetails instanceof DatanodeInfo) {

Review comment:
       @JacksonYao287 oh, thanks for reviewing, here the check is just to 
suppress downcasting warning actually.
   AFAIK, SCMNodeManager get nodes from SCMNodeStateManger and these 
datanodesDetails shall always be datanodeInfos, the situation will not be hit.
   We could do some refactoring for usage of `DatanodeDetails` and 
`DatanodeInfo` if needed, but not here I think.

##########
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/SCMCommonPlacementPolicy.java
##########
@@ -165,9 +166,15 @@ public ConfigurationSource getConf() {
    */
   public boolean hasEnoughSpace(DatanodeDetails datanodeDetails,
       long sizeRequired) {
-    SCMNodeMetric nodeMetric = nodeManager.getNodeStat(datanodeDetails);
-    return (nodeMetric != null) && (nodeMetric.get() != null)
-        && nodeMetric.get().getRemaining().hasResources(sizeRequired);
+    if (datanodeDetails instanceof DatanodeInfo) {
+      DatanodeInfo datanodeInfo = (DatanodeInfo) datanodeDetails;
+      for (StorageReportProto reportProto : datanodeInfo.getStorageReports()) {
+        if (reportProto.getRemaining() > sizeRequired) {
+          return true;
+        }
+      }
+    }
+    return false;

Review comment:
       @ChenSammi sure, we could add a WARN for the first 'false' case, if hit 
then it implies that we should find a better solution here.




-- 
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]

Reply via email to