activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/2] activemq-artemis git commit: ARTEMIS-710 Avoid inefficient iteration over Map
Date Wed, 31 Aug 2016 18:48:40 GMT
ARTEMIS-710 Avoid inefficient iteration over Map


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

Branch: refs/heads/master
Commit: 275924e8f4718ac07715eee464db4438099d63bb
Parents: 93b3cab
Author: Martin Styk <mstyk@redhat.com>
Authored: Wed Aug 31 16:36:09 2016 +0200
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Wed Aug 31 14:48:31 2016 -0400

----------------------------------------------------------------------
 .../artemis/core/server/impl/PostOfficeJournalLoader.java    | 8 ++++----
 .../activemq/artemis/core/server/impl/ScaleDownHandler.java  | 6 +++---
 .../apache/activemq/artemis/tests/util/ActiveMQTestBase.java | 5 +++--
 3 files changed, 10 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/275924e8/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java
index 2ced2d8..0645dca 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java
@@ -321,9 +321,9 @@ public class PostOfficeJournalLoader implements JournalLoader {
 
       Map<SimpleString, Map<Long, Map<Long, List<PageCountPending>>>>
perAddressMap = generateMapsOnPendingCount(queues, pendingNonTXPageCounter, txRecoverCounter);
 
-      for (SimpleString address : perAddressMap.keySet()) {
-         PagingStore store = pagingManager.getPageStore(address);
-         Map<Long, Map<Long, List<PageCountPending>>> perPageMap = perAddressMap.get(address);
+      for (Map.Entry<SimpleString, Map<Long, Map<Long, List<PageCountPending>>>>
addressPageMapEntry : perAddressMap.entrySet()) {
+         PagingStore store = pagingManager.getPageStore(addressPageMapEntry.getKey());
+         Map<Long, Map<Long, List<PageCountPending>>> perPageMap = addressPageMapEntry.getValue();
 
          // We have already generated this before, so it can't be null
          assert (perPageMap != null);
@@ -376,7 +376,7 @@ public class PostOfficeJournalLoader implements JournalLoader {
             }
             else {
                // on this case the page file didn't exist, we just remove all the records
since the page is already gone
-               logger.debug("Page " + pageId + " didn't exist on address " + address + ",
so we are just removing records");
+               logger.debug("Page " + pageId + " didn't exist on address " + addressPageMapEntry.getKey()
+ ", so we are just removing records");
                for (List<PageCountPending> records : perQueue.values()) {
                   for (PageCountPending record : records) {
                      logger.debug("Removing pending page counter " + record.getID());

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/275924e8/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java
index 41b7bd1..c6d3f70 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java
@@ -409,15 +409,15 @@ public class ScaleDownHandler {
       try (ClientSession session = sessionFactory.createSession(user, password, true, false,
false, false, 0);
            ClientProducer producer = session.createProducer(managementAddress)) {
          //todo - https://issues.jboss.org/browse/HORNETQ-1336
-         for (SimpleString address : duplicateIDMap.keySet()) {
+         for (Map.Entry<SimpleString,List<Pair<byte[], Long>>> entry :
duplicateIDMap.entrySet()) {
             ClientMessage message = session.createMessage(false);
-            List<Pair<byte[], Long>> list = duplicateIDMap.get(address);
+            List<Pair<byte[], Long>> list = entry.getValue();
             String[] array = new String[list.size()];
             for (int i = 0; i < list.size(); i++) {
                Pair<byte[], Long> pair = list.get(i);
                array[i] = new String(pair.getA());
             }
-            ManagementHelper.putOperationInvocation(message, ResourceNames.CORE_SERVER, "updateDuplicateIdCache",
address.toString(), array);
+            ManagementHelper.putOperationInvocation(message, ResourceNames.CORE_SERVER, "updateDuplicateIdCache",
entry.getKey().toString(), array);
             producer.send(message);
          }
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/275924e8/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
index 761af7d..8cfc31b 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
@@ -298,8 +298,9 @@ public abstract class ActiveMQTestBase extends Assert {
             fail("Client Session Factories still trying to reconnect, see above to see where
created");
          }
          Map<Thread, StackTraceElement[]> threadMap = Thread.getAllStackTraces();
-         for (Thread thread : threadMap.keySet()) {
-            StackTraceElement[] stack = threadMap.get(thread);
+         for (Map.Entry<Thread, StackTraceElement[]> entry : threadMap.entrySet())
{
+            Thread thread = entry.getKey();
+            StackTraceElement[] stack = entry.getValue();
             for (StackTraceElement stackTraceElement : stack) {
                if (stackTraceElement.getMethodName().contains("getConnectionWithRetry") &&
!alreadyFailedThread.contains(thread)) {
                   alreadyFailedThread.add(thread);


Mime
View raw message