Search in sources :

Example 6 with RpcTaskResult

use of alluxio.stress.rpc.RpcTaskResult in project alluxio by Alluxio.

the class StreamRegisterWorkerBench method simulateRegisterWorkerStream.

private RpcTaskResult simulateRegisterWorkerStream(BlockMasterClient client) {
    RpcTaskResult result = new RpcTaskResult();
    long i = 0;
    if (mWorkerPool == null) {
        result.addError("Worker ID pool is null");
        return result;
    }
    if (mWorkerPool.isEmpty()) {
        result.addError("No more worker IDs for use");
        return result;
    }
    long workerId = mWorkerPool.poll();
    // Each client will simulate only one worker register RPC
    // Because the number of concurrent register RPCs is the variable we want to control
    // And we want these RPCs to invoke at roughly the same time
    runOnce(client, result, i, workerId);
    return result;
}
Also used : RpcTaskResult(alluxio.stress.rpc.RpcTaskResult)

Example 7 with RpcTaskResult

use of alluxio.stress.rpc.RpcTaskResult in project alluxio by Alluxio.

the class StreamRegisterWorkerBench 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 (Map.Entry<BlockStoreLocation, List<Long>> entry : mBlockMap.entrySet()) {
                blockCount += entry.getValue().size();
            }
            client.acquireRegisterLeaseWithBackoff(workerId, blockCount, BlockMasterSync.getDefaultAcquireLeaseRetryPolicy());
            LOG.info("Lease acquired for {}", workerId);
        }
        client.registerWithStream(workerId, mTierAliases, mCapacityMap, mUsedMap, mBlockMap, // lost storage
        LOST_STORAGE, // extra config
        EMPTY_CONFIG);
        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) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) RpcTaskResult(alluxio.stress.rpc.RpcTaskResult) Map(java.util.Map) BlockStoreLocation(alluxio.worker.block.BlockStoreLocation)

Example 8 with RpcTaskResult

use of alluxio.stress.rpc.RpcTaskResult in project alluxio by Alluxio.

the class WorkerHeartbeatBench method simulateBlockHeartbeat.

private RpcTaskResult simulateBlockHeartbeat(alluxio.worker.block.BlockMasterClient client, long workerId, Instant endTime) {
    RpcTaskResult result = new RpcTaskResult();
    // Keep sending heartbeats until the expected end time
    long i = 0;
    while (Instant.now().isBefore(endTime)) {
        Instant s = Instant.now();
        try {
            Command cmd = client.heartbeat(workerId, CAPACITY_MEM, USED_MEM_EMPTY, EMPTY_REMOVED_BLOCKS, // So an empty map will be used here
            ImmutableMap.of(), LOST_STORAGE, EMPTY_METRICS);
            LOG.debug("Received command from heartbeat {}", cmd);
            Instant e = Instant.now();
            Duration d = Duration.between(s, e);
            RpcTaskResult.Point p = new RpcTaskResult.Point(d.toMillis());
            LOG.debug("Iter {} took {}ms", i, p.mDurationMs);
            result.addPoint(p);
        } catch (Exception e) {
            LOG.error("Failed to run blockHeartbeat {}", i, e);
            result.addError(e.getMessage());
        // Keep trying even when an exception is met
        }
    }
    return result;
}
Also used : Command(alluxio.grpc.Command) Instant(java.time.Instant) RpcTaskResult(alluxio.stress.rpc.RpcTaskResult) Duration(java.time.Duration)

Example 9 with RpcTaskResult

use of alluxio.stress.rpc.RpcTaskResult in project alluxio by Alluxio.

the class RegisterWorkerBench method runRPC.

@Override
public RpcTaskResult runRPC() throws Exception {
    // Use a mocked client to save conversion
    CachingBlockMasterClient client = new CachingBlockMasterClient(MasterClientContext.newBuilder(ClientContext.create(mConf)).build(), mLocationBlockIdList);
    RpcTaskResult taskResult = simulateRegisterWorker(client);
    LOG.info("Received task result {}", taskResult);
    LOG.info("Run finished");
    return taskResult;
}
Also used : CachingBlockMasterClient(alluxio.stress.CachingBlockMasterClient) RpcTaskResult(alluxio.stress.rpc.RpcTaskResult)

Example 10 with RpcTaskResult

use of alluxio.stress.rpc.RpcTaskResult 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)

Aggregations

RpcTaskResult (alluxio.stress.rpc.RpcTaskResult)10 Instant (java.time.Instant)4 CachingBlockMasterClient (alluxio.stress.CachingBlockMasterClient)3 AlluxioStatusException (alluxio.exception.status.AlluxioStatusException)1 Command (alluxio.grpc.Command)1 LocationBlockIdListEntry (alluxio.grpc.LocationBlockIdListEntry)1 RpcBenchParameters (alluxio.stress.rpc.RpcBenchParameters)1 BlockStoreLocation (alluxio.worker.block.BlockStoreLocation)1 ImmutableList (com.google.common.collect.ImmutableList)1 IOException (java.io.IOException)1 Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1