Search in sources :

Example 66 with InputObjectState

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

the class ExtendedResourceUnitTest method test.

@Test
public void test() throws Exception {
    DemoArjunaResource ares = new DemoArjunaResource();
    ArjunaTransactionImple tx = new ArjunaTransactionImple(null);
    ExtendedResourceRecord res1 = new ExtendedResourceRecord(false, new Uid(), ares.getReference(), null, new Uid(), tx);
    ExtendedResourceRecord res2 = new ExtendedResourceRecord(false, new Uid(), ares.getReference(), null, new Uid(), tx);
    assertTrue(res1.resourceHandle() != null);
    assertTrue(res1.value() != null);
    assertFalse(res1.propagateOnAbort());
    assertFalse(res1.propagateOnCommit());
    assertTrue(res1.order().notEquals(Uid.nullUid()));
    assertEquals(res1.typeIs(), 101);
    assertTrue(res1.order() != null);
    res1.setValue(null);
    res1.print(new PrintWriter(new ByteArrayOutputStream()));
    OutputObjectState os = new OutputObjectState();
    assertTrue(res1.save_state(os, ObjectType.ANDPERSISTENT));
    InputObjectState is = new InputObjectState(os);
    assertTrue(res1.restore_state(is, ObjectType.ANDPERSISTENT));
    assertFalse(res2.doSave());
    assertFalse(res1.shouldAdd(res2));
    assertFalse(res1.shouldAlter(res2));
    assertFalse(res1.shouldMerge(res2));
    assertFalse(res1.shouldReplace(res2));
    res1 = new ExtendedResourceRecord();
    assertTrue(res1.getRCUid().notEquals(res2.getRCUid()));
    res1.alter(res2);
    res1.merge(res2);
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) ExtendedResourceRecord(com.arjuna.ats.internal.jts.resources.ExtendedResourceRecord) DemoArjunaResource(com.hp.mwtests.ts.jts.orbspecific.resources.DemoArjunaResource) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 67 with InputObjectState

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

the class BusinessAgreementWithCoordinatorCompletionStub method restoreState.

public boolean restoreState(final InputObjectState ios) {
    try {
        final String id = ios.unpackString();
        final String eprValue = ios.unpackString();
        final XMLStreamReader reader = SoapUtils.getXMLStreamReader(new StringReader(eprValue));
        StreamHelper.checkNextStartTag(reader, QNAME_BACCWS_PARTICIPANT);
        String eprefText = reader.getElementText();
        StreamSource source = new StreamSource(new StringReader(eprefText));
        final W3CEndpointReference endpointReference = new W3CEndpointReference(source);
        String ns = ios.unpackString();
        final String localPart = ios.unpackString();
        String prefix = ios.unpackString();
        if ("".equals(ns)) {
            ns = null;
        }
        if ("".equals(prefix)) {
            prefix = null;
        }
        QName statename = new QName(ns, localPart, prefix);
        State state = State.toState11(statename);
        // if we already have an engine from a previous recovery scan or because
        // we had a heuristic outcome then reuse it with luck it will have been committed
        // or aborted between the last scan and this one
        // note that whatever happens it will not have been removed from the table
        // because it is marked as recovered
        participant = (CoordinatorCompletionCoordinatorEngine) CoordinatorCompletionCoordinatorProcessor.getProcessor().getCoordinator(id);
        if (participant == null) {
            participant = new CoordinatorCompletionCoordinatorEngine(id, endpointReference, state, true);
        }
        return true;
    } catch (final Throwable th) {
        WSTLogger.i18NLogger.error_wst11_stub_BusinessAgreementWithCoordinatorCompletionStub_3(th);
        return false;
    }
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) CoordinatorCompletionCoordinatorEngine(com.arjuna.wst11.messaging.engines.CoordinatorCompletionCoordinatorEngine) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) QName(javax.xml.namespace.QName) State(com.arjuna.webservices11.wsba.State) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) StreamSource(javax.xml.transform.stream.StreamSource) StringReader(java.io.StringReader)

Example 68 with InputObjectState

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

the class SubordinateATCoordinatorRecoveryModule method periodicWorkFirstPass.

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

Example 69 with InputObjectState

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

the class BAParticipantRecoveryModule method periodicWorkFirstPass.

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

Example 70 with InputObjectState

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

the class BAParticipantRecoveryModule 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.
    XTSBARecoveryManager recoveryManager = XTSBARecoveryManager.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);
                        BAParticipantRecoveryRecord participantRecord = (BAParticipantRecoveryRecord) participantRecordClazz.newInstance();
                        participantRecord.restoreState(inputState);
                        // ok, now insert into recovery map if needed
                        XTSBARecoveryManager.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_ba_BAParticipantRecoveryModule_4(participantRecordClazzName, recoverUid, cnfe);
                    } catch (InstantiationException ie) {
                        // this is also worrying, log an error
                        RecoveryLogger.i18NLogger.error_participant_ba_BAParticipantRecoveryModule_5(participantRecordClazzName, recoverUid, ie);
                    } catch (IllegalAccessException iae) {
                        // this is another configuration problem, log an error
                        RecoveryLogger.i18NLogger.error_participant_ba_BAParticipantRecoveryModule_5(participantRecordClazzName, recoverUid, iae);
                    }
                } catch (IOException ioe) {
                    // hmm, record corrupted? log this as a warning
                    RecoveryLogger.i18NLogger.warn_participant_ba_BAParticipantRecoveryModule_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_ba_BAParticipantRecoveryModule_7(recoverUid);
            }
        } catch (ObjectStoreException ose) {
            // if the object store is not working this is serious
            RecoveryLogger.i18NLogger.error_participant_ba_BAParticipantRecoveryModule_8(recoverUid, ose);
        }
    }
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) 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