[jboss-svn-commits] JBL Code SVN: r37573 - in labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta: utils and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Oct 17 09:26:51 EDT 2011
Author: tomjenkinson
Date: 2011-10-17 09:26:50 -0400 (Mon, 17 Oct 2011)
New Revision: 37573
Added:
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/SubordinateJTANodeNameXAResourceOrphanFilter.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/SubordinateJTATransactionLogXAResourceOrphanFilter.java
Modified:
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/utils/XAUtils.java
Log:
JBTM-917 added some new recovery filters to check if the subordinate resource is orphaned
Added: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/SubordinateJTANodeNameXAResourceOrphanFilter.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/SubordinateJTANodeNameXAResourceOrphanFilter.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/SubordinateJTANodeNameXAResourceOrphanFilter.java 2011-10-17 13:26:50 UTC (rev 37573)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates,
+ * 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) 2010,
+ * @author JBoss, by Red Hat.
+ */
+package com.arjuna.ats.internal.jta.recovery.arjunacore;
+
+
+import com.arjuna.ats.internal.jta.utils.XAUtils;
+import com.arjuna.ats.jta.common.jtaPropertyManager;
+import com.arjuna.ats.jta.logging.jtaLogger;
+import com.arjuna.ats.jta.recovery.XAResourceOrphanFilter;
+
+
+
+import javax.transaction.xa.Xid;
+import java.util.List;
+
+/**
+ * An XAResourceOrphanFilter which uses node name information encoded in the xid to determine if
+ * they should be rolled back or not.
+ *
+ * Note that this filter does not check xid format id, and therefore may attempt to extract node name
+ * information from foreign xids, resulting in random behaviour. Probably best combined with a filter
+ * that verifies formatIds.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com), 2010-03
+ */
+public class SubordinateJTANodeNameXAResourceOrphanFilter implements XAResourceOrphanFilter
+{
+ public static final int RECOVER_ALL_NODES = 0;
+
+ @Override
+ public Vote checkXid(Xid xid)
+ {
+ List<Integer> _xaRecoveryNodes = jtaPropertyManager.getJTAEnvironmentBean().getXaRecoveryNodes();
+
+ if(_xaRecoveryNodes == null || _xaRecoveryNodes.size() == 0) {
+ doWarning();
+ return Vote.ABSTAIN;
+ }
+
+ int nodeName = XAUtils.getSubordinateNodeName(xid);
+
+ if (jtaLogger.logger.isDebugEnabled()) {
+ jtaLogger.logger.debug("node name of " + xid + " is " + nodeName);
+ }
+
+ if (_xaRecoveryNodes.contains(nodeName))
+ {
+ return Vote.ROLLBACK;
+ }
+ else
+ {
+ return Vote.ABSTAIN;
+ }
+ }
+
+ private void doWarning() {
+ jtaLogger.i18NLogger.info_recovery_noxanodes();
+ }
+}
Added: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/SubordinateJTATransactionLogXAResourceOrphanFilter.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/SubordinateJTATransactionLogXAResourceOrphanFilter.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/SubordinateJTATransactionLogXAResourceOrphanFilter.java 2011-10-17 13:26:50 UTC (rev 37573)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates,
+ * 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) 2010,
+ * @author JBoss, by Red Hat.
+ */
+package com.arjuna.ats.internal.jta.recovery.arjunacore;
+
+import javax.transaction.xa.Xid;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.objectstore.RecoveryStore;
+import com.arjuna.ats.arjuna.objectstore.StateStatus;
+import com.arjuna.ats.arjuna.objectstore.StoreManager;
+import com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.jca.SubordinateAtomicAction;
+import com.arjuna.ats.jta.logging.jtaLogger;
+import com.arjuna.ats.jta.recovery.XAResourceOrphanFilter;
+import com.arjuna.ats.jta.utils.XAHelper;
+import com.arjuna.ats.jta.xa.XATxConverter;
+import com.arjuna.ats.jta.xa.XidImple;
+
+/**
+ * An XAResourceOrphanFilter which vetos rollback for xids owned by top level
+ * JTA transactions.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com), 2010-03
+ */
+public class SubordinateJTATransactionLogXAResourceOrphanFilter implements XAResourceOrphanFilter {
+ @Override
+ public Vote checkXid(Xid xid) {
+ if (xid.getFormatId() != XATxConverter.FORMAT_ID) {
+ // we only care about Xids created by the JTA
+ return Vote.ABSTAIN;
+ }
+
+ if (transactionLog(xid)) {
+ // it's owned by a logged transaction which
+ // will recover it top down in due course
+ return Vote.LEAVE_ALONE;
+ }
+
+ return Vote.ABSTAIN;
+ }
+
+ /**
+ * Is there a log file for this transaction?
+ *
+ * @param xid
+ * the transaction to check.
+ *
+ * @return <code>boolean</code>true if there is a log file,
+ * <code>false</code> if there isn't.
+ */
+ private boolean transactionLog(Xid xid) {
+ RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
+ String transactionType = SubordinateAtomicAction.getType();
+
+ XidImple theXid = new XidImple(xid);
+ Uid u = theXid.getTransactionUid();
+
+ if (jtaLogger.logger.isDebugEnabled()) {
+ jtaLogger.logger.debug("Checking whether Xid " + theXid + " exists in ObjectStore.");
+ }
+
+ if (!u.equals(Uid.nullUid())) {
+ try {
+
+ if (jtaLogger.logger.isDebugEnabled()) {
+ jtaLogger.logger.debug("Looking for " + u + " and " + transactionType);
+ }
+
+ if (recoveryStore.currentState(u, transactionType) != StateStatus.OS_UNKNOWN) {
+ if (jtaLogger.logger.isDebugEnabled()) {
+ jtaLogger.logger.debug("Found record for " + theXid);
+ }
+
+ return true;
+ } else {
+ if (jtaLogger.logger.isDebugEnabled()) {
+ jtaLogger.logger.debug("No record found for " + theXid);
+ }
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ } else {
+ jtaLogger.i18NLogger.info_recovery_notaxid(XAHelper.xidToString(xid));
+ }
+
+ return false;
+ }
+}
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/utils/XAUtils.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/utils/XAUtils.java 2011-10-17 12:58:11 UTC (rev 37572)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/utils/XAUtils.java 2011-10-17 13:26:50 UTC (rev 37573)
@@ -85,5 +85,15 @@
return xidImple.getNodeName();
}
+ public static int getSubordinateNodeName(Xid xid) {
+ XidImple xidImple;
+ if(xid instanceof XidImple) {
+ xidImple = (XidImple)xid;
+ } else {
+ xidImple = new XidImple(xid);
+ }
+ return xidImple.getSubordinateNodeName();
+ }
+
private static final String ORACLE = "oracle";
}
More information about the jboss-svn-commits
mailing list