[jboss-svn-commits] JBL Code SVN: r13616 - in labs/jbosstm/trunk: ArjunaJTA/docs/user_guide and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jul 18 17:16:53 EDT 2007
Author: mark.little at jboss.com
Date: 2007-07-18 17:16:52 -0400 (Wed, 18 Jul 2007)
New Revision: 13616
Removed:
labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/recovery/XAConnectionRecovery.java
Modified:
labs/jbosstm/trunk/ArjunaCore/docs/user_guide/FailureRecoveryGuide.doc
labs/jbosstm/trunk/ArjunaJTA/docs/user_guide/ProgrammersGuide.doc
labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java
Log:
http://jira.jboss.com/jira/browse/JBTM-97
Modified: labs/jbosstm/trunk/ArjunaCore/docs/user_guide/FailureRecoveryGuide.doc
===================================================================
(Binary files differ)
Modified: labs/jbosstm/trunk/ArjunaJTA/docs/user_guide/ProgrammersGuide.doc
===================================================================
(Binary files differ)
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java 2007-07-18 21:09:48 UTC (rev 13615)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java 2007-07-18 21:16:52 UTC (rev 13616)
@@ -64,1255 +64,1249 @@
public class XARecoveryModule implements RecoveryModule
{
-
- public static final String XARecoveryPropertyNamePrefixOld = "XAConnectionRecovery";
-
// why not in Environment?
- public static final String XARecoveryPropertyNamePrefix = "com.arjuna.ats.jta.recovery.XAResourceRecovery";
+ public static final String XARecoveryPropertyNamePrefix = "com.arjuna.ats.jta.recovery.XAResourceRecovery";
- private static final String RECOVER_ALL_NODES = "*";
+ private static final String RECOVER_ALL_NODES = "*";
- public XARecoveryModule ()
- {
- this(
- com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryResourceManagerImple.class
- .getName(), "Local XARecoveryModule");
+ public XARecoveryModule()
+ {
+ this(
+ com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryResourceManagerImple.class
+ .getName(), "Local XARecoveryModule");
- com.arjuna.ats.internal.jta.Implementations.initialise();
- }
+ com.arjuna.ats.internal.jta.Implementations.initialise();
+ }
- /**
- * @message com.arjuna.ats.internal.jta.recovery.xafirstpass {0} - first
- * pass
- * @message com.arjuna.ats.internal.jta.recovery.alluids could not get all
- * object Uids.
- * @message com.arjuna.ats.internal.jta.recovery.objstoreerror {0}
- * @message com.arjuna.ats.internal.jta.recovery.periodicfirstpass {0}
- * exception
- * @message com.arjuna.ats.internal.jta.recovery.info.firstpass {0} - first pass
- */
+ /**
+ * @message com.arjuna.ats.internal.jta.recovery.xafirstpass {0} - first
+ * pass
+ * @message com.arjuna.ats.internal.jta.recovery.alluids could not get
+ * all object Uids.
+ * @message com.arjuna.ats.internal.jta.recovery.objstoreerror {0}
+ * @message com.arjuna.ats.internal.jta.recovery.periodicfirstpass {0}
+ * exception
+ * @message com.arjuna.ats.internal.jta.recovery.info.firstpass {0} -
+ * first pass
+ */
- public void periodicWorkFirstPass ()
+ public void periodicWorkFirstPass ()
+ {
+ if (jtaLogger.loggerI18N.isInfoEnabled())
{
- if (jtaLogger.loggerI18N.isInfoEnabled())
- {
- jtaLogger.loggerI18N.info("com.arjuna.ats.internal.jta.recovery.info.firstpass",
- new Object[] { _logName});
- }
+ jtaLogger.loggerI18N.info(
+ "com.arjuna.ats.internal.jta.recovery.info.firstpass",
+ new Object[]
+ { _logName });
+ }
- _uids = new InputObjectState();
+ _uids = new InputObjectState();
- /*
- * Scan for resources in the object store.
- */
+ /*
+ * Scan for resources in the object store.
+ */
- try
+ try
+ {
+ if (!_objStore.allObjUids(_recoveryManagerClass.type(), _uids))
+ {
+ if (jtaLogger.loggerI18N.isWarnEnabled())
{
- if (!_objStore.allObjUids(_recoveryManagerClass.type(), _uids))
- {
- if (jtaLogger.loggerI18N.isWarnEnabled())
- {
- jtaLogger.loggerI18N
- .warn("com.arjuna.ats.internal.jta.recovery.alluids");
- }
- }
+ jtaLogger.loggerI18N
+ .warn("com.arjuna.ats.internal.jta.recovery.alluids");
}
- catch (ObjectStoreException e)
- {
- if (jtaLogger.loggerI18N.isWarnEnabled())
- {
- jtaLogger.loggerI18N
- .warn(
- "com.arjuna.ats.internal.jta.recovery.objstoreerror",
- e);
- }
- }
- catch (Exception e)
- {
- if (jtaLogger.loggerI18N.isWarnEnabled())
- {
- jtaLogger.loggerI18N
- .warn(
- "com.arjuna.ats.internal.jta.recovery.periodicfirstpass",
- new Object[] { _logName + ".periodicWorkFirstPass exception " },
- e);
- }
- }
+ }
}
+ catch (ObjectStoreException e)
+ {
+ if (jtaLogger.loggerI18N.isWarnEnabled())
+ {
+ jtaLogger.loggerI18N
+ .warn(
+ "com.arjuna.ats.internal.jta.recovery.objstoreerror",
+ e);
+ }
+ }
+ catch (Exception e)
+ {
+ if (jtaLogger.loggerI18N.isWarnEnabled())
+ {
+ jtaLogger.loggerI18N
+ .warn(
+ "com.arjuna.ats.internal.jta.recovery.periodicfirstpass",
+ new Object[]
+ { _logName
+ + ".periodicWorkFirstPass exception " },
+ e);
+ }
+ }
+ }
- /**
- * @message com.arjuna.ats.internal.jta.recovery.periodicsecondpass {0}
- * exception
- * @message com.arjuna.ats.internal.jta.recovery.info.secondpass {0} - second pass
- */
+ /**
+ * @message com.arjuna.ats.internal.jta.recovery.periodicsecondpass {0}
+ * exception
+ * @message com.arjuna.ats.internal.jta.recovery.info.secondpass {0} -
+ * second pass
+ */
- public void periodicWorkSecondPass ()
+ public void periodicWorkSecondPass ()
+ {
+ if (jtaLogger.logger.isInfoEnabled())
{
- if (jtaLogger.logger.isInfoEnabled())
- {
- if (jtaLogger.loggerI18N.isInfoEnabled())
- {
- jtaLogger.loggerI18N.info("com.arjuna.ats.internal.jta.recovery.info.secondpass",
- new Object[] { _logName});
- }
- }
+ if (jtaLogger.loggerI18N.isInfoEnabled())
+ {
+ jtaLogger.loggerI18N.info(
+ "com.arjuna.ats.internal.jta.recovery.info.secondpass",
+ new Object[]
+ { _logName });
+ }
+ }
- try
- {
- // do the recovery on anything from the scan in first pass
+ try
+ {
+ // do the recovery on anything from the scan in first pass
- transactionInitiatedRecovery();
+ transactionInitiatedRecovery();
- if (jtaLogger.logger.isDebugEnabled())
- {
- jtaLogger.logger.debug(DebugLevel.FUNCTIONS,
- VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CRASH_RECOVERY,
- _logName + ".transactionInitiatedRecovery completed");
- }
+ if (jtaLogger.logger.isDebugEnabled())
+ {
+ jtaLogger.logger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CRASH_RECOVERY, _logName
+ + ".transactionInitiatedRecovery completed");
+ }
- /*
- * See the comment about this routine!!
- */
+ /*
+ * See the comment about this routine!!
+ */
- resourceInitiatedRecovery();
+ resourceInitiatedRecovery();
- if (jtaLogger.logger.isDebugEnabled())
- {
- jtaLogger.logger.debug(DebugLevel.FUNCTIONS,
- VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CRASH_RECOVERY,
- _logName + ".resourceInitiatedRecovery completed");
- }
- }
- catch (Exception e)
- {
- if (jtaLogger.loggerI18N.isWarnEnabled())
- {
- jtaLogger.loggerI18N
- .warn(
- "com.arjuna.ats.internal.jta.recovery.periodicsecondpass",
- new Object[] { _logName + ".periodicWorkSecondPass exception " },
- e);
- }
- }
-
- clearAllFailures();
+ if (jtaLogger.logger.isDebugEnabled())
+ {
+ jtaLogger.logger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CRASH_RECOVERY, _logName
+ + ".resourceInitiatedRecovery completed");
+ }
}
-
- public String id ()
+ catch (Exception e)
{
- return "XARecoveryModule:" + _recoveryManagerClass;
+ if (jtaLogger.loggerI18N.isWarnEnabled())
+ {
+ jtaLogger.loggerI18N
+ .warn(
+ "com.arjuna.ats.internal.jta.recovery.periodicsecondpass",
+ new Object[]
+ { _logName
+ + ".periodicWorkSecondPass exception " },
+ e);
+ }
}
- /**
- * @param Xid
- * xid The transaction to commit/rollback.
- *
- * @return the XAResource than can be used to commit/rollback the specified
- * transaction.
- */
+ clearAllFailures();
+ }
- public XAResource getNewXAResource (Xid xid)
- {
- if (_xidScans != null)
- {
- Enumeration keys = _xidScans.keys();
+ public String id ()
+ {
+ return "XARecoveryModule:" + _recoveryManagerClass;
+ }
- while (keys.hasMoreElements())
- {
- XAResource theKey = (XAResource) keys.nextElement();
- RecoveryXids xids = (RecoveryXids) _xidScans.get(theKey);
+ /**
+ * @param Xid
+ * xid The transaction to commit/rollback.
+ *
+ * @return the XAResource than can be used to commit/rollback the
+ * specified transaction.
+ */
- if (xids.contains(xid)) return theKey;
- }
- }
-
- return null;
- }
-
- /**
- * @message com.arjuna.ats.internal.jta.recovery.constfail {0}
- * @message com.arjuna.ats.internal.jta.recovery.classloadfail {0} - could
- * not get class name for {1}
- * @message com.arjuna.ats.internal.jta.recovery.general Caught exception:
- * {0} for {1}
- * @message com.arjuna.ats.internal.jta.recovery.info.loading {0} loading {1}
- */
-
- protected XARecoveryModule (String recoveryClass, String logName)
+ public XAResource getNewXAResource (Xid xid)
+ {
+ if (_xidScans != null)
{
- _xaRecoverers = new Vector();
- _logName = logName;
+ Enumeration keys = _xidScans.keys();
- try
- {
- Class c = Thread.currentThread().getContextClassLoader().loadClass(
- recoveryClass);
+ while (keys.hasMoreElements())
+ {
+ XAResource theKey = (XAResource) keys.nextElement();
+ RecoveryXids xids = (RecoveryXids) _xidScans.get(theKey);
- _recoveryManagerClass = (XARecoveryResourceManager) c.newInstance();
- }
- catch (Exception ex)
- {
- if (jtaLogger.loggerI18N.isWarnEnabled())
- {
- jtaLogger.loggerI18N.warn(
- "com.arjuna.ats.internal.jta.recovery.constfail", ex);
- }
+ if (xids.contains(xid))
+ return theKey;
+ }
+ }
- _recoveryManagerClass = null;
- }
+ return null;
+ }
- Properties props = jtaPropertyManager.propertyManager.getProperties();
+ /**
+ * @message com.arjuna.ats.internal.jta.recovery.constfail {0}
+ * @message com.arjuna.ats.internal.jta.recovery.classloadfail {0} -
+ * could not get class name for {1}
+ * @message com.arjuna.ats.internal.jta.recovery.general Caught
+ * exception: {0} for {1}
+ * @message com.arjuna.ats.internal.jta.recovery.info.loading {0}
+ * loading {1}
+ */
- if (props != null)
- {
- Enumeration names = props.propertyNames();
+ protected XARecoveryModule(String recoveryClass, String logName)
+ {
+ _xaRecoverers = new Vector();
+ _logName = logName;
- while (names.hasMoreElements())
- {
- String propName = (String) names.nextElement();
+ try
+ {
+ Class c = Thread.currentThread().getContextClassLoader().loadClass(
+ recoveryClass);
- if (propName
- .startsWith(XARecoveryModule.XARecoveryPropertyNamePrefix) || propName
- .startsWith(XARecoveryModule.XARecoveryPropertyNamePrefixOld))
- {
- /*
- * Given the recovery string, create the class it refers to
- * and store it.
- */
+ _recoveryManagerClass = (XARecoveryResourceManager) c.newInstance();
+ }
+ catch (Exception ex)
+ {
+ if (jtaLogger.loggerI18N.isWarnEnabled())
+ {
+ jtaLogger.loggerI18N.warn(
+ "com.arjuna.ats.internal.jta.recovery.constfail", ex);
+ }
- String theClassAndParameter = jtaPropertyManager.propertyManager
- .getProperty(propName);
+ _recoveryManagerClass = null;
+ }
- // see if there is a string parameter
+ Properties props = jtaPropertyManager.propertyManager.getProperties();
- int breakPosition = theClassAndParameter
- .indexOf(BREAKCHARACTER);
+ if (props != null)
+ {
+ Enumeration names = props.propertyNames();
- String theClass = null;
- String theParameter = null;
+ while (names.hasMoreElements())
+ {
+ String propName = (String) names.nextElement();
- if (breakPosition != -1)
- {
- theClass = theClassAndParameter.substring(0,
- breakPosition);
- theParameter = theClassAndParameter
- .substring(breakPosition + 1);
- }
- else
- {
- theClass = theClassAndParameter;
- }
+ if (propName
+ .startsWith(XARecoveryModule.XARecoveryPropertyNamePrefix))
+ {
+ /*
+ * Given the recovery string, create the class it refers
+ * to and store it.
+ */
- if (jtaLogger.loggerI18N.isInfoEnabled())
- {
- if (jtaLogger.loggerI18N.isInfoEnabled())
- {
- jtaLogger.loggerI18N.info("com.arjuna.ats.internal.jta.recovery.info.loading",
- new Object[] { _logName, (theClass + ((theParameter != null) ? theParameter : ""))});
- }
- }
+ String theClassAndParameter = jtaPropertyManager.propertyManager
+ .getProperty(propName);
- if (theClass == null)
- {
- if (jtaLogger.loggerI18N.isWarnEnabled())
- {
- jtaLogger.loggerI18N
- .warn(
- "com.arjuna.ats.internal.jta.recovery.classloadfail",
- new Object[] { _logName, propName });
- }
- }
- else
- {
- try
- {
- Class c = Thread.currentThread()
- .getContextClassLoader()
- .loadClass(theClass);
- boolean newInterface = false;
+ // see if there is a string parameter
- try
- {
- XAConnectionRecovery ri = (XAConnectionRecovery) c
- .newInstance();
+ int breakPosition = theClassAndParameter
+ .indexOf(BREAKCHARACTER);
- if (theParameter != null)
- ri.initialise(theParameter);
+ String theClass = null;
+ String theParameter = null;
- _xaRecoverers.addElement(ri);
- }
- catch (ClassCastException ex)
- {
- newInterface = true;
- }
+ if (breakPosition != -1)
+ {
+ theClass = theClassAndParameter.substring(0,
+ breakPosition);
+ theParameter = theClassAndParameter
+ .substring(breakPosition + 1);
+ }
+ else
+ {
+ theClass = theClassAndParameter;
+ }
- if (newInterface)
- {
- XAResourceRecovery ri = (XAResourceRecovery) c
- .newInstance();
+ if (jtaLogger.loggerI18N.isInfoEnabled())
+ {
+ if (jtaLogger.loggerI18N.isInfoEnabled())
+ {
+ jtaLogger.loggerI18N
+ .info(
+ "com.arjuna.ats.internal.jta.recovery.info.loading",
+ new Object[]
+ {
+ _logName,
+ (theClass + ((theParameter != null) ? theParameter
+ : "")) });
+ }
+ }
- if (theParameter != null)
- ri.initialise(theParameter);
+ if (theClass == null)
+ {
+ if (jtaLogger.loggerI18N.isWarnEnabled())
+ {
+ jtaLogger.loggerI18N
+ .warn(
+ "com.arjuna.ats.internal.jta.recovery.classloadfail",
+ new Object[]
+ { _logName, propName });
+ }
+ }
+ else
+ {
+ try
+ {
+ Class c = Thread.currentThread()
+ .getContextClassLoader()
+ .loadClass(theClass);
- _xaRecoverers.addElement(ri);
- }
- }
- catch (Exception e)
- {
- if (jtaLogger.loggerI18N.isWarnEnabled())
- {
- jtaLogger.loggerI18N
- .warn(
- "com.arjuna.ats.internal.jta.recovery.general",
- new Object[] { e, theClass });
- }
- }
- }
- }
- else
- {
- if (propName.startsWith(Environment.XA_RECOVERY_NODE))
- {
- /*
- * Find the node(s) we can recover on behalf of.
- */
+ XAResourceRecovery ri = (XAResourceRecovery) c
+ .newInstance();
- String name = jtaPropertyManager.propertyManager
- .getProperty(propName);
+ if (theParameter != null)
+ ri.initialise(theParameter);
- if (_xaRecoveryNodes == null)
- _xaRecoveryNodes = new Vector();
-
- _xaRecoveryNodes.addElement(name);
- }
- }
+ _xaRecoverers.addElement(ri);
}
- }
-
- if ((_xaRecoveryNodes == null) || (_xaRecoveryNodes.size() == 0))
- {
- if (jtaLogger.loggerI18N.isInfoEnabled())
+ catch (Exception e)
{
+ if (jtaLogger.loggerI18N.isWarnEnabled())
+ {
jtaLogger.loggerI18N
- .info("com.arjuna.ats.internal.jta.recovery.noxanodes");
+ .warn(
+ "com.arjuna.ats.internal.jta.recovery.general",
+ new Object[]
+ { e, theClass });
+ }
}
+ }
}
- }
+ else
+ {
+ if (propName.startsWith(Environment.XA_RECOVERY_NODE))
+ {
+ /*
+ * Find the node(s) we can recover on behalf of.
+ */
- /**
- * @message com.arjuna.ats.internal.jta.recovery.recoveryfailed JTA failed
- * to recovery {0}; got status {1}
- * @message com.arjuna.ats.internal.jta.recovery.recoverydelayed JTA
- * recovery delayed for {0}; got status {1} so waiting for
- * coordinator driven recovery
- * @message com.arjuna.ats.internal.jta.recovery.recoveryerror Recovery
- * threw:
- * @message com.arjuna.ats.internal.jta.recovery.cannotadd Cannot add
- * resource to table: no XID value available.
- * @message com.arjuna.ats.internal.jta.recovery.unexpectedrecoveryerror
- * Unexpceted recovery error:
- * @message com.arjuna.ats.internal.jta.recovery.noxanodes No XA recovery
- * nodes specified. Will only recover saved states.
- */
+ String name = jtaPropertyManager.propertyManager
+ .getProperty(propName);
- private final boolean transactionInitiatedRecovery ()
- {
- Uid theUid = new Uid();
+ if (_xaRecoveryNodes == null)
+ _xaRecoveryNodes = new Vector();
- while (theUid.notEquals(Uid.nullUid()))
- {
- try
- {
- theUid.unpack(_uids);
+ _xaRecoveryNodes.addElement(name);
+ }
+ }
+ }
+ }
- if (theUid.notEquals(Uid.nullUid()))
- {
- /*
- * Ignore it if it isn't in the store any more. Transaction
- * probably recovered it.
- */
+ if ((_xaRecoveryNodes == null) || (_xaRecoveryNodes.size() == 0))
+ {
+ if (jtaLogger.loggerI18N.isInfoEnabled())
+ {
+ jtaLogger.loggerI18N
+ .info("com.arjuna.ats.internal.jta.recovery.noxanodes");
+ }
+ }
+ }
- if (_objStore.currentState(theUid, _recoveryManagerClass
- .type()) != ObjectStore.OS_UNKNOWN)
- {
- boolean problem = false;
- XARecoveryResource record = null;
+ /**
+ * @message com.arjuna.ats.internal.jta.recovery.recoveryfailed JTA
+ * failed to recovery {0}; got status {1}
+ * @message com.arjuna.ats.internal.jta.recovery.recoverydelayed JTA
+ * recovery delayed for {0}; got status {1} so waiting for
+ * coordinator driven recovery
+ * @message com.arjuna.ats.internal.jta.recovery.recoveryerror Recovery
+ * threw:
+ * @message com.arjuna.ats.internal.jta.recovery.cannotadd Cannot add
+ * resource to table: no XID value available.
+ * @message com.arjuna.ats.internal.jta.recovery.unexpectedrecoveryerror
+ * Unexpceted recovery error:
+ * @message com.arjuna.ats.internal.jta.recovery.noxanodes No XA
+ * recovery nodes specified. Will only recover saved states.
+ */
- try
- {
- record = _recoveryManagerClass.getResource(theUid);
+ private final boolean transactionInitiatedRecovery ()
+ {
+ Uid theUid = new Uid();
- problem = true;
+ while (theUid.notEquals(Uid.nullUid()))
+ {
+ try
+ {
+ theUid.unpack(_uids);
- switch (record.recoverable())
- {
- case XARecoveryResource.RECOVERY_REQUIRED:
- {
- if (jtaLogger.logger.isDebugEnabled())
- {
- jtaLogger.logger
- .debug(
- DebugLevel.FUNCTIONS,
- VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CRASH_RECOVERY,
- "XARecovery attempting recovery of " + theUid);
- }
+ if (theUid.notEquals(Uid.nullUid()))
+ {
+ /*
+ * Ignore it if it isn't in the store any more.
+ * Transaction probably recovered it.
+ */
- int recoveryStatus = record.recover();
+ if (_objStore.currentState(theUid, _recoveryManagerClass
+ .type()) != ObjectStore.OS_UNKNOWN)
+ {
+ boolean problem = false;
+ XARecoveryResource record = null;
- if (recoveryStatus != XARecoveryResource.RECOVERED_OK)
- {
- if (recoveryStatus == XARecoveryResource.WAITING_FOR_RECOVERY)
- {
- problem = false;
+ try
+ {
+ record = _recoveryManagerClass.getResource(theUid);
- if (jtaLogger.loggerI18N
- .isInfoEnabled())
- {
- jtaLogger.loggerI18N
- .info(
- "com.arjuna.ats.internal.jta.recovery.recoverydelayed",
- new Object[] { theUid, new Integer(
- recoveryStatus) });
- }
- }
- else
- {
- if (jtaLogger.loggerI18N
- .isWarnEnabled())
- {
- jtaLogger.loggerI18N
- .warn(
- "com.arjuna.ats.internal.jta.recovery.recoveryfailed",
- new Object[] { theUid, new Integer(
- recoveryStatus) });
- }
- }
- }
- else
- problem = false; // resource initiated
- // recovery not possible
- // (no distribution).
- }
- break;
- case XARecoveryResource.INFLIGHT_TRANSACTION:
- {
- /*
- * Transaction was inflight and between us
- * noticing it and trying to access the state,
- * it finished and removed the state.
- */
+ problem = true;
- problem = false;
- }
- break;
- case XARecoveryResource.INCOMPLETE_STATE:
- default:
- {
- if (jtaLogger.logger.isDebugEnabled())
- {
- jtaLogger.logger
- .debug(
- DebugLevel.FUNCTIONS,
- VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CRASH_RECOVERY,
- "XARecovery " + theUid + " is non-recoverable");
- }
- }
- break;
- }
- }
- catch (NullPointerException ex)
- {
- problem = true;
- }
- catch (Throwable e)
- {
- problem = true;
+ switch (record.recoverable())
+ {
+ case XARecoveryResource.RECOVERY_REQUIRED:
+ {
+ if (jtaLogger.logger.isDebugEnabled())
+ {
+ jtaLogger.logger.debug(
+ DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CRASH_RECOVERY,
+ "XARecovery attempting recovery of "
+ + theUid);
+ }
- if (jtaLogger.loggerI18N.isWarnEnabled())
- {
- jtaLogger.loggerI18N
- .warn(
- "com.arjuna.ats.internal.jta.recovery.recoveryerror",
- e);
- }
- }
+ int recoveryStatus = record.recover();
- if (problem && (record != null))
- {
- /*
- * Some error occurred which prevented the state of
- * the resource from being read from the log. Hence
- * we don't have a valid key to use to insert it
- * into the list of records to be recovered. Print a
- * warning and move on. Force recovery via the
- * administration tool. Should be a rare occurrence.
- */
+ if (recoveryStatus != XARecoveryResource.RECOVERED_OK)
+ {
+ if (recoveryStatus == XARecoveryResource.WAITING_FOR_RECOVERY)
+ {
+ problem = false;
- if (record.getXid() == null)
- {
- if (jtaLogger.loggerI18N.isWarnEnabled())
- {
- jtaLogger.loggerI18N
- .warn("com.arjuna.ats.internal.jta.recovery.cannotadd");
- }
- }
- else
- {
- addFailure(record.getXid(), record.get_uid());
- }
- }
+ if (jtaLogger.loggerI18N
+ .isInfoEnabled())
+ {
+ jtaLogger.loggerI18N
+ .info(
+ "com.arjuna.ats.internal.jta.recovery.recoverydelayed",
+ new Object[]
+ {
+ theUid,
+ new Integer(
+ recoveryStatus) });
}
+ }
+ else
+ {
+ if (jtaLogger.loggerI18N
+ .isWarnEnabled())
+ {
+ jtaLogger.loggerI18N
+ .warn(
+ "com.arjuna.ats.internal.jta.recovery.recoveryfailed",
+ new Object[]
+ {
+ theUid,
+ new Integer(
+ recoveryStatus) });
+ }
+ }
}
+ else
+ problem = false; // resource initiated
+ // recovery not possible
+ // (no distribution).
+ }
+ break;
+ case XARecoveryResource.INFLIGHT_TRANSACTION:
+ {
+ /*
+ * Transaction was inflight and between us
+ * noticing it and trying to access the state,
+ * it finished and removed the state.
+ */
+
+ problem = false;
+ }
+ break;
+ case XARecoveryResource.INCOMPLETE_STATE:
+ default:
+ {
+ if (jtaLogger.logger.isDebugEnabled())
+ {
+ jtaLogger.logger.debug(
+ DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CRASH_RECOVERY,
+ "XARecovery " + theUid
+ + " is non-recoverable");
+ }
+ }
+ break;
+ }
}
- catch (IOException e)
+ catch (NullPointerException ex)
{
- theUid = Uid.nullUid();
+ problem = true;
}
catch (Throwable e)
{
- if (jtaLogger.loggerI18N.isWarnEnabled())
- {
- jtaLogger.loggerI18N
- .warn(
- "com.arjuna.ats.internal.jta.recovery.unexpectedrecoveryerror",
- e);
- }
+ problem = true;
+
+ if (jtaLogger.loggerI18N.isWarnEnabled())
+ {
+ jtaLogger.loggerI18N
+ .warn(
+ "com.arjuna.ats.internal.jta.recovery.recoveryerror",
+ e);
+ }
}
- }
- return true;
- }
-
- /**
- * Now check for any outstanding transactions. If we didn't fail to recover
- * them, then roll them back - if they'd got through prepare we would have
- * an entry within the object store.
- *
- * Rely upon _xaRecoverers being set up properly (via properties).
- *
- * We cannot just remember the XAResourceRecords we used (if any) to cache
- * the JDBC connection information and use that since we may never have had
- * any such records!
- *
- * IMPORTANT: resourceInitiatedRecovery may rollback transactions which are
- * inflight: just because we have no entry for a transaction in the object
- * store does not mean it does not exist - it may be *about* to write its
- * intentions list. To try to reduce this probability we remember potential
- * rollback-ees at this scan, and wait for the next scan before actually
- * rolling them back.
- *
- * Note we cannot use the method that works with Transactions and
- * TransactionalObjects, of checking with original process that created the
- * transaction, because we don't know which process it was.
- *
- * @message com.arjuna.ats.internal.jta.recovery.getxaresource Caught:
- */
-
- private final boolean resourceInitiatedRecovery ()
- {
- /*
- * Now any additional connections we may need to create. Relies upon
- * information provided by the application.
- */
-
- if (_xaRecoverers.size() > 0)
- {
- for (int i = 0; i < _xaRecoverers.size(); i++)
+ if (problem && (record != null))
{
- XAResource resource = null;
+ /*
+ * Some error occurred which prevented the state
+ * of the resource from being read from the log.
+ * Hence we don't have a valid key to use to
+ * insert it into the list of records to be
+ * recovered. Print a warning and move on. Force
+ * recovery via the administration tool. Should
+ * be a rare occurrence.
+ */
- /*
- * All of this just because we deprecated XAConnectionRecovery.
- * Remove it once that class is removed.
- */
-
- if (_xaRecoverers.elementAt(i) instanceof XAConnectionRecovery)
+ if (record.getXid() == null)
+ {
+ if (jtaLogger.loggerI18N.isWarnEnabled())
{
- try
- {
- XAConnectionRecovery ri = (XAConnectionRecovery) _xaRecoverers
- .elementAt(i);
-
- while (ri.hasMoreConnections())
- {
- try
- {
- resource = ri.getConnection().getXAResource();
-
- xaRecovery(resource);
- }
- catch (Exception exp)
- {
- if (jtaLogger.loggerI18N.isWarnEnabled())
- {
- jtaLogger.loggerI18N
- .warn(
- "com.arjuna.ats.internal.jta.recovery.getxaresource",
- exp);
- }
- }
- }
- }
- catch (Exception ex)
- {
- if (jtaLogger.loggerI18N.isWarnEnabled())
- {
- jtaLogger.loggerI18N
- .warn(
- "com.arjuna.ats.internal.jta.recovery.getxaresource",
- ex);
- }
- }
+ jtaLogger.loggerI18N
+ .warn("com.arjuna.ats.internal.jta.recovery.cannotadd");
}
- else
- {
- try
- {
- XAResourceRecovery ri = (XAResourceRecovery) _xaRecoverers
- .elementAt(i);
-
- while (ri.hasMoreResources())
- {
- try
- {
- resource = ri.getXAResource();
-
- xaRecovery(resource);
- }
- catch (Exception exp)
- {
- if (jtaLogger.loggerI18N.isWarnEnabled())
- {
- jtaLogger.loggerI18N
- .warn(
- "com.arjuna.ats.internal.jta.recovery.getxaresource",
- exp);
- }
- }
- }
- }
- catch (Exception ex)
- {
- if (jtaLogger.loggerI18N.isWarnEnabled())
- {
- jtaLogger.loggerI18N
- .warn(
- "com.arjuna.ats.internal.jta.recovery.getxaresource",
- ex);
- }
- }
- }
+ }
+ else
+ {
+ addFailure(record.getXid(), record.get_uid());
+ }
}
+ }
}
-
- return true;
+ }
+ catch (IOException e)
+ {
+ theUid = Uid.nullUid();
+ }
+ catch (Throwable e)
+ {
+ if (jtaLogger.loggerI18N.isWarnEnabled())
+ {
+ jtaLogger.loggerI18N
+ .warn(
+ "com.arjuna.ats.internal.jta.recovery.unexpectedrecoveryerror",
+ e);
+ }
+ }
}
- /**
- * @message com.arjuna.ats.internal.jta.recovery.xarecovery1 {0} got XA
- * exception {1}, {2}
- * @message com.arjuna.ats.internal.jta.recovery.xarecovery2 {0} got
- * exception {1}
- * @message com.arjuna.ats.internal.jta.recovery.failedtorecover {0} -
- * failed to recover XAResource.
- * @message com.arjuna.ats.internal.jta.recovery.forgetfailed {0} - forget
- * threw: {1}
- * @message com.arjuna.ats.internal.jta.recovery.generalrecoveryerror {0} -
- * caught {1}
- * @message com.arjuna.ats.internal.jta.recovery.info.rollingback Rolling back {0}
- * @message com.arjuna.ats.internal.jta.recovery.info.notrollback Told not to rollback {0}
- */
+ return true;
+ }
- private final boolean xaRecovery (XAResource xares)
+ /**
+ * Now check for any outstanding transactions. If we didn't fail to
+ * recover them, then roll them back - if they'd got through prepare we
+ * would have an entry within the object store.
+ *
+ * Rely upon _xaRecoverers being set up properly (via properties).
+ *
+ * We cannot just remember the XAResourceRecords we used (if any) to
+ * cache the JDBC connection information and use that since we may never
+ * have had any such records!
+ *
+ * IMPORTANT: resourceInitiatedRecovery may rollback transactions which
+ * are inflight: just because we have no entry for a transaction in the
+ * object store does not mean it does not exist - it may be *about* to
+ * write its intentions list. To try to reduce this probability we
+ * remember potential rollback-ees at this scan, and wait for the next
+ * scan before actually rolling them back.
+ *
+ * Note we cannot use the method that works with Transactions and
+ * TransactionalObjects, of checking with original process that created
+ * the transaction, because we don't know which process it was.
+ *
+ * @message com.arjuna.ats.internal.jta.recovery.getxaresource Caught:
+ */
+
+ private final boolean resourceInitiatedRecovery ()
+ {
+ /*
+ * Now any additional connections we may need to create. Relies upon
+ * information provided by the application.
+ */
+
+ if (_xaRecoverers.size() > 0)
{
- if (jtaLogger.logger.isDebugEnabled())
- {
- jtaLogger.logger.debug(DebugLevel.FUNCTIONS,
- VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CRASH_RECOVERY, "xarecovery of " + xares);
- }
+ for (int i = 0; i < _xaRecoverers.size(); i++)
+ {
+ XAResource resource = null;
try
{
- Xid[] trans = null;
+ XAResourceRecovery ri = (XAResourceRecovery) _xaRecoverers
+ .elementAt(i);
+ while (ri.hasMoreResources())
+ {
try
{
- trans = xares.recover(XAResource.TMSTARTRSCAN);
+ resource = ri.getXAResource();
- if (jtaLogger.loggerI18N.isDebugEnabled())
- {
- jtaLogger.logger
- .debug(
- DebugLevel.FUNCTIONS,
- VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CRASH_RECOVERY,
- "Found " + ((trans != null) ? trans.length : 0) + " xids in doubt");
- }
+ xaRecovery(resource);
}
- catch (XAException e)
+ catch (Exception exp)
{
- if (jtaLogger.loggerI18N.isWarnEnabled())
- {
- jtaLogger.loggerI18N
- .warn(
- "com.arjuna.ats.internal.jta.recovery.xarecovery1",
- new Object[] { _logName + ".xaRecovery ", e, XAHelper
- .printXAErrorCode(e) });
- }
+ if (jtaLogger.loggerI18N.isWarnEnabled())
+ {
+ jtaLogger.loggerI18N
+ .warn(
+ "com.arjuna.ats.internal.jta.recovery.getxaresource",
+ exp);
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ if (jtaLogger.loggerI18N.isWarnEnabled())
+ {
+ jtaLogger.loggerI18N
+ .warn(
+ "com.arjuna.ats.internal.jta.recovery.getxaresource",
+ ex);
+ }
+ }
+ }
+ }
- try
- {
- xares.recover(XAResource.TMENDRSCAN);
- }
- catch (Exception e1)
- {
- }
+ return true;
+ }
- return false;
- }
+ /**
+ * @message com.arjuna.ats.internal.jta.recovery.xarecovery1 {0} got XA
+ * exception {1}, {2}
+ * @message com.arjuna.ats.internal.jta.recovery.xarecovery2 {0} got
+ * exception {1}
+ * @message com.arjuna.ats.internal.jta.recovery.failedtorecover {0} -
+ * failed to recover XAResource.
+ * @message com.arjuna.ats.internal.jta.recovery.forgetfailed {0} -
+ * forget threw: {1}
+ * @message com.arjuna.ats.internal.jta.recovery.generalrecoveryerror
+ * {0} - caught {1}
+ * @message com.arjuna.ats.internal.jta.recovery.info.rollingback
+ * Rolling back {0}
+ * @message com.arjuna.ats.internal.jta.recovery.info.notrollback Told
+ * not to rollback {0}
+ */
- RecoveryXids xidsToRecover = null;
+ private final boolean xaRecovery (XAResource xares)
+ {
+ if (jtaLogger.logger.isDebugEnabled())
+ {
+ jtaLogger.logger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CRASH_RECOVERY, "xarecovery of " + xares);
+ }
- if (_xidScans == null) _xidScans = new Hashtable();
- else
- {
- xidsToRecover = (RecoveryXids) _xidScans.get(xares);
+ try
+ {
+ Xid[] trans = null;
- if (xidsToRecover == null)
- {
- java.util.Enumeration elements = _xidScans.elements();
- boolean found = false;
+ try
+ {
+ trans = xares.recover(XAResource.TMSTARTRSCAN);
- while (elements.hasMoreElements())
- {
- xidsToRecover = (RecoveryXids) elements.nextElement();
+ if (jtaLogger.loggerI18N.isDebugEnabled())
+ {
+ jtaLogger.logger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CRASH_RECOVERY, "Found "
+ + ((trans != null) ? trans.length : 0)
+ + " xids in doubt");
+ }
+ }
+ catch (XAException e)
+ {
+ if (jtaLogger.loggerI18N.isWarnEnabled())
+ {
+ jtaLogger.loggerI18N.warn(
+ "com.arjuna.ats.internal.jta.recovery.xarecovery1",
+ new Object[]
+ { _logName + ".xaRecovery ", e,
+ XAHelper.printXAErrorCode(e) });
+ }
- if (xidsToRecover.isSameRM(xares))
- {
- found = true;
+ try
+ {
+ xares.recover(XAResource.TMENDRSCAN);
+ }
+ catch (Exception e1)
+ {
+ }
- break;
- }
- }
+ return false;
+ }
- if (!found) xidsToRecover = null;
- }
- }
+ RecoveryXids xidsToRecover = null;
- if (xidsToRecover == null)
+ if (_xidScans == null)
+ _xidScans = new Hashtable();
+ else
+ {
+ xidsToRecover = (RecoveryXids) _xidScans.get(xares);
+
+ if (xidsToRecover == null)
+ {
+ java.util.Enumeration elements = _xidScans.elements();
+ boolean found = false;
+
+ while (elements.hasMoreElements())
+ {
+ xidsToRecover = (RecoveryXids) elements.nextElement();
+
+ if (xidsToRecover.isSameRM(xares))
{
- xidsToRecover = new RecoveryXids(xares);
+ found = true;
- _xidScans.put(xares, xidsToRecover);
+ break;
}
+ }
- xidsToRecover.nextScan(trans);
+ if (!found)
+ xidsToRecover = null;
+ }
+ }
- Object[] xids = xidsToRecover.toRecover();
+ if (xidsToRecover == null)
+ {
+ xidsToRecover = new RecoveryXids(xares);
- if (xids != null)
- {
- if (jtaLogger.loggerI18N.isDebugEnabled())
- {
- jtaLogger.logger
- .debug(
- DebugLevel.FUNCTIONS,
- VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CRASH_RECOVERY,
- "Have " + xids.length + " Xids to recover on this pass.");
- }
+ _xidScans.put(xares, xidsToRecover);
+ }
- for (int j = 0; j < xids.length; j++)
- {
- boolean doForget = false;
+ xidsToRecover.nextScan(trans);
- /*
- * Check if in failure list.
- */
+ Object[] xids = xidsToRecover.toRecover();
- Uid recordUid = null;
- boolean foundTransaction = false;
+ if (xids != null)
+ {
+ if (jtaLogger.loggerI18N.isDebugEnabled())
+ {
+ jtaLogger.logger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CRASH_RECOVERY, "Have "
+ + xids.length
+ + " Xids to recover on this pass.");
+ }
- do
- {
- // is the xid known to be one that couldn't be recovered
+ for (int j = 0; j < xids.length; j++)
+ {
+ boolean doForget = false;
- recordUid = previousFailure((Xid) xids[j]);
+ /*
+ * Check if in failure list.
+ */
- if ((recordUid == null) && (foundTransaction)) break; // end
- // of
- // recovery
- // for
- // this
- // transaction
+ Uid recordUid = null;
+ boolean foundTransaction = false;
- if (recordUid == null)
- {
- /*
- * It wasn't an xid that we couldn't recover, so the
- * RM knows about it, but we don't. Therefore it may
- * have to be rolled back.
- */
+ do
+ {
+ // is the xid known to be one that couldn't be recovered
- if (jtaLogger.loggerI18N.isDebugEnabled())
- {
- jtaLogger.logger
- .debug(
- DebugLevel.FUNCTIONS,
- VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CRASH_RECOVERY,
- "Checking node name of " + ((Xid) xids[j]));
- }
+ recordUid = previousFailure((Xid) xids[j]);
- String nodeName = XAUtils
- .getXANodeName((Xid) xids[j]);
- boolean doRecovery = false;
+ if ((recordUid == null) && (foundTransaction))
+ break; // end
+ // of
+ // recovery
+ // for
+ // this
+ // transaction
- if (jtaLogger.loggerI18N.isDebugEnabled())
- {
- jtaLogger.logger.debug(DebugLevel.FUNCTIONS,
- VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CRASH_RECOVERY,
- "Node name is " + nodeName);
- }
+ if (recordUid == null)
+ {
+ /*
+ * It wasn't an xid that we couldn't recover, so
+ * the RM knows about it, but we don't.
+ * Therefore it may have to be rolled back.
+ */
- /*
- * If there is no node name but we have been told to
- * recover everything, then we can roll it back.
- */
+ if (jtaLogger.loggerI18N.isDebugEnabled())
+ {
+ jtaLogger.logger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CRASH_RECOVERY,
+ "Checking node name of "
+ + ((Xid) xids[j]));
+ }
- if ((nodeName == null) && (_xaRecoveryNodes != null) && (_xaRecoveryNodes
- .contains(RECOVER_ALL_NODES)))
- {
- if (jtaLogger.loggerI18N.isDebugEnabled())
- {
- jtaLogger.logger.debug(
- DebugLevel.FUNCTIONS,
- VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CRASH_RECOVERY,
- "Will recover this Xid (a)");
- }
+ String nodeName = XAUtils
+ .getXANodeName((Xid) xids[j]);
+ boolean doRecovery = false;
- doRecovery = true;
- }
- else
- {
- if (nodeName != null)
- {
- /*
- * Check that the node name is in our
- * recovery set or that we have been told to
- * recover everything.
- */
+ if (jtaLogger.loggerI18N.isDebugEnabled())
+ {
+ jtaLogger.logger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CRASH_RECOVERY,
+ "Node name is " + nodeName);
+ }
- if (_xaRecoveryNodes != null)
- {
- if (_xaRecoveryNodes
- .contains(RECOVER_ALL_NODES) || _xaRecoveryNodes
- .contains(nodeName))
- {
- if (jtaLogger.loggerI18N
- .isDebugEnabled())
- {
- jtaLogger.logger
- .debug(
- DebugLevel.FUNCTIONS,
- VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CRASH_RECOVERY,
- "Will recover this Xid (b)");
- }
+ /*
+ * If there is no node name but we have been
+ * told to recover everything, then we can roll
+ * it back.
+ */
- doRecovery = true;
- }
- else
- {
- if (jtaLogger.loggerI18N
- .isDebugEnabled())
- {
- jtaLogger.logger
- .debug(
- DebugLevel.FUNCTIONS,
- VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CRASH_RECOVERY,
- "Will not recover this Xid (a)");
- }
- }
- }
- else
- {
- if (jtaLogger.loggerI18N
- .isDebugEnabled())
- {
- jtaLogger.logger
- .debug(
- DebugLevel.FUNCTIONS,
- VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CRASH_RECOVERY,
- "Will not recover this Xid (b)");
- }
- }
- }
- else
- {
- if (jtaLogger.loggerI18N.isDebugEnabled())
- {
- jtaLogger.logger
- .debug(
- DebugLevel.FUNCTIONS,
- VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CRASH_RECOVERY,
- "Will not recover this Xid");
- }
- }
- }
+ if ((nodeName == null)
+ && (_xaRecoveryNodes != null)
+ && (_xaRecoveryNodes
+ .contains(RECOVER_ALL_NODES)))
+ {
+ if (jtaLogger.loggerI18N.isDebugEnabled())
+ {
+ jtaLogger.logger.debug(
+ DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CRASH_RECOVERY,
+ "Will recover this Xid (a)");
+ }
- try
- {
- if (doRecovery)
- {
- if (jtaLogger.loggerI18N.isInfoEnabled())
- {
- jtaLogger.loggerI18N.info("com.arjuna.ats.internal.jta.recovery.info.rollingback",
- new Object[] { XAHelper.xidToString((Xid) xids[j]) });
- }
-
- if (!transactionLog((Xid) xids[j])) xares
- .rollback((Xid) xids[j]);
- else
- {
- /*
- * Ignore it as the transaction system
- * will recovery it eventually.
- */
- }
- }
- else
- {
- if (jtaLogger.loggerI18N.isInfoEnabled())
- {
- jtaLogger.loggerI18N.info("com.arjuna.ats.internal.jta.recovery.info.notrollback",
- new Object[] { XAHelper.xidToString((Xid) xids[j]) });
- }
- }
- }
- catch (XAException e1)
- {
- e1.printStackTrace();
+ doRecovery = true;
+ }
+ else
+ {
+ if (nodeName != null)
+ {
+ /*
+ * Check that the node name is in our
+ * recovery set or that we have been
+ * told to recover everything.
+ */
- switch (e1.errorCode)
- {
- case XAException.XAER_RMERR:
- break;
- case XAException.XA_HEURHAZ:
- case XAException.XA_HEURCOM:
- case XAException.XA_HEURMIX:
- case XAException.XA_HEURRB:
- case XAException.XA_RBROLLBACK:
- {
- if (!doForget) // already done?
- doForget = true;
- }
- break;
- default:
- break;
- }
- }
- catch (Exception e2)
- {
- if (jtaLogger.loggerI18N.isWarnEnabled())
- {
- jtaLogger.loggerI18N
- .warn(
- "com.arjuna.ats.internal.jta.recovery.xarecovery2",
- new Object[] { _logName + ".xaRecovery ", e2 });
- }
- }
- }
- else
- {
- foundTransaction = true;
+ if (_xaRecoveryNodes != null)
+ {
+ if (_xaRecoveryNodes
+ .contains(RECOVER_ALL_NODES)
+ || _xaRecoveryNodes
+ .contains(nodeName))
+ {
+ if (jtaLogger.loggerI18N
+ .isDebugEnabled())
+ {
+ jtaLogger.logger
+ .debug(
+ DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CRASH_RECOVERY,
+ "Will recover this Xid (b)");
+ }
- /*
- * In the failures list so it may be that we just
- * need another XAResource to be able to recover
- * this.
- */
+ doRecovery = true;
+ }
+ else
+ {
+ if (jtaLogger.loggerI18N
+ .isDebugEnabled())
+ {
+ jtaLogger.logger
+ .debug(
+ DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CRASH_RECOVERY,
+ "Will not recover this Xid (a)");
+ }
+ }
+ }
+ else
+ {
+ if (jtaLogger.loggerI18N
+ .isDebugEnabled())
+ {
+ jtaLogger.logger
+ .debug(
+ DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CRASH_RECOVERY,
+ "Will not recover this Xid (b)");
+ }
+ }
+ }
+ else
+ {
+ if (jtaLogger.loggerI18N.isDebugEnabled())
+ {
+ jtaLogger.logger
+ .debug(
+ DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CRASH_RECOVERY,
+ "Will not recover this Xid");
+ }
+ }
+ }
- XARecoveryResource record = _recoveryManagerClass
- .getResource(recordUid, xares);
- int recoveryStatus = record.recover();
+ try
+ {
+ if (doRecovery)
+ {
+ if (jtaLogger.loggerI18N.isInfoEnabled())
+ {
+ jtaLogger.loggerI18N
+ .info(
+ "com.arjuna.ats.internal.jta.recovery.info.rollingback",
+ new Object[]
+ { XAHelper
+ .xidToString((Xid) xids[j]) });
+ }
- if (recoveryStatus != XARecoveryResource.RECOVERED_OK)
- {
- if (jtaLogger.loggerI18N.isWarnEnabled())
- {
- jtaLogger.loggerI18N
- .warn(
- "com.arjuna.ats.internal.jta.recovery.failedtorecover",
- new Object[] { _logName + ".xaRecovery ", new Integer(
- recoveryStatus) });
- }
- }
+ if (!transactionLog((Xid) xids[j]))
+ xares.rollback((Xid) xids[j]);
+ else
+ {
+ /*
+ * Ignore it as the transaction system
+ * will recovery it eventually.
+ */
+ }
+ }
+ else
+ {
+ if (jtaLogger.loggerI18N.isInfoEnabled())
+ {
+ jtaLogger.loggerI18N
+ .info(
+ "com.arjuna.ats.internal.jta.recovery.info.notrollback",
+ new Object[]
+ { XAHelper
+ .xidToString((Xid) xids[j]) });
+ }
+ }
+ }
+ catch (XAException e1)
+ {
+ e1.printStackTrace();
- removeFailure(record.getXid(), record.get_uid());
- }
+ switch (e1.errorCode)
+ {
+ case XAException.XAER_RMERR:
+ break;
+ case XAException.XA_HEURHAZ:
+ case XAException.XA_HEURCOM:
+ case XAException.XA_HEURMIX:
+ case XAException.XA_HEURRB:
+ case XAException.XA_RBROLLBACK:
+ {
+ if (!doForget) // already done?
+ doForget = true;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ catch (Exception e2)
+ {
+ if (jtaLogger.loggerI18N.isWarnEnabled())
+ {
+ jtaLogger.loggerI18N
+ .warn(
+ "com.arjuna.ats.internal.jta.recovery.xarecovery2",
+ new Object[]
+ {
+ _logName
+ + ".xaRecovery ",
+ e2 });
+ }
+ }
+ }
+ else
+ {
+ foundTransaction = true;
- if (doForget)
- {
- try
- {
- xares.forget((Xid) xids[j]);
- }
- catch (Exception e)
- {
- if (jtaLogger.loggerI18N.isWarnEnabled())
- {
- jtaLogger.loggerI18N
- .warn(
- "com.arjuna.ats.internal.jta.recovery.forgetfailed",
- new Object[] { _logName + ".xaRecovery", e });
- }
- }
- }
+ /*
+ * In the failures list so it may be that we
+ * just need another XAResource to be able to
+ * recover this.
+ */
- } while (recordUid != null);
+ XARecoveryResource record = _recoveryManagerClass
+ .getResource(recordUid, xares);
+ int recoveryStatus = record.recover();
+
+ if (recoveryStatus != XARecoveryResource.RECOVERED_OK)
+ {
+ if (jtaLogger.loggerI18N.isWarnEnabled())
+ {
+ jtaLogger.loggerI18N
+ .warn(
+ "com.arjuna.ats.internal.jta.recovery.failedtorecover",
+ new Object[]
+ {
+ _logName
+ + ".xaRecovery ",
+ new Integer(
+ recoveryStatus) });
}
+ }
+
+ removeFailure(record.getXid(), record.get_uid());
}
- }
- catch (Exception e)
- {
- if (jtaLogger.loggerI18N.isWarnEnabled())
+
+ if (doForget)
{
- jtaLogger.loggerI18N
- .warn(
- "com.arjuna.ats.internal.jta.recovery.generalrecoveryerror",
- new Object[] { _logName + ".xaRecovery", e });
+ try
+ {
+ xares.forget((Xid) xids[j]);
+ }
+ catch (Exception e)
+ {
+ if (jtaLogger.loggerI18N.isWarnEnabled())
+ {
+ jtaLogger.loggerI18N
+ .warn(
+ "com.arjuna.ats.internal.jta.recovery.forgetfailed",
+ new Object[]
+ { _logName + ".xaRecovery",
+ e });
+ }
+ }
}
- e.printStackTrace();
+ }
+ while (recordUid != null);
}
+ }
+ }
+ catch (Exception e)
+ {
+ if (jtaLogger.loggerI18N.isWarnEnabled())
+ {
+ jtaLogger.loggerI18N
+ .warn(
+ "com.arjuna.ats.internal.jta.recovery.generalrecoveryerror",
+ new Object[]
+ { _logName + ".xaRecovery", e });
+ }
- try
- {
- if (xares != null) xares.recover(XAResource.TMENDRSCAN);
- }
- catch (XAException e)
- {
- if (jtaLogger.loggerI18N.isWarnEnabled())
- {
- jtaLogger.loggerI18N.warn(
- "com.arjuna.ats.internal.jta.recovery.xarecovery1",
- new Object[] { _logName + ".xaRecovery", e, XAHelper
- .printXAErrorCode(e) });
- }
- }
-
- return true;
+ e.printStackTrace();
}
- /**
- * Is there a log file for this transaction?
- *
- * @param Xid
- * xid the transaction to check.
- *
- * @return <code>boolean</code>true if there is a log file,
- * <code>false</code> if there isn't.
- *
- * @message com.arjuna.ats.internal.jta.recovery.notaxid {0} not an Arjuna
- * XID
- */
-
- private final boolean transactionLog (Xid xid)
+ try
{
- if (_transactionStore == null)
- {
- _transactionStore = TxControl.getStore();
- }
+ if (xares != null)
+ xares.recover(XAResource.TMENDRSCAN);
+ }
+ catch (XAException e)
+ {
+ if (jtaLogger.loggerI18N.isWarnEnabled())
+ {
+ jtaLogger.loggerI18N.warn(
+ "com.arjuna.ats.internal.jta.recovery.xarecovery1",
+ new Object[]
+ { _logName + ".xaRecovery", e,
+ XAHelper.printXAErrorCode(e) });
+ }
+ }
- XidImple theXid = new XidImple(xid);
- Uid u = com.arjuna.ats.internal.arjuna.utils.XATxConverter
- .getUid(theXid.getXID());
+ return true;
+ }
- if (!u.equals(Uid.nullUid()))
- {
- try
- {
- if (_transactionStore.currentState(u, _transactionType) != ObjectStore.OS_UNKNOWN)
- {
- return true;
- }
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- }
- else
- {
- if (jtaLogger.logger.isInfoEnabled())
- {
- jtaLogger.loggerI18N.info(
- "com.arjuna.ats.internal.jta.recovery.notaxid",
- new Object[] { xid });
- }
- }
+ /**
+ * Is there a log file for this transaction?
+ *
+ * @param Xid
+ * xid the transaction to check.
+ *
+ * @return <code>boolean</code>true if there is a log file,
+ * <code>false</code> if there isn't.
+ *
+ * @message com.arjuna.ats.internal.jta.recovery.notaxid {0} not an
+ * Arjuna XID
+ */
- return false;
+ private final boolean transactionLog (Xid xid)
+ {
+ if (_transactionStore == null)
+ {
+ _transactionStore = TxControl.getStore();
}
- /**
- * Is the Xid is in the failure list, i.e., the list of those transactions
- * we couldn't recover, possibly because of transient failures. If so,
- * return the uid of (one of) the records and remove it from the list.
- */
+ XidImple theXid = new XidImple(xid);
+ Uid u = com.arjuna.ats.internal.arjuna.utils.XATxConverter
+ .getUid(theXid.getXID());
- private final Uid previousFailure (Xid xid)
+ if (!u.equals(Uid.nullUid()))
{
- if (_failures == null)
+ try
+ {
+ if (_transactionStore.currentState(u, _transactionType) != ObjectStore.OS_UNKNOWN)
{
- return null;
+ return true;
}
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ else
+ {
+ if (jtaLogger.logger.isInfoEnabled())
+ {
+ jtaLogger.loggerI18N.info(
+ "com.arjuna.ats.internal.jta.recovery.notaxid",
+ new Object[]
+ { xid });
+ }
+ }
- Enumeration e = _failures.keys();
+ return false;
+ }
- while (e.hasMoreElements())
- {
- Xid theXid = (Xid) e.nextElement();
+ /**
+ * Is the Xid is in the failure list, i.e., the list of those
+ * transactions we couldn't recover, possibly because of transient
+ * failures. If so, return the uid of (one of) the records and remove it
+ * from the list.
+ */
- if (XAHelper.sameXID(xid, theXid))
- {
- // remove uid from failure list
- Vector failureItem = (Vector) _failures.get(theXid);
- Uid u = (Uid) failureItem.remove(0);
+ private final Uid previousFailure (Xid xid)
+ {
+ if (_failures == null)
+ {
+ return null;
+ }
- if (failureItem.size() == 0) _failures.remove(theXid);
+ Enumeration e = _failures.keys();
- return u;
- }
- }
+ while (e.hasMoreElements())
+ {
+ Xid theXid = (Xid) e.nextElement();
- // not present in the failures list.
+ if (XAHelper.sameXID(xid, theXid))
+ {
+ // remove uid from failure list
+ Vector failureItem = (Vector) _failures.get(theXid);
+ Uid u = (Uid) failureItem.remove(0);
- return null;
+ if (failureItem.size() == 0)
+ _failures.remove(theXid);
+
+ return u;
+ }
}
- /* methods to manipulate the failure list */
+ // not present in the failures list.
- /**
- * Add record to failure list
- */
+ return null;
+ }
- private void addFailure (Xid xid, Uid uid)
- {
- if (_failures == null) _failures = new Hashtable();
+ /* methods to manipulate the failure list */
- Vector failureItem = (Vector) _failures.get(xid);
+ /**
+ * Add record to failure list
+ */
- if (failureItem == null)
- {
- failureItem = new Vector();
+ private void addFailure (Xid xid, Uid uid)
+ {
+ if (_failures == null)
+ _failures = new Hashtable();
- _failures.put(xid, failureItem);
- }
+ Vector failureItem = (Vector) _failures.get(xid);
- failureItem.addElement(uid);
+ if (failureItem == null)
+ {
+ failureItem = new Vector();
+
+ _failures.put(xid, failureItem);
}
- /**
- * @message com.arjuna.ats.internal.jta.recovery.removefailed {0} - could
- * not remove record for {1}
- */
+ failureItem.addElement(uid);
+ }
- /* remove record uid from failure list */
- private void removeFailure (Xid xid, Uid uid)
- {
- // find the failure item for this xid
- Vector failureItem = (Vector) _failures.get(xid);
+ /**
+ * @message com.arjuna.ats.internal.jta.recovery.removefailed {0} -
+ * could not remove record for {1}
+ */
- if (failureItem == null)
- {
- /*
- * if (jtaLogger.loggerI18N.isWarnEnabled()) {
- * jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.recovery.removefailed",
- * new Object[] { _logName, xid}); }
- */
+ /* remove record uid from failure list */
+ private void removeFailure (Xid xid, Uid uid)
+ {
+ // find the failure item for this xid
+ Vector failureItem = (Vector) _failures.get(xid);
- /*
- * Already removed via previousFailure.
- */
- }
- else
- {
- // remove this record from the item
- failureItem.remove(uid);
+ if (failureItem == null)
+ {
+ /*
+ * if (jtaLogger.loggerI18N.isWarnEnabled()) {
+ * jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.recovery.removefailed",
+ * new Object[] { _logName, xid}); }
+ */
- // if that was the last one, remove the item altogether
- if (failureItem.size() == 0) _failures.remove(xid);
- }
+ /*
+ * Already removed via previousFailure.
+ */
}
-
- private void clearAllFailures ()
+ else
{
- if (_failures != null) _failures.clear();
+ // remove this record from the item
+ failureItem.remove(uid);
+
+ // if that was the last one, remove the item altogether
+ if (failureItem.size() == 0)
+ _failures.remove(xid);
}
+ }
- private ObjectStore _objStore = new ObjectStore();
+ private void clearAllFailures ()
+ {
+ if (_failures != null)
+ _failures.clear();
+ }
- private InputObjectState _uids = new InputObjectState();
+ private ObjectStore _objStore = new ObjectStore();
- private Vector _xaRecoverers = null;
+ private InputObjectState _uids = new InputObjectState();
- private Hashtable _failures = null;
+ private Vector _xaRecoverers = null;
- private Vector _xaRecoveryNodes = null;
+ private Hashtable _failures = null;
- private Hashtable _xidScans = null;
+ private Vector _xaRecoveryNodes = null;
- private XARecoveryResourceManager _recoveryManagerClass = null;
+ private Hashtable _xidScans = null;
- private String _logName = null;
+ private XARecoveryResourceManager _recoveryManagerClass = null;
- // 'type' within the Object Store for AtomicActions.
- private String _transactionType = new AtomicAction().type();
+ private String _logName = null;
- // Reference to the Object Store.
- private static ObjectStore _transactionStore = null;
+ // 'type' within the Object Store for AtomicActions.
+ private String _transactionType = new AtomicAction().type();
- private static int _backoffPeriod = 0;
+ // Reference to the Object Store.
+ private static ObjectStore _transactionStore = null;
- private static final int XA_BACKOFF_PERIOD = 20000; // backoff in
- // milliseconds
+ private static int _backoffPeriod = 0;
- private static final char BREAKCHARACTER = ';'; // delimiter for xaconnrecov
- // property
+ private static final int XA_BACKOFF_PERIOD = 20000; // backoff in
- static
- {
- String env = jtaPropertyManager.propertyManager
- .getProperty(com.arjuna.ats.jta.common.Environment.XA_BACKOFF_PERIOD);
+ // milliseconds
- XARecoveryModule._backoffPeriod = XA_BACKOFF_PERIOD;
+ private static final char BREAKCHARACTER = ';'; // delimiter for
+ // xaconnrecov
+ // property
- if (env != null)
- {
- try
- {
- Integer i = new Integer(env);
+ static
+ {
+ String env = jtaPropertyManager.propertyManager
+ .getProperty(com.arjuna.ats.jta.common.Environment.XA_BACKOFF_PERIOD);
- XARecoveryModule._backoffPeriod = i.intValue();
- }
- catch (Exception e)
- {
- throw new ExceptionInInitializerError(e);
- }
- }
+ XARecoveryModule._backoffPeriod = XA_BACKOFF_PERIOD;
+
+ if (env != null)
+ {
+ try
+ {
+ Integer i = new Integer(env);
+
+ XARecoveryModule._backoffPeriod = i.intValue();
+ }
+ catch (Exception e)
+ {
+ throw new ExceptionInInitializerError(e);
+ }
}
+ }
}
Deleted: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/recovery/XAConnectionRecovery.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/recovery/XAConnectionRecovery.java 2007-07-18 21:09:48 UTC (rev 13615)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/recovery/XAConnectionRecovery.java 2007-07-18 21:16:52 UTC (rev 13616)
@@ -1,84 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-/*
- * Copyright (C) 2000, 2001,
- *
- * Arjuna Solutions Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: XAConnectionRecovery.java 2342 2006-03-30 13:06:17Z $
- */
-
-package com.arjuna.ats.jta.recovery;
-
-import java.sql.*;
-import javax.sql.*;
-import javax.transaction.*;
-import javax.transaction.xa.*;
-
-/**
- * To perform recovery on arbitrary connections we may need
- * to recreate those connections. Users can provide implementations
- * of this interface which we will use at recovery time to re-create
- * db connections and from them perform recovery.
- *
- * @deprecated As of ATS 3.3, replaced by @link XAResourceRecovery
- *
- * @since JTS 2.1.
- */
-
-public interface XAConnectionRecovery
-{
-
- /**
- * Get a connection to use for recovery purposes.
- *
- * @return a new XAConnection.
- */
-
- public XAConnection getConnection () throws SQLException;
-
- /**
- * Initialise with all properties required to create a connection.
- *
- * @param String p An arbitrary string from which initialization data
- * is obtained.
- *
- * @return <code>true</code> if initialization happened successfully,
- * <code>false</code> otherwise.
- */
-
- public boolean initialise (String p) throws SQLException;
-
- /**
- * Iterate through all of the connections this instance provides
- * access to.
- *
- * @return <code>true</code> if this instance can provide more
- * connections, <code>false</code> otherwise.
- */
-
- public boolean hasMoreConnections ();
-
-}
-
More information about the jboss-svn-commits
mailing list