Search in sources :

Example 6 with NetworkException

use of org.corfudb.runtime.exceptions.NetworkException in project CorfuDB by CorfuDB.

the class CorfuCompileProxy method abortTransaction.

private void abortTransaction(Exception e) {
    long snapshot_timestamp;
    AbortCause abortCause;
    AbstractTransactionalContext context = TransactionalContext.getCurrentContext();
    if (e instanceof NetworkException) {
        // If a 'NetworkException' was received within a transactional context, an attempt to
        // 'getSnapshotTimestamp' will also fail (as it requests it to the Sequencer). A new NetworkException
        // would prevent the earliest to be propagated and encapsulated as a TransactionAbortedException.
        snapshot_timestamp = -1L;
        abortCause = AbortCause.NETWORK;
    } else {
        snapshot_timestamp = context.getSnapshotTimestamp();
        abortCause = AbortCause.UNDEFINED;
    }
    TxResolutionInfo txInfo = new TxResolutionInfo(context.getTransactionID(), snapshot_timestamp);
    TransactionAbortedException tae = new TransactionAbortedException(txInfo, null, abortCause);
    context.abortTransaction(tae);
    TransactionalContext.removeContext();
    throw tae;
}
Also used : TxResolutionInfo(org.corfudb.protocols.wireprotocol.TxResolutionInfo) AbstractTransactionalContext(org.corfudb.runtime.object.transactions.AbstractTransactionalContext) AbortCause(org.corfudb.runtime.exceptions.AbortCause) NetworkException(org.corfudb.runtime.exceptions.NetworkException) TransactionAbortedException(org.corfudb.runtime.exceptions.TransactionAbortedException)

Aggregations

NetworkException (org.corfudb.runtime.exceptions.NetworkException)6 TransactionAbortedException (org.corfudb.runtime.exceptions.TransactionAbortedException)3 NoSuchElementException (java.util.NoSuchElementException)2 TxResolutionInfo (org.corfudb.protocols.wireprotocol.TxResolutionInfo)2 AbortCause (org.corfudb.runtime.exceptions.AbortCause)2 WrongEpochException (org.corfudb.runtime.exceptions.WrongEpochException)2 AbstractTransactionalContext (org.corfudb.runtime.object.transactions.AbstractTransactionalContext)2 Timer (com.codahale.metrics.Timer)1 Bootstrap (io.netty.bootstrap.Bootstrap)1 ChannelFuture (io.netty.channel.ChannelFuture)1 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)1 SocketChannel (io.netty.channel.socket.SocketChannel)1 NioSocketChannel (io.netty.channel.socket.nio.NioSocketChannel)1 LengthFieldBasedFrameDecoder (io.netty.handler.codec.LengthFieldBasedFrameDecoder)1 LengthFieldPrepender (io.netty.handler.codec.LengthFieldPrepender)1 DefaultEventExecutorGroup (io.netty.util.concurrent.DefaultEventExecutorGroup)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1