Package com.arjuna.ats.arjuna

Examples of com.arjuna.ats.arjuna.AtomicAction


    qautil.qadebug("end increase");
  }

  public int getValue()
  {
    AtomicAction a = new AtomicAction();
    a.begin();
    activate();
    deactivate();
    a.commit();
    return mValue;
  }
View Full Code Here


        return ids;
    }

    public int getStatus(Uid uid)
    {
        AtomicAction action = new AtomicAction(uid);

        action.activate();

        return action.status();
    }
View Full Code Here

   * @return +1 if tx was committed, 0 if tx was not committed
   */
  public int increase(int retry, int wait_time)
  {
    int returnValue = 0;
    AtomicAction a = new AtomicAction();
    a.begin();
    try
    {
      int locking_result = LockResult.REFUSED;
      int locking_attempt_count = 0;
      Lock lck = new Lock(LockMode.WRITE);
      do
      {
        locking_result = setlock(lck, retry, wait_time);

        if (locking_result == LockResult.GRANTED)
        {
          mValue++;
        }
        else
        {
          locking_attempt_count++;
        }
      }
      while ((locking_result != LockResult.GRANTED) && (locking_attempt_count < mLimit));

      if (locking_result != LockResult.GRANTED)
      {
        qautil.qadebug("trying to get lock for " + mLimit + "th time");
        a.abort();
      }
      else
      {
        a.commit();
        returnValue = 1;
      }
    }
    catch (Exception e)
    {
      a.abort();
      qautil.debug("exception in increase method ", e);
    }
    return returnValue;
  }
View Full Code Here

  public int getValue(int retry, int wait_time)
  {
    int return_value = 0;

    AtomicAction a = new AtomicAction();
    a.begin();
    try
    {
      int locking_result = LockResult.REFUSED;
      int locking_attempt_count = 0;
      Lock lck = new Lock(LockMode.READ);
      do
      {
        locking_result = setlock(lck, retry, wait_time);

        if (locking_result == LockResult.GRANTED)
        {
          return_value = mValue;
        }
        else
        {
          locking_attempt_count++;
        }
      }
      while ((locking_result != LockResult.GRANTED) && (locking_attempt_count < mLimit));

      if (locking_result != LockResult.GRANTED)
      {
        qautil.qadebug("trying to get lock for " + mLimit + "th time");
      }

      a.commit();
    }
    catch (Exception e)
    {
      a.abort();
      qautil.debug("exception in get method ", e);
    }

    return return_value;
  }
View Full Code Here

      for (int j = 0; j < mNumberOfResources; j++)
      {
        for (int i = 0; i < mMaxIteration; i++)
        {
          //start transaction
          AtomicAction a = new AtomicAction();
          a.begin();
          int incValue = mLockRecordList[j].increase();
          if (i % 2 == 0)
          {
            a.commit();
            expectedValue[j] += incValue;
          }
          else
          {
            a.abort();
          }
        }
      }

      for (int j = 0; j < mNumberOfResources; j++)
      {
        for (int i = 0; i < mMaxIteration; i++)
        {
          AtomicAction b = new AtomicAction();
          b.begin();
          int incValue = mLockRecordList[j].increase();
          if (i % 2 == 0)
          {
            b.commit();
            expectedValue[j] += incValue;
          }
          else
          {
            b.abort();
          }
        }
      }
    }
    catch (Exception e)
View Full Code Here

         _tests_failed = 0 ;

         // needed to force TxControl static initialization
         ObjectStore os = TxControl.getStore() ;

         _transaction_1 = new AtomicAction() ;
         _transaction_2 = new AtomicAction() ;
         _transaction_3 = new AtomicAction() ;

         _test_tran_type_1 = _transaction_1.type() ;
         _test_tran_type_2 = _transaction_2.type() ;
         _test_tran_type_3 = _transaction_3.type() ;
View Full Code Here

  System.runFinalization();
    }

private void test () throws Exception
    {
  AtomicAction A = new AtomicAction();
  BasicObject bo = new BasicObject();

  A.begin();

  bo.set(2);

  A.commit();
    }
View Full Code Here

    {
        TransactionImple theTransaction = (TransactionImple) which;

        try
        {
            AtomicAction act = ((theTransaction == null) ? null : theTransaction.getAtomicAction());

            if (!AtomicAction.resume(act))
                throw new InvalidTransactionException();

            theTransaction = null;
View Full Code Here

            if ((args[i].compareTo("-crash") == 0))
                crash = true;
        }

        // Create a new JBoss transaction
        AtomicAction tx = new AtomicAction();
        // Allocate space to monitor the transaction, this variable is overriden each time the transaction is used.
        int actionStatus = tx.begin(); // Top level begin

        // If the transaction was successful began
        if (actionStatus == ActionStatus.RUNNING)
        {
            // Enlist the participant
            int addOutcome = tx.add(new SimpleRecord(crash));
            // If the participant was succesfully added to the intentions list
            if (addOutcome == AddOutcome.AR_ADDED)
            {
                System.out.println("About to complete the transaction ");
                // Try to complete the transaction as requested by the user
                if (commit)
                    actionStatus = tx.commit()// Top level commit
                else
                    actionStatus = tx.abort()// Top level rollback

                System.out.println("The status of the transaction is " + ActionStatus.stringForm(actionStatus));
            }
            else
            {
View Full Code Here

  System.runFinalization();
    }

private void test () throws Exception
    {
  AtomicAction A = new AtomicAction();
  BasicObject bo = new BasicObject();
 
  A.begin();

  bo.set(2);
 
  A.commit();
    }
View Full Code Here

TOP

Related Classes of com.arjuna.ats.arjuna.AtomicAction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.