You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ma...@apache.org on 2016/11/30 13:27:28 UTC

[08/27] activemq-artemis git commit: Consolidate CreateQueueMessage impls

Consolidate CreateQueueMessage impls


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

Branch: refs/heads/ARTEMIS-780
Commit: 3017201ed2ddb4bcd63182bef5b8cb3c58928e9b
Parents: 806c688
Author: jbertram <jb...@apache.com>
Authored: Mon Nov 28 19:11:55 2016 -0600
Committer: jbertram <jb...@apache.com>
Committed: Mon Nov 28 19:11:55 2016 -0600

----------------------------------------------------------------------
 .../core/impl/ActiveMQSessionContext.java       |   4 +-
 .../core/protocol/core/impl/PacketDecoder.java  |   6 -
 .../core/protocol/core/impl/PacketImpl.java     |   4 +-
 .../impl/wireformat/CreateAddressMessage.java   |   5 +-
 .../impl/wireformat/CreateQueueMessage_V2.java  |  64 ++++++++-
 .../impl/wireformat/CreateQueueMessage_V3.java  | 134 -------------------
 .../core/ServerSessionPacketHandler.java        |  20 ---
 7 files changed, 67 insertions(+), 170 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/3017201e/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java
index 29426dd..ed08142 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java
@@ -54,7 +54,7 @@ import org.apache.activemq.artemis.core.protocol.core.Packet;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ActiveMQExceptionMessage;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateAddressMessage;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateQueueMessage;
-import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateQueueMessage_V3;
+import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateQueueMessage_V2;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSessionMessage;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSharedQueueMessage_V2;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.DisconnectConsumerMessage;
@@ -625,7 +625,7 @@ public class ActiveMQSessionContext extends SessionContext {
                            int maxConsumers,
                            boolean deleteOnNoConsumers,
                            boolean autoCreated) throws ActiveMQException {
-      CreateQueueMessage request = new CreateQueueMessage_V3(address, queueName, routingType, filterString, durable, temp, maxConsumers, deleteOnNoConsumers, autoCreated, true);
+      CreateQueueMessage request = new CreateQueueMessage_V2(address, queueName, routingType, filterString, durable, temp, maxConsumers, deleteOnNoConsumers, autoCreated, true);
       sessionChannel.sendBlocking(request, PacketImpl.NULL_RESPONSE);
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/3017201e/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/PacketDecoder.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/PacketDecoder.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/PacketDecoder.java
index dbd7091..15629c8 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/PacketDecoder.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/PacketDecoder.java
@@ -30,7 +30,6 @@ import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ClusterTop
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateAddressMessage;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateQueueMessage;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateQueueMessage_V2;
-import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateQueueMessage_V3;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSessionMessage;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSessionResponseMessage;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSharedQueueMessage;
@@ -95,7 +94,6 @@ import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CRE
 import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_ADDRESS;
 import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_QUEUE;
 import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_QUEUE_V2;
-import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_QUEUE_V3;
 import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_SHARED_QUEUE;
 import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_SHARED_QUEUE_V2;
 import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.DELETE_QUEUE;
@@ -255,10 +253,6 @@ public abstract class PacketDecoder implements Serializable {
             packet = new CreateQueueMessage_V2();
             break;
          }
-         case CREATE_QUEUE_V3: {
-            packet = new CreateQueueMessage_V3();
-            break;
-         }
          case CREATE_SHARED_QUEUE: {
             packet = new CreateSharedQueueMessage();
             break;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/3017201e/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/PacketImpl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/PacketImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/PacketImpl.java
index e252623..a65bdfc 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/PacketImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/PacketImpl.java
@@ -253,9 +253,7 @@ public class PacketImpl implements Packet {
 
    public static final byte CREATE_QUEUE_V2 = -12;
 
-   public static final byte CREATE_QUEUE_V3 = -13;
-
-   public static final byte CREATE_SHARED_QUEUE_V2 = -14;
+   public static final byte CREATE_SHARED_QUEUE_V2 = -13;
 
    // Static --------------------------------------------------------
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/3017201e/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateAddressMessage.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateAddressMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateAddressMessage.java
index 9b18e48..35f0f40 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateAddressMessage.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateAddressMessage.java
@@ -134,7 +134,10 @@ public class CreateAddressMessage extends PacketImpl {
             return false;
       } else if (!address.equals(other.address))
          return false;
-      if (routingTypes.equals(other.routingTypes))
+      if (routingTypes == null) {
+         if (other.routingTypes != null)
+            return false;
+      } else if (!routingTypes.equals(other.routingTypes))
          return false;
       if (autoCreated != other.autoCreated)
          return false;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/3017201e/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateQueueMessage_V2.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateQueueMessage_V2.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateQueueMessage_V2.java
index 610646e..e2867ab 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateQueueMessage_V2.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateQueueMessage_V2.java
@@ -18,16 +18,26 @@ package org.apache.activemq.artemis.core.protocol.core.impl.wireformat;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.server.RoutingType;
 
 public class CreateQueueMessage_V2 extends CreateQueueMessage {
 
    protected boolean autoCreated;
 
+   private RoutingType routingType;
+
+   private int maxConsumers;
+
+   private boolean deleteOnNoConsumers;
+
    public CreateQueueMessage_V2(final SimpleString address,
                                 final SimpleString queueName,
+                                final RoutingType routingType,
                                 final SimpleString filterString,
                                 final boolean durable,
                                 final boolean temporary,
+                                final int maxConsumers,
+                                final boolean deleteOnNoConsumers,
                                 final boolean autoCreated,
                                 final boolean requiresResponse) {
       this();
@@ -39,26 +49,52 @@ public class CreateQueueMessage_V2 extends CreateQueueMessage {
       this.temporary = temporary;
       this.autoCreated = autoCreated;
       this.requiresResponse = requiresResponse;
+      this.routingType = routingType;
+      this.maxConsumers = maxConsumers;
+      this.deleteOnNoConsumers = deleteOnNoConsumers;
    }
 
    public CreateQueueMessage_V2() {
       super(CREATE_QUEUE_V2);
    }
 
-   public CreateQueueMessage_V2(byte packet) {
-      super(packet);
-   }
-
    // Public --------------------------------------------------------
 
    @Override
    public String toString() {
       StringBuffer buff = new StringBuffer(super.getParentString());
       buff.append(", autoCreated=" + autoCreated);
+      buff.append(", routingType=" + routingType);
+      buff.append(", maxConsumers=" + maxConsumers);
+      buff.append(", deleteOnNoConsumers=" + deleteOnNoConsumers);
       buff.append("]");
       return buff.toString();
    }
 
+   public RoutingType getRoutingType() {
+      return routingType;
+   }
+
+   public void setRoutingType(RoutingType routingType) {
+      this.routingType = routingType;
+   }
+
+   public int getMaxConsumers() {
+      return maxConsumers;
+   }
+
+   public void setMaxConsumers(int maxConsumers) {
+      this.maxConsumers = maxConsumers;
+   }
+
+   public boolean isDeleteOnNoConsumers() {
+      return deleteOnNoConsumers;
+   }
+
+   public void setDeleteOnNoConsumers(boolean deleteOnNoConsumers) {
+      this.deleteOnNoConsumers = deleteOnNoConsumers;
+   }
+
    public boolean isAutoCreated() {
       return autoCreated;
    }
@@ -71,12 +107,18 @@ public class CreateQueueMessage_V2 extends CreateQueueMessage {
    public void encodeRest(final ActiveMQBuffer buffer) {
       super.encodeRest(buffer);
       buffer.writeBoolean(autoCreated);
+      buffer.writeByte(routingType.getType());
+      buffer.writeInt(maxConsumers);
+      buffer.writeBoolean(deleteOnNoConsumers);
    }
 
    @Override
    public void decodeRest(final ActiveMQBuffer buffer) {
       super.decodeRest(buffer);
       autoCreated = buffer.readBoolean();
+      routingType = RoutingType.getType(buffer.readByte());
+      maxConsumers = buffer.readInt();
+      deleteOnNoConsumers = buffer.readBoolean();
    }
 
    @Override
@@ -84,6 +126,9 @@ public class CreateQueueMessage_V2 extends CreateQueueMessage {
       final int prime = 31;
       int result = super.hashCode();
       result = prime * result + (autoCreated ? 1231 : 1237);
+      result = prime * result + (routingType.getType());
+      result = prime * result + (maxConsumers);
+      result = prime * result + (deleteOnNoConsumers ? 1231 : 1237);
       return result;
    }
 
@@ -98,6 +143,17 @@ public class CreateQueueMessage_V2 extends CreateQueueMessage {
       CreateQueueMessage_V2 other = (CreateQueueMessage_V2) obj;
       if (autoCreated != other.autoCreated)
          return false;
+      if (maxConsumers != other.maxConsumers)
+         return false;
+      if (deleteOnNoConsumers != other.deleteOnNoConsumers)
+         return false;
+      if (deleteOnNoConsumers != other.deleteOnNoConsumers)
+         return false;
+      if (routingType == null) {
+         if (other.routingType != null)
+            return false;
+      } else if (!routingType.equals(other.routingType))
+         return false;
       return true;
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/3017201e/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateQueueMessage_V3.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateQueueMessage_V3.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateQueueMessage_V3.java
deleted file mode 100644
index fb5c9ef..0000000
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateQueueMessage_V3.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.core.protocol.core.impl.wireformat;
-
-import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
-import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.server.RoutingType;
-
-public class CreateQueueMessage_V3 extends CreateQueueMessage_V2 {
-
-   private RoutingType routingType;
-
-   private int maxConsumers;
-
-   private boolean deleteOnNoConsumers;
-
-   public CreateQueueMessage_V3(final SimpleString address,
-                                final SimpleString queueName,
-                                final RoutingType routingType,
-                                final SimpleString filterString,
-                                final boolean durable,
-                                final boolean temporary,
-                                final int maxConsumers,
-                                final boolean deleteOnNoConsumers,
-                                final boolean autoCreated,
-                                final boolean requiresResponse) {
-      this();
-
-      this.address = address;
-      this.queueName = queueName;
-      this.filterString = filterString;
-      this.durable = durable;
-      this.temporary = temporary;
-      this.autoCreated = autoCreated;
-      this.requiresResponse = requiresResponse;
-      this.routingType = routingType;
-      this.maxConsumers = maxConsumers;
-      this.deleteOnNoConsumers = deleteOnNoConsumers;
-   }
-
-   public CreateQueueMessage_V3() {
-      super(CREATE_QUEUE_V3);
-   }
-
-   // Public --------------------------------------------------------
-
-   @Override
-   public String toString() {
-      StringBuffer buff = new StringBuffer(super.getParentString());
-      buff.append(", routingType=" + routingType);
-      buff.append(", maxConsumers=" + maxConsumers);
-      buff.append(", deleteOnNoConsumers=" + deleteOnNoConsumers);
-      buff.append("]");
-      return buff.toString();
-   }
-
-   public RoutingType getRoutingType() {
-      return routingType;
-   }
-
-   public void setRoutingType(RoutingType routingType) {
-      this.routingType = routingType;
-   }
-
-   public int getMaxConsumers() {
-      return maxConsumers;
-   }
-
-   public void setMaxConsumers(int maxConsumers) {
-      this.maxConsumers = maxConsumers;
-   }
-
-   public boolean isDeleteOnNoConsumers() {
-      return deleteOnNoConsumers;
-   }
-
-   public void setDeleteOnNoConsumers(boolean deleteOnNoConsumers) {
-      this.deleteOnNoConsumers = deleteOnNoConsumers;
-   }
-
-   @Override
-   public void encodeRest(final ActiveMQBuffer buffer) {
-      super.encodeRest(buffer);
-      buffer.writeByte(routingType.getType());
-      buffer.writeInt(maxConsumers);
-      buffer.writeBoolean(deleteOnNoConsumers);
-   }
-
-   @Override
-   public void decodeRest(final ActiveMQBuffer buffer) {
-      super.decodeRest(buffer);
-      routingType = RoutingType.getType(buffer.readByte());
-      maxConsumers = buffer.readInt();
-      deleteOnNoConsumers = buffer.readBoolean();
-   }
-
-   @Override
-   public int hashCode() {
-      final int prime = 31;
-      int result = super.hashCode();
-      result = prime * result + (routingType.getType());
-      result = prime * result + (maxConsumers);
-      result = prime * result + (deleteOnNoConsumers ? 1231 : 1237);
-      return result;
-   }
-
-   @Override
-   public boolean equals(Object obj) {
-      if (this == obj)
-         return true;
-      if (!super.equals(obj))
-         return false;
-      if (!(obj instanceof CreateQueueMessage_V3))
-         return false;
-      CreateQueueMessage_V3 other = (CreateQueueMessage_V3) obj;
-      if (autoCreated != other.autoCreated)
-         return false;
-      return true;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/3017201e/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java
index 5c43683..65ffc69 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java
@@ -33,7 +33,6 @@ import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ActiveMQEx
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateAddressMessage;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateQueueMessage;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateQueueMessage_V2;
-import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateQueueMessage_V3;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSharedQueueMessage;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSharedQueueMessage_V2;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.NullResponseMessage;
@@ -80,7 +79,6 @@ import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnection;
 import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.BindingQueryResult;
-import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.QueueQueryResult;
 import org.apache.activemq.artemis.core.server.RoutingType;
 import org.apache.activemq.artemis.core.server.ServerMessage;
@@ -91,7 +89,6 @@ import org.jboss.logging.Logger;
 import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_ADDRESS;
 import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_QUEUE;
 import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_QUEUE_V2;
-import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_QUEUE_V3;
 import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_SHARED_QUEUE;
 import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_SHARED_QUEUE_V2;
 import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.DELETE_QUEUE;
@@ -251,23 +248,6 @@ public class ServerSessionPacketHandler implements ChannelHandler {
                case CREATE_QUEUE_V2: {
                   CreateQueueMessage_V2 request = (CreateQueueMessage_V2) packet;
                   requiresResponse = request.isRequiresResponse();
-                  session.createQueue(request.getAddress(),
-                                      request.getQueueName(),
-                                      RoutingType.MULTICAST,
-                                      request.getFilterString(),
-                                      request.isTemporary(),
-                                      request.isDurable(),
-                                      Queue.MAX_CONSUMERS_UNLIMITED,
-                                      false,
-                                      request.isAutoCreated());
-                  if (requiresResponse) {
-                     response = new NullResponseMessage();
-                  }
-                  break;
-               }
-               case CREATE_QUEUE_V3: {
-                  CreateQueueMessage_V3 request = (CreateQueueMessage_V3) packet;
-                  requiresResponse = request.isRequiresResponse();
                   session.createQueue(request.getAddress(), request.getQueueName(), request.getRoutingType(), request.getFilterString(), request.isTemporary(), request.isDurable(), request.getMaxConsumers(), request.isDeleteOnNoConsumers(),
                                       request.isAutoCreated());
                   if (requiresResponse) {