Package com.arjuna.ats.arjuna.objectstore

Examples of com.arjuna.ats.arjuna.objectstore.ObjectStore


public class RemoveCachedTest
{
    public static void main (String[] args)
    {
  boolean passed = true;
  ObjectStore store = new ObjectStore(ArjunaNames.Implementation_ObjectStore_CacheStore());
  String type = "ArjunaMS/Destinations/a3d6227_dc656_3b77ce7e_2/Messages";
  InputObjectState buff = new InputObjectState();

  try
  {
      if (store.allObjUids(type, buff, ObjectStore.OS_COMMITTED))
      {
    Uid toRemove = new Uid(Uid.nullUid());

    do
    {
        toRemove.unpack(buff);

        if (toRemove.notEquals(Uid.nullUid()))
        {
      System.err.println("Removing "+toRemove+"\n");

      if (store.remove_committed(toRemove, type))
          passed = true;
      else
      {
          System.err.println("Failed for "+toRemove);
View Full Code Here


  for (int i = 0; i < 1000; i++)
  {
      try
      {
    ObjectStore store = null;

    if (!threaded)
        store = new ObjectStore(ArjunaNames.Implementation_ObjectStore_ShadowingStore());
    else
        store = new ObjectStore(ArjunaNames.Implementation_ObjectStore_CacheStore());

    byte[] data = new byte[10240];
    OutputObjectState state = new OutputObjectState();
    Uid u = new Uid();

    state.packBytes(data);

    if (store.write_committed(u, "/StateManager/LockManager/foo", state))
    {
        passed = true;
    }
    else
        passed = false;
View Full Code Here

  Thread[] t = new Thread[threads];

  System.setProperty("com.arjuna.ats.internal.arjuna.objectstore.cacheStore.size", cacheSize);

  ObjectStore store = new ObjectStore(ArjunaNames.Implementation_ObjectStore_CacheStore());

  long stime = Calendar.getInstance().getTime().getTime();

  for (int i = 0; (i < threads) && passed; i++)
  {
      try
      {
    t[i] = new WriterThread(store);

    t[i].start();
      }
      catch (Exception ex)
      {
    ex.printStackTrace();

    passed = false;
      }
  }

  for (int j = 0; j < threads; j++)
  {
      try
      {
    t[j].join();

    passed = passed && ((WriterThread) t[j]).passed;
      }
      catch (Exception ex)
      {
      }
  }

  long ftime = Calendar.getInstance().getTime().getTime();
  long timeTaken = ftime - stime;

  System.out.println("time for "+threads+" users is "+timeTaken);

  try
  {
      store.sync();
  }
  catch (Exception ex)
  {
  }
View Full Code Here

{
  public static void main (String[] args)
  {
    System.setProperty(Environment.OBJECTSTORE_TYPE, ArjunaNames.Implementation_ObjectStore_ActionLogStore().stringForm());
   
    ObjectStore objStore = TxControl.getStore();
    final int numberOfTransactions = 1000;
    final Uid[] ids = new Uid[numberOfTransactions];
    final int fakeData = 0xdeedbaaf;
    final String type = "/StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction/Test";
   
    for (int i = 0; i < numberOfTransactions; i++)
    {
      OutputObjectState dummyState = new OutputObjectState();
     
      try
      {
        dummyState.packInt(fakeData);     
        ids[i] = new Uid();
        objStore.write_committed(ids[i], type, dummyState);
      }
      catch (final Exception ex)
      {
        ex.printStackTrace();
      }
    }
   
    InputObjectState ios = new InputObjectState();
    boolean passed = false;
   
    try
    {
      if (objStore.allObjUids(type, ios, ObjectStore.OS_UNKNOWN))
      {
        Uid id = new Uid(Uid.nullUid());
        int numberOfEntries = 0;
       
        do
View Full Code Here

  public static void main (String[] args)
  {
    System.setProperty(Environment.OBJECTSTORE_TYPE, ArjunaNames.Implementation_ObjectStore_ActionLogStore().stringForm());
    System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "10000");
   
    ObjectStore objStore = TxControl.getStore();
    final int numberOfTransactions = 1000;
    final Uid[] ids = new Uid[numberOfTransactions];
    final int fakeData = 0xdeedbaaf;
    final String type = "/StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction/Test";
   
    for (int i = 0; i < numberOfTransactions; i++)
    {
      OutputObjectState dummyState = new OutputObjectState();
     
      try
      {
        dummyState.packInt(fakeData);     
        ids[i] = new Uid();
        objStore.write_committed(ids[i], type, dummyState);
      }
      catch (final Exception ex)
      {
        ex.printStackTrace();
      }
    }
   
    try
    {
      objStore.remove_committed(ids[0], type);
    }
    catch (final Exception ex)
    {
      ex.printStackTrace();
    }
   
    try
    {
      /*
       * Give the purger thread a chance to run and delete
       * the entry.
       */
     
      Thread.sleep(12000);
    }
    catch (final Exception ex)
    {
    }
   
    InputObjectState ios = new InputObjectState();
    boolean passed = false;
   
    try
    {
      if (objStore.allObjUids(type, ios, ObjectStore.OS_UNKNOWN))
      {
        Uid id = new Uid(Uid.nullUid());
        int numberOfEntries = 0;
       
        do
        {
          try
          {
            id.unpack(ios);
          }
          catch (Exception ex)
          {
            id = Uid.nullUid();
          }

          if (id.notEquals(Uid.nullUid()))
          {
            passed = true;
           
            numberOfEntries++;
           
            boolean found = false;
           
            for (int i = 0; i < ids.length; i++)
            {
              if (id.equals(ids[i]))
                found = true;
            }
           
            if (passed && !found)
            {
              passed = false;

              System.err.println("Found unexpected transaction!");
            }
          }
        }
        while (id.notEquals(Uid.nullUid()));
       
        if ((numberOfEntries == ids.length -1) && passed)
        {
          if (objStore.currentState(ids[0], type) != ObjectStore.OS_UNKNOWN)
            passed = false;
          else
          {
            if (objStore.currentState(ids[1], type) != ObjectStore.OS_COMMITTED)
              passed = false;
          }
        }
        else
        {
View Full Code Here

  {
      e.printStackTrace(System.err);
      assertFailure();
  }

  ObjectStore objStore = new ObjectStore(objName);

  System.out.println("\nchecking assumed valid store.");

  boolean passed = validate(objStore);

  if (passed)
  {
      // check with a known invalid implementation

      objStore = new ObjectStore();

      System.out.println("\nchecking known invalid store.");

      if (validate(objStore))
    passed = false;
View Full Code Here

public class AllObjUidsTest extends Test
{

    public void run (String[] args)
    {
  ObjectStore objStore = TxControl.getStore();
  boolean passed = false;
  InputObjectState ios = new InputObjectState();
  String type = "/StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction/ArjunaMSXAAtomicAction";

  for (int i = 0; i < args.length; i++)
  {
      if (args[i].equals("-help"))
      {
    System.err.println("Usage: [-help] [-type <type name>]");

    System.exit(0);
      }

      if (args[i].equals("-type"))
      {
    type = args[i+1];

    objStore = new ObjectStore();
      }
  }

  try
  {
      if (objStore.allObjUids(type, ios, ObjectStore.OS_UNKNOWN))
      {
    Uid id = new Uid(Uid.nullUid());

    do
    {
        try
        {
      id.unpack(ios);
        }
        catch (Exception ex)
        {
      id = Uid.nullUid();
        }

        if (id.notEquals(Uid.nullUid()))
      System.err.println("Got UNKNOWN "+id);

        passed = true;

    } while (id.notEquals(Uid.nullUid()));
      }

      System.err.println("\n");

      if (objStore.allObjUids(type, ios, ObjectStore.OS_COMMITTED))
      {
    Uid id = new Uid(Uid.nullUid());

    do
    {
        try
        {
      id.unpack(ios);
        }
        catch (Exception ex)
        {
      id = Uid.nullUid();
        }

        if (id.notEquals(Uid.nullUid()))
      System.err.println("Got COMMITTED "+id);

        passed = true;

    } while (id.notEquals(Uid.nullUid()));
      }

      System.err.println("\n");

      if (objStore.allObjUids(type, ios, ObjectStore.OS_UNCOMMITTED))
      {
    Uid id = new Uid(Uid.nullUid());

    do
    {
View Full Code Here

  Thread[] t = new Thread[threads];

  System.setProperty("com.arjuna.ats.internal.arjuna.objectstore.cacheStore.size", cacheSize);

  ObjectStore store = new ObjectStore(ArjunaNames.Implementation_ObjectStore_CacheStore());

  long stime = Calendar.getInstance().getTime().getTime();

  for (int i = 0; (i < threads) && passed; i++)
  {
      try
      {
    t[i] = new ThreadWriter(store);

    t[i].start();
      }
      catch (Exception ex)
      {
    ex.printStackTrace();

    passed = false;
      }
  }

  for (int j = 0; j < threads; j++)
  {
      try
      {
    t[j].join();

    passed = passed && ((ThreadWriter) t[j]).passed;
      }
      catch (Exception ex)
      {
      }
  }

  long ftime = Calendar.getInstance().getTime().getTime();
  long timeTaken = ftime - stime;

  try
  {
      store.sync();
  }
  catch (Exception ex)
  {
  }
View Full Code Here

  public static void main (String[] args)
  {
    System.setProperty(Environment.OBJECTSTORE_TYPE, ArjunaNames.Implementation_ObjectStore_ActionLogStore().stringForm());
    System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "10000");
   
    ObjectStore objStore = TxControl.getStore();
    final int numberOfTransactions = 1000;
    final Uid[] ids = new Uid[numberOfTransactions];
    final int fakeData = 0xdeedbaaf;
    final String type = "/StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction/LogStoreRecoveryTest";
   
    for (int i = 0; i < numberOfTransactions; i++)
    {
      OutputObjectState dummyState = new OutputObjectState();
     
      try
      {
        dummyState.packInt(fakeData);     
        ids[i] = new Uid();
        objStore.write_committed(ids[i], type, dummyState);
      }
      catch (final Exception ex)
      {
        ex.printStackTrace();
      }
    }
   
    /*
     * Remove 50% of the entries, simulating a crash during
     * normal execution.
     *
     * Q: why not just write 50% in the first place?
     * A: because we will extend this test to allow the recovery
     *    system to run in between writing and removing.
     */
   
    for (int i = 0; i < numberOfTransactions / 2; i++)
    {
      try
      {
        objStore.remove_committed(ids[i], type);
      }
      catch (final Exception ex)
      {
        ex.printStackTrace();
      }
    }
   
    try
    {
      /*
       * Give the purger thread a chance to run and delete
       * the entries we've "removed" (really only marked as
       * being removable.)
       */
     
      Thread.sleep(12000);
    }
    catch (final Exception ex)
    {
    }
   
    /*
     * Now get a list of entries to work on.
     */
   
    InputObjectState ios = new InputObjectState();
    boolean passed = true;
   
    try
    {
      if (objStore.allObjUids(type, ios, ObjectStore.OS_UNKNOWN))
      {
        Uid id = new Uid(Uid.nullUid());
        int numberOfEntries = 0;
       
        do
View Full Code Here

public class LogMoveTest
{
    public static void main (String[] args)
    {
        ObjectStore os = TxControl.getStore();
        OutputObjectState fluff = new OutputObjectState();
        Uid kungfuTx = new Uid();
        boolean outcome = false;
        final String tn = new AtomicAction().type();

        try
        {
            kungfuTx.pack(fluff);

            System.err.println("Creating dummy log");
           
            os.write_committed(kungfuTx, tn, fluff);

            if (os.currentState(kungfuTx, tn) == ObjectStore.OS_COMMITTED)
            {
                System.err.println("Wrote dummy transaction "+kungfuTx);

                System.setProperty(RecoveryEnvironment.EXPIRY_SCAN_INTERVAL, "1");
                System.setProperty(Environment.PERIODIC_RECOVERY_PERIOD, "8000000");
               
                RecoveryManager manager = RecoveryManager
                        .manager(RecoveryManager.DIRECT_MANAGEMENT);

                manager.scan();
               
                try
                {
                   Thread.sleep(3600000);
                }
                catch (final Exception ex)
                {                 
                }
               
                manager.scan();
               
                if (os.currentState(kungfuTx, tn) == ObjectStore.OS_COMMITTED)
                    System.err.println("Transaction log not moved!");
                else
                {
                    System.err.println("Transaction log moved!");
                   
View Full Code Here

TOP

Related Classes of com.arjuna.ats.arjuna.objectstore.ObjectStore

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.