You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2017/11/21 17:02:19 UTC

[1/2] activemq-artemis git commit: ARTEMIS-1416 Implementing cache on queue and address querying

Repository: activemq-artemis
Updated Branches:
  refs/heads/master 16d9b191a -> 482e49e3f


ARTEMIS-1416 Implementing cache on queue and address querying

This will cache the last query, optimizing most of the cases
This won't optimize the case where you are sending producers with different address,
but this is not the one I'm after now.


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

Branch: refs/heads/master
Commit: 1d1d6c8b4686f869df0ca5fc09c20128f8481cff
Parents: 16d9b19
Author: Clebert Suconic <cl...@apache.org>
Authored: Tue Nov 21 10:12:20 2017 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Nov 21 10:49:07 2017 -0500

----------------------------------------------------------------------
 .../amqp/broker/AMQPSessionCallback.java        | 51 +++++++++++++++++++-
 1 file changed, 49 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/1d1d6c8b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java
index 42e9625..14e13b1 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java
@@ -98,6 +98,11 @@ public class AMQPSessionCallback implements SessionCallback {
 
    private final AtomicBoolean draining = new AtomicBoolean(false);
 
+
+   private final AddressQueryCache<AddressQueryResult> addressQueryCache = new AddressQueryCache<>();
+
+   private final AddressQueryCache<BindingQueryResult> bindingQueryCache = new AddressQueryCache<>();
+
    public AMQPSessionCallback(AMQPConnectionCallback protonSPI,
                               ProtonProtocolManager manager,
                               AMQPConnectionContext connection,
@@ -277,9 +282,17 @@ public class AMQPSessionCallback implements SessionCallback {
       return queueQueryResult;
    }
 
+
+
    public boolean bindingQuery(String address, RoutingType routingType) throws Exception {
+      BindingQueryResult bindingQueryResult = bindingQueryCache.getResult(address);
+
+      if (bindingQueryResult != null) {
+         return bindingQueryResult.isExists();
+      }
+
       SimpleString simpleAddress = SimpleString.toSimpleString(address);
-      BindingQueryResult bindingQueryResult = serverSession.executeBindingQuery(simpleAddress);
+      bindingQueryResult = serverSession.executeBindingQuery(simpleAddress);
       if (routingType == RoutingType.MULTICAST && !bindingQueryResult.isExists() && bindingQueryResult.isAutoCreateAddresses()) {
          try {
             serverSession.createAddress(simpleAddress, routingType, true);
@@ -298,13 +311,22 @@ public class AMQPSessionCallback implements SessionCallback {
          }
          bindingQueryResult = serverSession.executeBindingQuery(simpleAddress);
       }
+
+      bindingQueryCache.setResult(address, bindingQueryResult);
       return bindingQueryResult.isExists();
    }
 
+
    public AddressQueryResult addressQuery(String addressName,
                                           RoutingType routingType,
                                           boolean autoCreate) throws Exception {
-      AddressQueryResult addressQueryResult = serverSession.executeAddressQuery(SimpleString.toSimpleString(addressName));
+
+      AddressQueryResult addressQueryResult = addressQueryCache.getResult(addressName);
+      if (addressQueryResult != null) {
+         return addressQueryResult;
+      }
+
+      addressQueryResult = serverSession.executeAddressQuery(SimpleString.toSimpleString(addressName));
 
       if (!addressQueryResult.isExists() && addressQueryResult.isAutoCreateAddresses() && autoCreate) {
          try {
@@ -314,6 +336,8 @@ public class AMQPSessionCallback implements SessionCallback {
          }
          addressQueryResult = serverSession.executeAddressQuery(SimpleString.toSimpleString(addressName));
       }
+
+      addressQueryCache.setResult(addressName, addressQueryResult);
       return addressQueryResult;
    }
 
@@ -685,4 +709,27 @@ public class AMQPSessionCallback implements SessionCallback {
    public void removeProducer(String name) {
       serverSession.removeProducer(name);
    }
+
+
+   class AddressQueryCache<T> {
+      String address;
+      T result;
+
+      public synchronized T getResult(String parameterAddress) {
+         if (address != null && address.equals(parameterAddress)) {
+            return result;
+         } else {
+            result = null;
+            address = null;
+            return null;
+         }
+      }
+
+      public synchronized void setResult(String parameterAddress, T result) {
+         this.address = parameterAddress;
+         this.result = result;
+      }
+
+   }
+
 }


[2/2] activemq-artemis git commit: This closes #1663

Posted by ta...@apache.org.
This closes #1663


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

Branch: refs/heads/master
Commit: 482e49e3fd9cb64acaccb571bca6e7def9ada783
Parents: 16d9b19 1d1d6c8
Author: Timothy Bish <ta...@gmail.com>
Authored: Tue Nov 21 12:01:48 2017 -0500
Committer: Timothy Bish <ta...@gmail.com>
Committed: Tue Nov 21 12:01:48 2017 -0500

----------------------------------------------------------------------
 .../amqp/broker/AMQPSessionCallback.java        | 51 +++++++++++++++++++-
 1 file changed, 49 insertions(+), 2 deletions(-)
----------------------------------------------------------------------