Examples of TransactionReaper


Examples of com.arjuna.ats.arjuna.coordinator.TransactionReaper

          {
            TransactionInfo info = new TransactionInfo();

            info.currentDepth = ctx.getImplHandle().getHierarchy().depth();

            TransactionReaper reaper = TransactionReaper.transactionReaper();

            info.timeout = reaper.getTimeout(ctx);

            info.numberOfThreads = ctx.getImplHandle().activeThreads();

            return info;
          }
View Full Code Here

Examples of com.arjuna.ats.arjuna.coordinator.TransactionReaper

   
    // add this transaction to the reaper list.
   
    if (timeout > 0)
    {
      TransactionReaper reaper = TransactionReaper.transactionReaper(true);
     
      reaper.insert(super.getControlWrapper(), timeout);
    }
  }
View Full Code Here

Examples of com.arjuna.ats.arjuna.coordinator.TransactionReaper

        /*
         * Currently we do not remove controls from the list once they
         * have terminated. We should to save time and space!
         */

        TransactionReaper reaper = TransactionReaper.transactionReaper();

        if (reaper == null)
          reaper = TransactionReaper.create();

        reaper.insert(new ControlWrapper((ControlImple) tranControl), theTimeout);
      }

      return tranControl;
    }
    catch (OutOfMemoryError e)
View Full Code Here

Examples of com.arjuna.ats.arjuna.coordinator.TransactionReaper

    else
      info.averageLifetime = (float) 0.0;

    info.numberOfHeuristics = com.arjuna.ats.arjuna.coordinator.TxStats.numberOfHeuristics();

    TransactionReaper reaper = TransactionReaper.transactionReaper();

    if (reaper == null)
      info.reaperTimeout = 0;
    else
      info.reaperTimeout = (int) reaper.checkingPeriod();

    info.defaultTimeout = TransactionFactoryImple._defaultTimeout;

    return info;
  }
View Full Code Here

Examples of com.arjuna.ats.arjuna.coordinator.TransactionReaper

          {
            TransactionInfo info = new TransactionInfo();

            info.currentDepth = ctx.getImplHandle().getHierarchy().depth();

            TransactionReaper reaper = TransactionReaper.transactionReaper();

            /*
             * If the reaper has not been created yet, then all
             * transactions so far must have 0 timeout.
             */

            if (reaper == null)
              info.timeout = 0;
            else
              info.timeout = (int) reaper.getTimeout(ctx);

            info.numberOfThreads = ctx.getImplHandle().activeThreads();

            return info;
          }
View Full Code Here

Examples of com.arjuna.ats.arjuna.coordinator.TransactionReaper

     * interposition classes we add the hierarchy to the reaper list.
     */

    if ((time_out != 0) && (parentImpl == null))
    {
      TransactionReaper reaper = TransactionReaper.transactionReaper();

      if (reaper == null)
        reaper = TransactionReaper.create();

      reaper.insert(new ServerControlWrapper((ControlImple) tranControl), time_out);
    }

    return tranControl;
  }
View Full Code Here

Examples of com.arjuna.ats.arjuna.coordinator.TransactionReaper

  public void testReaper() throws Exception {

    // test set+readback of interval
    TransactionReaper.create(100);
    TransactionReaper reaper = TransactionReaper.transactionReaper();
    assertEquals(100, reaper.checkingPeriod());


    Reapable reapable = new MockReapable(new Uid());
    Reapable reapable2 = new MockReapable(new Uid());
    Reapable reapable3 = new MockReapable(new Uid());

    ReaperElement reaperElement = new ReaperElement(reapable, 30);
    ReaperElement reaperElement2 = new ReaperElement(reapable2, 20);
    ReaperElement reaperElement3 = new ReaperElement(reapable3, 10);

    // test that ordering is by timeout, regardless of insertion order
    SortedSet sortedSet = new TreeSet();
    sortedSet.add(reaperElement);
    sortedSet.add(reaperElement3);
    sortedSet.add(reaperElement2);

    assertEquals(sortedSet.first(), reaperElement3);
    assertEquals(sortedSet.last(), reaperElement);

    // test insertion of timeout=0 is a nullop
    assertTrue(reaper.insert(reapable, 0));
    assertEquals(0, reaper.numberOfTransactions());
                assertEquals(0, reaper.numberOfTimeouts());
    assertFalse(reaper.remove(reapable));

    // test that duplicate insertion fails
    assertTrue(reaper.insert(reapable, 10));
    assertFalse(reaper.insert(reapable, 10));
    assertEquals(1, reaper.numberOfTransactions());
                assertEquals(1, reaper.numberOfTimeouts());
    assertTrue(reaper.remove(reapable));
    assertEquals(0, reaper.numberOfTransactions());
                assertEquals(0, reaper.numberOfTimeouts());

    // test that timeout change fails
    assertTrue(reaper.insert(reapable, 10));
    assertFalse(reaper.insert(reapable, 20));
    assertEquals(1, reaper.numberOfTransactions());
                assertEquals(1, reaper.numberOfTimeouts());
                assertEquals(10, reaper.getTimeout(reapable));
    assertTrue(reaper.remove(reapable));
                assertEquals(0, reaper.numberOfTransactions());
                assertEquals(0, reaper.numberOfTimeouts());

    // test reaping
    reaper.insert(reapable, 1); // seconds
    reaper.insert(reapable2, 5);
                assertEquals(2, reaper.numberOfTransactions());
                assertEquals(2, reaper.numberOfTimeouts());
    reaper.check();
                assertEquals(2, reaper.numberOfTransactions());
    Thread.sleep(2*1000);
    reaper.check();
                assertEquals(1, reaper.numberOfTransactions());
                assertEquals(1, reaper.numberOfTimeouts());
    Thread.sleep(4*1000);
    reaper.check();
                assertEquals(0, reaper.numberOfTransactions());
                assertEquals(0, reaper.numberOfTimeouts());

  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.