Search in sources :

Example 1 with ReplicationTask

use of org.apache.hadoop.ozone.container.replication.ReplicationTask in project ozone by apache.

the class ReplicateContainerCommandHandler method handle.

@Override
public void handle(SCMCommand command, OzoneContainer container, StateContext context, SCMConnectionManager connectionManager) {
    final ReplicateContainerCommand replicateCommand = (ReplicateContainerCommand) command;
    final List<DatanodeDetails> sourceDatanodes = replicateCommand.getSourceDatanodes();
    final long containerID = replicateCommand.getContainerID();
    Preconditions.checkArgument(sourceDatanodes.size() > 0, "Replication command is received for container %s " + "without source datanodes.", containerID);
    supervisor.addTask(new ReplicationTask(containerID, sourceDatanodes));
}
Also used : ReplicateContainerCommand(org.apache.hadoop.ozone.protocol.commands.ReplicateContainerCommand) ReplicationTask(org.apache.hadoop.ozone.container.replication.ReplicationTask) DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails)

Example 2 with ReplicationTask

use of org.apache.hadoop.ozone.container.replication.ReplicationTask in project ozone by apache.

the class ClosedContainerReplicator method replicateContainer.

private void replicateContainer(long counter) throws Exception {
    timer.time(() -> {
        final ReplicationTask replicationTask = replicationTasks.get((int) counter);
        supervisor.new TaskRunner(replicationTask).run();
        return null;
    });
}
Also used : ReplicationTask(org.apache.hadoop.ozone.container.replication.ReplicationTask)

Example 3 with ReplicationTask

use of org.apache.hadoop.ozone.container.replication.ReplicationTask in project ozone by apache.

the class ClosedContainerReplicator method call.

@Override
public Void call() throws Exception {
    OzoneConfiguration conf = createOzoneConfiguration();
    final Collection<String> datanodeStorageDirs = HddsServerUtil.getDatanodeStorageDirs(conf);
    for (String dir : datanodeStorageDirs) {
        checkDestinationDirectory(dir);
    }
    // logic same as the download+import on the destination datanode
    initializeReplicationSupervisor(conf);
    final ContainerOperationClient containerOperationClient = new ContainerOperationClient(conf);
    final List<ContainerInfo> containerInfos = containerOperationClient.listContainer(0L, 1_000_000);
    replicationTasks = new ArrayList<>();
    for (ContainerInfo container : containerInfos) {
        final ContainerWithPipeline containerWithPipeline = containerOperationClient.getContainerWithPipeline(container.getContainerID());
        if (container.getState() == LifeCycleState.CLOSED) {
            final List<DatanodeDetails> datanodesWithContainer = containerWithPipeline.getPipeline().getNodes();
            final List<String> datanodeUUIDs = datanodesWithContainer.stream().map(DatanodeDetails::getUuidString).collect(Collectors.toList());
            // replica.
            if (datanode.isEmpty() || datanodeUUIDs.contains(datanode)) {
                replicationTasks.add(new ReplicationTask(container.getContainerID(), datanodesWithContainer));
            }
        }
    }
    // important: override the max number of tasks.
    setTestNo(replicationTasks.size());
    init();
    timer = getMetrics().timer("replicate-container");
    runTests(this::replicateContainer);
    return null;
}
Also used : ReplicationTask(org.apache.hadoop.ozone.container.replication.ReplicationTask) DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) ContainerInfo(org.apache.hadoop.hdds.scm.container.ContainerInfo) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) ContainerWithPipeline(org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline) ContainerOperationClient(org.apache.hadoop.hdds.scm.cli.ContainerOperationClient)

Aggregations

ReplicationTask (org.apache.hadoop.ozone.container.replication.ReplicationTask)3 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)2 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)1 ContainerOperationClient (org.apache.hadoop.hdds.scm.cli.ContainerOperationClient)1 ContainerInfo (org.apache.hadoop.hdds.scm.container.ContainerInfo)1 ContainerWithPipeline (org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline)1 ReplicateContainerCommand (org.apache.hadoop.ozone.protocol.commands.ReplicateContainerCommand)1