Exemple #1
0
        public bool commit(TxInfo txInfo)
        {
            TransactionId           id        = (TransactionId)(object)txInfo.getTxId();
            bool                    commited  = false;
            CacheTransactionManager txManager = null;

            txManager = CacheHelper <TKey, TVal> .DCache.CacheTransactionManager;
            if (txManager.TryResume(id, 30000))
            {
                try
                {
                    txManager.Commit();
                    commited = true;
                }
                catch (CommitConflictException ex)
                {
                    //Expected exception with concurrent transactions.
                    Util.Log("Got expected exception {0}", ex);
                }
                catch (TransactionDataRebalancedException ex)
                {
                    FwkTest <TKey, TVal> .CurrentTest.FwkException("Got {0}", ex);
                }
                catch (TransactionDataNodeHasDepartedException ex)
                {
                    FwkTest <TKey, TVal> .CurrentTest.FwkException("Got {0}", ex);
                }
            }
            else
            {
                Util.Log("TxId {0} is not suspended in this member with tryResume time limit, cannot commit.  Expected, continuing test.");
            }
            Util.Log("Commited returning {0}", commited);
            return(commited);
        }
Exemple #2
0
        public void rollback(TxInfo txInfo)
        {
            TransactionId           id        = (TransactionId)(object)txInfo.getTxId();
            CacheTransactionManager txManager = null;
            bool isRollBack = false;

            txManager = CacheHelper <TKey, TVal> .DCache.CacheTransactionManager;
            if (txManager.TryResume(id, 30000))
            {
                txManager.Rollback();
                isRollBack = true;
            }
            else
            {
                Util.Log("TxId {0} is not suspended in this member with tryResume time limit, cannot rollback.  Expected with concurrent execution, continuing test.");
            }
            Util.Log("RollbackTx returning {0}", isRollBack);
        }
Exemple #3
0
        public void executeTxOps(TxInfo txInfo)
        {
            //This will do a resume+doOps+suspend
            TransactionId           id        = (TransactionId)(object)txInfo.getTxId();
            CacheTransactionManager txManager = null;

            txManager = CacheHelper <TKey, TVal> .DCache.CacheTransactionManager;
            bool executedOps  = false;
            int  numOfOpsToDo = 5;

            if (txManager.TryResume(id, 30000))
            {
                try
                {
                    doEntryOps(numOfOpsToDo);
                    executedOps = true;
                }
                catch (TransactionDataNodeHasDepartedException ex)
                {
                    FwkTest <TKey, TVal> .CurrentTest.FwkException("Caught {0}", ex);
                }
                catch (TransactionDataRebalancedException ex)
                {
                    FwkTest <TKey, TVal> .CurrentTest.FwkException("Caught {0}", ex);
                }
                catch (Exception ex)
                {
                    FwkTest <TKey, TVal> .CurrentTest.FwkException("Caught unexpected exception during doEntryOps task {0}", ex.Message);
                }
                finally
                {
                    id = txManager.Suspend();
                    Util.Log("Suspend() complete txId is {0}", id);
                }
            }
            Util.Log("EXECUTE_TX returned  {0}", executedOps);
        }
Exemple #4
0
        public void doValidateTxOps(TransactionId txId, int txState)
        {
            FwkInfo("Inside Resumabletx:DoValidateTxOps");
            FwkInfo("Transactional Id is {0} and transaction state is={1}", txId, txState);
            //int cnt =0;
            //TKey key;
            int           txnState = txState;
            TransactionId txnId    = txId;

            ResetKey("entryCount");
            int EntryCount = GetUIntValue("entryCount");
            CacheTransactionManager txManager = CacheHelper <TKey, TVal> .DCache.CacheTransactionManager;

            try
            {
                switch (txnState)
                {
                case 1001:
                    FwkInfo("...txnState is Begin ...");
                    checkContainsKey(txnState);
                    break;

                case 2:
                    FwkInfo("...txnState is Suspend...");
                    if (!txManager.IsSuspended(txId) && !txManager.Exists(txId))
                    {
                        FwkException("After Suspend(),the Transaction should have been Suspended and should still exist");
                    }
                    checkContainsKey(txnState);
                    break;

                case 3:
                    FwkInfo("...txnState is Resume...");
                    if (txManager.IsSuspended(txnId))
                    {
                        FwkException("After Resume(),the Transaction should NOT have been Suspended");
                    }
                    if (!txManager.Exists(txnId))
                    {
                        FwkException("After Resume(),the Transaction should still exist");
                    }
                    checkContainsKey(txnState);
                    break;

                case 1004:
                    FwkInfo("...txnState is Commit...");
                    if (txManager.IsSuspended(txnId))
                    {
                        FwkException("After Commit(),the Transaction should NOT have been Suspended");
                    }
                    if (txManager.Exists(txnId))
                    {
                        FwkException("After Commit(),the Transaction should Not exist");
                    }
                    if (txManager.TryResume(txnId))
                    {
                        FwkException("After Commit(),the Transaction should Not be resumed");
                    }
                    checkContainsKey(txnState);
                    FwkInfo("Commit BeforeTxMap.Count={0} ", BeforeTxMap.Count);
                    break;
                }
            }
            catch (Exception ex)
            {
                FwkException("doValidateTxOps caught exception {0}", ex.Message);
            }
        }