Exemple #1
0
        /** <inheritDoc /> */
        public ITransactionCollection GetLocalActiveTransactions()
        {
            return(DoInOp(OpLocalActiveTransactions, stream =>
            {
                var reader = Marshaller.StartUnmarshal(stream);

                var size = reader.ReadInt();

                var result = new List <ITransaction>(size);

                for (var i = 0; i < size; i++)
                {
                    var id = reader.ReadLong();

                    var concurrency = reader.ReadInt();

                    var isolation = reader.ReadInt();

                    var timeout = reader.ReadLongAsTimespan();

                    var label = reader.ReadString();

                    var innerTx = new TransactionImpl(id, this, (TransactionConcurrency)concurrency,
                                                      (TransactionIsolation)isolation, timeout, label, _localNodeId, false);

                    result.Add(new Transaction(innerTx));
                }

                return new TransactionCollectionImpl(result);
            }));
        }
Exemple #2
0
        /** <inheritDoc /> */
        public ITransaction TxStart(TransactionConcurrency concurrency, TransactionIsolation isolation,
                                    TimeSpan timeout, int txSize)
        {
            var id = UU.TransactionsStart(Target, (int)concurrency, (int)isolation, (long)timeout.TotalMilliseconds,
                                          txSize);

            var innerTx = new TransactionImpl(id, this, concurrency, isolation, timeout, _localNodeId);

            return(new Transaction(innerTx));
        }
