Permalink
Browse files

Merge branch 'master' of https://github.com/jbosstm/narayana

  • Loading branch information...
2 parents 74cabf5 + e0d0103 commit d126523809f3b1a1ddf583b13fc04f5bb99e4fbc @liweinan committed Mar 8, 2013
Showing with 5,301 additions and 168 deletions.
  1. +26 −0 ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/CoordinatorEnvironmentBean.java
  2. +45 −2 ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java
  3. +8 −0 ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TwoPhaseOutcome.java
  4. +2 −0 ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TxControl.java
  5. +95 −0 ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/OnePhaseCommitUnitTest.java
  6. +0 −1 ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/BasicRecord.java
  7. +173 −0 ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/OnePhaseAbstractRecord.java
  8. +140 −0 ArjunaJTS/jtax/tests/classes/WedgedResourceDemonstrator.java
  9. +4 −3 ...naJTS/jts/classes/com/arjuna/ats/internal/jts/orbspecific/coordinator/ArjunaTransactionImple.java
  10. +6 −1 ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/resources/ExtendedResourceRecord.java
  11. +4 −0 ArjunaJTS/jts/tests/classes/com/hp/mwtests/ts/jts/local/transactions/TransactionTest1.java
  12. +98 −0 XTS/WSTX/classes/com/arjuna/mw/wst11/client/AbstractWSTXHandler.java
  13. +46 −0 XTS/WSTX/classes/com/arjuna/mw/wst11/client/DisabledWSTXHandler.java
  14. +46 −0 XTS/WSTX/classes/com/arjuna/mw/wst11/client/EnabledWSTXHandler.java
  15. +28 −9 XTS/WSTX/classes/com/arjuna/mw/wst11/client/JaxBaseHeaderContextProcessor.java
  16. +19 −7 XTS/WSTX/classes/com/arjuna/mw/wst11/client/JaxWSHeaderContextProcessor.java
  17. +86 −0 XTS/WSTX/classes/com/arjuna/mw/wst11/client/WSTXFeature.java
  18. +6 −0 XTS/WSTX/pom.xml
  19. +10 −0 XTS/localjunit/pom.xml
  20. +251 −17 XTS/localjunit/unit/pom.xml
  21. +188 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/arq/ba/AbstractContextPropagationTest.java
  22. +262 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/arq/ba/DisabledContextPropagationTest.java
  23. +261 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/arq/ba/EnabledContextPropagationTest.java
  24. +188 −0 ...localjunit/unit/src/test/java/com/arjuna/wstx/tests/arq/basic/AbstractContextPropagationTest.java
  25. +263 −0 ...localjunit/unit/src/test/java/com/arjuna/wstx/tests/arq/basic/DisabledContextPropagationTest.java
  26. +265 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/arq/basic/EnabledContextPropagationTest.java
  27. +26 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/common/TestService.java
  28. +31 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/common/TestServiceAT.java
  29. +88 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/common/TestServiceATClient.java
  30. +97 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/common/TestServiceATImple.java
  31. +31 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/common/TestServiceBA.java
  32. +88 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/common/TestServiceBAClient.java
  33. +117 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/common/TestServiceBAImple.java
  34. +63 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/common/TestServiceClient.java
  35. +39 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/common/TestServiceImple.java
  36. +12 −0 XTS/localjunit/unit/src/test/resources/arquillian.xml
  37. +21 −0 XTS/localjunit/unit/src/test/resources/context-handlers.xml
  38. +0 −15 fileio/pom.xml
  39. +2 −2 pom.xml
  40. +6 −2 qa/TaskImpl.properties
  41. +3 −2 qa/tests/src/org/jboss/jbossts/qa/junit/testgroup/TestGroup_jtsremote.java
  42. +0 −2 rest-tx/webservice/pom.xml
  43. +1 −1 tools/maven/NOTICE.txt
  44. +2 −1 tools/maven/bin/m2.conf
  45. +18 −5 tools/maven/bin/mvn
  46. +0 −1 tools/maven/bin/mvn.bat
  47. +18 −5 tools/maven/bin/mvnDebug
  48. +0 −1 tools/maven/bin/mvnDebug.bat
  49. +17 −5 tools/maven/bin/mvnyjp
  50. +246 −1 tools/maven/conf/settings.xml
  51. BIN tools/maven/lib/aether-api-1.13.1.jar
  52. BIN tools/maven/lib/aether-api-1.9.jar
  53. BIN tools/maven/lib/aether-connector-wagon-1.13.1.jar
  54. BIN tools/maven/lib/aether-connector-wagon-1.9.jar
  55. BIN tools/maven/lib/aether-impl-1.13.1.jar
  56. BIN tools/maven/lib/aether-impl-1.9.jar
  57. BIN tools/maven/lib/aether-spi-1.13.1.jar
  58. BIN tools/maven/lib/aether-spi-1.9.jar
  59. BIN tools/maven/lib/aether-util-1.13.1.jar
  60. BIN tools/maven/lib/aether-util-1.9.jar
  61. +2 −0 tools/maven/lib/ext/README.txt
  62. BIN tools/maven/lib/maven-aether-provider-3.0.2.jar
  63. BIN tools/maven/lib/maven-aether-provider-3.0.5.jar
  64. BIN tools/maven/lib/maven-artifact-3.0.2.jar
  65. BIN tools/maven/lib/maven-artifact-3.0.5.jar
  66. BIN tools/maven/lib/{maven-compat-3.0.2.jar → maven-compat-3.0.5.jar}
  67. BIN tools/maven/lib/maven-core-3.0.2.jar
  68. BIN tools/maven/lib/maven-core-3.0.5.jar
  69. BIN tools/maven/lib/maven-embedder-3.0.2.jar
  70. BIN tools/maven/lib/maven-embedder-3.0.5.jar
  71. BIN tools/maven/lib/maven-model-3.0.2.jar
  72. BIN tools/maven/lib/maven-model-3.0.5.jar
  73. BIN tools/maven/lib/maven-model-builder-3.0.2.jar
  74. BIN tools/maven/lib/maven-model-builder-3.0.5.jar
  75. BIN tools/maven/lib/{maven-plugin-api-3.0.2.jar → maven-plugin-api-3.0.5.jar}
  76. BIN tools/maven/lib/{maven-repository-metadata-3.0.2.jar → maven-repository-metadata-3.0.5.jar}
  77. BIN tools/maven/lib/{maven-settings-3.0.2.jar → maven-settings-3.0.5.jar}
  78. BIN tools/maven/lib/{maven-settings-builder-3.0.2.jar → maven-settings-builder-3.0.5.jar}
  79. BIN tools/maven/lib/nekohtml-1.9.6.2.jar
  80. BIN tools/maven/lib/plexus-cipher-1.4.jar
  81. BIN tools/maven/lib/plexus-cipher-1.7.jar
  82. BIN tools/maven/lib/plexus-utils-2.0.4.jar
  83. BIN tools/maven/lib/plexus-utils-2.0.6.jar
  84. BIN tools/maven/lib/sisu-guava-0.9.9.jar
  85. BIN tools/maven/lib/sisu-guice-2.9.1-noaop.jar
  86. BIN tools/maven/lib/sisu-guice-3.1.0-no_aop.jar
  87. BIN tools/maven/lib/sisu-inject-bean-1.4.3.1.jar
  88. BIN tools/maven/lib/sisu-inject-bean-2.3.0.jar
  89. BIN tools/maven/lib/sisu-inject-plexus-1.4.3.1.jar
  90. BIN tools/maven/lib/sisu-inject-plexus-2.3.0.jar
  91. BIN tools/maven/lib/wagon-file-1.0-beta-7.jar
  92. BIN tools/maven/lib/wagon-file-2.4.jar
  93. BIN tools/maven/lib/wagon-http-2.4-shaded.jar
  94. BIN tools/maven/lib/wagon-http-lightweight-1.0-beta-7.jar
  95. BIN tools/maven/lib/wagon-http-shared-1.0-beta-7.jar
  96. BIN tools/maven/lib/wagon-provider-api-1.0-beta-7.jar
  97. BIN tools/maven/lib/wagon-provider-api-2.4.jar
  98. BIN tools/maven/lib/xercesMinimal-1.9.6.2.jar
  99. +115 −0 txbridge/pom.xml
  100. +214 −0 txbridge/src/main/java/org/jboss/jbossts/txbridge/outbound/AbstractJTAOverWSATHandler.java
  101. +47 −0 txbridge/src/main/java/org/jboss/jbossts/txbridge/outbound/DisabledJTAOverWSATHandler.java
  102. +47 −0 txbridge/src/main/java/org/jboss/jbossts/txbridge/outbound/EnabledJTAOverWSATHandler.java
  103. +67 −0 txbridge/src/main/java/org/jboss/jbossts/txbridge/outbound/JTAOverWSATFeature.java
  104. +5 −4 txbridge/src/test/java/org/jboss/jbossts/txbridge/tests/common/AbstractBasicTests.java
  105. +13 −0 txbridge/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/client/CommonTestService.java
  106. +269 −0 txbridge/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/client/TestATClient.java
  107. +30 −0 txbridge/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/client/TestATService.java
  108. +30 −0 txbridge/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/client/TestNonATService.java
  109. +402 −0 ...rc/test/java/org/jboss/jbossts/txbridge/tests/outbound/junit/DisabledContextPropagationTests.java
  110. +398 −0 ...src/test/java/org/jboss/jbossts/txbridge/tests/outbound/junit/EnabledContextPropagationTests.java
  111. +71 −0 txbridge/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/service/TestATServiceImpl.java
  112. +57 −0 ...dge/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/service/TestATServiceParticipant.java
  113. +56 −0 txbridge/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/service/TestNonATServiceImpl.java
  114. +5 −0 txframework/pom.xml
  115. +4 −3 ...st/java/org/jboss/narayana/txframework/functional/rest/at/simpleEJB/IndirectTXManagementTest.java
  116. +4 −16 ...amework/src/test/java/org/jboss/narayana/txframework/functional/ws/at/bridged/ATBridgeClient.java
  117. +4 −17 txframework/src/test/java/org/jboss/narayana/txframework/functional/ws/at/simplePOJO/ATClient.java
  118. +7 −13 ...mework/src/test/java/org/jboss/narayana/txframework/functional/ws/ba/bridged/BABridgedClient.java
  119. +4 −16 ...ss/narayana/txframework/functional/ws/ba/coordinatorCompletion/BACoordinatorCompletionClient.java
  120. +4 −16 ...ss/narayana/txframework/functional/ws/ba/participantCompletion/BAParticipantCompletionClient.java
