Search in sources :

Example 1 with Metric

use of alluxio.grpc.Metric in project alluxio by Alluxio.

the class BlockMasterClient method heartbeat.

/**
 * The method the worker should periodically execute to heartbeat back to the master.
 *
 * @param workerId the worker id
 * @param capacityBytesOnTiers a mapping from storage tier alias to capacity bytes
 * @param usedBytesOnTiers a mapping from storage tier alias to used bytes
 * @param removedBlocks a list of block removed from this worker
 * @param addedBlocks a mapping from storage tier alias to added blocks
 * @param lostStorage a mapping from storage tier alias to a list of lost storage paths
 * @param metrics a list of worker metrics
 * @return an optional command for the worker to execute
 */
public synchronized Command heartbeat(final long workerId, final Map<String, Long> capacityBytesOnTiers, final Map<String, Long> usedBytesOnTiers, final List<Long> removedBlocks, final Map<BlockStoreLocation, List<Long>> addedBlocks, final Map<String, List<String>> lostStorage, final List<Metric> metrics) throws IOException {
    final BlockHeartbeatPOptions options = BlockHeartbeatPOptions.newBuilder().addAllMetrics(metrics).putAllCapacityBytesOnTiers(capacityBytesOnTiers).build();
    final List<LocationBlockIdListEntry> entryList = convertBlockListMapToProto(addedBlocks);
    final Map<String, StorageList> lostStorageMap = lostStorage.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> StorageList.newBuilder().addAllStorage(e.getValue()).build()));
    final BlockHeartbeatPRequest request = BlockHeartbeatPRequest.newBuilder().setWorkerId(workerId).putAllUsedBytesOnTiers(usedBytesOnTiers).addAllRemovedBlockIds(removedBlocks).addAllAddedBlocks(entryList).setOptions(options).putAllLostStorage(lostStorageMap).build();
    return retryRPC(() -> mClient.withDeadlineAfter(mContext.getClusterConf().getMs(PropertyKey.WORKER_MASTER_PERIODICAL_RPC_TIMEOUT), TimeUnit.MILLISECONDS).blockHeartbeat(request).getCommand(), LOG, "Heartbeat", "workerId=%d", workerId);
}
Also used : WorkerNetAddress(alluxio.wire.WorkerNetAddress) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) PropertyKey(alluxio.conf.PropertyKey) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) BlockMasterWorkerServiceGrpc(alluxio.grpc.BlockMasterWorkerServiceGrpc) BlockHeartbeatPOptions(alluxio.grpc.BlockHeartbeatPOptions) Constants(alluxio.Constants) GetRegisterLeasePRequest(alluxio.grpc.GetRegisterLeasePRequest) GrpcUtils(alluxio.grpc.GrpcUtils) GetWorkerIdPRequest(alluxio.grpc.GetWorkerIdPRequest) Map(java.util.Map) BlockHeartbeatPRequest(alluxio.grpc.BlockHeartbeatPRequest) LocationBlockIdListEntry(alluxio.grpc.LocationBlockIdListEntry) AbstractMasterClient(alluxio.AbstractMasterClient) Metric(alluxio.grpc.Metric) RetryPolicy(alluxio.retry.RetryPolicy) BlockIdList(alluxio.grpc.BlockIdList) CommitBlockInUfsPRequest(alluxio.grpc.CommitBlockInUfsPRequest) FailedToAcquireRegisterLeaseException(alluxio.exception.FailedToAcquireRegisterLeaseException) Logger(org.slf4j.Logger) BlockStoreLocationProto(alluxio.grpc.BlockStoreLocationProto) GetRegisterLeasePResponse(alluxio.grpc.GetRegisterLeasePResponse) IOException(java.io.IOException) ThreadSafe(javax.annotation.concurrent.ThreadSafe) ConfigProperty(alluxio.grpc.ConfigProperty) Command(alluxio.grpc.Command) Collectors(java.util.stream.Collectors) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) RegisterWorkerPOptions(alluxio.grpc.RegisterWorkerPOptions) MasterClientContext(alluxio.master.MasterClientContext) CommitBlockPRequest(alluxio.grpc.CommitBlockPRequest) ServiceType(alluxio.grpc.ServiceType) VisibleForTesting(com.google.common.annotations.VisibleForTesting) RegisterWorkerPRequest(alluxio.grpc.RegisterWorkerPRequest) StorageList(alluxio.grpc.StorageList) BlockHeartbeatPRequest(alluxio.grpc.BlockHeartbeatPRequest) StorageList(alluxio.grpc.StorageList) HashMap(java.util.HashMap) Map(java.util.Map) BlockHeartbeatPOptions(alluxio.grpc.BlockHeartbeatPOptions) LocationBlockIdListEntry(alluxio.grpc.LocationBlockIdListEntry)

Aggregations

AbstractMasterClient (alluxio.AbstractMasterClient)1 Constants (alluxio.Constants)1 PropertyKey (alluxio.conf.PropertyKey)1 FailedToAcquireRegisterLeaseException (alluxio.exception.FailedToAcquireRegisterLeaseException)1 BlockHeartbeatPOptions (alluxio.grpc.BlockHeartbeatPOptions)1 BlockHeartbeatPRequest (alluxio.grpc.BlockHeartbeatPRequest)1 BlockIdList (alluxio.grpc.BlockIdList)1 BlockMasterWorkerServiceGrpc (alluxio.grpc.BlockMasterWorkerServiceGrpc)1 BlockStoreLocationProto (alluxio.grpc.BlockStoreLocationProto)1 Command (alluxio.grpc.Command)1 CommitBlockInUfsPRequest (alluxio.grpc.CommitBlockInUfsPRequest)1 CommitBlockPRequest (alluxio.grpc.CommitBlockPRequest)1 ConfigProperty (alluxio.grpc.ConfigProperty)1 GetRegisterLeasePRequest (alluxio.grpc.GetRegisterLeasePRequest)1 GetRegisterLeasePResponse (alluxio.grpc.GetRegisterLeasePResponse)1 GetWorkerIdPRequest (alluxio.grpc.GetWorkerIdPRequest)1 GrpcUtils (alluxio.grpc.GrpcUtils)1 LocationBlockIdListEntry (alluxio.grpc.LocationBlockIdListEntry)1 Metric (alluxio.grpc.Metric)1 RegisterWorkerPOptions (alluxio.grpc.RegisterWorkerPOptions)1