Search in sources :

Example 11 with CreateNamespaceResponse

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

the class TestRootRangeStoreImpl method testDeleteStreamSuccess.

@Test
public void testDeleteStreamSuccess() throws Exception {
    String nsName = name.getMethodName();
    String streamName = name.getMethodName();
    CreateNamespaceResponse createResp = createNamespaceAndVerify(nsName, 0L);
    createStreamAndVerify(nsName, streamName, MIN_DATA_STREAM_ID);
    verifyStreamExists(createResp.getColProps().getNamespaceId(), streamName, MIN_DATA_STREAM_ID);
    verifyStreamId(MIN_DATA_STREAM_ID);
    CompletableFuture<DeleteStreamResponse> deleteFuture = rootRangeStore.deleteStream(createDeleteStreamRequest(nsName, streamName));
    DeleteStreamResponse deleteResp = FutureUtils.result(deleteFuture);
    assertEquals(StatusCode.SUCCESS, deleteResp.getCode());
    verifyStreamNotExists(createResp.getColProps().getNamespaceId(), streamName, MIN_DATA_STREAM_ID);
    verifyStreamId(MIN_DATA_STREAM_ID);
}
Also used : DeleteStreamResponse(org.apache.bookkeeper.stream.proto.storage.DeleteStreamResponse) CreateNamespaceResponse(org.apache.bookkeeper.stream.proto.storage.CreateNamespaceResponse) Test(org.junit.Test)

Example 12 with CreateNamespaceResponse

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

the class TestRootRangeStoreImpl method testDeleteNamespaceSuccess.

@Test
public void testDeleteNamespaceSuccess() throws Exception {
    String nsName = name.getMethodName();
    CreateNamespaceResponse createResp = createNamespaceAndVerify(nsName, 0L);
    verifyNamespaceExists(nsName, createResp.getColProps().getNamespaceId());
    verifyNamespaceId(0L);
    deleteNamespaceAndVerify(nsName);
    verifyNamespaceNotExists(nsName, createResp.getColProps().getNamespaceId());
    verifyNamespaceId(0L);
}
Also used : CreateNamespaceResponse(org.apache.bookkeeper.stream.proto.storage.CreateNamespaceResponse) Test(org.junit.Test)

Example 13 with CreateNamespaceResponse

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

the class TestRootRangeStoreImpl method testCreateStreamExists.

@Test
public void testCreateStreamExists() throws Exception {
    String nsName = name.getMethodName();
    String streamName = name.getMethodName();
    CreateNamespaceResponse createResp = createNamespaceAndVerify(nsName, 0L);
    createStreamAndVerify(nsName, streamName, MIN_DATA_STREAM_ID);
    verifyStreamExists(createResp.getColProps().getNamespaceId(), streamName, MIN_DATA_STREAM_ID);
    verifyStreamId(MIN_DATA_STREAM_ID);
    // create the namespace with same name will fail
    CreateStreamResponse response2 = FutureUtils.result(rootRangeStore.createStream(createCreateStreamRequest(nsName, streamName, streamConf)));
    // TODO: change it later
    assertEquals(StatusCode.INTERNAL_SERVER_ERROR, response2.getCode());
    verifyStreamId(MIN_DATA_STREAM_ID);
}
Also used : CreateStreamResponse(org.apache.bookkeeper.stream.proto.storage.CreateStreamResponse) CreateNamespaceResponse(org.apache.bookkeeper.stream.proto.storage.CreateNamespaceResponse) Test(org.junit.Test)

Example 14 with CreateNamespaceResponse

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

the class StorageContainerImplTest method testCreateNamespace.

// 
// Root Range Methods
// 
@Test
public void testCreateNamespace() throws Exception {
    mockStorageContainer(SCID);
    CreateNamespaceResponse expectedResp = CreateNamespaceResponse.getDefaultInstance();
    when(rrStore.createNamespace(any(CreateNamespaceRequest.class))).thenReturn(FutureUtils.value(expectedResp));
    CreateNamespaceRequest expectedReq = CreateNamespaceRequest.getDefaultInstance();
    assertSame(expectedResp, FutureUtils.result(rrStore.createNamespace(expectedReq)));
    verify(rrStore, times(1)).createNamespace(same(expectedReq));
}
Also used : CreateNamespaceResponse(org.apache.bookkeeper.stream.proto.storage.CreateNamespaceResponse) CreateNamespaceRequest(org.apache.bookkeeper.stream.proto.storage.CreateNamespaceRequest) Test(org.junit.Test)

Aggregations

CreateNamespaceResponse (org.apache.bookkeeper.stream.proto.storage.CreateNamespaceResponse)14 Test (org.junit.Test)12 CreateNamespaceRequest (org.apache.bookkeeper.stream.proto.storage.CreateNamespaceRequest)5 ProtoUtils.createCreateNamespaceRequest (org.apache.bookkeeper.stream.protocol.util.ProtoUtils.createCreateNamespaceRequest)3 StreamObserver (io.grpc.stub.StreamObserver)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 CreateStreamResponse (org.apache.bookkeeper.stream.proto.storage.CreateStreamResponse)2 DeleteStreamResponse (org.apache.bookkeeper.stream.proto.storage.DeleteStreamResponse)2 UTF_8 (com.google.common.base.Charsets.UTF_8)1 ByteString (com.google.protobuf.ByteString)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 URI (java.net.URI)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 Slf4j (lombok.extern.slf4j.Slf4j)1 CompareResult (org.apache.bookkeeper.api.kv.op.CompareResult)1 RangeOp (org.apache.bookkeeper.api.kv.op.RangeOp)1 TxnOp (org.apache.bookkeeper.api.kv.op.TxnOp)1 Options (org.apache.bookkeeper.api.kv.options.Options)1