use of org.apache.bookkeeper.stream.storage.impl.RangeStoreImpl in project bookkeeper by apache.
the class TestRangeStoreBuilder method testBuild.
@Test
public void testBuild() {
RangeStore rangeStore = RangeStoreBuilder.newBuilder().withStorageConfiguration(mock(StorageConfiguration.class)).withStorageContainerManagerFactory(mock(StorageContainerManagerFactory.class)).withStorageResources(StorageResources.create()).withRangeStoreFactory(storeFactory).withDefaultBackendUri(uri).build();
assertTrue(rangeStore instanceof RangeStoreImpl);
}
use of org.apache.bookkeeper.stream.storage.impl.RangeStoreImpl in project bookkeeper by apache.
the class TestGrpcRootRangeService method testCreateStreamFailure.
@Test
public void testCreateStreamFailure() throws Exception {
RangeStoreImpl rangeService = mock(RangeStoreImpl.class);
GrpcRootRangeService grpcService = new GrpcRootRangeService(rangeService);
CreateStreamResponse createResp = CreateStreamResponse.newBuilder().setCode(StatusCode.INTERNAL_SERVER_ERROR).build();
CreateStreamRequest createReq = createCreateStreamRequest(nsName, streamName, DEFAULT_STREAM_CONF);
when(rangeService.createStream(createReq)).thenReturn(FutureUtils.exception(CAUSE));
AtomicReference<CreateStreamResponse> resultHolder = new AtomicReference<>();
AtomicReference<Throwable> exceptionHolder = new AtomicReference<>();
CountDownLatch latch = new CountDownLatch(1);
StreamObserver<CreateStreamResponse> streamObserver = new StreamObserver<CreateStreamResponse>() {
@Override
public void onNext(CreateStreamResponse resp) {
resultHolder.set(resp);
}
@Override
public void onError(Throwable t) {
exceptionHolder.set(t);
latch.countDown();
}
@Override
public void onCompleted() {
latch.countDown();
}
};
grpcService.createStream(CreateStreamRequest.newBuilder().setColName(nsName).setName(streamName).setStreamConf(DEFAULT_STREAM_CONF).build(), streamObserver);
latch.await();
assertNull(exceptionHolder.get());
assertNotNull(resultHolder.get());
assertEquals(createResp, resultHolder.get());
verify(rangeService, times(1)).createStream(createReq);
}
use of org.apache.bookkeeper.stream.storage.impl.RangeStoreImpl in project bookkeeper by apache.
the class TestGrpcRootRangeService method testDeleteNamespaceSuccess.
@Test
public void testDeleteNamespaceSuccess() throws Exception {
RangeStoreImpl rangeService = mock(RangeStoreImpl.class);
GrpcRootRangeService grpcService = new GrpcRootRangeService(rangeService);
DeleteNamespaceResponse deleteResp = DeleteNamespaceResponse.newBuilder().setCode(StatusCode.SUCCESS).build();
DeleteNamespaceRequest deleteReq = createDeleteNamespaceRequest(nsName);
when(rangeService.deleteNamespace(deleteReq)).thenReturn(CompletableFuture.completedFuture(deleteResp));
AtomicReference<DeleteNamespaceResponse> resultHolder = new AtomicReference<>();
AtomicReference<Throwable> exceptionHolder = new AtomicReference<>();
CountDownLatch latch = new CountDownLatch(1);
StreamObserver<DeleteNamespaceResponse> streamObserver = new StreamObserver<DeleteNamespaceResponse>() {
@Override
public void onNext(DeleteNamespaceResponse resp) {
resultHolder.set(resp);
}
@Override
public void onError(Throwable t) {
exceptionHolder.set(t);
latch.countDown();
}
@Override
public void onCompleted() {
latch.countDown();
}
};
grpcService.deleteNamespace(DeleteNamespaceRequest.newBuilder().setName(nsName).build(), streamObserver);
latch.await();
assertNull(exceptionHolder.get());
assertNotNull(resultHolder.get());
assertTrue(deleteResp == resultHolder.get());
verify(rangeService, times(1)).deleteNamespace(deleteReq);
}
use of org.apache.bookkeeper.stream.storage.impl.RangeStoreImpl in project bookkeeper by apache.
the class TestGrpcRootRangeService method testGetNamespaceSuccess.
@Test
public void testGetNamespaceSuccess() throws Exception {
RangeStoreImpl rangeService = mock(RangeStoreImpl.class);
GrpcRootRangeService grpcService = new GrpcRootRangeService(rangeService);
GetNamespaceResponse getResp = GetNamespaceResponse.newBuilder().setCode(StatusCode.SUCCESS).setColProps(namespaceProps).build();
GetNamespaceRequest getReq = createGetNamespaceRequest(nsName);
when(rangeService.getNamespace(getReq)).thenReturn(CompletableFuture.completedFuture(getResp));
AtomicReference<GetNamespaceResponse> resultHolder = new AtomicReference<>();
AtomicReference<Throwable> exceptionHolder = new AtomicReference<>();
CountDownLatch latch = new CountDownLatch(1);
StreamObserver<GetNamespaceResponse> streamObserver = new StreamObserver<GetNamespaceResponse>() {
@Override
public void onNext(GetNamespaceResponse resp) {
resultHolder.set(resp);
}
@Override
public void onError(Throwable t) {
exceptionHolder.set(t);
latch.countDown();
}
@Override
public void onCompleted() {
latch.countDown();
}
};
grpcService.getNamespace(GetNamespaceRequest.newBuilder().setName(nsName).build(), streamObserver);
latch.await();
assertNull(exceptionHolder.get());
assertNotNull(resultHolder.get());
assertTrue(getResp == resultHolder.get());
verify(rangeService, times(1)).getNamespace(getReq);
}
use of org.apache.bookkeeper.stream.storage.impl.RangeStoreImpl in project bookkeeper by apache.
the class TestGrpcRootRangeService method testDeleteStreamFailure.
@Test
public void testDeleteStreamFailure() throws Exception {
RangeStoreImpl rangeService = mock(RangeStoreImpl.class);
GrpcRootRangeService grpcService = new GrpcRootRangeService(rangeService);
DeleteStreamResponse deleteResp = DeleteStreamResponse.newBuilder().setCode(StatusCode.INTERNAL_SERVER_ERROR).build();
DeleteStreamRequest deleteReq = createDeleteStreamRequest(nsName, streamName);
when(rangeService.deleteStream(deleteReq)).thenReturn(FutureUtils.exception(CAUSE));
AtomicReference<DeleteStreamResponse> resultHolder = new AtomicReference<>();
AtomicReference<Throwable> exceptionHolder = new AtomicReference<>();
CountDownLatch latch = new CountDownLatch(1);
StreamObserver<DeleteStreamResponse> streamObserver = new StreamObserver<DeleteStreamResponse>() {
@Override
public void onNext(DeleteStreamResponse resp) {
resultHolder.set(resp);
}
@Override
public void onError(Throwable t) {
exceptionHolder.set(t);
latch.countDown();
}
@Override
public void onCompleted() {
latch.countDown();
}
};
grpcService.deleteStream(DeleteStreamRequest.newBuilder().setColName(nsName).setName(streamName).build(), streamObserver);
latch.await();
assertNull(exceptionHolder.get());
assertNotNull(resultHolder.get());
assertEquals(deleteResp, resultHolder.get());
verify(rangeService, times(1)).deleteStream(deleteReq);
}
Aggregations