Exemple #3
0
        public ITransaction TxStart(TransactionConcurrency concurrency, TransactionIsolation isolation,
                                    TimeSpan timeout, int txSize)
        {
            var id = DoOutInOp(OpStart, w =>
            {
                w.WriteInt((int)concurrency);
                w.WriteInt((int)isolation);
                w.WriteTimeSpanAsLong(timeout);
                w.WriteInt(txSize);
            }, s => s.ReadLong());

            var innerTx = new TransactionImpl(id, this, concurrency, isolation, timeout, _label, _localNodeId);

            return(new Transaction(innerTx));
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="id">ID.</param>
        /// <param name="txs">Transactions.</param>
        /// <param name="concurrency">TX concurrency.</param>
        /// <param name="isolation">TX isolation.</param>
        /// <param name="timeout">Timeout.</param>
        /// <param name="nodeId">The originating node identifier.</param>
        public TransactionImpl(long id, TransactionsImpl txs, TransactionConcurrency concurrency,
                               TransactionIsolation isolation, TimeSpan timeout, Guid nodeId)
        {
            _id          = id;
            _txs         = txs;
            _concurrency = concurrency;
            _isolation   = isolation;
            _timeout     = timeout;
            _nodeId      = nodeId;

            _startTime = DateTime.Now;

            _threadId = Thread.CurrentThread.ManagedThreadId;

            THREAD_TX = this;
        }
Exemple #5
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="id">ID.</param>
        /// <param name="txs">Transactions.</param>
        /// <param name="concurrency">TX concurrency.</param>
        /// <param name="isolation">TX isolation.</param>
        /// <param name="timeout">Timeout.</param>
        /// <param name="label">TX label.</param>
        /// <param name="nodeId">The originating node identifier.</param>
        /// <param name="bindToThread">Bind transaction to current thread or not.</param>
        public TransactionImpl(long id, TransactionsImpl txs, TransactionConcurrency concurrency,
                               TransactionIsolation isolation, TimeSpan timeout, string label, Guid nodeId, bool bindToThread = true)
        {
            _id          = id;
            _txs         = txs;
            _concurrency = concurrency;
            _isolation   = isolation;
            _timeout     = timeout;
            _label       = label;
            _nodeId      = nodeId;

            _startTime = DateTime.Now;

            _threadId = Thread.CurrentThread.ManagedThreadId;

            if (bindToThread)
            {
                THREAD_TX = this;
            }
        }
Exemple #6
0
 /// <summary>
 /// Commits tx in async mode.
 /// </summary>
 internal Task CommitAsync(TransactionImpl tx)
 {
     return(DoOutOpAsync(OpCommitAsync, w => w.WriteLong(tx.Id)));
 }
Exemple #7
0
 /// <summary>
 /// Set transaction rollback-only flag.
 /// </summary>
 /// <param name="tx">Transaction.</param>
 /// <returns><c>true</c> if the flag was set.</returns>
 internal bool TxSetRollbackOnly(TransactionImpl tx)
 {
     return(DoOutInOp(OpSetRollbackOnly, tx.Id) == True);
 }
Exemple #8
0
 /// <summary>
 /// Get transaction current state.
 /// </summary>
 /// <param name="tx">Transaction.</param>
 /// <returns>Transaction current state.</returns>
 internal TransactionState TxState(TransactionImpl tx)
 {
     return((TransactionState)DoOutInOp(OpState, tx.Id));
 }
Exemple #9
0
 /// <summary>
 /// Close transaction.
 /// </summary>
 /// <param name="tx">Transaction.</param>
 /// <returns>Final transaction state.</returns>
 internal int TxClose(TransactionImpl tx)
 {
     return((int)DoOutInOp(OpClose, tx.Id));
 }
Exemple #10
0
 /// <summary>
 /// Rollback transaction.
 /// </summary>
 /// <param name="tx">Transaction.</param>
 /// <returns>Final transaction state.</returns>
 internal TransactionState TxRollback(TransactionImpl tx)
 {
     return((TransactionState)DoOutInOp(OpRollback, tx.Id));
 }
Exemple #11
0
 /// <summary>
 /// Commit transaction.
 /// </summary>
 /// <param name="tx">Transaction.</param>
 /// <returns>Final transaction state.</returns>
 internal TransactionState TxCommit(TransactionImpl tx)
 {
     return((TransactionState)DoOutInOp(OpCommit, tx.Id));
 }
Exemple #12
0
 /// <summary>
 /// Executes prepare step of the two phase commit.
 /// </summary>
 internal void TxPrepare(TransactionImpl tx)
 {
     DoOutInOp(OpPrepare, tx.Id);
 }
Exemple #13
0
 /// <summary>
 /// Rollback transaction.
 /// </summary>
 /// <param name="tx">Transaction.</param>
 /// <returns>Final transaction state.</returns>
 internal TransactionState TxRollback(TransactionImpl tx)
 {
     return((TransactionState)UU.TransactionsRollback(Target, tx.Id));
 }
Exemple #14
0
 /// <summary>
 /// Commit transaction.
 /// </summary>
 /// <param name="tx">Transaction.</param>
 /// <returns>Final transaction state.</returns>
 internal TransactionState TxCommit(TransactionImpl tx)
 {
     return((TransactionState)UU.TransactionsCommit(Target, tx.Id));
 }
Exemple #15
0
 /// <summary>
 /// Rolls tx back in async mode.
 /// </summary>
 internal Task RollbackAsync(TransactionImpl tx)
 {
     return(DoOutOpAsync(OpRollbackAsync, w => w.WriteLong(tx.Id)));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AsyncTransaction"/> class.
 /// </summary>
 /// <param name="tx">The tx to wrap.</param>
 public AsyncTransaction(TransactionImpl tx) : base(tx)
 {
     // No-op.
 }
Exemple #17
0
 /// <summary>
 /// Close transaction.
 /// </summary>
 /// <param name="tx">Transaction.</param>
 /// <returns>Final transaction state.</returns>
 internal int TxClose(TransactionImpl tx)
 {
     return(UU.TransactionsClose(Target, tx.Id));
 }
Exemple #18
0
 /// <summary>
 /// Rolls tx back in async mode.
 /// </summary>
 internal Task RollbackAsync(TransactionImpl tx)
 {
     return(GetFuture <object>((futId, futTyp) => UU.TransactionsRollbackAsync(Target, tx.Id, futId)).Task);
 }
Exemple #19
0
 /// <summary>
 /// Set transaction rollback-only flag.
 /// </summary>
 /// <param name="tx">Transaction.</param>
 /// <returns><c>true</c> if the flag was set.</returns>
 internal bool TxSetRollbackOnly(TransactionImpl tx)
 {
     return(UU.TransactionsSetRollbackOnly(Target, tx.Id));
 }
Exemple #20
0
 /// <summary>
 /// Get transaction current state.
 /// </summary>
 /// <param name="tx">Transaction.</param>
 /// <returns>Transaction current state.</returns>
 internal TransactionState TxState(TransactionImpl tx)
 {
     return(GetTransactionState(UU.TransactionsState(Target, tx.Id)));
 }
Exemple #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Transaction" /> class.
 /// </summary>
 /// <param name="tx">The tx to wrap.</param>
 public Transaction(TransactionImpl tx)
 {
     _tx = tx;
 }
Exemple #22
0
 /// <summary>
 /// Commits tx in async mode.
 /// </summary>
 internal IFuture CommitAsync(TransactionImpl tx)
 {
     return(GetFuture <object>((futId, futTyp) => UU.TransactionsCommitAsync(Target, tx.Id, futId)));
 }