Search in sources :

Example 16 with RegisterWorkerPRequest

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);
}
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 17 with RegisterWorkerPRequest

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);
}
Also used : RegisterWorkerPRequest(alluxio.grpc.RegisterWorkerPRequest) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) AssertionException(javolution.testing.AssertionException) UnavailableException(alluxio.exception.status.UnavailableException) BlockInfoException(alluxio.exception.BlockInfoException) IOException(java.io.IOException) Test(org.junit.Test)

Example 18 with RegisterWorkerPRequest

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

Example 19 with RegisterWorkerPRequest

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;
}
Also used : TierAlias(alluxio.stress.rpc.TierAlias) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) RegisterWorkerPRequest(alluxio.grpc.RegisterWorkerPRequest) BlockStoreLocation(alluxio.worker.block.BlockStoreLocation) RegisterStreamer(alluxio.worker.block.RegisterStreamer)

Example 20 with RegisterWorkerPRequest

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);
}
Also used : RegisterWorkerPRequest(alluxio.grpc.RegisterWorkerPRequest) LocationBlockIdListEntry(alluxio.grpc.LocationBlockIdListEntry)

Aggregations

RegisterWorkerPRequest (alluxio.grpc.RegisterWorkerPRequest)30 Test (org.junit.Test)22 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)15 LocationBlockIdListEntry (alluxio.grpc.LocationBlockIdListEntry)9 BlockStoreLocation (alluxio.worker.block.BlockStoreLocation)9 MasterWorkerInfo (alluxio.master.block.meta.MasterWorkerInfo)8 StorageList (alluxio.grpc.StorageList)6 List (java.util.List)6 BlockIdList (alluxio.grpc.BlockIdList)5 BlockStoreLocationProto (alluxio.grpc.BlockStoreLocationProto)5 RegisterWorkerPResponse (alluxio.grpc.RegisterWorkerPResponse)5 RegisterStreamer (alluxio.worker.block.RegisterStreamer)5 ImmutableList (com.google.common.collect.ImmutableList)5 IOException (java.io.IOException)5 Command (alluxio.grpc.Command)4 StreamObserver (io.grpc.stub.StreamObserver)4 BlockInfoException (alluxio.exception.BlockInfoException)3 UnavailableException (alluxio.exception.status.UnavailableException)3 GetRegisterLeasePRequest (alluxio.grpc.GetRegisterLeasePRequest)3 BlockMasterWorkerServiceHandler (alluxio.master.block.BlockMasterWorkerServiceHandler)3