Search in sources :

Example 6 with BlockMasterWorkerServiceStub

use of alluxio.grpc.BlockMasterWorkerServiceGrpc.BlockMasterWorkerServiceStub in project alluxio by Alluxio.

the class BlockWorkerRegisterStreamIntegrationTest method masterHangsInStream.

@Test
public void masterHangsInStream() throws Exception {
    // Create the stream and control the request/response observers
    BlockMasterWorkerServiceStub asyncClient = PowerMockito.mock(BlockMasterWorkerServiceStub.class);
    when(asyncClient.withDeadlineAfter(anyLong(), any())).thenReturn(asyncClient);
    ManualRegisterStreamObserver requestObserver = new ManualRegisterStreamObserver(MasterMode.HANG_IN_STREAM);
    when(asyncClient.registerWorkerStream(any())).thenReturn(requestObserver);
    RegisterStreamer registerStreamer = new RegisterStreamer(asyncClient, WORKER_ID, mTierAliases, mCapacityMap, mUsedMap, mBlockMap, LOST_STORAGE, EMPTY_CONFIG);
    StreamObserver<RegisterWorkerPResponse> responseObserver = getResponseObserver(registerStreamer);
    requestObserver.setResponseObserver(responseObserver);
    // The master will hang during the stream which exceeds the deadline between messages
    assertThrows(DeadlineExceededException.class, () -> {
        registerStreamer.registerWithMaster();
    });
}
Also used : RegisterWorkerPResponse(alluxio.grpc.RegisterWorkerPResponse) BlockMasterWorkerServiceStub(alluxio.grpc.BlockMasterWorkerServiceGrpc.BlockMasterWorkerServiceStub) RegisterStreamer(alluxio.worker.block.RegisterStreamer) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 7 with BlockMasterWorkerServiceStub

use of alluxio.grpc.BlockMasterWorkerServiceGrpc.BlockMasterWorkerServiceStub in project alluxio by Alluxio.

the class BlockWorkerRegisterStreamIntegrationTest method registerWorkerErrorAtStreamStart.

/**
 * Tests below cover various failure cases.
 */
@Test
public void registerWorkerErrorAtStreamStart() throws Exception {
    // Create the stream and control the request/response observers
    BlockMasterWorkerServiceStub asyncClient = PowerMockito.mock(BlockMasterWorkerServiceStub.class);
    when(asyncClient.withDeadlineAfter(anyLong(), any())).thenReturn(asyncClient);
    ManualRegisterStreamObserver requestObserver = new ManualRegisterStreamObserver(MasterMode.FIRST_REQUEST);
    when(asyncClient.registerWorkerStream(any())).thenReturn(requestObserver);
    RegisterStreamer registerStreamer = new RegisterStreamer(asyncClient, WORKER_ID, mTierAliases, mCapacityMap, mUsedMap, mBlockMap, LOST_STORAGE, EMPTY_CONFIG);
    StreamObserver<RegisterWorkerPResponse> responseObserver = getResponseObserver(registerStreamer);
    requestObserver.setResponseObserver(responseObserver);
    assertThrows(InternalException.class, () -> {
        // An error received from the master side will be InternalException
        registerStreamer.registerWithMaster();
    });
}
Also used : RegisterWorkerPResponse(alluxio.grpc.RegisterWorkerPResponse) BlockMasterWorkerServiceStub(alluxio.grpc.BlockMasterWorkerServiceGrpc.BlockMasterWorkerServiceStub) RegisterStreamer(alluxio.worker.block.RegisterStreamer) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

BlockMasterWorkerServiceStub (alluxio.grpc.BlockMasterWorkerServiceGrpc.BlockMasterWorkerServiceStub)7 RegisterWorkerPResponse (alluxio.grpc.RegisterWorkerPResponse)7 RegisterStreamer (alluxio.worker.block.RegisterStreamer)7 Test (org.junit.Test)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 DeadlineExceededException (alluxio.exception.status.DeadlineExceededException)1 InternalException (alluxio.exception.status.InternalException)1 NotFoundException (alluxio.exception.status.NotFoundException)1 RegisterWorkerPRequest (alluxio.grpc.RegisterWorkerPRequest)1 StorageList (alluxio.grpc.StorageList)1 MasterClientContext (alluxio.master.MasterClientContext)1 BlockMasterSync (alluxio.worker.block.BlockMasterSync)1 BlockStoreLocation (alluxio.worker.block.BlockStoreLocation)1 ImmutableList (com.google.common.collect.ImmutableList)1 StatusException (io.grpc.StatusException)1 IOException (java.io.IOException)1 List (java.util.List)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Future (java.util.concurrent.Future)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1