Search in sources :

Example 1 with BlockMasterWorkerServiceHandler

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);
}
Also used : BlockMasterWorkerServiceHandler(alluxio.master.block.BlockMasterWorkerServiceHandler) RegisterWorkerPRequest(alluxio.grpc.RegisterWorkerPRequest) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) RegisterStreamObserver(alluxio.master.block.RegisterStreamObserver) Test(org.junit.Test)

Example 2 with BlockMasterWorkerServiceHandler

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);
}
Also used : BlockMasterWorkerServiceHandler(alluxio.master.block.BlockMasterWorkerServiceHandler) RegisterWorkerPRequest(alluxio.grpc.RegisterWorkerPRequest) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) RegisterStreamObserver(alluxio.master.block.RegisterStreamObserver) Test(org.junit.Test)

Example 3 with BlockMasterWorkerServiceHandler

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);
}
Also used : BlockMasterWorkerServiceHandler(alluxio.master.block.BlockMasterWorkerServiceHandler) RegisterWorkerPRequest(alluxio.grpc.RegisterWorkerPRequest) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) RegisterStreamObserver(alluxio.master.block.RegisterStreamObserver) Test(org.junit.Test)

Example 4 with BlockMasterWorkerServiceHandler

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);
}
Also used : ManualClock(alluxio.clock.ManualClock) DefaultBlockMaster(alluxio.master.block.DefaultBlockMaster) BlockMasterWorkerServiceHandler(alluxio.master.block.BlockMasterWorkerServiceHandler) MasterRegistry(alluxio.master.MasterRegistry) MetricsMasterFactory(alluxio.master.metrics.MetricsMasterFactory) Before(org.junit.Before)

Aggregations

BlockMasterWorkerServiceHandler (alluxio.master.block.BlockMasterWorkerServiceHandler)4 RegisterWorkerPRequest (alluxio.grpc.RegisterWorkerPRequest)3 RegisterStreamObserver (alluxio.master.block.RegisterStreamObserver)3 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)3 Test (org.junit.Test)3 ManualClock (alluxio.clock.ManualClock)1 MasterRegistry (alluxio.master.MasterRegistry)1 DefaultBlockMaster (alluxio.master.block.DefaultBlockMaster)1 MetricsMasterFactory (alluxio.master.metrics.MetricsMasterFactory)1 Before (org.junit.Before)1