Search in sources :

Example 6 with ReplicationManager

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;
    }
}
Also used : NodeNotFoundException(org.apache.hadoop.hdds.scm.node.states.NodeNotFoundException) ReplicationManager(org.apache.hadoop.hdds.scm.container.ReplicationManager) ContainerID(org.apache.hadoop.hdds.scm.container.ContainerID) ContainerNotFoundException(org.apache.hadoop.hdds.scm.container.ContainerNotFoundException)

Aggregations

ReplicationManager (org.apache.hadoop.hdds.scm.container.ReplicationManager)6 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)2 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)2 ContainerID (org.apache.hadoop.hdds.scm.container.ContainerID)2 SCMContext (org.apache.hadoop.hdds.scm.ha.SCMContext)2 StorageContainerManager (org.apache.hadoop.hdds.scm.server.StorageContainerManager)2 EventPublisher (org.apache.hadoop.hdds.server.events.EventPublisher)2 Before (org.junit.Before)2 Test (org.junit.Test)2 Field (java.lang.reflect.Field)1 UUID (java.util.UUID)1 TimeoutException (java.util.concurrent.TimeoutException)1 MockDatanodeDetails (org.apache.hadoop.hdds.protocol.MockDatanodeDetails)1 HddsProtos (org.apache.hadoop.hdds.protocol.proto.HddsProtos)1 BlockManagerImpl (org.apache.hadoop.hdds.scm.block.BlockManagerImpl)1 ContainerInfo (org.apache.hadoop.hdds.scm.container.ContainerInfo)1 ContainerManager (org.apache.hadoop.hdds.scm.container.ContainerManager)1 ContainerManagerImpl (org.apache.hadoop.hdds.scm.container.ContainerManagerImpl)1 ContainerNotFoundException (org.apache.hadoop.hdds.scm.container.ContainerNotFoundException)1 MockNodeManager (org.apache.hadoop.hdds.scm.container.MockNodeManager)1