Skip to content

Commit

Permalink
[HOPS-891] prevent NullPointers in FSNamesystem.getAdditionalDatanode
Browse files Browse the repository at this point in the history
  • Loading branch information
berthoug committed Dec 14, 2018
1 parent d83173e commit caf5a40
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,10 @@ private DatanodeStorageInfo[] chooseTarget(int numOfReplicas,

final List<DatanodeStorageInfo> results = new ArrayList<DatanodeStorageInfo>(chosenStorage);
for (DatanodeStorageInfo storage : chosenStorage) {
// add localMachine and related nodes to excludedNodes
addToExcludedNodes(storage.getDatanodeDescriptor(), excludedNodes);
if(storage!=null){
// add localMachine and related nodes to excludedNodes
addToExcludedNodes(storage.getDatanodeDescriptor(), excludedNodes);
}
}

boolean avoidStaleNodes = (stats != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3165,7 +3165,11 @@ public Object performTask() throws IOException {

//find datanode storages
final DatanodeManager dm = blockManager.getDatanodeManager();
chosen = Arrays.asList(dm.getDatanodeStorageInfos(existings, storageIDs));
if(existings.length!=0){
chosen = Arrays.asList(dm.getDatanodeStorageInfos(existings, storageIDs));
} else {
chosen = Collections.<DatanodeStorageInfo>emptyList();
}

// choose new datanodes.
final DatanodeStorageInfo[] targets = blockManager.chooseTarget4AdditionalDatanode(
Expand Down

0 comments on commit caf5a40

Please sign in to comment.