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());
}
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);
}
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);
}
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());
}
Aggregations