Search in sources :

Example 1 with StatusCode

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

the class RootRangeClientImpl method processCreateNamespaceResponse.

private void processCreateNamespaceResponse(String namespace, CreateNamespaceResponse response, CompletableFuture<NamespaceProperties> createNamespaceFuture) {
    StatusCode code = response.getCode();
    if (StatusCode.SUCCESS == code) {
        createNamespaceFuture.complete(response.getColProps());
        return;
    }
    createNamespaceFuture.completeExceptionally(createRootRangeException(namespace, code));
}
Also used : StatusCode(org.apache.bookkeeper.stream.proto.storage.StatusCode)

Example 2 with StatusCode

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

the class RootRangeClientImpl method processGetNamespaceResponse.

private void processGetNamespaceResponse(String namespace, GetNamespaceResponse response, CompletableFuture<NamespaceProperties> getFuture) {
    StatusCode code = response.getCode();
    if (StatusCode.SUCCESS == code) {
        getFuture.complete(response.getColProps());
        return;
    }
    getFuture.completeExceptionally(createRootRangeException(namespace, code));
}
Also used : StatusCode(org.apache.bookkeeper.stream.proto.storage.StatusCode)

Example 3 with StatusCode

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

the class RootRangeClientImpl method processCreateStreamResponse.

private void processCreateStreamResponse(String streamName, CreateStreamResponse response, CompletableFuture<StreamProperties> createStreamFuture) {
    StatusCode code = response.getCode();
    if (StatusCode.SUCCESS == code) {
        createStreamFuture.complete(response.getStreamProps());
        return;
    }
    createStreamFuture.completeExceptionally(createRootRangeException(streamName, code));
}
Also used : StatusCode(org.apache.bookkeeper.stream.proto.storage.StatusCode)

Example 4 with StatusCode

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

the class TableStoreUtilsTest method testHandleCause.

@Test
public void testHandleCause() {
    StatusCode[] protoCodes = new StatusCode[] { StatusCode.SUCCESS, StatusCode.INTERNAL_SERVER_ERROR, StatusCode.BAD_REQUEST, StatusCode.BAD_REQUEST, StatusCode.UNEXPECTED, StatusCode.BAD_REVISION, StatusCode.BAD_REVISION, StatusCode.KEY_NOT_FOUND, StatusCode.KEY_EXISTS };
    Code[] codes = new Code[] { Code.OK, Code.INTERNAL_ERROR, Code.INVALID_ARGUMENT, Code.ILLEGAL_OP, Code.UNEXPECTED, Code.BAD_REVISION, Code.SMALLER_REVISION, Code.KEY_NOT_FOUND, Code.KEY_EXISTS };
    for (int i = 0; i < codes.length; i++) {
        Code code = codes[i];
        MVCCStoreException exception = new MVCCStoreException(code, "test-" + code);
        assertEquals(protoCodes[i], handleCause(exception));
    }
}
Also used : MVCCStoreException(org.apache.bookkeeper.statelib.api.exceptions.MVCCStoreException) StatusCode(org.apache.bookkeeper.stream.proto.storage.StatusCode) Code(org.apache.bookkeeper.api.kv.result.Code) StatusCode(org.apache.bookkeeper.stream.proto.storage.StatusCode) Test(org.junit.Test)

Example 5 with StatusCode

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

the class RootRangeStoreImpl method verifyDeleteNamespaceRequest.

StatusCode verifyDeleteNamespaceRequest(DeleteNamespaceRequest request) {
    String colName = request.getName();
    StatusCode code = StatusCode.SUCCESS;
    if (!validateNamespaceName(colName)) {
        log.error("Failed to delete namespace due to invalid namespace name {}", colName);
        code = StatusCode.INVALID_NAMESPACE_NAME;
    }
    return code;
}
Also used : StatusCode(org.apache.bookkeeper.stream.proto.storage.StatusCode)

Aggregations

StatusCode (org.apache.bookkeeper.stream.proto.storage.StatusCode)13 UTF_8 (com.google.common.base.Charsets.UTF_8)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 Code (org.apache.bookkeeper.api.kv.result.Code)1 KeyValue (org.apache.bookkeeper.api.kv.result.KeyValue)1 FutureUtils (org.apache.bookkeeper.common.concurrent.FutureUtils)1 Bytes (org.apache.bookkeeper.common.util.Bytes)1 MVCCStoreException (org.apache.bookkeeper.statelib.api.exceptions.MVCCStoreException)1 MVCCAsyncStore (org.apache.bookkeeper.statelib.api.mvcc.MVCCAsyncStore)1 NamespaceMetadata (org.apache.bookkeeper.stream.proto.NamespaceMetadata)1 NamespaceProperties (org.apache.bookkeeper.stream.proto.NamespaceProperties)1 StreamConfiguration (org.apache.bookkeeper.stream.proto.StreamConfiguration)1