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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

clebertsuconic-2
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 5b07c635a -> 1aa211f90


This closes #2200


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

Branch: refs/heads/master
Commit: 1aa211f900fb10a71d8db570c63b5bc9e78eff60
Parents: 5b07c63 332cee8
Author: Clebert Suconic <[hidden email]>
Authored: Tue Jul 31 14:17:20 2018 -0400
Committer: Clebert Suconic <[hidden email]>
Committed: Tue Jul 31 14:17:20 2018 -0400

----------------------------------------------------------------------
 artemis-selector/pom.xml                                |  5 +++++
 .../activemq/artemis/selector/filter/Filterable.java    |  4 +++-
 .../artemis/selector/filter/PropertyExpression.java     | 12 +++++++++---
 .../apache/activemq/artemis/selector/SelectorTest.java  | 10 ++++++----
 .../activemq/artemis/core/filter/impl/FilterImpl.java   | 10 +++++-----
 5 files changed, 28 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


Reply | Threaded
Open this post in threaded view
|

[2/2] activemq-artemis git commit: ARTEMIS-1997 - un-needed SimpleString creation on hotpath with Filters

clebertsuconic-2
ARTEMIS-1997 - un-needed SimpleString creation on hotpath with Filters

Create the SimpleString on construction of PropertyExpression so it can be re-used instead of creating it every time its filtered in the FilterImpl


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

Branch: refs/heads/master
Commit: 332cee8e663e729e2af274715cf0e1911a320297
Parents: 5b07c63
Author: Michael André Pearce <[hidden email]>
Authored: Sun Jul 22 04:17:50 2018 +0100
Committer: Clebert Suconic <[hidden email]>
Committed: Tue Jul 31 14:17:20 2018 -0400

----------------------------------------------------------------------
 artemis-selector/pom.xml                                |  5 +++++
 .../activemq/artemis/selector/filter/Filterable.java    |  4 +++-
 .../artemis/selector/filter/PropertyExpression.java     | 12 +++++++++---
 .../apache/activemq/artemis/selector/SelectorTest.java  | 10 ++++++----
 .../activemq/artemis/core/filter/impl/FilterImpl.java   | 10 +++++-----
 5 files changed, 28 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/332cee8e/artemis-selector/pom.xml
----------------------------------------------------------------------
diff --git a/artemis-selector/pom.xml b/artemis-selector/pom.xml
index 1fc51b3..7d9b644 100644
--- a/artemis-selector/pom.xml
+++ b/artemis-selector/pom.xml
@@ -33,6 +33,11 @@
 
    <dependencies>
       <dependency>
+         <groupId>org.apache.activemq</groupId>
+         <artifactId>artemis-commons</artifactId>
+         <version>${project.version}</version>
+      </dependency>
+      <dependency>
          <groupId>xml-apis</groupId>
          <artifactId>xml-apis</artifactId>
          <optional>true</optional>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/332cee8e/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/Filterable.java
----------------------------------------------------------------------
diff --git a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/Filterable.java b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/Filterable.java
index 5339613..4ac7620 100755
--- a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/Filterable.java
+++ b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/Filterable.java
@@ -16,6 +16,8 @@
  */
 package org.apache.activemq.artemis.selector.filter;
 
+import org.apache.activemq.artemis.api.core.SimpleString;
+
 /**
  * A Filterable is the object being evaluated by the filters.  It provides
  * access to filtered properties.
@@ -41,7 +43,7 @@ public interface Filterable {
     * @param name
     * @return
     */
-   Object getProperty(String name);
+   Object getProperty(SimpleString name);
 
    /**
     * Used by the NoLocal filter.

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/332cee8e/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/PropertyExpression.java
----------------------------------------------------------------------
diff --git a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/PropertyExpression.java b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/PropertyExpression.java
index 4c8c8c5..9fa6267 100755
--- a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/PropertyExpression.java
+++ b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/PropertyExpression.java
@@ -16,6 +16,8 @@
  */
 package org.apache.activemq.artemis.selector.filter;
 
