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;
}
}
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());
}
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());
}
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());
}
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);
}
}
Aggregations