Search in sources :

Example 1 with StorageContainerResponse

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

the class MetaRangeRequestProcessor method sendRPC.

@Override
protected ListenableFuture<StorageContainerResponse> sendRPC(StorageServerChannel rsChannel, StorageContainerRequest request) {
    switch(request.getRequestCase()) {
        case GET_ACTIVE_RANGES_REQ:
            return rsChannel.getMetaRangeService().getActiveRanges(request);
        default:
            SettableFuture<StorageContainerResponse> respFuture = SettableFuture.create();
            respFuture.setException(new Exception("Unknown request " + request));
            return respFuture;
    }
}
Also used : ProtocolInternalUtils.createMetaRangeException(org.apache.bookkeeper.clients.impl.internal.ProtocolInternalUtils.createMetaRangeException) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse)

Example 2 with StorageContainerResponse

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

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

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

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

the class TableStoreImplTest method deleteKeyFromTableStore.

KeyValue deleteKeyFromTableStore(int key) throws Exception {
    StorageContainerResponse response = result(tableStore.delete(StorageContainerRequest.newBuilder().setScId(SC_ID).setKvDeleteReq(DeleteRangeRequest.newBuilder().setHeader(HEADER).setKey(getKey(key)).setPrevKv(true).build()).build()));
    assertEquals(StatusCode.SUCCESS, response.getCode());
    assertEquals(ResponseCase.KV_DELETE_RESP, response.getResponseCase());
    DeleteRangeResponse delResp = response.getKvDeleteResp();
    assertEquals(HEADER, delResp.getHeader().getRoutingHeader());
    if (0 == delResp.getPrevKvsCount()) {
        return null;
    } else {
        return delResp.getPrevKvs(0);
    }
}
Also used : DeleteRangeResponse(org.apache.bookkeeper.stream.proto.kv.rpc.DeleteRangeResponse) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse)

Aggregations

StorageContainerResponse (org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse)42 Test (org.junit.Test)33 StorageContainerRequest (org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest)27 TestResponseObserver (org.apache.bookkeeper.stream.server.TestResponseObserver)12 RangeStore (org.apache.bookkeeper.stream.storage.api.RangeStore)9 StatusRuntimeException (io.grpc.StatusRuntimeException)6 DeleteRangeResponse (org.apache.bookkeeper.stream.proto.kv.rpc.DeleteRangeResponse)5 StorageContainer (org.apache.bookkeeper.stream.storage.api.sc.StorageContainer)4 StreamObserver (io.grpc.stub.StreamObserver)3 RangeResponse (org.apache.bookkeeper.stream.proto.kv.rpc.RangeResponse)3 GetActiveRangesResponse (org.apache.bookkeeper.stream.proto.storage.GetActiveRangesResponse)3 RangeStoreImpl (org.apache.bookkeeper.stream.storage.impl.RangeStoreImpl)3 StatusException (io.grpc.StatusException)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 StorageServerChannel (org.apache.bookkeeper.clients.impl.channel.StorageServerChannel)2 PutResponse (org.apache.bookkeeper.stream.proto.kv.rpc.PutResponse)2 Status (io.grpc.Status)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 Cleanup (lombok.Cleanup)1