@@ -53,6 +53,7 @@
@FullPropertyName(name = "com.arjuna.ats.arjuna.coordinator.transactionLog.writeOptimisation")
private volatile boolean writeOptimisation = false;
+ private volatile boolean dynamic1PC = true;
private volatile boolean readonlyOptimisation = true;
private volatile boolean classicPrepare = false;
private volatile boolean enableStatistics = false;
@@ -195,6 +196,31 @@ public void setCommitOnePhase(boolean commitOnePhase)
{
this.commitOnePhase = commitOnePhase;
}
+
+ /**
+ * Returns true if dynamic one phase commit optimization is to be used. This means that
+ * if the first N-1 participants in the intentions list return read-only then commit_one_phase
+ * will be called on the last participant.
+ *
+ * Default: true
+ * Equivalent deprecated property: com.arjuna.ats.arjuna.coordinator.dynamic1PC
+ *
+ * @return true if one phase commit is enabled, false otherwise.
+ */
+ public boolean getDynamic1PC()
+ {
+ return dynamic1PC;
+ }
+
+ /**
+ * Sets if dynamic one phase commit behaviour is enabled or not.
+ *
+ * @param dynamic1PC true to enable, false to disable.
+ */
+ public void setDynamic1PC(boolean dynamic1PC)
+ {
+ this.dynamic1PC = dynamic1PC;
+ }
/**
* Returns true if heuristic outcomes should be recorded.
@@ -1948,6 +1948,13 @@ protected synchronized final void phase2Abort (boolean reportHeuristics)
}
}
+ /*
+ * Various optimisations which are possible during synchronous prepare are
+ * not possible for asynchronous prepare due to lack of ordering. For instance
+ * dynamically determining one-phase optimisation while running through the
+ * intentions list and getting read-only responses from N-1 participants.
+ */
+
protected int async_prepare(boolean reportHeuristics) {
int p = TwoPhaseOutcome.PREPARE_OK;
Collection<AbstractRecord> lastResourceRecords = new ArrayList<AbstractRecord>();
@@ -2006,7 +2013,10 @@ protected int async_prepare(boolean reportHeuristics) {
* all the records indicate that they are readonly records. Such records do
* not take part in the second phase commit processing.
*
- * @return <code>TwoPhaseOutcome</code> indicating outcome.
+ * @return <code>TwoPhaseOutcome</code> indicating outcome. Note that if
+ * 1PC optimisation is enabled then it is possible for prepare to dynamically
+ * optimise and commit if the first N-1 participants return read-only, causing the
+ * protcol to commit the last participant rather than go through prepare.
*/
protected synchronized final int prepare (boolean reportHeuristics)
@@ -2081,6 +2091,22 @@ protected synchronized final int prepare (boolean reportHeuristics)
}
}
+ /*
+ * Now let's see if we are able to dynamically optimise 1PC. As we went
+ * through prepare, if the first N-1 participants returned read-only
+ * then we returned read-only from doPrepare but left one entry on
+ * the intentions list.
+ */
+
+ if ((p == TwoPhaseOutcome.PREPARE_READONLY) && (pendingList.size() == 1))
+ {
+ onePhaseCommit(reportHeuristics);
+
+ ActionManager.manager().remove(get_uid());
+
+ return TwoPhaseOutcome.PREPARE_ONE_PHASE_COMMITTED;
+ }
+
if ((p != TwoPhaseOutcome.PREPARE_OK)
&& (p != TwoPhaseOutcome.PREPARE_READONLY))
{
@@ -2485,7 +2511,7 @@ private int doPrepare (boolean reportHeuristics)
*/
int overallTwoPhaseOutcome = TwoPhaseOutcome.PREPARE_READONLY;
-
+
/*
* March down the pendingList and pass the head of the list to the
* main work routine until either we run out of elements, or one of
@@ -2507,6 +2533,23 @@ private int doPrepare (boolean reportHeuristics)
}
keepGoing = ( individualTwoPhaseOutcome == TwoPhaseOutcome.PREPARE_OK) || ( individualTwoPhaseOutcome == TwoPhaseOutcome.PREPARE_READONLY);
+
+ /*
+ * If we are allowed to do dynamic 1PC optimisation then check to see if the first N-1
+ * participants returned read-only and there's a single entry left on the
+ * intentions list.
+ */
+
+ if (keepGoing && TxControl.dynamic1PC)
+ {
+ /*
+ * If N-1 returned read-only and 1 record left then exit prepare now and force
+ * a call to commitOnePhase on the last record.
+ */
+
+ if ((pendingList.size() == 1) && (overallTwoPhaseOutcome == TwoPhaseOutcome.PREPARE_READONLY))
+ keepGoing = false;
+ }
}
return overallTwoPhaseOutcome;
@@ -53,6 +53,11 @@
public class TwoPhaseOutcome
{
+ /*
+ * WARNING!!
+ * Do not re-order this list.
+ */
+
public static final int PREPARE_OK = 0; // prepared OK
public static final int PREPARE_NOTOK = 1; // did not prepare so force roll back
public static final int PREPARE_READONLY = 2; // only used to read the state, so no need for second phase
@@ -65,6 +70,7 @@
public static final int NOT_PREPARED = 9; // participant told to do second phase operation when it hadn't seen the first phase
public static final int ONE_PHASE_ERROR = 10; // WARNING this has different meanings depending upon nested or top-level usage.
public static final int INVALID_TRANSACTION = 11; // invalid!
+ public static final int PREPARE_ONE_PHASE_COMMITTED = 12; // dynamic one-phase commit optimisation during prepare
public TwoPhaseOutcome (int outcome)
{
@@ -113,6 +119,8 @@ public static String stringForm (int res)
return "TwoPhaseOutcome.ONE_PHASE_ERROR";
case INVALID_TRANSACTION:
return "TwoPhaseOutcome.INVALID_TRANSACTION";
+ case PREPARE_ONE_PHASE_COMMITTED:
+ return "TwoPhaseOutcome.PREPARE_ONE_PHASE_COMMITTED";
default:
return "Unknown";
}
@@ -222,6 +222,8 @@ private final static synchronized void removeTransactionStatusManager ()
static final boolean readonlyOptimisation = arjPropertyManager.getCoordinatorEnvironmentBean().isReadonlyOptimisation();
+ static final boolean dynamic1PC = arjPropertyManager.getCoordinatorEnvironmentBean().getDynamic1PC();
+
/**
* flag which is true if transaction service is enabled and false if it is disabled
*/
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+package com.hp.mwtests.ts.arjuna.atomicaction;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.AtomicAction;
+import com.arjuna.ats.arjuna.coordinator.ActionStatus;
+import com.arjuna.ats.arjuna.coordinator.BasicAction;
+import com.arjuna.ats.internal.arjuna.thread.ThreadActionData;
+import com.hp.mwtests.ts.arjuna.resources.BasicRecord;
+import com.hp.mwtests.ts.arjuna.resources.OnePhaseAbstractRecord;
+
+public class OnePhaseCommitUnitTest
+{
+ @Test
+ public void testBasic () throws Exception
+ {
+ AtomicAction A = new AtomicAction();
+ OnePhaseAbstractRecord rec = new OnePhaseAbstractRecord();
+
+ A.begin();
+
+ A.add(rec);
+
+ A.commit();
+
+ assertTrue(rec.onePhaseCalled());
+ }
+
+ @Test
+ public void testFailed () throws Exception
+ {
+ AtomicAction A = new AtomicAction();
+ OnePhaseAbstractRecord rec1 = new OnePhaseAbstractRecord();
+ BasicRecord rec2 = new BasicRecord();
+
+ A.begin();
+
+ A.add(rec1);
+ A.add(rec2);
+
+ A.commit();
+
+ assertTrue(!rec1.onePhaseCalled());
+ }
+
+ @Test
+ public void testDynamic () throws Exception
+ {
+ AtomicAction A = new AtomicAction();
+ OnePhaseAbstractRecord rec1 = new OnePhaseAbstractRecord();
+ OnePhaseAbstractRecord rec2 = new OnePhaseAbstractRecord();
+
+ A.begin();
+
+ /*
+ * Because these are the same record type, we know that they will
+ * be called in the order in which they were registered.
+ *
+ * There are two records, so 1PC will not be triggered initially. But
+ * the first record will return read-only from prepare, which will
+ * then trigger 1PC to happen dynamically.
+ */
+
+ A.add(rec1);
+ A.add(rec2);
+
+ A.commit();
+
+ assertTrue(!rec1.onePhaseCalled());
+ assertTrue(rec2.onePhaseCalled());
+ }
+}
@@ -85,7 +85,6 @@ public int topLevelPrepare()
public void print(PrintWriter strm)
{
- strm.println("Shutdown for:");
super.print(strm);
}
Oops, something went wrong.

0 comments on commit d126523

Please sign in to comment.