You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2018/07/12 18:26:29 UTC

[1/2] activemq-artemis git commit: ARTEMIS-1956 move MessageCounterInfo to core-client

Repository: activemq-artemis
Updated Branches:
  refs/heads/master c3375b9d5 -> 7d5a31af3


ARTEMIS-1956 move MessageCounterInfo to core-client


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

Branch: refs/heads/master
Commit: 9ad90511659c72b99488062a21a91d454bbfc367
Parents: c3375b9
Author: Justin Bertram <jb...@apache.org>
Authored: Wed Jun 27 14:34:00 2018 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Jul 12 14:26:22 2018 -0400

----------------------------------------------------------------------
 .../api/core/management/MessageCounterInfo.java | 152 ++++++++++++++++
 .../api/core/management/MessageCounterInfo.java | 172 -------------------
 .../core/management/impl/QueueControlImpl.java  |   3 +-
 .../core/messagecounter/MessageCounter.java     |  28 +++
 4 files changed, 181 insertions(+), 174 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/9ad90511/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/MessageCounterInfo.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/MessageCounterInfo.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/MessageCounterInfo.java
new file mode 100644
index 0000000..b0dd16c
--- /dev/null
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/MessageCounterInfo.java
@@ -0,0 +1,152 @@
+/*
+ * 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.api.core.management;
+
+import javax.json.JsonObject;
+
+import org.apache.activemq.artemis.api.core.JsonUtil;
+
+/**
+ * Helper class to create Java Objects from the
+ * JSON serialization returned by {@link QueueControl#listMessageCounter()}.
+ */
+public final class MessageCounterInfo {
+
+   private final String name;
+
+   private final String subscription;
+
+   private final boolean durable;
+
+   private final long count;
+
+   private final long countDelta;
+
+   private final int depth;
+
+   private final int depthDelta;
+
+   private final String lastAddTimestamp;
+
+   private final String udpateTimestamp;
+
+   /**
+    * Returns a MessageCounterInfo corresponding to the JSON serialization returned
+    * by {@link QueueControl#listMessageCounter()}.
+    */
+   public static MessageCounterInfo fromJSON(final String jsonString) throws Exception {
+      JsonObject data = JsonUtil.readJsonObject(jsonString);
+      String name = data.getString("destinationName");
+      String subscription = data.getString("destinationSubscription", null);
+      boolean durable = data.getBoolean("destinationDurable");
+      long count = data.getJsonNumber("count").longValue();
+      long countDelta = data.getJsonNumber("countDelta").longValue();
+      int depth = data.getInt("messageCount");
+      int depthDelta = data.getInt("messageCountDelta");
+      String lastAddTimestamp = data.getString("lastAddTimestamp");
+      String updateTimestamp = data.getString("updateTimestamp");
+
+      return new MessageCounterInfo(name, subscription, durable, count, countDelta, depth, depthDelta, lastAddTimestamp, updateTimestamp);
+   }
+
+   // Constructors --------------------------------------------------
+
+   public MessageCounterInfo(final String name,
+                             final String subscription,
+                             final boolean durable,
+                             final long count,
+                             final long countDelta,
+                             final int depth,
+                             final int depthDelta,
+                             final String lastAddTimestamp,
+                             final String udpateTimestamp) {
+      this.name = name;
+      this.subscription = subscription;
+      this.durable = durable;
+      this.count = count;
+      this.countDelta = countDelta;
+      this.depth = depth;
+      this.depthDelta = depthDelta;
+      this.lastAddTimestamp = lastAddTimestamp;
+      this.udpateTimestamp = udpateTimestamp;
+   }
+
+   // Public --------------------------------------------------------
+
+   /**
+    * Returns the name of the queue.
+    */
+   public String getName() {
+      return name;
+   }
+
+   /**
+    * Returns the name of the subscription.
+    */
+   public String getSubscription() {
+      return subscription;
+   }
+
+   /**
+    * Returns whether the queue is durable.
+    */
+   public boolean isDurable() {
+      return durable;
+   }
+
+   /**
+    * Returns the number of messages added to the queue since it was created.
+    */
+   public long getCount() {
+      return count;
+   }
+
+   /**
+    * Returns the number of messages added to the queue since the last counter sample.
+    */
+   public long getCountDelta() {
+      return countDelta;
+   }
+
+   /**
+    * Returns the number of messages currently in the queue.
+    */
+   public int getDepth() {
+      return depth;
+   }
+
+   /**
+    * Returns the number of messages in the queue since last counter sample.
+    */
+   public int getDepthDelta() {
+      return depthDelta;
+   }
+
+   /**
+    * Returns the timestamp of the last time a message was added to the queue.
+    */
+   public String getLastAddTimestamp() {
+      return lastAddTimestamp;
+   }
+
+   /**
+    * Returns the timestamp of the last time the queue was updated.
+    */
+   public String getUdpateTimestamp() {
+      return udpateTimestamp;
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/9ad90511/artemis-server/src/main/java/org/apache/activemq/artemis/api/core/management/MessageCounterInfo.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/api/core/management/MessageCounterInfo.java b/artemis-server/src/main/java/org/apache/activemq/artemis/api/core/management/MessageCounterInfo.java
deleted file mode 100644
index 8339a0f..0000000
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/api/core/management/MessageCounterInfo.java
+++ /dev/null
@@ -1,172 +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.api.core.management;
-
-import javax.json.JsonObject;
-import java.text.DateFormat;
-import java.util.Date;
-
-import org.apache.activemq.artemis.api.core.JsonUtil;
-import org.apache.activemq.artemis.core.messagecounter.MessageCounter;
-import org.apache.activemq.artemis.utils.JsonLoader;
-
-import static org.apache.activemq.artemis.api.core.JsonUtil.nullSafe;
-
-/**
- * Helper class to create Java Objects from the
- * JSON serialization returned by {@link QueueControl#listMessageCounter()}.
- */
-public final class MessageCounterInfo {
-
-   private final String name;
-
-   private final String subscription;
-
-   private final boolean durable;
-
-   private final long count;
-
-   private final long countDelta;
-
-   private final int depth;
-
-   private final int depthDelta;
-
-   private final String lastAddTimestamp;
-
-   private final String udpateTimestamp;
-
-   /**
-    * Returns a JSON String serialization of a {@link MessageCounter} object.
-    *
-    * @param counter
-    * @return
-    * @throws Exception
-    */
-   public static String toJSon(final MessageCounter counter) throws Exception {
-      DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
-      String lastAddTimestamp = dateFormat.format(new Date(counter.getLastAddedMessageTime()));
-      String updateTimestamp = dateFormat.format(new Date(counter.getLastUpdate()));
-      return JsonLoader.createObjectBuilder().add("destinationName", nullSafe(counter.getDestinationName())).add("destinationSubscription", nullSafe(counter.getDestinationSubscription())).add("destinationDurable", counter.isDestinationDurable()).add("count", counter.getCount()).add("countDelta", counter.getCountDelta()).add("messageCount", counter.getMessageCount()).add("messageCountDelta", counter.getMessageCountDelta()).add("lastAddTimestamp", lastAddTimestamp).add("updateTimestamp", updateTimestamp).build().toString();
-   }
-
-   /**
-    * Returns a MessageCounterInfo corresponding to the JSON serialization returned
-    * by {@link QueueControl#listMessageCounter()}.
-    */
-   public static MessageCounterInfo fromJSON(final String jsonString) throws Exception {
-      JsonObject data = JsonUtil.readJsonObject(jsonString);
-      String name = data.getString("destinationName");
-      String subscription = data.getString("destinationSubscription", null);
-      boolean durable = data.getBoolean("destinationDurable");
-      long count = data.getJsonNumber("count").longValue();
-      long countDelta = data.getJsonNumber("countDelta").longValue();
-      int depth = data.getInt("messageCount");
-      int depthDelta = data.getInt("messageCountDelta");
-      String lastAddTimestamp = data.getString("lastAddTimestamp");
-      String updateTimestamp = data.getString("updateTimestamp");
-
-      return new MessageCounterInfo(name, subscription, durable, count, countDelta, depth, depthDelta, lastAddTimestamp, updateTimestamp);
-   }
-
-   // Constructors --------------------------------------------------
-
-   public MessageCounterInfo(final String name,
-                             final String subscription,
-                             final boolean durable,
-                             final long count,
-                             final long countDelta,
-                             final int depth,
-                             final int depthDelta,
-                             final String lastAddTimestamp,
-                             final String udpateTimestamp) {
-      this.name = name;
-      this.subscription = subscription;
-      this.durable = durable;
-      this.count = count;
-      this.countDelta = countDelta;
-      this.depth = depth;
-      this.depthDelta = depthDelta;
-      this.lastAddTimestamp = lastAddTimestamp;
-      this.udpateTimestamp = udpateTimestamp;
-   }
-
-   // Public --------------------------------------------------------
-
-   /**
-    * Returns the name of the queue.
-    */
-   public String getName() {
-      return name;
-   }
-
-   /**
-    * Returns the name of the subscription.
-    */
-   public String getSubscription() {
-      return subscription;
-   }
-
-   /**
-    * Returns whether the queue is durable.
-    */
-   public boolean isDurable() {
-      return durable;
-   }
-
-   /**
-    * Returns the number of messages added to the queue since it was created.
-    */
-   public long getCount() {
-      return count;
-   }
-
-   /**
-    * Returns the number of messages added to the queue since the last counter sample.
-    */
-   public long getCountDelta() {
-      return countDelta;
-   }
-
-   /**
-    * Returns the number of messages currently in the queue.
-    */
-   public int getDepth() {
-      return depth;
-   }
-
-   /**
-    * Returns the number of messages in the queue since last counter sample.
-    */
-   public int getDepthDelta() {
-      return depthDelta;
-   }
-
-   /**
-    * Returns the timestamp of the last time a message was added to the queue.
-    */
-   public String getLastAddTimestamp() {
-      return lastAddTimestamp;
-   }
-
-   /**
-    * Returns the timestamp of the last time the queue was updated.
-    */
-   public String getUdpateTimestamp() {
-      return udpateTimestamp;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/9ad90511/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
index 8963b24..16e9483 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
@@ -35,7 +35,6 @@ import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.JsonUtil;
 import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.api.core.management.MessageCounterInfo;
 import org.apache.activemq.artemis.api.core.management.QueueControl;
 import org.apache.activemq.artemis.core.filter.Filter;
 import org.apache.activemq.artemis.core.filter.impl.FilterImpl;
@@ -993,7 +992,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
 
       clearIO();
       try {
-         return MessageCounterInfo.toJSon(counter);
+         return counter.toJSon();
       } catch (Exception e) {
          throw new IllegalStateException(e);
       } finally {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/9ad90511/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/MessageCounter.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/MessageCounter.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/MessageCounter.java
index 3ee5e4a..be58182 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/MessageCounter.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/MessageCounter.java
@@ -19,10 +19,14 @@ package org.apache.activemq.artemis.core.messagecounter;
 import java.text.DateFormat;
 import java.util.ArrayList;
 import java.util.Calendar;
+import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.List;
 
 import org.apache.activemq.artemis.core.server.Queue;
+import org.apache.activemq.artemis.utils.JsonLoader;
+
+import static org.apache.activemq.artemis.api.core.JsonUtil.nullSafe;
 
 /**
  * This class stores message count informations for a given queue
@@ -308,6 +312,30 @@ public class MessageCounter {
          "]";
    }
 
+   /**
+    * Returns a JSON String serialization of a {@link MessageCounter} object.
+    *
+    * @return
+    */
+   public String toJSon() {
+      DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
+      String lastAddTimestamp = dateFormat.format(new Date(this.getLastAddedMessageTime()));
+      String updateTimestamp = dateFormat.format(new Date(this.getLastUpdate()));
+      return JsonLoader
+         .createObjectBuilder()
+         .add("destinationName", nullSafe(this.getDestinationName()))
+         .add("destinationSubscription", nullSafe(this.getDestinationSubscription()))
+         .add("destinationDurable", this.isDestinationDurable())
+         .add("count", this.getCount())
+         .add("countDelta", this.getCountDelta())
+         .add("messageCount", this.getMessageCount())
+         .add("messageCountDelta", this.getMessageCountDelta())
+         .add("lastAddTimestamp", lastAddTimestamp)
+         .add("updateTimestamp", updateTimestamp)
+         .build()
+         .toString();
+   }
+
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------


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

Posted by cl...@apache.org.
This closes #2163


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

Branch: refs/heads/master
Commit: 7d5a31af34301eb2a29b02a1c0f07d2a55933d72
Parents: c3375b9 9ad9051
Author: Clebert Suconic <cl...@apache.org>
Authored: Thu Jul 12 14:26:23 2018 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Jul 12 14:26:23 2018 -0400

----------------------------------------------------------------------
 .../api/core/management/MessageCounterInfo.java | 152 ++++++++++++++++
 .../api/core/management/MessageCounterInfo.java | 172 -------------------
 .../core/management/impl/QueueControlImpl.java  |   3 +-
 .../core/messagecounter/MessageCounter.java     |  28 +++
 4 files changed, 181 insertions(+), 174 deletions(-)
----------------------------------------------------------------------