Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ public NavigableSet<ContainerID> getCandidateContainers(
* @param second second container to compare
* @return An integer greater than 0 if first is more used, 0 if they're
* the same containers or a container is not found, and a value less than 0
* if first is not more used than second.
* if first is less used than second. If both containers have equal used
* space, they're compared using {@link ContainerID#compareTo(ContainerID)}.
*/
private int isContainerMoreUsed(ContainerID first,
ContainerID second) {
Expand All @@ -132,8 +133,10 @@ private int isContainerMoreUsed(ContainerID first,
ContainerInfo secondInfo = containerManager.getContainer(second);
if (firstInfo.getUsedBytes() > secondInfo.getUsedBytes()) {
return 1;
} else {
} else if (firstInfo.getUsedBytes() < secondInfo.getUsedBytes()) {
return -1;
} else {
return first.compareTo(second);
}
} catch (ContainerNotFoundException e) {
LOG.warn("Could not retrieve ContainerInfo from container manager for " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1163,14 +1163,17 @@ private void createReplicasForContainers() {

// randomly pick a datanode for this replica
int datanodeIndex = RANDOM.nextInt(0, numberOfNodes);
if (nodeUtilizations.get(i) != 0.0d) {
// don't put replicas in DNs that are supposed to have 0 utilization
if (Math.abs(nodeUtilizations.get(datanodeIndex) - 0.0d) > 0.00001) {
DatanodeDetails node =
nodesInCluster.get(datanodeIndex).getDatanodeDetails();
Set<ContainerReplica> replicas =
cidToReplicasMap.get(container.containerID());
replicas.add(createReplica(container.containerID(), node,
container.getUsedBytes()));
cidToReplicasMap.put(container.containerID(), replicas);
datanodeToContainersMap.get(nodesInCluster.get(datanodeIndex))
.add(container.containerID());
}
}
}
Expand Down