Search in sources :

Example 1 with GetActiveRangesResponse

use of org.apache.bookkeeper.stream.proto.storage.GetActiveRangesResponse in project bookkeeper by apache.

the class TestProtocolInternalUtils method testCreateActiveRanges.

// 
// Test Meta KeyRange Server Requests
// 
@Test
public void testCreateActiveRanges() {
    GetActiveRangesResponse.Builder responseBuilder = GetActiveRangesResponse.newBuilder();
    responseBuilder.addRanges(RelatedRanges.newBuilder().setProps(RangeProperties.newBuilder().setStartHashKey(Long.MIN_VALUE).setEndHashKey(0L).setRangeId(1L).setStorageContainerId(1L)).setType(RelationType.PARENTS).addRelatedRanges(INVALID_RANGE_ID)).addRanges(RelatedRanges.newBuilder().setProps(RangeProperties.newBuilder().setStartHashKey(0L).setEndHashKey(Long.MAX_VALUE).setRangeId(2L).setStorageContainerId(2L)).setType(RelationType.PARENTS).addRelatedRanges(INVALID_RANGE_ID));
    GetActiveRangesResponse response = responseBuilder.build();
    HashStreamRanges hsr = createActiveRanges(response);
    TreeMap<Long, RangeProperties> activeRanges = Maps.newTreeMap();
    activeRanges.put(Long.MIN_VALUE, response.getRanges(0).getProps());
    activeRanges.put(0L, response.getRanges(1).getProps());
    HashStreamRanges expectedHSR = HashStreamRanges.ofHash(RangeKeyType.HASH, activeRanges);
    assertEquals(expectedHSR, hsr);
    assertEquals(2L, hsr.getMaxRangeId());
}
Also used : HashStreamRanges(org.apache.bookkeeper.clients.impl.internal.api.HashStreamRanges) RangeProperties(org.apache.bookkeeper.stream.proto.RangeProperties) GetActiveRangesResponse(org.apache.bookkeeper.stream.proto.storage.GetActiveRangesResponse) Test(org.junit.Test)

Example 2 with GetActiveRangesResponse

use of org.apache.bookkeeper.stream.proto.storage.GetActiveRangesResponse in project bookkeeper by apache.

the class MetaRangeStoreImplTest method testGetTwice.

@Test
public void testGetTwice() throws Exception {
    StorageContainerResponse resp = FutureUtils.result(this.mrStoreImpl.getActiveRanges(createRequest(streamProps)));
    assertEquals(StatusCode.SUCCESS, resp.getCode());
    GetActiveRangesResponse getResp = resp.getGetActiveRangesResp();
    verifyGetResponse(getResp);
    StorageContainerResponse secondResp = FutureUtils.result(this.mrStoreImpl.getActiveRanges(createRequest(streamProps)));
    assertEquals(StatusCode.SUCCESS, secondResp.getCode());
    GetActiveRangesResponse secondGetResp = resp.getGetActiveRangesResp();
    verifyGetResponse(secondGetResp);
}
Also used : GetActiveRangesResponse(org.apache.bookkeeper.stream.proto.storage.GetActiveRangesResponse) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse) Test(org.junit.Test)

Example 3 with GetActiveRangesResponse

use of org.apache.bookkeeper.stream.proto.storage.GetActiveRangesResponse in project bookkeeper by apache.

the class MetaRangeStoreImplTest method testCreateIfMissing.

@Test
public void testCreateIfMissing() throws Exception {
    StorageContainerResponse resp = FutureUtils.result(this.mrStoreImpl.getActiveRanges(createRequest(streamProps)));
    assertEquals(StatusCode.SUCCESS, resp.getCode());
    GetActiveRangesResponse getResp = resp.getGetActiveRangesResp();
    verifyGetResponse(getResp);
}
Also used : GetActiveRangesResponse(org.apache.bookkeeper.stream.proto.storage.GetActiveRangesResponse) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse) Test(org.junit.Test)

Example 4 with GetActiveRangesResponse

use of org.apache.bookkeeper.stream.proto.storage.GetActiveRangesResponse in project bookkeeper by apache.

the class TestMetaRangeClientImpl method testGetActiveStreamRanges.

@Test
public void testGetActiveStreamRanges() throws Exception {
    CompletableFuture<StorageServerChannel> serviceFuture = FutureUtils.createFuture();
    metaRangeClient.getStorageContainerClient().setStorageServerChannelFuture(serviceFuture);
    // create response
    GetActiveRangesResponse getActiveRangesResponse = GetActiveRangesResponse.newBuilder().addRanges(buildRelatedRange(Long.MIN_VALUE, 0L, 123L, 1L, Lists.newArrayList(113L))).addRanges(buildRelatedRange(0L, Long.MAX_VALUE, 124L, 2L, Lists.newArrayList(114L))).build();
    StorageContainerResponse response = StorageContainerResponse.newBuilder().setCode(StatusCode.SUCCESS).setGetActiveRangesResp(getActiveRangesResponse).build();
    MetaRangeServiceImplBase metaRangeService = new MetaRangeServiceImplBase() {

        @Override
        public void getActiveRanges(StorageContainerRequest request, StreamObserver<StorageContainerResponse> responseObserver) {
            responseObserver.onNext(response);
            responseObserver.onCompleted();
        }
    };
    serviceRegistry.addService(metaRangeService.bindService());
    StorageServerChannel rsChannel = new StorageServerChannel(InProcessChannelBuilder.forName(serverName).directExecutor().build(), Optional.empty());
    serviceFuture.complete(rsChannel);
    HashStreamRanges expectedStream = createActiveRanges(response.getGetActiveRangesResp());
    CompletableFuture<HashStreamRanges> getFuture = metaRangeClient.getActiveDataRanges();
    assertEquals(expectedStream, getFuture.get());
}
Also used : StreamObserver(io.grpc.stub.StreamObserver) HashStreamRanges(org.apache.bookkeeper.clients.impl.internal.api.HashStreamRanges) StorageContainerRequest(org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest) GetActiveRangesResponse(org.apache.bookkeeper.stream.proto.storage.GetActiveRangesResponse) StorageServerChannel(org.apache.bookkeeper.clients.impl.channel.StorageServerChannel) MetaRangeServiceImplBase(org.apache.bookkeeper.stream.proto.storage.MetaRangeServiceGrpc.MetaRangeServiceImplBase) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse) Test(org.junit.Test)

Aggregations

GetActiveRangesResponse (org.apache.bookkeeper.stream.proto.storage.GetActiveRangesResponse)4 Test (org.junit.Test)4 StorageContainerResponse (org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse)3 HashStreamRanges (org.apache.bookkeeper.clients.impl.internal.api.HashStreamRanges)2 StreamObserver (io.grpc.stub.StreamObserver)1 StorageServerChannel (org.apache.bookkeeper.clients.impl.channel.StorageServerChannel)1 RangeProperties (org.apache.bookkeeper.stream.proto.RangeProperties)1 MetaRangeServiceImplBase (org.apache.bookkeeper.stream.proto.storage.MetaRangeServiceGrpc.MetaRangeServiceImplBase)1 StorageContainerRequest (org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest)1