Search in sources :

Example 1 with StorageContainerRequest

use of org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest 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 StorageContainerRequest

use of org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest 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 3 with StorageContainerRequest

use of org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest 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)

Example 4 with StorageContainerRequest

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

the class StorageContainerImplTest method testGetActiveRanges.

// 
// Meta Range Methods
// 
@Test
public void testGetActiveRanges() throws Exception {
    mockStorageContainer(SCID);
    StorageContainerResponse expectedResp = StorageContainerResponse.getDefaultInstance();
    when(mrStore.getActiveRanges(any(StorageContainerRequest.class))).thenReturn(FutureUtils.value(expectedResp));
    StorageContainerRequest expectedReq = StorageContainerRequest.getDefaultInstance();
    assertSame(expectedResp, FutureUtils.result(mrStore.getActiveRanges(expectedReq)));
    verify(mrStore, times(1)).getActiveRanges(same(expectedReq));
}
Also used : StorageContainerRequest(org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse) Test(org.junit.Test)

Example 5 with StorageContainerRequest

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

the class StorageContainerImplTest method testTxnWhenTableStoreNotCached.

@Test
public void testTxnWhenTableStoreNotCached() throws Exception {
    mockStorageContainer(SCID);
    StorageContainerResponse expectedResp = StorageContainerResponse.getDefaultInstance();
    when(trStore.txn(any(StorageContainerRequest.class))).thenReturn(FutureUtils.value(expectedResp));
    StorageContainerRequest request = newStorageContainerRequest(KV_TXN_REQ);
    StorageContainerResponse response = FutureUtils.result(container.txn(request));
    assertSame(expectedResp, response);
    assertSame(trStore, container.getTableStoreCache().getTableStore(RID));
}
Also used : StorageContainerRequest(org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse) Test(org.junit.Test)

Aggregations

StorageContainerRequest (org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest)33 Test (org.junit.Test)31 StorageContainerResponse (org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse)27 TestResponseObserver (org.apache.bookkeeper.stream.server.TestResponseObserver)12 RangeStore (org.apache.bookkeeper.stream.storage.api.RangeStore)9 StatusRuntimeException (io.grpc.StatusRuntimeException)5 ByteBuf (io.netty.buffer.ByteBuf)4 StorageContainer (org.apache.bookkeeper.stream.storage.api.sc.StorageContainer)4 StreamObserver (io.grpc.stub.StreamObserver)3 StorageServerChannel (org.apache.bookkeeper.clients.impl.channel.StorageServerChannel)3 RangeStoreImpl (org.apache.bookkeeper.stream.storage.impl.RangeStoreImpl)3 HashStreamRanges (org.apache.bookkeeper.clients.impl.internal.api.HashStreamRanges)2 DeleteRangeRequest (org.apache.bookkeeper.stream.proto.kv.rpc.DeleteRangeRequest)2 MetaRangeServiceImplBase (org.apache.bookkeeper.stream.proto.storage.MetaRangeServiceGrpc.MetaRangeServiceImplBase)2 ExecutionException (java.util.concurrent.ExecutionException)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Cleanup (lombok.Cleanup)1 StorageContainerChannel (org.apache.bookkeeper.clients.impl.container.StorageContainerChannel)1 KvUtils.newIncrementRequest (org.apache.bookkeeper.clients.impl.kv.KvUtils.newIncrementRequest)1