Package com.arjuna.ats.jts.extensions

Examples of com.arjuna.ats.jts.extensions.AtomicTransaction


      Date start = new Date();

      for (int index = 0; index < numberOfCalls; index++)
      {
        AtomicTransaction atomicTransaction = new AtomicTransaction();

        atomicTransaction.begin();

        explicitObject.tran_rollback_writelock(OTS.current().get_control());

        atomicTransaction.rollback();
      }

      Date end = new Date();

      float operationDuration = ((float) (end.getTime() - start.getTime())) / ((float) numberOfCalls);
View Full Code Here


      Date start = new Date();

      for (int index = 0; index < numberOfCalls; index++)
      {
        AtomicTransaction atomicTransaction = new AtomicTransaction();

        atomicTransaction.begin();

        explicitObject.tran_commit_writelock(OTS.current().get_control());

        atomicTransaction.commit(true);
      }

      Date end = new Date();

      float operationDuration = ((float) (end.getTime() - start.getTime())) / ((float) numberOfCalls);
View Full Code Here

      Date start = new Date();

      for (int index = 0; index < numberOfCalls; index++)
      {
        AtomicTransaction atomicTransaction = new AtomicTransaction();

        atomicTransaction.begin();

        implicitObject.no_tran_readlock();

        atomicTransaction.rollback();
      }

      Date end = new Date();

      float operationDuration = ((float) (end.getTime() - start.getTime())) / ((float) numberOfCalls);
