Search in sources :

Example 71 with InputObjectState

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

the class XTSBASubordinateRecoveryModule method recreateCoordinatorCompletionParticipant.

public BusinessAgreementWithCoordinatorCompletionParticipant recreateCoordinatorCompletionParticipant(String id, byte[] recoveryState) throws Exception {
    if (id.startsWith(SubordinateBACoordinator.PARTICIPANT_PREFIX)) {
        if (!id.endsWith("_CCP")) {
            // throw an exception because we don't expect participant completion participants at present
            throw new Exception("XTSBASubordinateRecoveryModule : invalid name for subordinate WS-BA coordinator coordinator completion participant participant " + id);
        }
        // ok, try to recreate the participant
        InputObjectState ios = new InputObjectState();
        ios.setBuffer(recoveryState);
        String className = ios.unpackString();
        Class participantClass = this.getClass().getClassLoader().loadClass(className);
        BusinessAgreementWithCoordinatorCompletionParticipant participant = (BusinessAgreementWithCoordinatorCompletionParticipant) participantClass.newInstance();
        ((PersistableParticipant) participant).restoreState(ios);
        return participant;
    }
    return null;
}
Also used : BusinessAgreementWithCoordinatorCompletionParticipant(com.arjuna.wst.BusinessAgreementWithCoordinatorCompletionParticipant) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) PersistableParticipant(com.arjuna.wst.PersistableParticipant)

Example 72 with InputObjectState

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

the class ObjStoreBrowserImpl method types.

@Override
public List<String> types() {
    recordTypes.clear();
    InputObjectState types = new InputObjectState();
    try {
        if (StoreManager.getRecoveryStore().allTypes(types)) {
            String typeName;
            do {
                try {
                    typeName = types.unpackString();
                    if (!recordTypes.contains(typeName))
                        recordTypes.add(typeName);
                } catch (IOException e) {
                    typeName = "";
                }
            } while (typeName.length() != 0);
        }
    } catch (ObjectStoreException e) {
        System.out.println(e);
    }
    return recordTypes;
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) IOException(java.io.IOException)

Example 73 with InputObjectState

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

the class BasicActionFinalizer method activate.

/**
 * Overloaded version of activate -- sets up the store, performs read_state
 * followed by restore_state. The root of the object store to use is
 * specified in the <code>root</code> parameter.
 *
 * @return <code>true</code> if successful, <code>false</code>
 *         otherwise.
 */
public boolean activate(String root) {
    if (tsLogger.logger.isTraceEnabled()) {
        tsLogger.logger.trace("BasicAction::activate() for action-id " + get_uid());
    }
    boolean restored = false;
    // Set up store
    ParticipantStore aaStore = getStore();
    if (aaStore == null)
        return false;
    try {
        // Read object state
        InputObjectState oState = aaStore.read_committed(getSavingUid(), type());
        if (oState != null) {
            synchronized (this) {
                restored = restore_state(oState, ObjectType.ANDPERSISTENT);
            }
            oState = null;
        } else {
            tsLogger.i18NLogger.warn_coordinator_BasicAction_5(get_uid(), type());
            restored = false;
        }
        return restored;
    } catch (ObjectStoreException e) {
        tsLogger.logger.warn(e);
        return false;
    }
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) ParticipantStore(com.arjuna.ats.arjuna.objectstore.ParticipantStore)

Example 74 with InputObjectState

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

the class RecoveryStoreBean method allObjUids.

// RecoveryStore interface implementation
public ObjectStateWrapper allObjUids(String type, int m) throws ObjectStoreException {
    InputObjectState ios = new InputObjectState();
    boolean ok = rs.allObjUids(type, ios, m);
    return new ObjectStateWrapper(ios, ok);
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState)

Example 75 with InputObjectState

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

the class OTM method getTransactions.

@SuppressWarnings("unchecked")
private synchronized void getTransactions(DefaultMutableTreeNode machineName) {
    removeTransactions();
    scanningNode = machineName;
    DefaultMutableTreeNode top = new DefaultMutableTreeNode(scanningNode);
    try {
        RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
        InputObjectState types = new InputObjectState();
        if (recoveryStore.allTypes(types)) {
            String fullPathName = null;
            boolean found = false;
            try {
                boolean endOfList = false;
                DefaultMutableTreeNode currentNode = null;
                DefaultMutableTreeNode currentRoot = top;
                topTran.add(currentRoot);
                while (!endOfList) {
                    fullPathName = types.unpackString();
                    if (fullPathName.compareTo("") == 0)
                        endOfList = true;
                    else {
                        found = true;
                        InputObjectState uids = new InputObjectState();
                        String nodeName = stripName(fullPathName);
                        currentNode = new DefaultMutableTreeNode(nodeName);
                        addDirectory(currentNode, fullPathName);
                        currentRoot = findRoot(top, currentNode);
                        currentRoot.add(currentNode);
                        if (recoveryStore.allObjUids(fullPathName, 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 {
                                        DefaultMutableTreeNode tranID = new DefaultMutableTreeNode(theUid.stringForm());
                                        tranID.add(new DefaultMutableTreeNode(new String("status: " + statusToString(recoveryStore.currentState(theUid, fullPathName)))));
                                        currentNode.add(tranID);
                                    }
                                }
                            } catch (Exception e) {
                            // end of uids!
                            }
                        }
                    }
                    if (!found)
                        currentRoot.add(emptyTx);
                }
            } catch (Exception e) {
            // end of list!
            }
        }
    } catch (Exception e) {
        System.err.println(e);
    }
    DefaultTreeModel model = (DefaultTreeModel) transactions.getModel();
    model.reload();
    transactions.repaint();
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) Uid(com.arjuna.ats.arjuna.common.Uid) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) RecoveryStore(com.arjuna.ats.arjuna.objectstore.RecoveryStore) UnknownHostException(java.net.UnknownHostException)

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