Search in sources :

Example 6 with StorageContainerResponse

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

the class TableStoreImplTest method deleteRange.

List<KeyValue> deleteRange(int startKey, int endKey) throws Exception {
    StorageContainerResponse response = result(tableStore.delete(StorageContainerRequest.newBuilder().setScId(SC_ID).setKvDeleteReq(DeleteRangeRequest.newBuilder().setHeader(HEADER).setKey(getKey(startKey)).setRangeEnd(getKey(endKey)).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());
    return delResp.getPrevKvsList();
}
Also used : DeleteRangeResponse(org.apache.bookkeeper.stream.proto.kv.rpc.DeleteRangeResponse) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse)

Example 7 with StorageContainerResponse

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

the class TableStoreImplTest method range.

List<KeyValue> range(int startKey, int endKey) throws Exception {
    StorageContainerResponse response = result(tableStore.range(StorageContainerRequest.newBuilder().setScId(SC_ID).setKvRangeReq(RangeRequest.newBuilder().setHeader(HEADER).setKey(getKey(startKey)).setRangeEnd(getKey(endKey)).build()).build()));
    assertEquals(StatusCode.SUCCESS, response.getCode());
    assertEquals(ResponseCase.KV_RANGE_RESP, response.getResponseCase());
    RangeResponse rangeResp = response.getKvRangeResp();
    assertEquals(HEADER, rangeResp.getHeader().getRoutingHeader());
    return rangeResp.getKvsList();
}
Also used : DeleteRangeResponse(org.apache.bookkeeper.stream.proto.kv.rpc.DeleteRangeResponse) RangeResponse(org.apache.bookkeeper.stream.proto.kv.rpc.RangeResponse) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse)

Example 8 with StorageContainerResponse

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

the class MetaRangeStoreImplTest method testGetTwice.

@Test
public void testGetTwice() throws Exception {
    StorageContainerResponse resp = FutureUtils.result(this.mrStoreImpl.getActiveRanges(createRequest(streamProps)));
    assertEquals(StatusCode.SUCCESS, resp.getCode());
    GetActiveRangesResponse getResp = resp.getGetActiveRangesResp();
    verifyGetResponse(getResp);
    StorageContainerResponse secondResp = FutureUtils.result(this.mrStoreImpl.getActiveRanges(createRequest(streamProps)));
    assertEquals(StatusCode.SUCCESS, secondResp.getCode());
    GetActiveRangesResponse secondGetResp = resp.getGetActiveRangesResp();
    verifyGetResponse(secondGetResp);
}
Also used : GetActiveRangesResponse(org.apache.bookkeeper.stream.proto.storage.GetActiveRangesResponse) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse) Test(org.junit.Test)

Example 9 with StorageContainerResponse

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

the class MetaRangeStoreImplTest method testCreateIfMissing.

@Test
public void testCreateIfMissing() throws Exception {
    StorageContainerResponse resp = FutureUtils.result(this.mrStoreImpl.getActiveRanges(createRequest(streamProps)));
    assertEquals(StatusCode.SUCCESS, resp.getCode());
    GetActiveRangesResponse getResp = resp.getGetActiveRangesResp();
    verifyGetResponse(getResp);
}
Also used : GetActiveRangesResponse(org.apache.bookkeeper.stream.proto.storage.GetActiveRangesResponse) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse) Test(org.junit.Test)

Example 10 with StorageContainerResponse

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

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