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