Search in sources :

Example 1 with AbortTransaction

use of io.pravega.shared.protocol.netty.WireCommands.AbortTransaction in project pravega by pravega.

the class MockController method abortTxSegment.

private CompletableFuture<Void> abortTxSegment(UUID txId, Segment segment) {
    CompletableFuture<Void> result = new CompletableFuture<>();
    FailingReplyProcessor replyProcessor = new FailingReplyProcessor() {

        @Override
        public void connectionDropped() {
            result.completeExceptionally(new ConnectionClosedException());
        }

        @Override
        public void wrongHost(WrongHost wrongHost) {
            result.completeExceptionally(new UnsupportedOperationException());
        }

        @Override
        public void transactionCommitted(TransactionCommitted transactionCommitted) {
            result.completeExceptionally(new RuntimeException("Transaction already committed."));
        }

        @Override
        public void transactionAborted(TransactionAborted transactionAborted) {
            result.complete(null);
        }

        @Override
        public void processingFailure(Exception error) {
            result.completeExceptionally(error);
        }

        @Override
        public void authTokenCheckFailed(WireCommands.AuthTokenCheckFailed authTokenCheckFailed) {
            result.completeExceptionally(new AuthenticationException(authTokenCheckFailed.toString()));
        }
    };
    sendRequestOverNewConnection(new AbortTransaction(idGenerator.get(), segment.getScopedName(), txId, ""), replyProcessor, result);
    return result;
}
Also used : AuthenticationException(io.pravega.common.auth.AuthenticationException) FailingReplyProcessor(io.pravega.shared.protocol.netty.FailingReplyProcessor) TransactionAborted(io.pravega.shared.protocol.netty.WireCommands.TransactionAborted) ConnectionClosedException(io.pravega.client.stream.impl.ConnectionClosedException) WrongHost(io.pravega.shared.protocol.netty.WireCommands.WrongHost) AuthenticationException(io.pravega.common.auth.AuthenticationException) TxnFailedException(io.pravega.client.stream.TxnFailedException) ConnectionClosedException(io.pravega.client.stream.impl.ConnectionClosedException) TransactionCommitted(io.pravega.shared.protocol.netty.WireCommands.TransactionCommitted) CompletableFuture(java.util.concurrent.CompletableFuture) AbortTransaction(io.pravega.shared.protocol.netty.WireCommands.AbortTransaction)

Aggregations

TxnFailedException (io.pravega.client.stream.TxnFailedException)1 ConnectionClosedException (io.pravega.client.stream.impl.ConnectionClosedException)1 AuthenticationException (io.pravega.common.auth.AuthenticationException)1 FailingReplyProcessor (io.pravega.shared.protocol.netty.FailingReplyProcessor)1 AbortTransaction (io.pravega.shared.protocol.netty.WireCommands.AbortTransaction)1 TransactionAborted (io.pravega.shared.protocol.netty.WireCommands.TransactionAborted)1 TransactionCommitted (io.pravega.shared.protocol.netty.WireCommands.TransactionCommitted)1 WrongHost (io.pravega.shared.protocol.netty.WireCommands.WrongHost)1 CompletableFuture (java.util.concurrent.CompletableFuture)1