View Full Code Here

    {
      boolean successful = false;

      try
      {
        AtomicTransaction atomicTransaction = new AtomicTransaction();

        try
        {
          atomicTransaction.begin();

          try
          {
            int d = Math.abs(_random.nextInt() % 10) + 1;

            int x0 = Math.abs(_random.nextInt() % _matrixWidth);
            int y0 = Math.abs(_random.nextInt() % _matrixHeight);
            int x1 = Math.abs(_random.nextInt() % _matrixWidth);
            int y1 = Math.abs(_random.nextInt() % _matrixHeight);

            IntHolder location0Value = new IntHolder();
            IntHolder location1Value = new IntHolder();

            _matrix.get_value(x0, y0, location0Value);
            _matrix.get_value(x1, y1, location1Value);

            _matrix.set_value(x0, y0, location1Value.value + d);
            _matrix.set_value(x1, y1, location0Value.value - d);

            successful = (x0 != x1) || (y0 != y1);
          }
          catch (InvocationException invocationException)
          {
            if (invocationException.myreason != Reason.ReasonConcurrencyControl)
            {
              throw invocationException;
            }
          }

          if (successful)
          {
            atomicTransaction.commit(true);
          }
          else
          {
            atomicTransaction.rollback();
          }
        }
        catch (Exception exception)
        {
          if (atomicTransaction.get_status() == Status.StatusActive)
          {
            atomicTransaction.rollback();
          }

          throw exception;
        }
      }
View Full Code Here

    {
      boolean successful = false;

      try
      {
        AtomicTransaction atomicTransaction = new AtomicTransaction();

        try
        {
          atomicTransaction.begin();

          try
          {
            int x0 = Math.abs(_random.nextInt() % _matrixWidth);
            int y0 = Math.abs(_random.nextInt() % _matrixHeight);
            int x1 = Math.abs(_random.nextInt() % _matrixWidth);
            int y1 = Math.abs(_random.nextInt() % _matrixHeight);

            IntHolder srcValue = new IntHolder();
            IntHolder dstValue = new IntHolder();

            _matrix.get_value(x0, y0, srcValue);

            if (srcValue.value == 1)
            {
              _matrix.get_value(x1, y1, dstValue);

              if (dstValue.value == 0)
              {
                _matrix.set_value(x0, y0, 0);
                _matrix.set_value(x1, y1, 1);

                successful = true;
              }
            }
          }
          catch (InvocationException invocationException)
          {
            if (invocationException.myreason != Reason.ReasonConcurrencyControl)
            {
              throw invocationException;
            }
          }

          if (successful)
          {
            atomicTransaction.commit(true);
          }
          else
          {
            atomicTransaction.rollback();
          }
        }
        catch (Exception exception)
        {
          if (atomicTransaction.get_status() == Status.StatusActive)
          {
            atomicTransaction.rollback();
          }

          throw exception;
        }
      }
View Full Code Here

  {
    boolean successful = false;

    try
    {
      AtomicTransaction atomicTransaction = new AtomicTransaction();

      try
      {
        atomicTransaction.begin();

        try
        {
          int x0 = Math.abs(_random.nextInt() % _matrixWidth);
          int y0 = Math.abs(_random.nextInt() % _matrixHeight);
          int x1 = Math.abs(_random.nextInt() % _matrixWidth);
          int y1 = Math.abs(_random.nextInt() % _matrixHeight);

          IntHolder srcValue = new IntHolder();
          IntHolder dstValue = new IntHolder();

          _matrix.get_value(x0, y0, srcValue);

          if (srcValue.value == 1)
          {
            _matrix.get_value(x1, y1, dstValue);

            if (dstValue.value == 0)
            {
              _matrix.set_value(x0, y0, 0);
              _matrix.set_value(x1, y1, 1);

              successful = true;
            }
          }
        }
        catch (InvocationException invocationException)
        {
          if (invocationException.myreason != Reason.ReasonConcurrencyControl)
          {
            throw invocationException;
          }
        }

        if (successful)
        {
          atomicTransaction.commit(true);
        }
        else
        {
          atomicTransaction.rollback();
        }
      }
      catch (Exception exception)
      {
        if (atomicTransaction.get_status() == Status.StatusActive)
        {
          atomicTransaction.rollback();
        }

        throw exception;
      }
    }
View Full Code Here

  {
    boolean successful = false;

    try
    {
      AtomicTransaction atomicTransaction = new AtomicTransaction();

      try
      {
        atomicTransaction.begin();

        try
        {
          int d = Math.abs(_random.nextInt() % 10) + 1;

          int x0 = Math.abs(_random.nextInt() % _matrixWidth);
          int y0 = Math.abs(_random.nextInt() % _matrixHeight);
          int x1 = Math.abs(_random.nextInt() % _matrixWidth);
          int y1 = Math.abs(_random.nextInt() % _matrixHeight);

          IntHolder location0Value = new IntHolder();
          IntHolder location1Value = new IntHolder();

          _matrix.get_value(x0, y0, location0Value);
          _matrix.get_value(x1, y1, location1Value);

          _matrix.set_value(x0, y0, location1Value.value + d);
          _matrix.set_value(x1, y1, location0Value.value - d);

          successful = (x0 != x1) || (y0 != y1);
        }
        catch (InvocationException invocationException)
        {
          if (invocationException.myreason != Reason.ReasonConcurrencyControl)
          {
            throw invocationException;
          }
        }

        if (successful)
        {
          atomicTransaction.commit(true);
        }
        else
        {
          atomicTransaction.rollback();
        }
      }
      catch (Exception exception)
      {
        if (atomicTransaction.get_status() == Status.StatusActive)
        {
          atomicTransaction.rollback();
        }

        throw exception;
      }
    }
View Full Code Here

    _value = 0;

    try
    {
      AtomicTransaction atomicTransaction = new AtomicTransaction();

      atomicTransaction.begin();

      if (setlock(new Lock(LockMode.WRITE), 0) == LockResult.GRANTED)
      {
        atomicTransaction.commit(true);
      }
      else
      {
        System.err.println("AITPingPongImpl01.AITPingPongImpl01: failed to get lock");
        atomicTransaction.rollback();
      }
    }
    catch (Exception exception)
    {
      System.err.println("AITPingPongImpl01.AITPingPongImpl01: " + exception);
View Full Code Here

    {
      com.arjuna.ats.jts.ExplicitInterposition interposition = new com.arjuna.ats.jts.ExplicitInterposition();

      interposition.registerTransaction(ctrl);

      AtomicTransaction atomicTransaction = new AtomicTransaction();

      try
      {
        atomicTransaction.begin();

        if (count != 0)
        {
          ponger.hit(count - 1, pinger, ponger, OTS.current().get_control());
          atomicTransaction.commit(true);
        }
        else if (setlock(new Lock(LockMode.WRITE), 0) == LockResult.GRANTED)
        {
          _value++;
          atomicTransaction.commit(true);
        }
        else
        {
          System.err.println("AITPingPongImpl01.hit: failed to get lock");
          atomicTransaction.rollback();

          throw new InvocationException();
        }
      }
      catch (InvocationException invocationException)
      {
        interposition.unregisterTransaction();

        throw invocationException;
      }
      catch (Exception exception)
      {
        System.err.println("AITPingPongImpl01.hit: " + exception);
        if (atomicTransaction.get_status() == Status.StatusActive)
        {
          atomicTransaction.rollback();
        }

        interposition.unregisterTransaction();

        throw new InvocationException();
      }
      catch (Error error)
      {
        System.err.println("AITPingPongImpl01.hit: " + error);
        if (atomicTransaction.get_status() == Status.StatusActive)
        {
          atomicTransaction.rollback();
        }

        interposition.unregisterTransaction();

        throw new InvocationException();
View Full Code Here

    {
      com.arjuna.ats.jts.ExplicitInterposition interposition = new com.arjuna.ats.jts.ExplicitInterposition();

      interposition.registerTransaction(ctrl);

      AtomicTransaction atomicTransaction = new AtomicTransaction();

      try
      {
        atomicTransaction.begin();

        if (count != 0)
        {
          ponger.bad_hit(count - 1, bad_count - 1, pinger, ponger, OTS.current().get_control());
          if (bad_count != 0)
          {
            atomicTransaction.commit(true);
          }
          else
          {
            atomicTransaction.rollback();
          }
        }
        else if (setlock(new Lock(LockMode.WRITE), 0) == LockResult.GRANTED)
        {
          _value++;
          if (bad_count != 0)
          {
            atomicTransaction.commit(true);
          }
          else
          {
            atomicTransaction.rollback();
          }
        }
        else
        {
          System.err.println("AITPingPongImpl01.bad_hit: failed to get lock");
          atomicTransaction.rollback();

          throw new InvocationException();
        }
      }
      catch (InvocationException invocationException)
      {
        interposition.unregisterTransaction();

        throw invocationException;
      }
      catch (Exception exception)
      {
        System.err.println("AITPingPongImpl01.bad_hit: " + exception);
        if (atomicTransaction.get_status() == Status.StatusActive)
        {
          atomicTransaction.rollback();
        }

        interposition.unregisterTransaction();

        throw new InvocationException();
      }
      catch (Error error)
      {
        System.err.println("AITPingPongImpl01.bad_hit: " + error);
        if (atomicTransaction.get_status() == Status.StatusActive)
        {
          atomicTransaction.rollback();
        }

        interposition.unregisterTransaction();

        throw new InvocationException();
View Full Code Here

TOP

Related Classes of com.arjuna.ats.jts.extensions.AtomicTransaction

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.