use of alluxio.master.block.BlockMasterWorkerServiceHandler in project alluxio by Alluxio.
the class BlockMasterRegisterStreamIntegrationTest method workerRegisterBatchThrowsError.
@Test
public void workerRegisterBatchThrowsError() throws Exception {
// Hijack the block master so it throws errors
BrokenBlockMaster brokenBlockMaster = new BrokenBlockMaster(mMetricsMaster, mMasterContext, mClock, ExecutorServiceFactories.constantExecutorServiceFactory(mExecutorService), WorkerRegisterMode.ERROR_STREAM);
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();
// All requests except the 1st one + onCompleted should receive an error
assertEquals(requestChunks.size() - 1 + 1, errorQueue.size());
// The BlockMaster is not throwing error this time
brokenBlockMaster.setCorrect();
verifyWorkerCanReregister(workerId, requestChunks, TIER_BLOCK_TOTAL);
}
use of alluxio.master.block.BlockMasterWorkerServiceHandler in project alluxio by Alluxio.
the class BlockMasterRegisterStreamIntegrationTest method workerRegisterStartThrowsError.
@Test
public void workerRegisterStartThrowsError() throws Exception {
// Hijack the block master so it throws errors
BrokenBlockMaster brokenBlockMaster = new BrokenBlockMaster(mMetricsMaster, mMasterContext, mClock, ExecutorServiceFactories.constantExecutorServiceFactory(mExecutorService), WorkerRegisterMode.ERROR_START);
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();
// All requests + onCompleted should receive an error
assertEquals(requestChunks.size() + 1, errorQueue.size());
// The BlockMaster is not throwing error this time
brokenBlockMaster.setCorrect();
verifyWorkerCanReregister(workerId, requestChunks, TIER_BLOCK_TOTAL);
}
use of alluxio.master.block.BlockMasterWorkerServiceHandler 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.master.block.BlockMasterWorkerServiceHandler in project alluxio by Alluxio.
the class BlockMasterRegisterStreamIntegrationTest method before.
/**
* Sets up the dependencies before a test runs.
*/
@Before
public void before() throws Exception {
// Set the config properties
ServerConfiguration.set(PropertyKey.WORKER_REGISTER_STREAM_ENABLED, true);
ServerConfiguration.set(PropertyKey.WORKER_REGISTER_STREAM_BATCH_SIZE, BATCH_SIZE);
ServerConfiguration.set(PropertyKey.MASTER_WORKER_TIMEOUT_MS, MASTER_WORKER_TIMEOUT);
ServerConfiguration.set(PropertyKey.MASTER_WORKER_REGISTER_STREAM_RESPONSE_TIMEOUT, "1s");
ServerConfiguration.set(PropertyKey.MASTER_WORKER_REGISTER_LEASE_ENABLED, false);
mRegistry = new MasterRegistry();
mMasterContext = MasterTestUtils.testMasterContext();
mMetricsMaster = new MetricsMasterFactory().create(mRegistry, mMasterContext);
mRegistry.add(MetricsMaster.class, mMetricsMaster);
mClock = new ManualClock();
mExecutorService = Executors.newFixedThreadPool(10, ThreadFactoryUtils.build("TestBlockMaster-%d", true));
mBlockMaster = new DefaultBlockMaster(mMetricsMaster, mMasterContext, mClock, ExecutorServiceFactories.constantExecutorServiceFactory(mExecutorService));
mRegistry.add(BlockMaster.class, mBlockMaster);
mRegistry.start(true);
mHandler = new BlockMasterWorkerServiceHandler(mBlockMaster);
}
Aggregations