[ 
https://issues.apache.org/jira/browse/HDFS-5222?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13776104#comment-13776104
 ] 

Junping Du commented on HDFS-5222:
----------------------------------

Hi Nicholas, Thanks for the patch. A couple of comments:
{code}
+  private static boolean hasSpace(final long blockSize, final long remaining,
+      final long scheduled) {
+    final long required = blockSize * HdfsConstants.MIN_BLOCKS_FOR_WRITE;
+    return required > remaining - scheduled * blockSize;
+  }
{code}
Shall we rename it to something like: notEnoughSpace? As this means space is 
not enough. Isn't it?

{code}
-    final long requiredSize = blockSize * HdfsConstants.MIN_BLOCKS_FOR_WRITE;
-    if (requiredSize > storage.getRemaining()) {
+    if (hasSpace(blockSize, storage.getRemaining(), 
storage.getBlocksScheduled())) {
       logNodeIsNotChosen(storage, "the storage does not have enough space ");
       return false;
     }
-    //TODO: move getBlocksScheduled() to DatanodeStorageInfo. 
-    long remaining = node.getRemaining() - 
-                     (node.getBlocksScheduled() * blockSize); 
     // check the remaining capacity of the target machine
-    if (requiredSize > remaining) {
+    if (hasSpace(blockSize, node.getRemaining(), node.getBlocksScheduled())) {
       logNodeIsNotChosen(storage, "the node does not have enough space ");
       return false;
     }
{code}
Shall we remove checking node's remaining as previous storage capacity checking 
is good enough?
                
> Move block schedule information from DatanodeDescriptor to DatanodeStorageInfo
> ------------------------------------------------------------------------------
>
>                 Key: HDFS-5222
>                 URL: https://issues.apache.org/jira/browse/HDFS-5222
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>          Components: namenode
>            Reporter: Tsz Wo (Nicholas), SZE
>            Assignee: Tsz Wo (Nicholas), SZE
>         Attachments: h5222_20130819.patch
>
>
> In HDFS-4990, the block placement target type was changed from 
> DatanodeDescriptor to DatanodeStorageInfo.  The block schedule information, 
> such as the number of blocks scheduled for replication (i.e. 
> getBlocksScheduled()), should be moved from DatanodeDescriptor to 
> DatanodeStorageInfo.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to