use of alluxio.grpc.RegisterWorkerPRequest in project alluxio by Alluxio.
the class BlockMasterRegisterStreamIntegrationTest method workerRegisterCompleteThrowsError.
@Test
public void workerRegisterCompleteThrowsError() throws Exception {
// Hijack the block master so it throws errors
BrokenBlockMaster brokenBlockMaster = new BrokenBlockMaster(mMetricsMaster, mMasterContext, mClock, ExecutorServiceFactories.constantExecutorServiceFactory(mExecutorService), WorkerRegisterMode.ERROR_COMPLETE);
mBlockMaster = brokenBlockMaster;
mHandler = new BlockMasterWorkerServiceHandler(brokenBlockMaster);
long workerId = brokenBlockMaster.getWorkerId(NET_ADDRESS_1);
Queue<Throwable> errorQueue = new ConcurrentLinkedQueue<>();
RegisterStreamObserver streamOb = new RegisterStreamObserver(brokenBlockMaster, getErrorCapturingResponseObserver(errorQueue));
// Generate requests
List<RegisterWorkerPRequest> requestChunks = RegisterStreamTestUtils.generateRegisterStreamForWorker(workerId);
prepareBlocksOnMaster(requestChunks);
for (RegisterWorkerPRequest chunk : requestChunks) {
streamOb.onNext(chunk);
}
streamOb.onCompleted();
// Only onCompleted should receive an error
assertEquals(1, errorQueue.size());
// The BlockMaster is not throwing error this time
brokenBlockMaster.setCorrect();
verifyWorkerCanReregister(workerId, requestChunks, TIER_BLOCK_TOTAL);
}
use of alluxio.grpc.RegisterWorkerPRequest in project alluxio by Alluxio.
the class BlockMasterRegisterStreamIntegrationTest method workerSendsErrorOnStart.
@Test
public void workerSendsErrorOnStart() throws Exception {
long workerId = mBlockMaster.getWorkerId(NET_ADDRESS_1);
List<RegisterWorkerPRequest> requestChunks = RegisterStreamTestUtils.generateRegisterStreamForWorker(workerId);
prepareBlocksOnMaster(requestChunks);
Queue<Throwable> errorQueue = new ConcurrentLinkedQueue<>();
StreamObserver<RegisterWorkerPRequest> requestObserver = mHandler.registerWorkerStream(RegisterStreamTestUtils.getErrorCapturingResponseObserver(errorQueue));
// Instead of sending requests to the master, the worker is interrupted
// around the beginning of the stream. The error propagated to the master.
Exception e = new InterruptedException("Worker is interrupted");
assertThrows(IllegalStateException.class, () -> {
requestObserver.onError(e);
});
// shall be accepted by the master.
for (RegisterWorkerPRequest chunk : requestChunks) {
requestObserver.onNext(chunk);
}
requestObserver.onCompleted();
assertEquals(requestChunks.size() + 1, errorQueue.size());
// verify the worker is not registered
assertEquals(0, mBlockMaster.getWorkerCount());
verifyWorkerCanReregister(workerId, requestChunks, TIER_BLOCK_TOTAL);
}
use of alluxio.grpc.RegisterWorkerPRequest in project alluxio by Alluxio.
the class BlockMasterRegisterStreamIntegrationTest method registerWorkerStream.
@Test
public void registerWorkerStream() throws Exception {
long workerId = mBlockMaster.getWorkerId(NET_ADDRESS_1);
List<RegisterWorkerPRequest> requestChunks = RegisterStreamTestUtils.generateRegisterStreamForWorker(workerId);
prepareBlocksOnMaster(requestChunks);
Queue<Throwable> errorQueue = new ConcurrentLinkedQueue<>();
sendStreamToMaster(requestChunks, RegisterStreamTestUtils.getErrorCapturingResponseObserver(errorQueue));
// Verify the worker is registered
assertEquals(0, errorQueue.size());
MasterWorkerInfo worker = mBlockMaster.getWorker(workerId);
assertEquals(TIER_BLOCK_TOTAL, worker.getBlockCount());
assertEquals(0, worker.getToRemoveBlockCount());
assertEquals(1, mBlockMaster.getWorkerCount());
// Verify the worker is readable and writable
verifyWorkerWritable(workerId);
}
use of alluxio.grpc.RegisterWorkerPRequest in project alluxio by Alluxio.
the class RegisterStreamTestUtils method generateRegisterStreamForWorker.
public static List<RegisterWorkerPRequest> generateRegisterStreamForWorker(long workerId) {
List<String> tierAliases = getTierAliases(parseTierConfig(TIER_CONFIG));
// Generate block IDs heuristically
Map<TierAlias, List<Integer>> tierConfigMap = parseTierConfig(TIER_CONFIG);
Map<BlockStoreLocation, List<Long>> blockMap = RpcBenchPreparationUtils.generateBlockIdOnTiers(tierConfigMap);
// We just use the RegisterStreamer to generate the batch of requests
RegisterStreamer registerStreamer = new RegisterStreamer(null, workerId, tierAliases, CAPACITY_MAP, USAGE_MAP, blockMap, LOST_STORAGE, EMPTY_CONFIG);
// Get chunks from the RegisterStreamer
List<RegisterWorkerPRequest> requestChunks = ImmutableList.copyOf(registerStreamer);
int expectedBatchCount = (int) Math.ceil((TIER_BLOCK_TOTAL) / (double) BATCH_SIZE);
assertEquals(expectedBatchCount, requestChunks.size());
return requestChunks;
}
use of alluxio.grpc.RegisterWorkerPRequest in project alluxio by Alluxio.
the class RegisterStreamTestUtils method findFirstBlock.
static long findFirstBlock(List<RegisterWorkerPRequest> chunks) {
RegisterWorkerPRequest firstBatch = chunks.get(0);
LocationBlockIdListEntry entry = firstBatch.getCurrentBlocks(0);
return entry.getValue().getBlockId(0);
}
Aggregations