use of alluxio.exception.RegisterLeaseNotFoundException in project alluxio by Alluxio.
the class BlockMasterWorkerServiceHandler method registerWorker.
@Override
public void registerWorker(RegisterWorkerPRequest request, StreamObserver<RegisterWorkerPResponse> responseObserver) {
if (LOG.isDebugEnabled()) {
LOG.debug("Register worker request is {} bytes, containing {} blocks", request.getSerializedSize(), request.getCurrentBlocksCount());
}
final long workerId = request.getWorkerId();
RegisterWorkerPOptions options = request.getOptions();
RpcUtils.call(LOG, (RpcUtils.RpcCallableThrowsIOException<RegisterWorkerPResponse>) () -> {
// The exception will be propagated to the worker side and the worker should retry.
if (ServerConfiguration.getBoolean(PropertyKey.MASTER_WORKER_REGISTER_LEASE_ENABLED) && !mBlockMaster.hasRegisterLease(workerId)) {
String errorMsg = String.format("Worker %s does not have a lease or the lease " + "has expired. The worker should acquire a new lease and retry to register.", workerId);
LOG.warn(errorMsg);
throw new RegisterLeaseNotFoundException(errorMsg);
}
LOG.debug("Worker {} proceeding to register...", workerId);
final List<String> storageTiers = request.getStorageTiersList();
final Map<String, Long> totalBytesOnTiers = request.getTotalBytesOnTiersMap();
final Map<String, Long> usedBytesOnTiers = request.getUsedBytesOnTiersMap();
final Map<String, StorageList> lostStorageMap = request.getLostStorageMap();
final Map<Block.BlockLocation, List<Long>> currBlocksOnLocationMap = reconstructBlocksOnLocationMap(request.getCurrentBlocksList(), workerId);
// If the register is unsuccessful, the lease will be kept around until the expiry.
// The worker can retry and use the existing lease.
mBlockMaster.workerRegister(workerId, storageTiers, totalBytesOnTiers, usedBytesOnTiers, currBlocksOnLocationMap, lostStorageMap, options);
LOG.info("Worker {} finished registering, releasing its lease.", workerId);
mBlockMaster.releaseRegisterLease(workerId);
return RegisterWorkerPResponse.getDefaultInstance();
}, "registerWorker", true, "request=%s", responseObserver, workerId);
}
Aggregations