activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From martyntay...@apache.org
Subject [24/33] activemq-artemis git commit: ARTEMIS-781 add journal record for address binding
Date Tue, 25 Oct 2016 13:19:39 GMT
ARTEMIS-781 add journal record for address binding


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

Branch: refs/heads/ARTEMIS-780
Commit: 35f97113ac672586ff6db2b7ea3d8e2943c9776f
Parents: 8b18229
Author: jbertram <jbertram@apache.com>
Authored: Mon Oct 10 15:11:50 2016 -0500
Committer: Martyn Taylor <mtaylor@redhat.com>
Committed: Tue Oct 25 14:17:24 2016 +0100

----------------------------------------------------------------------
 .../core/persistence/AddressBindingInfo.java    |  34 +++++
 .../core/persistence/impl/RoutingType.java      |  43 ++++++
 .../codec/PersistentAddressBindingEncoding.java | 135 +++++++++++++++++++
 3 files changed, 212 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/35f97113/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/AddressBindingInfo.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/AddressBindingInfo.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/AddressBindingInfo.java
new file mode 100644
index 0000000..4256774
--- /dev/null
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/AddressBindingInfo.java
@@ -0,0 +1,34 @@
+/*
+ * 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.persistence;
+
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.persistence.impl.RoutingType;
+
+public interface AddressBindingInfo {
+
+   long getId();
+
+   SimpleString getName();
+
+   boolean isAutoCreated();
+
+   SimpleString getUser();
+
+   RoutingType getRoutingType();
+
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/35f97113/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/RoutingType.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/RoutingType.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/RoutingType.java
new file mode 100644
index 0000000..329d8e9
--- /dev/null
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/RoutingType.java
@@ -0,0 +1,43 @@
+/*
+ * 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.persistence.impl;
+
+public enum RoutingType {
+   Multicast, Anycast;
+
+   public byte getType() {
+      switch (this) {
+         case Multicast:
+            return 0;
+         case Anycast:
+            return 1;
+         default:
+            return -1;
+      }
+   }
+
+   public static RoutingType getType(byte type) {
+      switch (type) {
+         case 0:
+            return Multicast;
+         case 1:
+            return Anycast;
+         default:
+            return null;
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/35f97113/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/PersistentAddressBindingEncoding.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/PersistentAddressBindingEncoding.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/PersistentAddressBindingEncoding.java
new file mode 100644
index 0000000..8aa54e4
--- /dev/null
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/PersistentAddressBindingEncoding.java
@@ -0,0 +1,135 @@
+/*
+ * 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.persistence.impl.journal.codec;
+
+import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.journal.EncodingSupport;
+import org.apache.activemq.artemis.core.persistence.AddressBindingInfo;
+import org.apache.activemq.artemis.core.persistence.impl.RoutingType;
+import org.apache.activemq.artemis.utils.DataConstants;
+
+public class PersistentAddressBindingEncoding implements EncodingSupport, AddressBindingInfo
{
+
+   public long id;
+
+   public SimpleString name;
+
+   public boolean autoCreated;
+
+   public SimpleString user;
+
+   public RoutingType routingType;
+
+   public PersistentAddressBindingEncoding() {
+   }
+
+   @Override
+   public String toString() {
+      return "PersistentAddressBindingEncoding [id=" + id +
+         ", name=" +
+         name +
+         ", user=" +
+         user +
+         ", autoCreated=" +
+         autoCreated +
+         ", routingType=" +
+         routingType +
+         "]";
+   }
+
+   public PersistentAddressBindingEncoding(final SimpleString name,
+                                           final SimpleString user,
+                                           final boolean autoCreated,
+                                           final RoutingType routingType) {
+      this.name = name;
+      this.user = user;
+      this.autoCreated = autoCreated;
+      this.routingType = routingType;
+   }
+
+   @Override
+   public long getId() {
+      return id;
+   }
+
+   public void setId(final long id) {
+      this.id = id;
+   }
+
+   @Override
+   public SimpleString getName() {
+      return name;
+   }
+
+   @Override
+   public SimpleString getUser() {
+      return user;
+   }
+
+   @Override
+   public boolean isAutoCreated() {
+      return autoCreated;
+   }
+
+   @Override
+   public RoutingType getRoutingType() {
+      return routingType;
+   }
+
+   @Override
+   public void decode(final ActiveMQBuffer buffer) {
+      name = buffer.readSimpleString();
+
+      String metadata = buffer.readNullableSimpleString().toString();
+      if (metadata != null) {
+         String[] elements = metadata.split(";");
+         for (String element : elements) {
+            String[] keyValuePair = element.split("=");
+            if (keyValuePair.length == 2) {
+               if (keyValuePair[0].equals("user")) {
+                  user = SimpleString.toSimpleString(keyValuePair[1]);
+               }
+            }
+         }
+      }
+
+      autoCreated = buffer.readBoolean();
+      routingType = RoutingType.getType(buffer.readByte());
+   }
+
+   @Override
+   public void encode(final ActiveMQBuffer buffer) {
+      buffer.writeSimpleString(name);
+      buffer.writeNullableSimpleString(createMetadata());
+      buffer.writeBoolean(autoCreated);
+      buffer.writeByte(routingType.getType());
+   }
+
+   @Override
+   public int getEncodeSize() {
+      return SimpleString.sizeofString(name) + DataConstants.SIZE_BOOLEAN +
+         SimpleString.sizeofNullableString(createMetadata()) +
+         DataConstants.SIZE_BYTE;
+   }
+
+   private SimpleString createMetadata() {
+      StringBuilder metadata = new StringBuilder();
+      metadata.append("user=").append(user).append(";");
+      return SimpleString.toSimpleString(metadata.toString());
+   }
+}


Mime
View raw message