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));
}
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;
});
}
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;
}
Aggregations