Search in sources :

Example 11 with LocationBlockIdListEntry

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

the class RegisterStreamTestUtils method findFirstBlock.

static long findFirstBlock(List<RegisterWorkerPRequest> chunks) {
    RegisterWorkerPRequest firstBatch = chunks.get(0);
    LocationBlockIdListEntry entry = firstBatch.getCurrentBlocks(0);
    return entry.getValue().getBlockId(0);
}
Also used : RegisterWorkerPRequest(alluxio.grpc.RegisterWorkerPRequest) LocationBlockIdListEntry(alluxio.grpc.LocationBlockIdListEntry)

Example 12 with LocationBlockIdListEntry

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

the class StreamRegisterWorkerBench method debriefBlockListProto.

private static void debriefBlockListProto(List<LocationBlockIdListEntry> entries) {
    StringBuilder sb = new StringBuilder();
    for (LocationBlockIdListEntry e : entries) {
        sb.append(String.format("%s,", e.getKey()));
    }
    LOG.info("Generated locations: {}", sb.toString());
}
Also used : LocationBlockIdListEntry(alluxio.grpc.LocationBlockIdListEntry)

Example 13 with LocationBlockIdListEntry

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

the class RegisterWorkerBench method runOnce.

private void runOnce(alluxio.worker.block.BlockMasterClient client, RpcTaskResult result, long i, long workerId) {
    try {
        Instant s = Instant.now();
        if (mConf.getBoolean(PropertyKey.WORKER_REGISTER_LEASE_ENABLED)) {
            LOG.info("Acquiring lease for {}", workerId);
            int blockCount = 0;
            for (LocationBlockIdListEntry entry : mLocationBlockIdList) {
                blockCount += entry.getValue().getBlockIdCount();
            }
            client.acquireRegisterLeaseWithBackoff(workerId, blockCount, BlockMasterSync.getDefaultAcquireLeaseRetryPolicy());
            LOG.info("Lease acquired for {}", workerId);
        }
        // TODO(jiacheng): The 1st reported RPC time is always very long, this does
        // not match with the time recorded by Jaeger.
        // I suspect it's the time spend in establishing the connection.
        // The easiest way out is just to ignore the 1st point.
        client.register(workerId, mTierAliases, mCapacityMap, mUsedMap, // So an empty block list will be used here
        ImmutableMap.of(), // lost storage
        LOST_STORAGE, // extra config
        EMPTY_CONFIG);
        LOG.info("Worker {} registered", workerId);
        Instant e = Instant.now();
        RpcTaskResult.Point p = new RpcTaskResult.Point(Duration.between(s, e).toMillis());
        result.addPoint(p);
        LOG.debug("Iter {} took {}ns", i, p.mDurationMs);
    } catch (Exception e) {
        LOG.error("Failed to run iter {}", i, e);
        result.addError(e.getMessage());
    }
}
Also used : Instant(java.time.Instant) RpcTaskResult(alluxio.stress.rpc.RpcTaskResult) LocationBlockIdListEntry(alluxio.grpc.LocationBlockIdListEntry)

Example 14 with LocationBlockIdListEntry

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

the class BlockMasterClient method register.

/**
 * The method the worker should execute to register with the block master.
 *
 * @param workerId the worker id of the worker registering
 * @param storageTierAliases a list of storage tier aliases in ordinal order
 * @param totalBytesOnTiers mapping from storage tier alias to total bytes
 * @param usedBytesOnTiers mapping from storage tier alias to used bytes
 * @param currentBlocksOnLocation mapping from storage tier alias to the list of list of blocks
 * @param lostStorage mapping from storage tier alias to the list of lost storage paths
 * @param configList a list of configurations
 */
// TODO(yupeng): rename to workerBlockReport or workerInitialize?
public void register(final long workerId, final List<String> storageTierAliases, final Map<String, Long> totalBytesOnTiers, final Map<String, Long> usedBytesOnTiers, final Map<BlockStoreLocation, List<Long>> currentBlocksOnLocation, final Map<String, List<String>> lostStorage, final List<ConfigProperty> configList) throws IOException {
    final RegisterWorkerPOptions options = RegisterWorkerPOptions.newBuilder().addAllConfigs(configList).build();
    final List<LocationBlockIdListEntry> currentBlocks = convertBlockListMapToProto(currentBlocksOnLocation);
    final Map<String, StorageList> lostStorageMap = lostStorage.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> StorageList.newBuilder().addAllStorage(e.getValue()).build()));
    final RegisterWorkerPRequest request = RegisterWorkerPRequest.newBuilder().setWorkerId(workerId).addAllStorageTiers(storageTierAliases).putAllTotalBytesOnTiers(totalBytesOnTiers).putAllUsedBytesOnTiers(usedBytesOnTiers).addAllCurrentBlocks(currentBlocks).putAllLostStorage(lostStorageMap).setOptions(options).build();
    retryRPC(() -> {
        mClient.registerWorker(request);
        return null;
    }, LOG, "Register", "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) StorageList(alluxio.grpc.StorageList) RegisterWorkerPRequest(alluxio.grpc.RegisterWorkerPRequest) RegisterWorkerPOptions(alluxio.grpc.RegisterWorkerPOptions) HashMap(java.util.HashMap) Map(java.util.Map) LocationBlockIdListEntry(alluxio.grpc.LocationBlockIdListEntry)

Example 15 with LocationBlockIdListEntry

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

the class BlockMapIterator method nextBatchFromTier.

private LocationBlockIdListEntry nextBatchFromTier(BlockStoreLocationProto currentLoc, Iterator<Long> currentIterator, int spaceLeft) {
    // Generate the next batch
    List<Long> blockIdBatch = new ArrayList<>(spaceLeft);
    while (blockIdBatch.size() < spaceLeft && currentIterator.hasNext()) {
        blockIdBatch.add(currentIterator.next());
        mCounter++;
    }
    BlockIdList blockIdList = BlockIdList.newBuilder().addAllBlockId(blockIdBatch).build();
    LocationBlockIdListEntry listEntry = LocationBlockIdListEntry.newBuilder().setKey(currentLoc).setValue(blockIdList).build();
    return listEntry;
}
Also used : BlockIdList(alluxio.grpc.BlockIdList) ArrayList(java.util.ArrayList) LocationBlockIdListEntry(alluxio.grpc.LocationBlockIdListEntry)

Aggregations

LocationBlockIdListEntry (alluxio.grpc.LocationBlockIdListEntry)19 BlockStoreLocationProto (alluxio.grpc.BlockStoreLocationProto)10 RegisterWorkerPRequest (alluxio.grpc.RegisterWorkerPRequest)10 Test (org.junit.Test)10 BlockIdList (alluxio.grpc.BlockIdList)9 ArrayList (java.util.ArrayList)7 List (java.util.List)6 StorageList (alluxio.grpc.StorageList)5 BlockStoreLocation (alluxio.worker.block.BlockStoreLocation)5 StreamObserver (io.grpc.stub.StreamObserver)5 GetRegisterLeasePRequest (alluxio.grpc.GetRegisterLeasePRequest)4 RegisterWorkerPResponse (alluxio.grpc.RegisterWorkerPResponse)4 HashMap (java.util.HashMap)4 BlockHeartbeatPRequest (alluxio.grpc.BlockHeartbeatPRequest)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3 ConcurrentLinkedDeque (java.util.concurrent.ConcurrentLinkedDeque)3 AbstractMasterClient (alluxio.AbstractMasterClient)2 Constants (alluxio.Constants)2