[jboss-svn-commits] JBL Code SVN: r25352 - in labs/jbosstm/trunk/XTS: WS-T/dev/src11/com/arjuna/wst11/stub and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Feb 19 13:37:52 EST 2009
Author: adinn
Date: 2009-02-19 13:37:52 -0500 (Thu, 19 Feb 2009)
New Revision: 25352
Added:
labs/jbosstm/trunk/XTS/sar/src/org/jboss/jbossts/xts/recovery/participant/at/XTSATSubordinateRecoveryModule.java
Modified:
labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/stub/SubordinateDurable2PCStub.java
labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/stub/SubordinateDurable2PCStub.java
labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/model/twophase/arjunacore/subordinate/SubordinateCoordinator.java
labs/jbosstm/trunk/XTS/sar/src/org/jboss/jbossts/xts/recovery/participant/at/ATParticipantRecoveryModule.java
Log:
added AT recovery module for SubordinateDurable2PCStub and made it capable of saving and restoring itself via the PersistableATParticipant interface -- fixes reopened defect JBTM-409
Modified: labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/stub/SubordinateDurable2PCStub.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/stub/SubordinateDurable2PCStub.java 2009-02-19 18:26:47 UTC (rev 25351)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/stub/SubordinateDurable2PCStub.java 2009-02-19 18:37:52 UTC (rev 25352)
@@ -10,12 +10,13 @@
import java.io.IOException;
import org.jboss.jbossts.xts.recovery.participant.at.XTSATRecoveryManager;
+import org.jboss.jbossts.xts.recovery.participant.at.PersistableATParticipant;
/**
* A durable participant registered on behalf of an interposed WS-AT coordinator in order to ensure that
* durable participants in the subtransaction prepared, committed and aborted at the right time.
*/
-public class SubordinateDurable2PCStub implements Durable2PCParticipant
+public class SubordinateDurable2PCStub implements Durable2PCParticipant, PersistableParticipant, PersistableATParticipant
{
/**
* normal constructor used when the subordinate coordinator is registered as a durable participant
@@ -215,4 +216,17 @@
*/
private boolean recovered;
+
+ /**
+ * this participant implements the PersistableATarticipant interface so it can save its state.
+ * recovery is managed by an XTS recovery module
+ * @return
+ * @throws Exception
+ */
+ public byte[] getRecoveryState() throws Exception {
+ OutputObjectState oos = new OutputObjectState();
+ oos.packString(this.getClass().getName());
+ this.saveState(oos);
+ return oos.buffer();
+ }
}
\ No newline at end of file
Modified: labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/stub/SubordinateDurable2PCStub.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/stub/SubordinateDurable2PCStub.java 2009-02-19 18:26:47 UTC (rev 25351)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/stub/SubordinateDurable2PCStub.java 2009-02-19 18:37:52 UTC (rev 25352)
@@ -10,12 +10,13 @@
import java.io.IOException;
import org.jboss.jbossts.xts.recovery.participant.at.XTSATRecoveryManager;
+import org.jboss.jbossts.xts.recovery.participant.at.PersistableATParticipant;
/**
* A durable participant registered on behalf of an interposed WS-AT coordinator in order to ensure that
* durable participants in the subtransaction prepared, committed and aborted at the right time.
*/
-public class SubordinateDurable2PCStub implements Durable2PCParticipant, PersistableParticipant
+public class SubordinateDurable2PCStub implements Durable2PCParticipant, PersistableParticipant, PersistableATParticipant
{
/**
* normal constructor used when the subordinate coordinator is registered as a durable participant
@@ -215,4 +216,17 @@
*/
private boolean recovered;
+
+ /**
+ * this participant implements the PersistableATarticipant interface so it can save its state.
+ * recovery is managed by an XTS recovery module
+ * @return
+ * @throws Exception
+ */
+ public byte[] getRecoveryState() throws Exception {
+ OutputObjectState oos = new OutputObjectState();
+ oos.packString(this.getClass().getName());
+ this.saveState(oos);
+ return oos.buffer();
+ }
}
\ No newline at end of file
Modified: labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/model/twophase/arjunacore/subordinate/SubordinateCoordinator.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/model/twophase/arjunacore/subordinate/SubordinateCoordinator.java 2009-02-19 18:26:47 UTC (rev 25351)
+++ labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/model/twophase/arjunacore/subordinate/SubordinateCoordinator.java 2009-02-19 18:37:52 UTC (rev 25352)
@@ -250,11 +250,16 @@
}
/**
+ * unique string used as prefix for participant ids to ensure they can be identified at recovery
+ */
+ public static String PARTICIPANT_PREFIX = "org.jboss.jbossts.xts.at.subordinate.participant.";
+
+ /**
* return a uid for the volatile participant registered on behalf of this corodinator
*/
public String getVolatile2PhaseId()
{
- return get_uid().stringForm() + "_V";
+ return PARTICIPANT_PREFIX + get_uid().stringForm() + "_V";
}
/**
@@ -262,7 +267,7 @@
*/
public String getDurable2PhaseId()
{
- return get_uid().stringForm() + "_D";
+ return PARTICIPANT_PREFIX + get_uid().stringForm() + "_D";
}
Modified: labs/jbosstm/trunk/XTS/sar/src/org/jboss/jbossts/xts/recovery/participant/at/ATParticipantRecoveryModule.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/src/org/jboss/jbossts/xts/recovery/participant/at/ATParticipantRecoveryModule.java 2009-02-19 18:26:47 UTC (rev 25351)
+++ labs/jbosstm/trunk/XTS/sar/src/org/jboss/jbossts/xts/recovery/participant/at/ATParticipantRecoveryModule.java 2009-02-19 18:37:52 UTC (rev 25352)
@@ -83,14 +83,26 @@
public void install()
{
XTSATRecoveryManager.setRecoveryManager(new XTSATRecoveryManagerImple(_objectStore));
+ // Subordinate Coordinators register durable participants with their parent transaction so
+ // we need to add an XTSATRecoveryModule which knows about the registered participants
+
+ subordinateRecoveryModule = new XTSATSubordinateRecoveryModule();
+ XTSATRecoveryManager.getRecoveryManager().registerRecoveryModule(subordinateRecoveryModule);
}
/**
+ * a recovery module which knows hwo to recover the participants registered by Subordinate AT Coordinators
+ */
+
+ private XTSATSubordinateRecoveryModule subordinateRecoveryModule;
+
+ /**
* called by the service shutdown code after the recovery module is removed from the recovery managers
* module list
*/
public void uninstall()
{
+ XTSATRecoveryManager.getRecoveryManager().unregisterRecoveryModule(subordinateRecoveryModule);
}
/**
Added: labs/jbosstm/trunk/XTS/sar/src/org/jboss/jbossts/xts/recovery/participant/at/XTSATSubordinateRecoveryModule.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/src/org/jboss/jbossts/xts/recovery/participant/at/XTSATSubordinateRecoveryModule.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/src/org/jboss/jbossts/xts/recovery/participant/at/XTSATSubordinateRecoveryModule.java 2009-02-19 18:37:52 UTC (rev 25352)
@@ -0,0 +1,36 @@
+package org.jboss.jbossts.xts.recovery.participant.at;
+
+import com.arjuna.wst.Durable2PCParticipant;
+import com.arjuna.wst.PersistableParticipant;
+import com.arjuna.mwlabs.wscf.model.twophase.arjunacore.subordinate.SubordinateCoordinator;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+
+import java.io.ObjectInputStream;
+
+/**
+ * A recovery module which recovers durable participants registered by subordinate coordinators
+ */
+
+public class XTSATSubordinateRecoveryModule implements XTSATRecoveryModule
+{
+ public Durable2PCParticipant deserialize(String id, ObjectInputStream stream) throws Exception {
+ if (id.startsWith(SubordinateCoordinator.PARTICIPANT_PREFIX)) {
+ // throw an exception because we don't expect these participants to use serialization
+ throw new Exception("XTSATSubordinateRecoveryModule : invalid request to deserialize() subordinate WS-AT coordinator durable participant " + id);
+ }
+ return null;
+ }
+
+ public Durable2PCParticipant recreate(String id, byte[] recoveryState) throws Exception {
+ if (id.startsWith(SubordinateCoordinator.PARTICIPANT_PREFIX)) {
+ InputObjectState ios = new InputObjectState();
+ ios.setBuffer(recoveryState);
+ String className = ios.unpackString();
+ Class participantClass = this.getClass().getClassLoader().loadClass(className);
+ Durable2PCParticipant participant = (Durable2PCParticipant)participantClass.newInstance();
+ ((PersistableParticipant)participant).restoreState(ios);
+ return participant;
+ }
+ return null;
+ }
+}
More information about the jboss-svn-commits
mailing list