Search in sources :

Example 81 with ObjectStoreException

use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.

the class ATParticipantRecoveryModule method doRecoverParticipant.

private void doRecoverParticipant(Uid recoverUid) {
    if (RecoveryLogger.logger.isDebugEnabled()) {
        RecoveryLogger.logger.debug("participant type is " + _participantType + " uid is " + recoverUid.toString());
    }
    // we don't need to use a lock here because we only attempt the read
    // when the uid is inactive which means it cannto be pulled out form under our
    // feet at commit. uniqueness of uids also means we can't be foiled by a reused
    // uid.
    XTSATRecoveryManager recoveryManager = XTSATRecoveryManager.getRecoveryManager();
    if (!recoveryManager.isParticipantPresent(recoverUid)) {
        // an application recovery module so we need to load it
        try {
            // retrieve the data for the participant
            InputObjectState inputState = _recoveryStore.read_committed(recoverUid, _participantType);
            if (inputState != null) {
                try {
                    String participantRecordClazzName = inputState.unpackString();
                    try {
                        // create a participant engine instance and tell it to recover itself
                        Class participantRecordClazz = Class.forName(participantRecordClazzName);
                        ATParticipantRecoveryRecord participantRecord = (ATParticipantRecoveryRecord) participantRecordClazz.newInstance();
                        participantRecord.restoreState(inputState);
                        // ok, now insert into recovery map if needed
                        XTSATRecoveryManager.getRecoveryManager().addParticipantRecoveryRecord(recoverUid, participantRecord);
                    } catch (ClassNotFoundException cnfe) {
                        // oh boy, not supposed to happen -- n.b. either the user deployed 1.0
                        // last time and 1.1 this time or vice versa or something is rotten in
                        // the state of Danmark
                        RecoveryLogger.i18NLogger.error_participant_at_ATParticipantRecoveryModule_4(participantRecordClazzName, recoverUid, cnfe);
                    } catch (InstantiationException ie) {
                        // this is also worrying, log an error
                        RecoveryLogger.i18NLogger.error_participant_at_ATParticipantRecoveryModule_5(participantRecordClazzName, recoverUid, ie);
                    } catch (IllegalAccessException iae) {
                        // this is another configuration problem, log an error
                        RecoveryLogger.i18NLogger.error_participant_at_ATParticipantRecoveryModule_5(participantRecordClazzName, recoverUid, iae);
                    }
                } catch (IOException ioe) {
                    // hmm, record corrupted? log this as a warning
                    RecoveryLogger.i18NLogger.error_participant_at_ATParticipantRecoveryModule_6(recoverUid, ioe);
                }
            } else {
                // hmm, it ought not to be able to disappear unless the recovery manager knows about it
                // this is an error!
                RecoveryLogger.i18NLogger.error_participant_at_ATParticipantRecoveryModule_7(recoverUid);
            }
        } catch (ObjectStoreException ose) {
            // if the object store is not working this is serious
            RecoveryLogger.i18NLogger.error_participant_at_ATParticipantRecoveryModule_8(recoverUid, ose);
        }
    }
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) IOException(java.io.IOException)

Example 82 with ObjectStoreException

use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.

the class XTSBARecoveryManagerImple method writeParticipantRecoveryRecord.

/**
 * save the supplied participant recovery record to persistent storage
 *
 * @param participantRecoveryRecord
 */
public boolean writeParticipantRecoveryRecord(BAParticipantRecoveryRecord participantRecoveryRecord) {
    OutputObjectState oos = new OutputObjectState();
    // create an instancde to load the rest of the participant specific data
    try {
        oos.packString(participantRecoveryRecord.getClass().getCanonicalName());
    } catch (IOException ioe) {
        RecoveryLogger.i18NLogger.warn_participant_ba_XTSBARecoveryModule_1(participantRecoveryRecord.getId(), ioe);
        return false;
    }
    if (participantRecoveryRecord.saveState(oos)) {
        Uid uid = new Uid();
        try {
            txLog.write_committed(uid, type, oos);
            // we need to be able to identify the uid from the participant id
            // in order to delete it later
            uidMap.put(participantRecoveryRecord.getId(), uid);
            return true;
        } catch (ObjectStoreException ose) {
            RecoveryLogger.i18NLogger.warn_participant_ba_XTSBARecoveryModule_1(participantRecoveryRecord.getId(), ose);
        }
    }
    return false;
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) IOException(java.io.IOException)

