activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject activemq-artemis git commit: ARTEMIS-2072 eliminate unnecessary binding queries
Date Tue, 04 Sep 2018 17:28:32 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/2.6.x 170fa4c76 -> 64568efca


ARTEMIS-2072 eliminate unnecessary binding queries

(cherry picked from commit d91da412c36c590bd6f0e18f660b45c28e2ad346)


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

Branch: refs/heads/2.6.x
Commit: 64568efca75f7ee012a854af89dc259d3fbeba96
Parents: 170fa4c
Author: Justin Bertram <jbertram@apache.org>
Authored: Tue Sep 4 10:34:03 2018 -0500
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Tue Sep 4 13:28:25 2018 -0400

----------------------------------------------------------------------
 .../amqp/broker/AMQPSessionCallback.java        | 38 +++++++++-----------
 .../proton/ProtonServerReceiverContext.java     |  2 +-
 2 files changed, 18 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64568efc/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 b99a053..b32a4c7 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
@@ -38,7 +38,6 @@ import org.apache.activemq.artemis.core.persistence.StorageManager;
 import org.apache.activemq.artemis.core.security.CheckType;
 import org.apache.activemq.artemis.core.security.SecurityAuth;
 import org.apache.activemq.artemis.core.server.AddressQueryResult;
-import org.apache.activemq.artemis.core.server.BindingQueryResult;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.QueueQueryResult;
 import org.apache.activemq.artemis.core.server.ServerConsumer;
@@ -109,8 +108,6 @@ public class AMQPSessionCallback implements SessionCallback {
 
    private final AddressQueryCache<AddressQueryResult> addressQueryCache = new AddressQueryCache<>();
 
-   private final AddressQueryCache<BindingQueryResult> bindingQueryCache = new AddressQueryCache<>();
-
    public AMQPSessionCallback(AMQPConnectionCallback protonSPI,
                               ProtonProtocolManager manager,
                               AMQPConnectionContext connection,
@@ -308,35 +305,34 @@ public class AMQPSessionCallback implements SessionCallback {
 
 
 
-   public boolean bindingQuery(SimpleString address, RoutingType routingType) throws Exception
{
-      BindingQueryResult bindingQueryResult = bindingQueryCache.getResult(address);
+   public boolean checkAddressAndAutocreateIfPossible(SimpleString address, RoutingType routingType)
throws Exception {
+      AddressInfo addressInfo = manager.getServer().getAddressInfo(address);
 
-      if (bindingQueryResult != null) {
-         return bindingQueryResult.isExists();
+      // if the address exists go ahead and return
+      if (addressInfo != null) {
+         return true;
       }
 
-      bindingQueryResult = serverSession.executeBindingQuery(address);
-      if (routingType == RoutingType.MULTICAST && !bindingQueryResult.isExists()
&& bindingQueryResult.isAutoCreateAddresses()) {
-         try {
-            serverSession.createAddress(address, routingType, true);
-         } catch (ActiveMQAddressExistsException e) {
-            // The address may have been created by another thread in the mean time.  Catch
and do nothing.
+      // if the address and/or queue don't exist then create them if possible
+      if (routingType == RoutingType.MULTICAST && addressInfo == null) {
+         if (manager.getServer().getAddressSettingsRepository().getMatch(address.toString()).isAutoCreateAddresses())
{
+            try {
+               serverSession.createAddress(address, routingType, true);
+            } catch (ActiveMQAddressExistsException e) {
+               // The address may have been created by another thread in the mean time. 
Catch and do nothing.
+            }
          }
-         bindingQueryResult = serverSession.executeBindingQuery(address);
-      } else if (routingType == RoutingType.ANYCAST && bindingQueryResult.isAutoCreateQueues())
{
-         QueueQueryResult queueBinding = serverSession.executeQueueQuery(address);
-         if (!queueBinding.isExists()) {
+      } else if (routingType == RoutingType.ANYCAST && manager.getServer().locateQueue(address)
== null) {
+         if (manager.getServer().getAddressSettingsRepository().getMatch(address.toString()).isAutoCreateQueues())
{
             try {
                serverSession.createQueue(address, address, routingType, null, false, true,
true);
             } catch (ActiveMQQueueExistsException e) {
                // The queue may have been created by another thread in the mean time.  Catch
and do nothing.
             }
          }
-         bindingQueryResult = serverSession.executeBindingQuery(address);
       }
 
-      bindingQueryCache.setResult(address, bindingQueryResult);
-      return bindingQueryResult.isExists();
+      return manager.getServer().getAddressInfo(address) != null;
    }
 
 
@@ -475,7 +471,7 @@ public class AMQPSessionCallback implements SessionCallback {
 
       //here check queue-autocreation
       RoutingType routingType = context.getRoutingType(receiver, address);
-      if (!bindingQuery(address, routingType)) {
+      if (!checkAddressAndAutocreateIfPossible(address, routingType)) {
          throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.addressDoesntExist();
       }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64568efc/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerReceiverContext.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerReceiverContext.java
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerReceiverContext.java
index e54a1a5..30dd10a 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerReceiverContext.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerReceiverContext.java
@@ -127,7 +127,7 @@ public class ProtonServerReceiverContext extends ProtonInitializable implements
             if (address != null && !address.isEmpty()) {
                defRoutingType = getRoutingType(target.getCapabilities(), address);
                try {
-                  if (!sessionSPI.bindingQuery(address, defRoutingType)) {
+                  if (!sessionSPI.checkAddressAndAutocreateIfPossible(address, defRoutingType))
{
                      throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.addressDoesntExist();
                   }
                } catch (ActiveMQAMQPNotFoundException e) {


Mime
View raw message