Package com.arjuna.ats.arjuna

Examples of com.arjuna.ats.arjuna.AtomicAction


   */
  public void run()
  {
    try
    {
      AtomicAction a = new AtomicAction();
      //start transaction
      a.begin();
      mService.setupOper();
      mService.doWork(mMaxIteration);
      //comit transaction
      a.commit();

      mService = new Service01(mNumberOfResources);
      //start new AtomicAction
      AtomicAction b = new AtomicAction();
      b.begin();
      mService.setupOper();
      mService.doWork(mMaxIteration);
      b.abort();
    }
    catch (Exception e)
    {
      mCorrect = false;
      qautil.debug("exception in worker001: ", e);
View Full Code Here


  {
    //create abstract records
    mTransaction = (AtomicAction) AtomicAction.Current();
    if (nest || mTransaction == null)
    {
      mTransaction = new AtomicAction();
      mTransaction.begin();
    }

    qautil.qadebug("createing abstract records and enlisting them");
    mAbstractRecordList = new BasicAbstractRecord[mNumberOfResources];
View Full Code Here

  public void dowork(int workload)
  {
    for (int i = 0; i < workload; i++)
    {
      BasicAbstractRecord[] mAbstractRecordList = new BasicAbstractRecord[mNumberOfResources];
      mTransaction = new AtomicAction();
      mTransaction.begin();
      for (int j = 0; j < mNumberOfResources; j++)
      {
        mAbstractRecordList[j] = new BasicAbstractRecord();
        if (mTransaction.add(mAbstractRecordList[j]) != AddOutcome.AR_ADDED)
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;
      do
      {
        locking_result = setlock(new Lock(LockMode.WRITE), retry, wait_time);

        if (locking_result == LockResult.GRANTED)
        {
          mValue++;
        }
        else
        {
          locking_attempt_count++;
        }

        if (timeOfLastWaiting < (System.currentTimeMillis() - 15000))
        {
          System.out.println("Thread: [" + Thread.currentThread() + "]");
          timeOfLastWaiting = System.currentTimeMillis();
        }
      }
      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;

      do
      {
        locking_result = setlock(new Lock(LockMode.READ), 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();
          //perform increase (this will enlist resource)
          mStatetRecordList[j].increase();
          if (i % 2 == 0)
          {
            a.commit();
          }
          else
          {
            a.abort();
          }
        }
      }

      //start second loop
      for (int j = 0; j < mNumberOfResources; j++)
      {
        for (int i = 0; i < mMaxIteration; i++)
        {
          //start transaction
          AtomicAction b = new AtomicAction();
          b.begin();
          //perform increase(this will enlist resource)
          mStatetRecordList[j].increase();
          if (i % 2 != 0)
          {
            b.commit();
          }
          else
          {
            b.abort();
          }
        }
      }
    }
    catch (Exception e)
View Full Code Here

   */
  public void run()
  {
    try
    {
      AtomicAction a = new AtomicAction();
      //start transaction
      a.begin();
      for (int j = 0; j < mNumberOfResources; j++)
      {
        for (int i = 0; i < mMaxIteration; i++)
        {
          mStatetRecordList[j].increase();
        }
      }
      //comit transaction
      a.commit();

      //start new AtomicAction
      AtomicAction b = new AtomicAction();
      b.begin();
      for (int j = 0; j < mNumberOfResources; j++)
      {
        for (int i = 0; i < mMaxIteration; i++)
        {
          mStatetRecordList[j].increase();
        }
      }
      //abort transaction
      b.abort();
    }
    catch (Exception e)
    {
      mCorrect = false;
      qautil.debug("exception in worker002: ", e);
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();
          //perform increase
          mStatetRecordList[j].increase();
          if (i % 2 == 0)
          {
            a.commit();
          }
          else
          {
            a.abort();
          }
        }
      }

      //start second loop
      for (int j = 0; j < mNumberOfResources; j++)
      {
        for (int i = 0; i < mMaxIteration; i++)
        {
          //start transaction
          AtomicAction b = new AtomicAction();
          b.begin();
          //perform increase
          mStatetRecordList[j].increase();
          if (i % 2 != 0)
          {
            b.commit();
          }
          else
          {
            b.abort();
          }
        }
      }
    }
    catch (Exception e)
View Full Code Here

   */
  public void run()
  {
    try
    {
      AtomicAction a = new AtomicAction();
      //start transaction
      a.begin();
      for (int j = 0; j < mNumberOfResources; j++)
      {
        for (int i = 0; i < mMaxIteration; i++)
        {
          mStatetRecordList[j].increase();
        }
      }
      //comit transaction
      a.commit();

      //start new AtomicAction
      AtomicAction b = new AtomicAction();
      b.begin();
      for (int j = 0; j < mNumberOfResources; j++)
      {
        for (int i = 0; i < mMaxIteration; i++)
        {
          mStatetRecordList[j].increase();
        }
      }
      //abort transaction
      b.abort();
    }
    catch (Exception e)
    {
      mCorrect = false;
      qautil.debug("exception in worker001: ", e);
View Full Code Here

   * We will start a subtrancastion during the increase to see what effet this has.
   */
  public void increase()
  {
    qautil.qadebug("start increase");
    AtomicAction a = new AtomicAction();
    try
    {
      a.begin();
      activate();
      modified();
      mValue++;
      a.commit();
    }
    catch (Exception e)
    {
      a.abort();
      qautil.debug("exception in increase method ", e);
    }
    qautil.qadebug("end increase");
  }
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.