Example 83 with ObjectStoreException

use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.

the class ATCoordinatorRecoveryModule method periodicWorkFirstPass.

/**
 * This is called periodically by the RecoveryManager
 */
public void periodicWorkFirstPass() {
    // Transaction type
    boolean ACCoordinators = false;
    // uids per transaction type
    InputObjectState acc_uids = new InputObjectState();
    try {
        if (RecoveryLogger.logger.isDebugEnabled()) {
            RecoveryLogger.logger.debug("StatusModule: first pass ");
        }
        ACCoordinators = _recoveryStore.allObjUids(_transactionType, acc_uids);
    } catch (ObjectStoreException ex) {
        RecoveryLogger.i18NLogger.warn_coordinator_at_ATCoordinatorRecoveryModule_1(ex);
    }
    if (ACCoordinators) {
        _transactionUidVector = processTransactions(acc_uids);
    }
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException)

Example 84 with ObjectStoreException

use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.

the class XTSATRecoveryManagerImple method deleteParticipantRecoveryRecord.

/**
 * remove any participant recovery record with the supplied id from persistent storage
 * @param id the id of the participant whose recovery details are being deleted
 */
public boolean deleteParticipantRecoveryRecord(String id) {
    Uid uid = uidMap.get(id);
    if (uid != null) {
        try {
            txLog.remove_committed(uid, type);
            uidMap.remove(id);
            return true;
        } catch (ObjectStoreException ose) {
            RecoveryLogger.i18NLogger.warn_participant_at_XTSATRecoveryModule_2(uid, id, ose);
        }
    }
    return false;
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException)

Example 85 with ObjectStoreException

use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.

the class XTSATRecoveryManagerImple method writeParticipantRecoveryRecord.

/**
 * save the supplied participant recovery record to persistent storage
 *
 * @param participantRecoveryRecord
 */
public boolean writeParticipantRecoveryRecord(ATParticipantRecoveryRecord participantRecoveryRecord) {
    OutputObjectState oos = new OutputObjectState();
    // create an instancde to load the rest of the participant specific data
    try {
        oos.packString(participantRecoveryRecord.getClass().getCanonicalName());
    } catch (IOException ioe) {
        RecoveryLogger.i18NLogger.warn_participant_at_XTSATRecoveryModule_1(participantRecoveryRecord.getId(), ioe);
        return false;
    }
    if (participantRecoveryRecord.saveState(oos)) {
        Uid uid = new Uid();
        try {
            txLog.write_committed(uid, type, oos);
            // we need to be able to identify the uid from the participant id
            // in order to delete it later
            uidMap.put(participantRecoveryRecord.getId(), uid);
            return true;
        } catch (ObjectStoreException ose) {
            RecoveryLogger.i18NLogger.warn_participant_at_XTSATRecoveryModule_1(participantRecoveryRecord.getId(), ose);
        }
    }
    return false;
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) IOException(java.io.IOException)

Aggregations

ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)87 IOException (java.io.IOException)44 Uid (com.arjuna.ats.arjuna.common.Uid)35 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)34 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)23 File (java.io.File)11 Connection (java.sql.Connection)9 PreparedStatement (java.sql.PreparedStatement)9 SQLException (java.sql.SQLException)9 NamingException (javax.naming.NamingException)9 Enumeration (java.util.Enumeration)8 RecoveryStore (com.arjuna.ats.arjuna.objectstore.RecoveryStore)6 FileNotFoundException (java.io.FileNotFoundException)5 ResultSet (java.sql.ResultSet)5 ArrayList (java.util.ArrayList)5 ParticipantStore (com.arjuna.ats.arjuna.objectstore.ParticipantStore)4 XidImple (com.arjuna.ats.jta.xa.XidImple)4 RandomAccessFile (java.io.RandomAccessFile)3 SyncFailedException (java.io.SyncFailedException)3 Statement (java.sql.Statement)3