+import org.apache.activemq.artemis.api.core.SimpleString;
+
 /**
  * Represents a property expression
  *
@@ -23,9 +25,13 @@ package org.apache.activemq.artemis.selector.filter;
  */
 public class PropertyExpression implements Expression {
 
-   private final String name;
+   private final SimpleString name;
 
    public PropertyExpression(String name) {
+      this(SimpleString.toSimpleString(name));
+   }
+
+   public PropertyExpression(SimpleString name) {
       this.name = name;
    }
 
@@ -35,7 +41,7 @@ public class PropertyExpression implements Expression {
    }
 
    public String getName() {
-      return name;
+      return name.toString();
    }
 
    /**
@@ -43,7 +49,7 @@ public class PropertyExpression implements Expression {
     */
    @Override
    public String toString() {
-      return name;
+      return name.toString();
    }
 
    /**

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/332cee8e/artemis-selector/src/test/java/org/apache/activemq/artemis/selector/SelectorTest.java
----------------------------------------------------------------------
diff --git a/artemis-selector/src/test/java/org/apache/activemq/artemis/selector/SelectorTest.java b/artemis-selector/src/test/java/org/apache/activemq/artemis/selector/SelectorTest.java
index a540ed7..1be9d47 100755
--- a/artemis-selector/src/test/java/org/apache/activemq/artemis/selector/SelectorTest.java
+++ b/artemis-selector/src/test/java/org/apache/activemq/artemis/selector/SelectorTest.java
@@ -18,6 +18,7 @@ package org.apache.activemq.artemis.selector;
 
 import java.util.HashMap;
 
+import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.selector.filter.BooleanExpression;
 import org.apache.activemq.artemis.selector.filter.FilterException;
 import org.apache.activemq.artemis.selector.filter.Filterable;
@@ -100,14 +101,15 @@ public class SelectorTest {
       }
 
       @Override
-      public Object getProperty(String name) {
-         if ("JMSType".equals(name)) {
+      public Object getProperty(SimpleString name) {
+         String stringName = name.toString();
+         if ("JMSType".equals(stringName)) {
             return type;
          }
-         if ("JMSMessageID".equals(name)) {
+         if ("JMSMessageID".equals(stringName)) {
             return messageId;
          }
-         return properties.get(name);
+         return properties.get(stringName);
       }
 
       public Object getDestination() {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/332cee8e/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java
index 33a1187..7ee7b6b 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java
@@ -154,7 +154,7 @@ public class FilterImpl implements Filter {
             // Proton stores JMSMessageID as NATIVE_MESSAGE_ID that is an arbitrary string
             String amqpNativeID = msg.getStringProperty(NATIVE_MESSAGE_ID);
             if (amqpNativeID != null) {
-               return new SimpleString(amqpNativeID);
+               return SimpleString.toSimpleString(amqpNativeID);
             }
          }
          // It's the stringified (hex) representation of a user id that can be used in a selector expression
@@ -162,7 +162,7 @@ public class FilterImpl implements Filter {
          if (userID.startsWith("ID:")) {
             return SimpleString.toSimpleString(userID);
          } else {
-            return new SimpleString("ID:" + msg.getUserID());
+            return SimpleString.toSimpleString("ID:" + msg.getUserID());
          }
       } else if (FilterConstants.ACTIVEMQ_PRIORITY.equals(fieldName)) {
          return Integer.valueOf(msg.getPriority());
@@ -190,10 +190,10 @@ public class FilterImpl implements Filter {
       }
 
       @Override
-      public Object getProperty(String id) {
+      public Object getProperty(SimpleString id) {
          Object result = null;
-         if (id.startsWith(FilterConstants.ACTIVEMQ_PREFIX.toString())) {
-            result = getHeaderFieldValue(message, new SimpleString(id));
+         if (id.startsWith(FilterConstants.ACTIVEMQ_PREFIX)) {
+            result = getHeaderFieldValue(message, id);
          }
          if (result == null) {
             result = message.getObjectProperty(id);