Search in sources :

Example 1 with OTSAbstractRecord

use of com.arjuna.ArjunaOTS.OTSAbstractRecord in project narayana by jbosstm.

the class ExtendedResourceRecord method shouldAdd.

public boolean shouldAdd(AbstractRecord absRec) {
    boolean result = false;
    OTSAbstractRecord resHandle = otsRecord();
    if ((resHandle != null) && !_endpointFailed) {
        OTSAbstractRecord rec = otsRecord(absRec);
        if (rec != null) {
            try {
                result = resHandle.shouldAdd(rec);
            } catch (OBJECT_NOT_EXIST ex) {
            // This is expected to happen whenever a resource has gone away, for example during a crash or if it has exited the 2PC process early by returning XA_RDONLY out of prepare
            } catch (Exception e) {
                _endpointFailed = true;
                jtsLogger.i18NLogger.warn_resources_errgenerr("ExtendedResourceRecord.shouldAdd", e);
            }
            rec = null;
        }
    }
    resHandle = null;
    return result;
}
Also used : OBJECT_NOT_EXIST(org.omg.CORBA.OBJECT_NOT_EXIST) OTSAbstractRecord(com.arjuna.ArjunaOTS.OTSAbstractRecord) SystemException(org.omg.CORBA.SystemException) IOException(java.io.IOException)

Example 2 with OTSAbstractRecord

use of com.arjuna.ArjunaOTS.OTSAbstractRecord in project narayana by jbosstm.

the class ExtendedResourceRecord method doSave.

public boolean doSave() {
    if (_restored)
        return true;
    switch(// check cached value first
    _doSave) {
        case -1:
            // not cached yet
            break;
        case 0:
            return false;
        case 1:
            return true;
        default:
            break;
    }
    OTSAbstractRecord resHandle = otsRecord();
    boolean save = true;
    try {
        if ((resHandle != null) && !_endpointFailed)
            save = resHandle.saveRecord();
    } catch (Exception e) {
        // just to be on the safe side!
        save = true;
        _endpointFailed = true;
        jtsLogger.i18NLogger.warn_resources_errsavefail("ExtendedResourceRecord.doSave", Boolean.toString(save));
    }
    resHandle = null;
    _doSave = (save ? 1 : 0);
    return save;
}
Also used : OTSAbstractRecord(com.arjuna.ArjunaOTS.OTSAbstractRecord) SystemException(org.omg.CORBA.SystemException) IOException(java.io.IOException)

Example 3 with OTSAbstractRecord

use of com.arjuna.ArjunaOTS.OTSAbstractRecord in project narayana by jbosstm.

the class ExtendedResourceRecord method merge.

public void merge(AbstractRecord absRec) {
    OTSAbstractRecord resHandle = otsRecord();
    if (resHandle != null) {
        OTSAbstractRecord rec = otsRecord(absRec);
        if (rec != null) {
            try {
                resHandle.merge(rec);
            } catch (OBJECT_NOT_EXIST ex) {
            } catch (Exception e) {
                jtsLogger.i18NLogger.warn_resources_errgenerr("ExtendedResourceRecord.merge", e);
            }
            rec = null;
        }
    }
    resHandle = null;
}
Also used : OBJECT_NOT_EXIST(org.omg.CORBA.OBJECT_NOT_EXIST) OTSAbstractRecord(com.arjuna.ArjunaOTS.OTSAbstractRecord) SystemException(org.omg.CORBA.SystemException) IOException(java.io.IOException)

Example 4 with OTSAbstractRecord

use of com.arjuna.ArjunaOTS.OTSAbstractRecord in project narayana by jbosstm.

the class ExtendedResourceRecord method alter.

public void alter(AbstractRecord absRec) {
    OTSAbstractRecord resHandle = otsRecord();
    if (resHandle != null) {
        OTSAbstractRecord rec = otsRecord(absRec);
        if (rec != null) {
            try {
                resHandle.alter(rec);
            } catch (OBJECT_NOT_EXIST ex) {
            } catch (Exception e) {
                jtsLogger.i18NLogger.warn_resources_errgenerr("ExtendedResourceRecord.alter", e);
            }
            rec = null;
        }
    }
    resHandle = null;
}
Also used : OBJECT_NOT_EXIST(org.omg.CORBA.OBJECT_NOT_EXIST) OTSAbstractRecord(com.arjuna.ArjunaOTS.OTSAbstractRecord) SystemException(org.omg.CORBA.SystemException) IOException(java.io.IOException)

