Search in sources :

Example 6 with GetRegisterLeasePRequest

use of alluxio.grpc.GetRegisterLeasePRequest in project alluxio by Alluxio.

the class BlockMasterWorkerServiceHandlerTest method registerWorkerFailsOnDuplicateBlockLocation.

@Test
public void registerWorkerFailsOnDuplicateBlockLocation() throws Exception {
    long workerId = mBlockMaster.getWorkerId(NET_ADDRESS_1);
    // Prepare LocationBlockIdListEntry objects
    BlockStoreLocation loc = new BlockStoreLocation("MEM", 0);
    BlockStoreLocationProto locationProto = BlockStoreLocationProto.newBuilder().setTierAlias(loc.tierAlias()).setMediumType(loc.mediumType()).build();
    BlockIdList blockIdList1 = BlockIdList.newBuilder().addAllBlockId(ImmutableList.of(1L, 2L)).build();
    LocationBlockIdListEntry listEntry1 = LocationBlockIdListEntry.newBuilder().setKey(locationProto).setValue(blockIdList1).build();
    BlockIdList blockIdList2 = BlockIdList.newBuilder().addAllBlockId(ImmutableList.of(3L, 4L)).build();
    LocationBlockIdListEntry listEntry2 = LocationBlockIdListEntry.newBuilder().setKey(locationProto).setValue(blockIdList2).build();
    // Prepare a lease
    GetRegisterLeasePRequest leaseRequest = GetRegisterLeasePRequest.newBuilder().setWorkerId(workerId).setBlockCount(blockIdList1.getBlockIdCount() + blockIdList2.getBlockIdCount()).build();
    Optional<RegisterLease> lease = mBlockMaster.tryAcquireRegisterLease(leaseRequest);
    assertTrue(lease.isPresent());
    // The request is not deduplicated
    RegisterWorkerPRequest request = RegisterWorkerPRequest.newBuilder().setWorkerId(workerId).addStorageTiers("MEM").putTotalBytesOnTiers("MEM", 1000L).putUsedBytesOnTiers("MEM", 0L).setOptions(RegisterWorkerPOptions.getDefaultInstance()).addCurrentBlocks(listEntry1).addCurrentBlocks(listEntry2).build();
    // Noop response observer
    StreamObserver<RegisterWorkerPResponse> noopResponseObserver = new StreamObserver<RegisterWorkerPResponse>() {

        @Override
        public void onNext(RegisterWorkerPResponse response) {
        }

        @Override
        public void onError(Throwable t) {
        }

        @Override
        public void onCompleted() {
        }
    };
    assertThrows(AssertionError.class, () -> {
        mHandler.registerWorker(request, noopResponseObserver);
    });
    mBlockMaster.releaseRegisterLease(workerId);
}
Also used : StreamObserver(io.grpc.stub.StreamObserver) BlockIdList(alluxio.grpc.BlockIdList) RegisterLease(alluxio.wire.RegisterLease) RegisterWorkerPRequest(alluxio.grpc.RegisterWorkerPRequest) LocationBlockIdListEntry(alluxio.grpc.LocationBlockIdListEntry) GetRegisterLeasePRequest(alluxio.grpc.GetRegisterLeasePRequest) RegisterWorkerPResponse(alluxio.grpc.RegisterWorkerPResponse) BlockStoreLocation(alluxio.worker.block.BlockStoreLocation) BlockStoreLocationProto(alluxio.grpc.BlockStoreLocationProto) Test(org.junit.Test)

Aggregations

GetRegisterLeasePRequest (alluxio.grpc.GetRegisterLeasePRequest)6 Test (org.junit.Test)6 RegisterLease (alluxio.wire.RegisterLease)5 BlockIdList (alluxio.grpc.BlockIdList)2 BlockStoreLocationProto (alluxio.grpc.BlockStoreLocationProto)2 LocationBlockIdListEntry (alluxio.grpc.LocationBlockIdListEntry)2 RegisterWorkerPRequest (alluxio.grpc.RegisterWorkerPRequest)2 RegisterWorkerPResponse (alluxio.grpc.RegisterWorkerPResponse)2 BlockStoreLocation (alluxio.worker.block.BlockStoreLocation)2 StreamObserver (io.grpc.stub.StreamObserver)2 Gauge (com.codahale.metrics.Gauge)1 MetricRegistry (com.codahale.metrics.MetricRegistry)1 TreeMap (java.util.TreeMap)1 ConcurrentLinkedDeque (java.util.concurrent.ConcurrentLinkedDeque)1