use of alluxio.grpc.MoveBlockRequest in project alluxio by Alluxio.
the class MoveDefinition method runTask.
/**
* {@inheritDoc}
*
* This task will move the given block.
*/
@Override
public SerializableVoid runTask(MoveConfig config, SerializableVoid args, RunTaskContext context) throws Exception {
long blockId = config.getBlockId();
String localHostName = NetworkAddressUtils.getConnectHost(ServiceType.WORKER_RPC, ServerConfiguration.global());
List<BlockWorkerInfo> workerInfoList = context.getFsContext().getCachedWorkers();
WorkerNetAddress localNetAddress = null;
for (BlockWorkerInfo workerInfo : workerInfoList) {
if (workerInfo.getNetAddress().getHost().equals(localHostName)) {
localNetAddress = workerInfo.getNetAddress();
break;
}
}
if (localNetAddress == null) {
String message = String.format("Cannot find a local block worker to move block %d", blockId);
throw new NotFoundException(message);
}
MoveBlockRequest request = MoveBlockRequest.newBuilder().setBlockId(blockId).setMediumType(config.getMediumType()).build();
try (CloseableResource<BlockWorkerClient> blockWorker = context.getFsContext().acquireBlockWorkerClient(localNetAddress)) {
blockWorker.get().moveBlock(request);
}
return null;
}
Aggregations