Example 5 with OTSAbstractRecord

use of com.arjuna.ArjunaOTS.OTSAbstractRecord in project narayana by jbosstm.

the class ArjunaTransactionImple method createOTSRecord.

protected final AbstractRecord createOTSRecord(boolean propagate, Resource resource, Coordinator coord, Uid recCoordUid) {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ArjunaTransactionImple::createOTSRecord for " + get_uid());
    }
    /*
		 * If the resource is an ArjunaOTS.OTSAbstractRecord or an
		 * ArjunaOTS.ArjunaSubtranAwareResource then we can do better record
		 * manipulation, and proper nested actions.
		 *
		 * Based on the type of resource we create the right abstract record to
		 * handle it, rather than a single abstract record which switches
		 * protocols internally.
		 */
    ArjunaSubtranAwareResource absRec = null;
    AbstractRecord corbaRec = null;
    if (resource != null) {
        try {
            absRec = com.arjuna.ArjunaOTS.ArjunaSubtranAwareResourceHelper.narrow(resource);
            if (absRec == null)
                throw new BAD_PARAM(0, CompletionStatus.COMPLETED_NO);
        } catch (Exception e) {
            // can't be an ArjunaOTS.ArjunaSubtranAwareResource
            absRec = null;
        }
    }
    if (absRec == null) {
        corbaRec = new ResourceRecord(propagate, resource, coord, recCoordUid, this);
    } else {
        Uid u = null;
        OTSAbstractRecord otsRec;
        try {
            otsRec = com.arjuna.ArjunaOTS.OTSAbstractRecordHelper.narrow(absRec);
            if (otsRec == null)
                throw new BAD_PARAM(0, CompletionStatus.COMPLETED_NO);
        } catch (Exception e) {
            otsRec = null;
        }
        if (otsRec != null) {
            try {
                u = new Uid(otsRec.uid());
            } catch (Exception e) {
                u = null;
            }
            if (u == null) {
                jtsLogger.i18NLogger.warn_orbspecific_coordinator_uidfail("ArjunaTransactionImple.createOTSRecord");
            }
        }
        if (u == null)
            u = new Uid();
        corbaRec = new ExtendedResourceRecord(propagate, u, absRec, coord, recCoordUid, this);
        otsRec = null;
        absRec = null;
        u = null;
    }
    return corbaRec;
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) ExtendedResourceRecord(com.arjuna.ats.internal.jts.resources.ExtendedResourceRecord) ArjunaSubtranAwareResource(com.arjuna.ArjunaOTS.ArjunaSubtranAwareResource) OTSAbstractRecord(com.arjuna.ArjunaOTS.OTSAbstractRecord) OTSAbstractRecord(com.arjuna.ArjunaOTS.OTSAbstractRecord) AbstractRecord(com.arjuna.ats.arjuna.coordinator.AbstractRecord) BAD_PARAM(org.omg.CORBA.BAD_PARAM) ResourceRecord(com.arjuna.ats.internal.jts.resources.ResourceRecord) ExtendedResourceRecord(com.arjuna.ats.internal.jts.resources.ExtendedResourceRecord) SystemException(org.omg.CORBA.SystemException)

Aggregations

OTSAbstractRecord (com.arjuna.ArjunaOTS.OTSAbstractRecord)10 SystemException (org.omg.CORBA.SystemException)10 IOException (java.io.IOException)9 OBJECT_NOT_EXIST (org.omg.CORBA.OBJECT_NOT_EXIST)6 ArjunaSubtranAwareResource (com.arjuna.ArjunaOTS.ArjunaSubtranAwareResource)2 Uid (com.arjuna.ats.arjuna.common.Uid)1 AbstractRecord (com.arjuna.ats.arjuna.coordinator.AbstractRecord)1 ExtendedResourceRecord (com.arjuna.ats.internal.jts.resources.ExtendedResourceRecord)1 ResourceRecord (com.arjuna.ats.internal.jts.resources.ResourceRecord)1 BAD_PARAM (org.omg.CORBA.BAD_PARAM)1