activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [1/2] activemq-artemis git commit: ARTEMIS-1830 only return prepared txns with listPreparedTxns mgmnt op
Date Wed, 25 Apr 2018 18:54:11 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 932f0f408 -> f37df329d


ARTEMIS-1830 only return prepared txns with listPreparedTxns mgmnt op


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/6598ab27
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/6598ab27
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/6598ab27

Branch: refs/heads/master
Commit: 6598ab271fc90929a6606014feb73c301514ba2f
Parents: 932f0f4
Author: Justin Bertram <jbertram@apache.org>
Authored: Wed Apr 25 11:44:47 2018 -0500
Committer: Justin Bertram <jbertram@apache.org>
Committed: Wed Apr 25 12:45:23 2018 -0500

----------------------------------------------------------------------
 .../transaction/impl/ResourceManagerImpl.java   |  4 +++-
 .../management/ActiveMQServerControlTest.java   | 23 +++++++++++++++++++-
 2 files changed, 25 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6598ab27/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/ResourceManagerImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/ResourceManagerImpl.java
index 3ff73d7..068cd4e 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/ResourceManagerImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/ResourceManagerImpl.java
@@ -129,7 +129,9 @@ public class ResourceManagerImpl implements ResourceManager {
       Map<Xid, Long> xidsWithCreationTime = new HashMap<>();
 
       for (Map.Entry<Xid, Transaction> entry : transactions.entrySet()) {
-         xidsWithCreationTime.put(entry.getKey(), entry.getValue().getCreateTime());
+         if (entry.getValue().getState() == Transaction.State.PREPARED) {
+            xidsWithCreationTime.put(entry.getKey(), entry.getValue().getCreateTime());
+         }
       }
       return xidsWithCreationTime;
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6598ab27/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
index 400d594..a16e72f 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
@@ -914,12 +914,29 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
       clientSession.end(xid, XAResource.TMSUCCESS);
       clientSession.prepare(xid);
 
+      // add another TX, but don't prepare it
+      ClientMessage m5 = createTextMessage(clientSession, "");
+      ClientMessage m6 = createTextMessage(clientSession, "");
+      ClientMessage m7 = createTextMessage(clientSession, "");
+      ClientMessage m8 = createTextMessage(clientSession, "");
+      m5.putStringProperty("m5", "m5");
+      m6.putStringProperty("m6", "m6");
+      m7.putStringProperty("m7", "m7");
+      m8.putStringProperty("m8", "m8");
+      Xid xid2 = newXID();
+      clientSession.start(xid2, XAResource.TMNOFLAGS);
+      clientProducer.send(m5);
+      clientProducer.send(m6);
+      clientProducer.send(m7);
+      clientProducer.send(m8);
+      clientSession.end(xid2, XAResource.TMSUCCESS);
+
       ActiveMQServerControl serverControl = createManagementControl();
 
       JsonArray jsonArray = JsonUtil.readJsonArray(serverControl.listProducersInfoAsJSON());
 
       assertEquals(1, jsonArray.size());
-      assertEquals(4, ((JsonObject) jsonArray.get(0)).getInt("msgSent"));
+      assertEquals(8, ((JsonObject) jsonArray.get(0)).getInt("msgSent"));
 
       clientSession.close();
       locator.close();
@@ -930,6 +947,10 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
       Assert.assertTrue(txDetails.matches(".*m2.*"));
       Assert.assertTrue(txDetails.matches(".*m3.*"));
       Assert.assertTrue(txDetails.matches(".*m4.*"));
+      Assert.assertFalse(txDetails.matches(".*m5.*"));
+      Assert.assertFalse(txDetails.matches(".*m6.*"));
+      Assert.assertFalse(txDetails.matches(".*m7.*"));
+      Assert.assertFalse(txDetails.matches(".*m8.*"));
    }
 
    @Test


Mime
View raw message