use of org.apache.hadoop.hdds.scm.container.ReplicationManager in project ozone by apache.
the class ContainerBalancer method moveContainer.
/**
* Asks {@link ReplicationManager} to move the specified container from
* source to target.
*
* @param source the source datanode
* @param moveSelection the selected container to move and target datanode
* @return false if an exception occurred, the move completed
* exceptionally, or the move completed with a result other than
* ReplicationManager.MoveResult.COMPLETED. Returns true if the move
* completed with MoveResult.COMPLETED or move is not yet done
*/
private boolean moveContainer(DatanodeDetails source, ContainerMoveSelection moveSelection) {
ContainerID container = moveSelection.getContainerID();
CompletableFuture<ReplicationManager.MoveResult> future;
try {
future = replicationManager.move(container, source, moveSelection.getTargetNode());
} catch (ContainerNotFoundException e) {
LOG.warn("Could not find Container {} for container move", container, e);
return false;
} catch (NodeNotFoundException e) {
LOG.warn("Container move failed for container {}", container, e);
return false;
}
if (future.isDone()) {
if (future.isCompletedExceptionally()) {
LOG.info("Container move for container {} from source {} to target {}" + "completed exceptionally", container.toString(), source.getUuidString(), moveSelection.getTargetNode().getUuidString());
return false;
} else {
ReplicationManager.MoveResult result = future.join();
moveSelectionToFutureMap.put(moveSelection, future);
return result == ReplicationManager.MoveResult.COMPLETED;
}
} else {
moveSelectionToFutureMap.put(moveSelection, future);
return true;
}
}
Aggregations