Search in sources :

Example 1 with RpcTaskResult

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

the class RegisterWorkerBench method simulateRegisterWorker.

private RpcTaskResult simulateRegisterWorker(alluxio.worker.block.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 2 with RpcTaskResult

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

the class WorkerHeartbeatBench method runRPC.

@Override
public RpcTaskResult runRPC() throws Exception {
    RpcTaskResult result = new RpcTaskResult();
    if (mWorkerPool == null) {
        result.addError("Worker ID pool is null");
        return result;
    }
    // Get the worker to use
    if (mWorkerPool.isEmpty()) {
        result.addError("No more worker IDs for use");
        return result;
    }
    long workerId = mWorkerPool.poll();
    LOG.info("Acquired worker ID {}", workerId);
    // Use a mocked client to save conversion
    CachingBlockMasterClient client = new CachingBlockMasterClient(MasterClientContext.newBuilder(ClientContext.create(mConf)).build(), mLocationBlockIdList);
    long durationMs = FormatUtils.parseTimeSize(mParameters.mDuration);
    Instant startTime = Instant.now();
    Instant endTime = startTime.plus(durationMs, ChronoUnit.MILLIS);
    LOG.info("Test start time {}, end time {}", startTime, endTime);
    // Stop after certain time has elapsed
    RpcTaskResult taskResult = simulateBlockHeartbeat(client, workerId, endTime);
    LOG.info("Test finished with results: {}", taskResult);
    return taskResult;
}
Also used : Instant(java.time.Instant) CachingBlockMasterClient(alluxio.stress.CachingBlockMasterClient) RpcTaskResult(alluxio.stress.rpc.RpcTaskResult)

Example 3 with RpcTaskResult

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

the class GetPinnedFileIdsBench method runRPC.

@Override
public RpcTaskResult runRPC() throws Exception {
    RpcTaskResult result = new RpcTaskResult();
    mDurationStopwatch.get().reset().start();
    long durationMs = FormatUtils.parseTimeSize(mParameters.mDuration);
    LOG.info("Beginning benchmark, running for {} ms", durationMs);
    while (mDurationStopwatch.get().elapsed(TimeUnit.MILLISECONDS) < durationMs) {
        try {
            mPointStopwatch.get().reset().start();
            int numPinnedFiles = mWorkerClient.getPinListLength();
            mPointStopwatch.get().stop();
            if (numPinnedFiles != mParameters.mNumFiles) {
                result.addError(String.format("Unexpected number of files: %d, expected %d", numPinnedFiles, mParameters.mNumFiles));
                continue;
            }
            result.addPoint(new RpcTaskResult.Point(mPointStopwatch.get().elapsed(TimeUnit.MILLISECONDS)));
        } catch (Exception e) {
            LOG.error("Failed when running", e);
            result.addError(e.getMessage());
        }
    }
    return result;
}
Also used : RpcTaskResult(alluxio.stress.rpc.RpcTaskResult) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) IOException(java.io.IOException)

Example 4 with RpcTaskResult

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

the class RpcBench method runLocal.

@Override
public RpcTaskResult runLocal() throws Exception {
    RpcBenchParameters rpcBenchParameters = getParameters();
    LOG.info("Running locally with {} threads", rpcBenchParameters.mConcurrency);
    List<CompletableFuture<RpcTaskResult>> futures = new ArrayList<>();
    try {
        for (int i = 0; i < rpcBenchParameters.mConcurrency; i++) {
            CompletableFuture<RpcTaskResult> future = CompletableFuture.supplyAsync(() -> {
                RpcTaskResult threadResult = new RpcTaskResult();
                threadResult.setBaseParameters(mBaseParameters);
                threadResult.setParameters(rpcBenchParameters);
                try {
                    RpcTaskResult r = runRPC();
                    threadResult.merge(r);
                    return threadResult;
                } catch (Exception e) {
                    LOG.error("Failed to execute RPC", e);
                    threadResult.addError(e.getMessage());
                    return threadResult;
                }
            }, getPool());
            futures.add(future);
        }
        LOG.info("{} jobs submitted", futures.size());
        // Collect the result
        RpcTaskResult merged = futures.stream().map(CompletableFuture::join).reduce(new RpcTaskResult(mBaseParameters, rpcBenchParameters), (sum, one) -> {
            sum.merge(one);
            return sum;
        });
        return merged;
    } catch (Exception e) {
        LOG.error("Failed to execute RPC in pool", e);
        RpcTaskResult result = new RpcTaskResult();
        result.setBaseParameters(mBaseParameters);
        result.setParameters(rpcBenchParameters);
        result.addError(e.getMessage());
        return result;
    }
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) ArrayList(java.util.ArrayList) RpcTaskResult(alluxio.stress.rpc.RpcTaskResult) RpcBenchParameters(alluxio.stress.rpc.RpcBenchParameters)

Example 5 with RpcTaskResult

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

the class StreamRegisterWorkerBench 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(), mBlockMap);
    RpcTaskResult taskResult = simulateRegisterWorkerStream(client);
    LOG.info("Received task result {}", taskResult);
    LOG.info("Run finished");
    return taskResult;
}
Also used : CachingBlockMasterClient(alluxio.stress.CachingBlockMasterClient) RpcTaskResult(alluxio.stress.rpc.RpcTaskResult)

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