hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Masatake Iwasaki (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HDFS-8946) Improve choosing datanode storage for block placement
Date Fri, 28 Aug 2015 08:44:45 GMT

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

Masatake Iwasaki commented on HDFS-8946:
----------------------------------------

DatanodeDescriptor.java
{code}
679	    final long requiredSize =
680	        blockSize * HdfsServerConstants.MIN_BLOCKS_FOR_WRITE;
681	    final long scheduledSize = getBlocksScheduled(t);
682	    long remaining = 0;
683	    DatanodeStorageInfo storage = null;
684	    for (DatanodeStorageInfo s : getStorageInfos()) {
685	      if (s.getState() == State.NORMAL &&
686	          s.getStorageType() == t) {
687	        if (storage == null) {
688	          storage = s;
689	        }
690	        long r = s.getRemaining();
691	        if (r >= requiredSize) {
692	          remaining += r;
693	        }
694	      }
695	    }
696	    if (requiredSize > remaining - scheduledSize) {
697	      return null;
{code}

{{scheduledSize}} is number of blocks but used as if it's bytes.

Any reason to change the logic of remaining size checking?


> Improve choosing datanode storage for block placement
> -----------------------------------------------------
>
>                 Key: HDFS-8946
>                 URL: https://issues.apache.org/jira/browse/HDFS-8946
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>          Components: namenode
>            Reporter: Yi Liu
>            Assignee: Yi Liu
>         Attachments: HDFS-8946.001.patch, HDFS-8946.002.patch
>
>
> This JIRA is to:
> Improve chooseing datanode storage for block placement:
> In {{BlockPlacementPolicyDefault}} ({{chooseLocalStorage}}, {{chooseRandom}}), we have
following logic to choose datanode storage to place block.
> For given storage type, we iterate storages of the datanode. But for datanode, it only
cares about the storage type. In the loop, we check according to Storage type and return the
first storage if the storages of the type on the datanode fit in requirement. So we can remove
the iteration of storages, and just need to do once to find a good storage of given type,
it's efficient if the storages of the type on the datanode don't fit in requirement since
we don't need to loop all storages and do the same check.
> Besides, no need to shuffle the storages, since we only need to check according to the
storage type on the datanode once.
> This also improves the logic and make it more clear.
> {code}
>       if (excludedNodes.add(localMachine) // was not in the excluded list
>           && isGoodDatanode(localDatanode, maxNodesPerRack, false,
>               results, avoidStaleNodes)) {
>         for (Iterator<Map.Entry<StorageType, Integer>> iter = storageTypes
>             .entrySet().iterator(); iter.hasNext(); ) {
>           Map.Entry<StorageType, Integer> entry = iter.next();
>           for (DatanodeStorageInfo localStorage : DFSUtil.shuffle(
>               localDatanode.getStorageInfos())) {
>             StorageType type = entry.getKey();
>             if (addIfIsGoodTarget(localStorage, excludedNodes, blocksize,
>                 results, type) >= 0) {
>               int num = entry.getValue();
>               ...
> {code}
> (current logic above)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message