Search in sources :

Example 1 with TransactionAborted

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

the class PravegaRequestProcessor method abortTransaction.

@Override
public void abortTransaction(AbortTransaction abortTx) {
    long requestId = abortTx.getRequestId();
    if (!verifyToken(abortTx.getSegment(), abortTx.getRequestId(), abortTx.getDelegationToken(), READ_UPDATE, "Abort Transaction")) {
        return;
    }
    String transactionName = StreamSegmentNameUtils.getTransactionNameFromId(abortTx.getSegment(), abortTx.getTxid());
    log.debug("Aborting transaction {} ", abortTx);
    segmentStore.deleteStreamSegment(transactionName, TIMEOUT).thenRun(() -> connection.send(new TransactionAborted(requestId, abortTx.getSegment(), abortTx.getTxid()))).exceptionally(e -> {
        if (Exceptions.unwrap(e) instanceof StreamSegmentNotExistsException) {
            connection.send(new TransactionAborted(requestId, abortTx.getSegment(), abortTx.getTxid()));
            return null;
        } else {
            return handleException(requestId, transactionName, "Abort transaction", e);
        }
    });
}
Also used : TransactionAborted(io.pravega.shared.protocol.netty.WireCommands.TransactionAborted) StreamSegmentNotExistsException(io.pravega.segmentstore.contracts.StreamSegmentNotExistsException)

Example 2 with TransactionAborted

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

the class MockController method commitTxSegment.

private CompletableFuture<Void> commitTxSegment(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.complete(null);
        }

        @Override
        public void transactionAborted(TransactionAborted transactionAborted) {
            result.completeExceptionally(new TxnFailedException("Transaction already aborted."));
        }

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

        @Override
        public void authTokenCheckFailed(WireCommands.AuthTokenCheckFailed authTokenCheckFailed) {
            result.completeExceptionally(new AuthenticationException(authTokenCheckFailed.toString()));
        }
    };
    sendRequestOverNewConnection(new CommitTransaction(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) CommitTransaction(io.pravega.shared.protocol.netty.WireCommands.CommitTransaction) CompletableFuture(java.util.concurrent.CompletableFuture) TxnFailedException(io.pravega.client.stream.TxnFailedException)

Example 3 with TransactionAborted

use of io.pravega.shared.protocol.netty.WireCommands.TransactionAborted 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

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