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;
}
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;
}
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;
}
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;
}
}
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;
}
Aggregations