Search in sources :

Example 1 with StorageContainer

use of org.apache.bookkeeper.stream.storage.api.sc.StorageContainer in project bookkeeper by apache.

the class TestRangeStoreImpl method testPutMockStorageContainer.

@Test
public void testPutMockStorageContainer() throws Exception {
    StorageContainer scStore = mock(StorageContainer.class);
    when(scStore.stop()).thenReturn(FutureUtils.value(null));
    rangeStore.getRegistry().setStorageContainer(ROOT_STORAGE_CONTAINER_ID, scStore);
    StorageContainerResponse response = createPutResponse(StatusCode.SUCCESS);
    StorageContainerRequest request = createPutRequest(ROOT_STORAGE_CONTAINER_ID);
    when(scStore.put(request)).thenReturn(CompletableFuture.completedFuture(response));
    CompletableFuture<StorageContainerResponse> future = rangeStore.put(request);
    verify(scStore, times(1)).put(eq(request));
    assertTrue(response == future.get());
}
Also used : StorageContainerRequest(org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest) StorageContainer(org.apache.bookkeeper.stream.storage.api.sc.StorageContainer) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse) Test(org.junit.Test)

Example 2 with StorageContainer

use of org.apache.bookkeeper.stream.storage.api.sc.StorageContainer in project bookkeeper by apache.

the class TestRangeStoreImpl method testGetStreamMockRootStorageContainerStore.

@Test
public void testGetStreamMockRootStorageContainerStore() throws Exception {
    String colName = "test-get-namespace-no-root-storage-container-store";
    String streamName = colName;
    StorageContainer scStore = mock(StorageContainer.class);
    when(scStore.stop()).thenReturn(FutureUtils.value(null));
    rangeStore.getRegistry().setStorageContainer(ROOT_STORAGE_CONTAINER_ID, scStore);
    GetStreamResponse getResp = GetStreamResponse.newBuilder().setCode(StatusCode.STREAM_NOT_FOUND).build();
    GetStreamRequest getReq = createGetStreamRequest(colName, streamName);
    when(scStore.getStream(getReq)).thenReturn(CompletableFuture.completedFuture(getResp));
    CompletableFuture<GetStreamResponse> getRespFuture = rangeStore.getStream(getReq);
    verify(scStore, times(1)).getStream(getReq);
    assertTrue(getResp == getRespFuture.get());
}
Also used : ByteString(com.google.protobuf.ByteString) GetStreamResponse(org.apache.bookkeeper.stream.proto.storage.GetStreamResponse) ProtoUtils.createGetStreamRequest(org.apache.bookkeeper.stream.protocol.util.ProtoUtils.createGetStreamRequest) GetStreamRequest(org.apache.bookkeeper.stream.proto.storage.GetStreamRequest) StorageContainer(org.apache.bookkeeper.stream.storage.api.sc.StorageContainer) Test(org.junit.Test)

Example 3 with StorageContainer

use of org.apache.bookkeeper.stream.storage.api.sc.StorageContainer in project bookkeeper by apache.

the class TestRangeStoreImpl method testDeleteMockStorageContainer.

@Test
public void testDeleteMockStorageContainer() throws Exception {
    StorageContainer scStore = mock(StorageContainer.class);
    when(scStore.stop()).thenReturn(FutureUtils.value(null));
    rangeStore.getRegistry().setStorageContainer(ROOT_STORAGE_CONTAINER_ID, scStore);
    StorageContainerResponse response = createDeleteResponse(StatusCode.SUCCESS);
    StorageContainerRequest request = createDeleteRequest(ROOT_STORAGE_CONTAINER_ID);
    when(scStore.delete(request)).thenReturn(CompletableFuture.completedFuture(response));
    CompletableFuture<StorageContainerResponse> future = rangeStore.delete(request);
    verify(scStore, times(1)).delete(eq(request));
    assertTrue(response == future.get());
}
Also used : StorageContainerRequest(org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest) StorageContainer(org.apache.bookkeeper.stream.storage.api.sc.StorageContainer) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse) Test(org.junit.Test)

Example 4 with StorageContainer

use of org.apache.bookkeeper.stream.storage.api.sc.StorageContainer in project bookkeeper by apache.

the class TestRangeStoreImpl method testGetNamespaceMockRootStorageContainerStore.

