/// <summary>
        /// Creates a transaction
        /// </summary>
        /// <param name="transactionId">Transaction identifier</param>
        /// <param name="isPrimaryTransaction">If the transaction is a primary transaction</param>
        /// <returns>An instance of a transaction object</returns>
        internal static TransactionBase CreateTransaction(long transactionId, bool isPrimaryTransaction)
        {
            long            positiveTransactionId;
            TransactionBase transaction;

            if (transactionId >= 0)
            {
                positiveTransactionId = transactionId;

                transaction = new Transaction(transactionId, null, isPrimaryTransaction);
            }
            else
            {
                positiveTransactionId = -transactionId;
                transaction           = AtomicOperation.CreateAtomicOperation(transactionId, isPrimaryTransaction);
            }

            lock (TransactionLock)
            {
                if (positiveTransactionId > LastTransactionId)
                {
                    LastTransactionId = positiveTransactionId;
                }
            }

            return(transaction);
        }
Exemple #2
0
        public async Task <long> AddOperationAsync(
            AtomicOperation atomicOperation,
            OperationData metaData,
            OperationData undo,
            OperationData redo,
            object operationContext)
        {
            var record = new OperationLogRecord(atomicOperation, metaData, undo, redo, operationContext);

            await this.ProcessLogicalRecordOnPrimaryAsync(record).ConfigureAwait(false);

            return(record.Lsn.LSN);
        }
 /// <summary>
 /// Called when state providers need to replicate their atomic operation and when local state needs to be replicated.
 /// </summary>
 Task <long> ITransactionalReplicator.AddOperationAsync(
     AtomicOperation atomicOperation,
     OperationData metaData,
     OperationData undo,
     OperationData redo,
     object operationContext,
     long stateProviderId)
 {
     return(this.stateManager.AddOperationAsync(
                atomicOperation,
                metaData,
                undo,
                redo,
                operationContext,
                stateProviderId));
 }