Search in sources :

Example 16 with RecoveryStore

use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.

the class ObjectStoreMonitor method main.

@SuppressWarnings("unchecked")
public static void main(String[] args) {
    String root = null;
    for (int i = 0; i < args.length; i++) {
        if (args[i].compareTo("-help") == 0) {
            usage();
            System.exit(0);
        } else {
            if (args[i].compareTo("-root") == 0) {
                root = args[i + 1];
                i++;
                arjPropertyManager.getObjectStoreEnvironmentBean().setLocalOSRoot(root);
            } else {
                System.out.println("Unknown option " + args[i]);
                usage();
                System.exit(0);
            }
        }
    }
    try {
        RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
        InputObjectState types = new InputObjectState();
        if (recoveryStore.allTypes(types)) {
            String theName = null;
            int count = 0;
            try {
                boolean endOfList = false;
                while (!endOfList) {
                    theName = types.unpackString();
                    if (theName.compareTo("") == 0)
                        endOfList = true;
                    else {
                        count++;
                        System.out.println(count + ": " + theName);
                        InputObjectState uids = new InputObjectState();
                        if (recoveryStore.allObjUids(theName, uids)) {
                            Uid theUid = new Uid(Uid.nullUid());
                            try {
                                boolean endOfUids = false;
                                while (!endOfUids) {
                                    theUid = UidHelper.unpackFrom(uids);
                                    if (theUid.equals(Uid.nullUid()))
                                        endOfUids = true;
                                    else {
                                        System.out.print("\t" + theUid + " state is ");
                                        System.out.print(StateStatus.stateStatusString(recoveryStore.currentState(theUid, theName)));
                                        System.out.println();
                                    }
                                }
                            } catch (Exception e) {
                            // end of uids!
                            }
                        }
                        System.out.println();
                    }
                }
            } catch (Exception e) {
                System.err.println(e);
            // end of list!
            }
        }
    } catch (Exception e) {
        System.err.println("Caught unexpected exception: " + e);
    }
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) Uid(com.arjuna.ats.arjuna.common.Uid) RecoveryStore(com.arjuna.ats.arjuna.objectstore.RecoveryStore)

Example 17 with RecoveryStore

use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.

the class TransactionMonitor method main.

public static void main(String[] args) {
    String root = null;
    for (int i = 0; i < args.length; i++) {
        if (args[i].compareTo("-help") == 0) {
            usage();
            System.exit(0);
        } else {
            if (args[i].compareTo("-root") == 0) {
                root = args[i + 1];
                i++;
            } else {
                System.out.println("Unknown option " + args[i]);
                usage();
                System.exit(0);
            }
        }
    }
    /* Determine transaction (BasicAction) type name */
    BasicAction ba = new BasicAction();
    String baType = ba.type();
    if (baType.charAt(0) == '/')
        baType = baType.substring(1);
    try {
        RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
        InputObjectState types = new InputObjectState();
        if (recoveryStore.allTypes(types)) {
            String theName = null;
            int count = 0;
            try {
                boolean endOfList = false;
                while (!endOfList) {
                    theName = types.unpackString();
                    if (theName.compareTo("") == 0)
                        endOfList = true;
                    else if (theName.startsWith(baType)) {
                        count++;
                        System.out.println(count + ": " + theName);
                        InputObjectState uids = new InputObjectState();
                        if (recoveryStore.allObjUids(theName, uids)) {
                            Uid theUid = new Uid(Uid.nullUid());
                            try {
                                boolean endOfUids = false;
                                while (!endOfUids) {
                                    theUid = UidHelper.unpackFrom(uids);
                                    if (theUid.equals(Uid.nullUid()))
                                        endOfUids = true;
                                    else {
                                        System.out.print("\t" + theUid + " state is ");
                                        System.out.print(StateStatus.stateStatusString(recoveryStore.currentState(theUid, theName)));
                                        System.out.println();
                                    }
                                }
                            } catch (Exception e) {
                            // end of uids!
                            }
                        }
                        System.out.println();
                    }
                }
            } catch (Exception e) {
                System.err.println(e);
            // end of list!
            }
        }
    } catch (Exception e) {
        System.err.println("Caught unexpected exception: " + e);
    }
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) Uid(com.arjuna.ats.arjuna.common.Uid) BasicAction(com.arjuna.ats.arjuna.coordinator.BasicAction) RecoveryStore(com.arjuna.ats.arjuna.objectstore.RecoveryStore)

Example 18 with RecoveryStore

use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.

the class LogStoreTest2 method test.

