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);
}
});
}
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;
}
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;
}
Aggregations