use of org.apache.bookkeeper.stream.storage.api.sc.StorageContainer in project bookkeeper by apache.
the class TestRangeStoreImpl method testCreateNamespaceMockRootStorageContainerStore.
@Test
public void testCreateNamespaceMockRootStorageContainerStore() throws Exception {
String colName = "test-create-namespace-mock-root-storage-container-store";
StorageContainer scStore = mock(StorageContainer.class);
when(scStore.stop()).thenReturn(FutureUtils.value(null));
rangeStore.getRegistry().setStorageContainer(ROOT_STORAGE_CONTAINER_ID, scStore);
CreateNamespaceResponse createResp = CreateNamespaceResponse.newBuilder().setCode(StatusCode.NAMESPACE_EXISTS).build();
CreateNamespaceRequest request = createCreateNamespaceRequest(colName, namespaceConf);
when(scStore.createNamespace(request)).thenReturn(CompletableFuture.completedFuture(createResp));
CompletableFuture<CreateNamespaceResponse> createRespFuture = rangeStore.createNamespace(request);
verify(scStore, times(1)).createNamespace(request);
assertTrue(createResp == createRespFuture.get());
}
use of org.apache.bookkeeper.stream.storage.api.sc.StorageContainer in project bookkeeper by apache.
the class TestRangeStoreImpl method testDeleteNamespaceMockRootStorageContainerStore.
@Test
public void testDeleteNamespaceMockRootStorageContainerStore() throws Exception {
String colName = "test-delete-namespace-no-root-storage-container-store";
StorageContainer scStore = mock(StorageContainer.class);
when(scStore.stop()).thenReturn(FutureUtils.value(null));
rangeStore.getRegistry().setStorageContainer(ROOT_STORAGE_CONTAINER_ID, scStore);
DeleteNamespaceResponse deleteResp = DeleteNamespaceResponse.newBuilder().setCode(StatusCode.NAMESPACE_NOT_FOUND).build();
DeleteNamespaceRequest request = createDeleteNamespaceRequest(colName);
when(scStore.deleteNamespace(request)).thenReturn(CompletableFuture.completedFuture(deleteResp));
CompletableFuture<DeleteNamespaceResponse> deleteRespFuture = rangeStore.deleteNamespace(request);
verify(scStore, times(1)).deleteNamespace(request);
assertTrue(deleteResp == deleteRespFuture.get());
}
use of org.apache.bookkeeper.stream.storage.api.sc.StorageContainer in project bookkeeper by apache.
the class TestRangeStoreImpl method testRangeMockStorageContainer.
@Test
public void testRangeMockStorageContainer() throws Exception {
StorageContainer scStore = mock(StorageContainer.class);
when(scStore.stop()).thenReturn(FutureUtils.value(null));
rangeStore.getRegistry().setStorageContainer(ROOT_STORAGE_CONTAINER_ID, scStore);
StorageContainerResponse response = createRangeResponse(StatusCode.SUCCESS);
StorageContainerRequest request = createRangeRequest(ROOT_STORAGE_CONTAINER_ID);
when(scStore.range(request)).thenReturn(CompletableFuture.completedFuture(response));
CompletableFuture<StorageContainerResponse> future = rangeStore.range(request);
verify(scStore, times(1)).range(eq(request));
assertTrue(response == future.get());
}
use of org.apache.bookkeeper.stream.storage.api.sc.StorageContainer in project bookkeeper by apache.
the class TestDefaultStorageContainerFactory method testCreate.
@Test
public void testCreate() throws Exception {
OrderedScheduler scheduler = mock(OrderedScheduler.class);
OrderedScheduler snapshotScheduler = mock(OrderedScheduler.class);
MVCCStoreFactory storeFactory = mock(MVCCStoreFactory.class);
ListeningScheduledExecutorService snapshotExecutor = mock(ListeningScheduledExecutorService.class);
when(snapshotScheduler.chooseThread(anyLong())).thenReturn(snapshotExecutor);
Mockito.doReturn(mock(ListenableScheduledFuture.class)).when(snapshotExecutor).scheduleWithFixedDelay(any(Runnable.class), anyInt(), anyInt(), any(TimeUnit.class));
DefaultStorageContainerFactory factory = new DefaultStorageContainerFactory(new StorageConfiguration(new CompositeConfiguration()), (streamId, rangeId) -> streamId, scheduler, storeFactory, URI.create("distributedlog://127.0.0.1/stream/storage"));
StorageContainer sc = factory.createStorageContainer(1234L);
assertTrue(sc instanceof StorageContainerImpl);
assertEquals(1234L, sc.getId());
}
use of org.apache.bookkeeper.stream.storage.api.sc.StorageContainer in project bookkeeper by apache.
the class TestHelixStorageContainerManager method createRegistry.
private StorageContainerRegistryImpl createRegistry() {
return new StorageContainerRegistryImpl((scId) -> {
StorageContainer sc = mock(StorageContainer.class);
when(sc.getId()).thenReturn(scId);
when(sc.start()).thenReturn(FutureUtils.value(null));
when(sc.stop()).thenReturn(FutureUtils.value(null));
return sc;
}, scheduler);
}
Aggregations