use of alluxio.stress.rpc.RpcBenchParameters 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;
}
}
Aggregations