@Test
public void test() {
    arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreType(LogStore.class.getName());
    // the byteman script will manage this
    // System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "10000");
    RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
    final int numberOfTransactions = 1000;
    final Uid[] ids = new Uid[numberOfTransactions];
    final int fakeData = 0xdeedbaaf;
    // use unique path to prevent pollution from other tests
    final String type = "/StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction/TestTest";
    for (int i = 0; i < numberOfTransactions; i++) {
        OutputObjectState dummyState = new OutputObjectState();
        try {
            dummyState.packInt(fakeData);
            ids[i] = new Uid();
            recoveryStore.write_committed(ids[i], type, dummyState);
        } catch (final Exception ex) {
            ex.printStackTrace();
        }
    }
    try {
        recoveryStore.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 (recoveryStore.allObjUids(type, ios, StateStatus.OS_UNKNOWN)) {
            Uid id = new Uid(Uid.nullUid());
            int numberOfEntries = 0;
            do {
                try {
                    id = UidHelper.unpackFrom(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 (recoveryStore.currentState(ids[0], type) != StateStatus.OS_UNKNOWN)
                    passed = false;
                else {
                    if (recoveryStore.currentState(ids[1], type) != StateStatus.OS_COMMITTED)
                        passed = false;
                }
            } else {
                passed = false;
                System.err.println("Expected " + ids.length + " and got " + numberOfEntries);
            }
        }
    } catch (final Exception ex) {
        ex.printStackTrace();
    }
    assertTrue(passed);
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) LogStore(com.arjuna.ats.internal.arjuna.objectstore.LogStore) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) RecoveryStore(com.arjuna.ats.arjuna.objectstore.RecoveryStore) Test(org.junit.Test)

Example 19 with RecoveryStore

use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.

the class AllObjUidsTest method test.

@Test
public void test() throws IOException, ObjectStoreException {
    RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
    String type = "/StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction/DummyAtomicAction";
    InputObjectState ios = new InputObjectState();
    recoveryStore.allObjUids(type, ios, StateStatus.OS_UNKNOWN);
    Uid uid = UidHelper.unpackFrom(ios);
    assertEquals(Uid.nullUid(), uid);
    ios = new InputObjectState();
    recoveryStore.allObjUids(type, ios, StateStatus.OS_COMMITTED);
    uid = UidHelper.unpackFrom(ios);
    assertEquals(Uid.nullUid(), uid);
    ios = new InputObjectState();
    recoveryStore.allObjUids(type, ios, StateStatus.OS_UNCOMMITTED);
    uid = UidHelper.unpackFrom(ios);
    assertEquals(Uid.nullUid(), uid);
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) Uid(com.arjuna.ats.arjuna.common.Uid) RecoveryStore(com.arjuna.ats.arjuna.objectstore.RecoveryStore) Test(org.junit.Test)

Example 20 with RecoveryStore

use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.

the class LogStoreRecoveryTest method test.

@Test
public void test() {
    RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
    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();
            recoveryStore.write_committed(ids[i], type, dummyState);
        } catch (final Exception ex) {
            ex.printStackTrace();
        }
    }
    for (int i = 0; i < numberOfTransactions / 2; i++) {
        try {
            recoveryStore.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 (recoveryStore.allObjUids(type, ios, StateStatus.OS_UNKNOWN)) {
            Uid id = new Uid(Uid.nullUid());
            int numberOfEntries = 0;
            do {
                try {
                    id = UidHelper.unpackFrom(ios);
                } catch (Exception ex) {
                    id = Uid.nullUid();
                }
                if (id.notEquals(Uid.nullUid())) {
                    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 == numberOfTransactions / 2) && passed) {
                System.err.println("Would attempt recovery on " + numberOfEntries + " dead transactions.");
            } else {
                passed = false;
                System.err.println("Expected " + (numberOfTransactions / 2) + " and got " + numberOfEntries);
            }
        }
    } catch (final Exception ex) {
        ex.printStackTrace();
    }
    assertTrue(passed);
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) RecoveryStore(com.arjuna.ats.arjuna.objectstore.RecoveryStore) Test(org.junit.Test)

Aggregations

RecoveryStore (com.arjuna.ats.arjuna.objectstore.RecoveryStore)29 Uid (com.arjuna.ats.arjuna.common.Uid)27 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)23 IOException (java.io.IOException)10 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)9 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)8 Test (org.junit.Test)7 XAException (javax.transaction.xa.XAException)5 SubordinateAtomicAction (com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.jca.SubordinateAtomicAction)4 XidImple (com.arjuna.ats.jta.xa.XidImple)3 Stack (java.util.Stack)3 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)2 LogStore (com.arjuna.ats.internal.arjuna.objectstore.LogStore)2 UnexpectedConditionException (com.arjuna.ats.jta.exceptions.UnexpectedConditionException)2 UnknownHostException (java.net.UnknownHostException)2 HashSet (java.util.HashSet)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)2 HeuristicCommitException (javax.transaction.HeuristicCommitException)2 HeuristicMixedException (javax.transaction.HeuristicMixedException)2