Search in sources :

Example 76 with InputObjectState

use of com.arjuna.ats.arjuna.state.InputObjectState 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 77 with InputObjectState

use of com.arjuna.ats.arjuna.state.InputObjectState 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 78 with InputObjectState

use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.

the class ActionStatusService method getOsStatus.

/**
 * Obtains the status for the specified transaction Uid when
 * the transaction type is unknown.
 */
private int getOsStatus(Uid tranUid) {
    int action_status = ActionStatus.INVALID;
    Vector matchingUidVector = new Vector();
    Vector matchingUidTypeVector = new Vector();
    try {
        InputObjectState types = new InputObjectState();
        // find all types
        if (_recoveryStore.allTypes(types)) {
            String theTypeName = null;
            boolean endOfList = false;
            while (!endOfList) {
                // extract a type
                theTypeName = types.unpackString();
                if (theTypeName.compareTo("") == 0) {
                    endOfList = true;
                } else {
                    InputObjectState uids = new InputObjectState();
                    boolean endOfUids = false;
                    if (_recoveryStore.allObjUids(theTypeName, uids)) {
                        Uid theUid = null;
                        while (!endOfUids) {
                            // extract a uid
                            theUid = UidHelper.unpackFrom(uids);
                            if (theUid.equals(Uid.nullUid())) {
                                endOfUids = true;
                            } else if (theUid.equals(tranUid)) {
                                // add to vector
                                matchingUidVector.addElement(tranUid);
                                matchingUidTypeVector.addElement(theTypeName);
                                tsLogger.i18NLogger.info_recovery_ActionStatusService_4(tranUid);
                            }
                        }
                    } else {
                        // Errors contacting recovery store for the list of uids it has for a type so return INVALID state
                        return action_status;
                    }
                }
            }
        } else {
            // Errors contacting recovery store for the list of types it holds so return INVALID state
            return action_status;
        }
    } catch (Exception ex) {
        tsLogger.i18NLogger.warn_recovery_ActionStatusService_5(tranUid, ex);
        // Read invalid data from the objectstore so return INVALID state
        return action_status;
    }
    int uidVectorSize = matchingUidVector.size();
    int first_index = 0;
    if (uidVectorSize == 0) {
        // no state means aborted because of presumed abort rules
        action_status = ActionStatus.ABORTED;
    } else if (uidVectorSize == 1) {
        Uid uid = (Uid) matchingUidVector.get(first_index);
        String typeName = (String) matchingUidTypeVector.get(first_index);
        action_status = getObjectStoreStatus(uid, typeName);
    } else if (uidVectorSize > 1) {
        // find root of hierarchy
        Uid rootUid = (Uid) matchingUidVector.get(first_index);
        String rootTypeName = (String) matchingUidTypeVector.get(first_index);
        for (int index = first_index + 1; index < uidVectorSize; index++) {
            String typeName = (String) matchingUidTypeVector.get(index);
            if (typeName.length() < rootTypeName.length()) {
                rootTypeName = typeName;
                rootUid = (Uid) matchingUidVector.get(index);
            }
        }
        action_status = getObjectStoreStatus(rootUid, rootTypeName);
    }
    return action_status;
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) Uid(com.arjuna.ats.arjuna.common.Uid) Vector(java.util.Vector) IOException(java.io.IOException)

Example 79 with InputObjectState

use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.

the class HornetqJournalStore method read_committed.

/**
 * Read the object's committed state.
 *
 * @param uid  The object to work on.
 * @param typeName The type of the object to work on.
 * @return the state of the object.
 * @throws ObjectStoreException if things go wrong.
 */
public InputObjectState read_committed(Uid uid, String typeName) throws ObjectStoreException {
    RecordInfo record = getContentForType(typeName).get(uid);
    if (record == null) {
        return null;
    }
    // not too much of an issue as log reads are done for recovery only.
    try {
        InputBuffer inputBuffer = new InputBuffer(record.data);
        UidHelper.unpackFrom(inputBuffer);
        inputBuffer.unpackString();
        return new InputObjectState(uid, typeName, inputBuffer.unpackBytes());
    } catch (Exception e) {
        throw new ObjectStoreException(e);
    }
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) RecordInfo(org.apache.activemq.artemis.core.journal.RecordInfo) InputBuffer(com.arjuna.ats.arjuna.state.InputBuffer) IOException(java.io.IOException) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException)

Example 80 with InputObjectState

use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.

the class LogStore method allObjUids.

public final InputObjectState allObjUids() throws ObjectStoreException {
    OutputObjectState state = new OutputObjectState();
    Iterator<Uid> iter = _ids.keySet().iterator();
    try {
        while (iter.hasNext()) {
            UidHelper.packInto(iter.next(), state);
        }
        // don't forget to null terminate
        UidHelper.packInto(Uid.nullUid(), state);
    } catch (final IOException ex) {
        throw new ObjectStoreException(ex);
    }
    return new InputObjectState(state);
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) IOException(java.io.IOException)

Aggregations

InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)133 Uid (com.arjuna.ats.arjuna.common.Uid)83 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)55 Test (org.junit.Test)47 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)42 IOException (java.io.IOException)30 RecoveryStore (com.arjuna.ats.arjuna.objectstore.RecoveryStore)23 ObjectStoreEnvironmentBean (com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean)17 XidImple (com.arjuna.ats.jta.xa.XidImple)9 XAException (javax.transaction.xa.XAException)9 ArrayList (java.util.ArrayList)8 ParticipantStore (com.arjuna.ats.arjuna.objectstore.ParticipantStore)7 Xid (javax.transaction.xa.Xid)6 SubordinateAtomicAction (com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.jca.SubordinateAtomicAction)5 Date (java.util.Date)5 Vector (java.util.Vector)5 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)4 HashedActionStore (com.arjuna.ats.internal.arjuna.objectstore.HashedActionStore)4 NullActionStore (com.arjuna.ats.internal.arjuna.objectstore.NullActionStore)4 TransactionImple (com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple)4