@Test
public void testGetNamespaceMockRootStorageContainerStore() throws Exception {
    String colName = "test-get-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);
    GetNamespaceResponse getResp = GetNamespaceResponse.newBuilder().setCode(StatusCode.NAMESPACE_NOT_FOUND).build();
    GetNamespaceRequest request = createGetNamespaceRequest(colName);
    when(scStore.getNamespace(request)).thenReturn(CompletableFuture.completedFuture(getResp));
    CompletableFuture<GetNamespaceResponse> getRespFuture = rangeStore.getNamespace(request);
    verify(scStore, times(1)).getNamespace(request);
    assertTrue(getResp == getRespFuture.get());
}
Also used : GetNamespaceResponse(org.apache.bookkeeper.stream.proto.storage.GetNamespaceResponse) ByteString(com.google.protobuf.ByteString) ProtoUtils.createGetNamespaceRequest(org.apache.bookkeeper.stream.protocol.util.ProtoUtils.createGetNamespaceRequest) GetNamespaceRequest(org.apache.bookkeeper.stream.proto.storage.GetNamespaceRequest) StorageContainer(org.apache.bookkeeper.stream.storage.api.sc.StorageContainer) Test(org.junit.Test)

Example 5 with StorageContainer

use of org.apache.bookkeeper.stream.storage.api.sc.StorageContainer in project bookkeeper by apache.

the class TestRangeStoreImpl method testGetActiveRangesMockManager.

@Test
public void testGetActiveRangesMockManager() throws Exception {
    long scId = System.currentTimeMillis();
    StreamProperties props = StreamProperties.newBuilder(streamProps).setStorageContainerId(scId).build();
    StorageContainer scStore = mock(StorageContainer.class);
    when(scStore.stop()).thenReturn(FutureUtils.value(null));
    rangeStore.getRegistry().setStorageContainer(scId, scStore);
    StorageContainerResponse resp = StorageContainerResponse.newBuilder().setCode(StatusCode.STREAM_NOT_FOUND).build();
    StorageContainerRequest request = createGetActiveRangesRequest(scId, 34L);
    when(scStore.getActiveRanges(request)).thenReturn(CompletableFuture.completedFuture(resp));
    CompletableFuture<StorageContainerResponse> future = rangeStore.getActiveRanges(request);
    verify(scStore, times(1)).getActiveRanges(request);
    assertTrue(resp == future.get());
}
Also used : StorageContainerRequest(org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest) StreamProperties(org.apache.bookkeeper.stream.proto.StreamProperties) StorageContainer(org.apache.bookkeeper.stream.storage.api.sc.StorageContainer) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse) Test(org.junit.Test)

Aggregations

StorageContainer (org.apache.bookkeeper.stream.storage.api.sc.StorageContainer)16 Test (org.junit.Test)12 ByteString (com.google.protobuf.ByteString)6 StorageContainerRequest (org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest)4 StorageContainerResponse (org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse)4 ObjectClosedException (org.apache.bookkeeper.common.exceptions.ObjectClosedException)3 OrderedScheduler (org.apache.bookkeeper.common.util.OrderedScheduler)2 StorageException (org.apache.bookkeeper.stream.storage.exceptions.StorageException)2 ListenableScheduledFuture (com.google.common.util.concurrent.ListenableScheduledFuture)1 ListeningScheduledExecutorService (com.google.common.util.concurrent.ListeningScheduledExecutorService)1 TimeUnit (java.util.concurrent.TimeUnit)1 FutureUtils (org.apache.bookkeeper.common.concurrent.FutureUtils)1 StreamProperties (org.apache.bookkeeper.stream.proto.StreamProperties)1 CreateNamespaceRequest (org.apache.bookkeeper.stream.proto.storage.CreateNamespaceRequest)1 CreateNamespaceResponse (org.apache.bookkeeper.stream.proto.storage.CreateNamespaceResponse)1 CreateStreamRequest (org.apache.bookkeeper.stream.proto.storage.CreateStreamRequest)1 CreateStreamResponse (org.apache.bookkeeper.stream.proto.storage.CreateStreamResponse)1 DeleteNamespaceRequest (org.apache.bookkeeper.stream.proto.storage.DeleteNamespaceRequest)1 DeleteNamespaceResponse (org.apache.bookkeeper.stream.proto.storage.DeleteNamespaceResponse)1 DeleteStreamRequest (org.apache.bookkeeper.stream.proto.storage.DeleteStreamRequest)1