Search in sources :

Example 1 with RegisterLeaseNotFoundException

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);
}
Also used : RpcUtils(alluxio.RpcUtils) RegisterWorkerPResponse(alluxio.grpc.RegisterWorkerPResponse) Block(alluxio.proto.meta.Block) List(java.util.List) StorageList(alluxio.grpc.StorageList) RegisterWorkerPOptions(alluxio.grpc.RegisterWorkerPOptions) RegisterLeaseNotFoundException(alluxio.exception.RegisterLeaseNotFoundException) Map(java.util.Map)

Aggregations

RpcUtils (alluxio.RpcUtils)1 RegisterLeaseNotFoundException (alluxio.exception.RegisterLeaseNotFoundException)1 RegisterWorkerPOptions (alluxio.grpc.RegisterWorkerPOptions)1 RegisterWorkerPResponse (alluxio.grpc.RegisterWorkerPResponse)1 StorageList (alluxio.grpc.StorageList)1 Block (alluxio.proto.meta.Block)1 List (java.util.List)1 Map (java.util.Map)1