|
@@ -725,7 +725,6 @@ public class BlockManager {
|
|
|
final List<DatanodeStorageInfo> locations
|
|
|
= new ArrayList<DatanodeStorageInfo>(blocksMap.numNodes(block));
|
|
|
for(DatanodeStorageInfo storage : blocksMap.getStorages(block)) {
|
|
|
- final String storageID = storage.getStorageID();
|
|
|
// filter invalidate replicas
|
|
|
if(!invalidateBlocks.contains(storage.getDatanodeDescriptor(), block)) {
|
|
|
locations.add(storage);
|
|
@@ -2637,7 +2636,7 @@ public class BlockManager {
|
|
|
if (addedNode == delNodeHint) {
|
|
|
delNodeHint = null;
|
|
|
}
|
|
|
- Collection<DatanodeDescriptor> nonExcess = new ArrayList<DatanodeDescriptor>();
|
|
|
+ Collection<DatanodeStorageInfo> nonExcess = new ArrayList<DatanodeStorageInfo>();
|
|
|
Collection<DatanodeDescriptor> corruptNodes = corruptReplicas
|
|
|
.getNodes(block);
|
|
|
for(DatanodeStorageInfo storage : blocksMap.getStorages(block, State.NORMAL)) {
|
|
@@ -2657,7 +2656,7 @@ public class BlockManager {
|
|
|
if (!cur.isDecommissionInProgress() && !cur.isDecommissioned()) {
|
|
|
// exclude corrupt replicas
|
|
|
if (corruptNodes == null || !corruptNodes.contains(cur)) {
|
|
|
- nonExcess.add(cur);
|
|
|
+ nonExcess.add(storage);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2681,7 +2680,7 @@ public class BlockManager {
|
|
|
* If no such a node is available,
|
|
|
* then pick a node with least free space
|
|
|
*/
|
|
|
- private void chooseExcessReplicates(Collection<DatanodeDescriptor> nonExcess,
|
|
|
+ private void chooseExcessReplicates(final Collection<DatanodeStorageInfo> nonExcess,
|
|
|
Block b, short replication,
|
|
|
DatanodeDescriptor addedNode,
|
|
|
DatanodeDescriptor delNodeHint,
|
|
@@ -2689,28 +2688,33 @@ public class BlockManager {
|
|
|
assert namesystem.hasWriteLock();
|
|
|
// first form a rack to datanodes map and
|
|
|
BlockCollection bc = getBlockCollection(b);
|
|
|
- final Map<String, List<DatanodeDescriptor>> rackMap
|
|
|
- = new HashMap<String, List<DatanodeDescriptor>>();
|
|
|
- final List<DatanodeDescriptor> moreThanOne = new ArrayList<DatanodeDescriptor>();
|
|
|
- final List<DatanodeDescriptor> exactlyOne = new ArrayList<DatanodeDescriptor>();
|
|
|
+
|
|
|
+ final Map<String, List<DatanodeStorageInfo>> rackMap
|
|
|
+ = new HashMap<String, List<DatanodeStorageInfo>>();
|
|
|
+ final List<DatanodeStorageInfo> moreThanOne = new ArrayList<DatanodeStorageInfo>();
|
|
|
+ final List<DatanodeStorageInfo> exactlyOne = new ArrayList<DatanodeStorageInfo>();
|
|
|
|
|
|
// split nodes into two sets
|
|
|
// moreThanOne contains nodes on rack with more than one replica
|
|
|
// exactlyOne contains the remaining nodes
|
|
|
- replicator.splitNodesWithRack(nonExcess, rackMap, moreThanOne,
|
|
|
- exactlyOne);
|
|
|
+ replicator.splitNodesWithRack(nonExcess, rackMap, moreThanOne, exactlyOne);
|
|
|
|
|
|
// pick one node to delete that favors the delete hint
|
|
|
// otherwise pick one with least space from priSet if it is not empty
|
|
|
// otherwise one node with least space from remains
|
|
|
boolean firstOne = true;
|
|
|
+ final DatanodeStorageInfo delNodeHintStorage
|
|
|
+ = DatanodeStorageInfo.getDatanodeStorageInfo(nonExcess, delNodeHint);
|
|
|
+ final DatanodeStorageInfo addedNodeStorage
|
|
|
+ = DatanodeStorageInfo.getDatanodeStorageInfo(nonExcess, addedNode);
|
|
|
while (nonExcess.size() - replication > 0) {
|
|
|
// check if we can delete delNodeHint
|
|
|
- final DatanodeInfo cur;
|
|
|
- if (firstOne && delNodeHint !=null && nonExcess.contains(delNodeHint)
|
|
|
- && (moreThanOne.contains(delNodeHint)
|
|
|
- || (addedNode != null && !moreThanOne.contains(addedNode))) ) {
|
|
|
- cur = delNodeHint;
|
|
|
+ final DatanodeStorageInfo cur;
|
|
|
+ if (firstOne && delNodeHintStorage != null
|
|
|
+ && (moreThanOne.contains(delNodeHintStorage)
|
|
|
+ || (addedNodeStorage != null
|
|
|
+ && !moreThanOne.contains(addedNodeStorage)))) {
|
|
|
+ cur = delNodeHintStorage;
|
|
|
} else { // regular excessive replica removal
|
|
|
cur = replicator.chooseReplicaToDelete(bc, b, replication,
|
|
|
moreThanOne, exactlyOne);
|
|
@@ -2722,7 +2726,7 @@ public class BlockManager {
|
|
|
exactlyOne, cur);
|
|
|
|
|
|
nonExcess.remove(cur);
|
|
|
- addToExcessReplicate(cur, b);
|
|
|
+ addToExcessReplicate(cur.getDatanodeDescriptor(), b);
|
|
|
|
|
|
//
|
|
|
// The 'excessblocks' tracks blocks until we get confirmation
|
|
@@ -2733,7 +2737,7 @@ public class BlockManager {
|
|
|
// should be deleted. Items are removed from the invalidate list
|
|
|
// upon giving instructions to the namenode.
|
|
|
//
|
|
|
- addToInvalidates(b, cur);
|
|
|
+ addToInvalidates(b, cur.getDatanodeDescriptor());
|
|
|
blockLog.info("BLOCK* chooseExcessReplicates: "
|
|
|
+"("+cur+", "+b+") is added to invalidated blocks set");
|
|
|
}
|