Package com.hp.mwtests.ts.txoj.common.resources

Examples of com.hp.mwtests.ts.txoj.common.resources.AtomicObject


    public static final int EXPECTED_RESULT = START_VALUE_1 + START_VALUE_2;

public void run(String[] args)
    {
  rand = new Random();
  atomicObject1 = new AtomicObject();
  atomicObject2 = new AtomicObject();

  System.out.println(atomicObject1.get_uid());
  System.out.println(atomicObject2.get_uid());

  try
View Full Code Here


  return System.currentTimeMillis() - t1;
    }

public static long persistentTest (long iters)
    {
  AtomicObject foo = new AtomicObject();
  AtomicAction A = null;
  long t1 = System.currentTimeMillis();

  try
  {
      for (int c = 0; c < iters; c++)
      {
    A = new AtomicAction();
   
    A.begin();
   
    foo.set(2);

    A.commit();

    A = null;
      }
View Full Code Here


public void run(String[] args)
    {
  rand = new Random();
  atomicObject1 = new AtomicObject();
  atomicObject2 = new AtomicObject();

  System.out.println(atomicObject1.get_uid());
  System.out.println(atomicObject2.get_uid());

  try
View Full Code Here

    public void run (String[] args)
    {
  try
  {
      AtomicObject obj = new AtomicObject();
      Uid objRef = obj.get_uid();

      AtomicAction A = new AtomicAction();

      A.begin();

      obj.set(1234);

      A.commit();

      AtomicObject recObj = new AtomicObject(objRef);

      AtomicAction B = new AtomicAction();

      B.begin();

      if (recObj.get() == 1234)
      {
    System.out.print("Passed.");

    assertSuccess();
      }
View Full Code Here

public class ConcurrencyTest extends Test
{

public void run(String[] args)
    {
  AtomicObject foo = null;
  Uid u = null;

  for (int i = 0; i < args.length; i++)
  {
      if (args[i].compareTo("-uid") == 0)
      {
    u = new Uid(args[i+1]);

    if (!u.valid())
    {
        logInformation("Invalid uid.");
        assertFailure();
    }
      }
      if (args[i].compareTo("-help") == 0)
      {
    System.out.println("Usage: [-uid <uid>] [-help]");
    assertFailure();
      }
  }

  if (u == null)
      foo = new AtomicObject();
  else
      foo = new AtomicObject(u);

  logInformation("Starting top-level action.");

  AtomicAction A = new AtomicAction();

  try
  {
      A.begin();

      logInformation("Current atomic object state: " + foo.get());

      foo.set(7);

      if (u == null)
      {
    logInformation("Now waiting for 20 seconds.");
View Full Code Here

  return System.currentTimeMillis() - t1;
    }

public static long persistentTest (long iters)
    {
  AtomicObject foo = new AtomicObject();
  AtomicAction A = new AtomicAction();
  long t1 = System.currentTimeMillis();

  A.begin();

  try
  {
      for (int c = 0; c < iters; c++)
      {
    foo.set(2);
      }
  }
  catch (TestException e)
  {
      System.out.println("AtomicObject exception raised.");
View Full Code Here

public void run(String[] args)
    {
  rand = new Random();

  atomicObject1 = new AtomicObject();
  atomicObject2 = new AtomicObject();

  System.out.println(atomicObject1.get_uid());
  System.out.println(atomicObject2.get_uid());

  try
View Full Code Here

public class DestroyTest extends Test
{

public void run(String[] args)
    {
  AtomicObject atomicObject = new AtomicObject();
  Uid u = atomicObject.get_uid();
  AtomicAction a = new AtomicAction();

  a.begin();

  try
  {
      atomicObject.set(10);
  }
  catch (TestException e)
  {
      logInformation("set : failed");
            logInformation("Unexpected exception - "+e);
            e.printStackTrace(System.err);
      assertFailure();
  }

  logInformation("set : ok");

  if (!atomicObject.destroy())
  {
      logInformation("destroy : failed");

      a.abort();

      assertFailure();
  }

  a.commit();

  atomicObject = new AtomicObject(u);

  boolean passed = false;

  try
  {
      int val = atomicObject.get();

      if (val != -1)
      {
    logInformation("got : "+val);
View Full Code Here

      System.exit(-1);
  }

  try
  {
      AtomicObject obj = null;

      if (uid != null)
      {
    Uid u = new Uid(uid);
 
    obj = new AtomicObject(u, objName);
      }
      else
    obj = new AtomicObject(objName);

      AtomicAction A = new AtomicAction();

      A.begin();
     
      if (write)
      {
    obj.set(1234);
    System.out.println("set state to 1234");
      }
      else
    System.out.println("got "+obj.get());

      System.out.println("Thread sleeping");
     
      Thread.sleep(10000);
View Full Code Here

public static void main (String[] args)
    {
  AtomicAction A = new AtomicAction();
  TopLevelAction B = new TopLevelAction();
  AtomicAction C = new AtomicAction();
  AtomicObject foo1 = new AtomicObject();
  AtomicObject foo2 = new AtomicObject();
  boolean passed = false;

  try
  {
      System.out.println("\nStarting top-level action.\n");
 
      A.begin();

      System.out.println(A);

      foo1.set(5);

      System.out.println("Current atomic object 1 state: " + foo1.get());

      System.out.println("\nStarting nested top-level action.");

      B.begin();

      System.out.println(B);

      foo2.set(7);

      System.out.println("Current atomic object 2 state: " + foo2.get());

      System.out.println("\nCommitting nested top-level action.");
 
      B.commit();

      System.out.println("\nAborting top-level action.");

      A.abort();

      C.begin();

      int val1 = foo1.get();
      int val2 = foo2.get();
     
      System.out.println("\nFinal atomic object 1 state: " + val1);
     
      if (val1 == 0)
      {
View Full Code Here

TOP

Related Classes of com.hp.mwtests.ts.txoj.common.resources.AtomicObject

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.