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

Previous Topic Next Topic
 
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 #1749

martyntaylor
Repository: activemq-artemis
Updated Branches:
  refs/heads/master e5251ce60 -> 18d2d13d9


This closes #1749


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

Branch: refs/heads/master
Commit: 18d2d13d9175183ef2f3cbe140095dc90167f9bb
Parents: e5251ce 21b58bf
Author: Martyn Taylor <[hidden email]>
Authored: Thu Jan 11 10:56:46 2018 +0000
Committer: Martyn Taylor <[hidden email]>
Committed: Thu Jan 11 10:56:46 2018 +0000

----------------------------------------------------------------------
 .../api/core/management/QueueControl.java       | 10 +++--
 .../src/main/webapp/plugin/js/browse.js         | 21 ++++++++-
 .../core/management/impl/QueueControlImpl.java  | 46 ++++++++++++++++++++
 .../management/QueueControlUsingCoreTest.java   | 15 +++++++
 4 files changed, 88 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


Reply | Threaded
Open this post in threaded view
|

[2/2] activemq-artemis git commit: ARTEMIS-1579 browsing messages in hawtio console

martyntaylor
ARTEMIS-1579 browsing messages in hawtio console


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

Branch: refs/heads/master
Commit: 21b58bfea84c984fd2065abdbd3fcb05dba23b54
Parents: e5251ce
Author: Stanislav Knot <[hidden email]>
Authored: Thu Jan 4 16:25:46 2018 +0100
Committer: Martyn Taylor <[hidden email]>
Committed: Thu Jan 11 10:56:46 2018 +0000

----------------------------------------------------------------------
 .../api/core/management/QueueControl.java       | 10 +++--
 .../src/main/webapp/plugin/js/browse.js         | 21 ++++++++-
 .../core/management/impl/QueueControlImpl.java  | 46 ++++++++++++++++++++
 .../management/QueueControlUsingCoreTest.java   | 15 +++++++
 4 files changed, 88 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21b58bfe/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/QueueControl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/QueueControl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/QueueControl.java
index d678977..9eec8e0 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/QueueControl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/QueueControl.java
@@ -223,6 +223,9 @@ public interface QueueControl {
    @Operation(desc = "Returns the number of the messages in the queue matching the given filter", impact = MBeanOperationInfo.INFO)
    long countMessages(@Parameter(name = "filter", desc = "A message filter (can be empty)") String filter) throws Exception;
 
+   @Operation(desc = "Returns the number of the messages in the queue", impact = MBeanOperationInfo.INFO)
+   long countMessages() throws Exception;
+
    /**
     * Removes the message corresponding to the specified message ID.
     *
@@ -464,12 +467,13 @@ public interface QueueControl {
    @Operation(desc = "Browse Messages", impact = MBeanOperationInfo.ACTION)
    CompositeData[] browse() throws Exception;
 
-   /**
-    * Resets the MessagesAdded property
-    */
    @Operation(desc = "Browse Messages", impact = MBeanOperationInfo.ACTION)
    CompositeData[] browse(@Parameter(name = "filter", desc = "A message filter (can be empty)") String filter) throws Exception;
 
+   @Operation(desc = "Browse Messages", impact = MBeanOperationInfo.ACTION)
+   CompositeData[] browse(@Parameter(name = "page", desc = "Current page") int page,
+                          @Parameter(name = "pageSize", desc = "Page size") int pageSize) throws Exception;
+
    /**
     * Resets the MessagesAdded property
     */

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21b58bfe/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/browse.js
----------------------------------------------------------------------
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/browse.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/browse.js
index 7e06b17..a58d9eb 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/browse.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/browse.js
@@ -20,6 +20,12 @@
 var ARTEMIS = (function(ARTEMIS) {
 
     ARTEMIS.BrowseQueueController = function ($scope, workspace, ARTEMISService, jolokia, localStorage, artemisMessage, $location, $timeout) {
+    $scope.pagingOptions = {
+          pageSizes: [50, 100, 200],
+          pageSize: 100,
+          currentPage: 1
+       };
+       $scope.totalServerItems = 0;
        $scope.searchText = '';
        $scope.allMessages = [];
        $scope.messages = [];
@@ -28,6 +34,10 @@ var ARTEMIS = (function(ARTEMIS) {
        $scope.deleteDialog = false;
        $scope.moveDialog = false;
        $scope.gridOptions = {
+          pagingOptions: $scope.pagingOptions,
+          enablePaging: true,
+          totalServerItems: 'totalServerItems',
+          showFooter: true,
           selectedItems: [],
           data: 'messages',
           displayFooter: false,
@@ -102,6 +112,14 @@ var ARTEMIS = (function(ARTEMIS) {
        $scope.$watch('gridOptions.filterOptions.filterText', function (filterText) {
           filterMessages(filterText);
        });
+       $scope.$watch('pagingOptions', function (newVal, oldVal) {
+          if (parseInt(newVal.currentPage) && newVal !== oldVal && newVal.currentPage !== oldVal.currentPage) {
+             loadTable();
+          }
+          if (parseInt(newVal.pageSize) && newVal !== oldVal && newVal.pageSize !== oldVal.pageSize) {
+            $scope.pagingOptions.currentPage = 1;
+          }
+       }, true);
        $scope.openMessageDialog = function (message) {
           ARTEMIS.selectCurrentMessage(message, "messageID", $scope);
           if ($scope.row) {
@@ -362,7 +380,8 @@ var ARTEMIS = (function(ARTEMIS) {
              else {
                 onDlq(false);
              }
-             ARTEMISService.artemisConsole.browse(objName, jolokia, onSuccess(populateTable));
+             jolokia.request({ type: 'exec', mbean: objName, operation: 'countMessages()'}, onSuccess(function(response) {$scope.totalServerItems = response.value;}));
+             jolokia.request({ type: 'exec', mbean: objName, operation: 'browse(int, int)', arguments: [$scope.pagingOptions.currentPage, $scope.pagingOptions.pageSize] }, onSuccess(populateTable));
           }
        }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21b58bfe/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 6f75297..9f051fd 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
@@ -545,6 +545,11 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
    }
 
    @Override
+   public long countMessages() throws Exception {
+      return countMessages(null);
+   }
+
+   @Override
    public long countMessages(final String filterStr) throws Exception {
       checkStarted();
 
@@ -961,6 +966,47 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
    }
 
    @Override
+   public CompositeData[] browse(int page, int pageSize) throws Exception {
+      String filter = null;
+      checkStarted();
+
+      clearIO();
+      try {
+         long index = 0;
+         long start = (page - 1) * pageSize;
+         long end = Math.min((long)(page * pageSize), queue.getMessageCount());
+
+         ArrayList<CompositeData> c = new ArrayList<>();
+         Filter thefilter = FilterImpl.createFilter(filter);
+         queue.flushExecutor();
+
+         try (LinkedListIterator<MessageReference> iterator = queue.browserIterator()) {
+            try {
+               while (iterator.hasNext() && index < end) {
+                  MessageReference ref = iterator.next();
+                  if (thefilter == null || thefilter.match(ref.getMessage())) {
+                     if (index >= start) {
+                        c.add(OpenTypeSupport.convert(ref));
+                     }
+                  }
+                  index++;
+               }
+            } catch (NoSuchElementException ignored) {
+               // this could happen through paging browsing
+            }
+
+            CompositeData[] rc = new CompositeData[c.size()];
+            c.toArray(rc);
+            return rc;
+         }
+      } catch (ActiveMQException e) {
+         throw new IllegalStateException(e.getMessage());
+      } finally {
+         blockOnIO();
+      }
+   }
+
+   @Override
    public CompositeData[] browse() throws Exception {
       return browse(null);
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21b58bfe/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlUsingCoreTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlUsingCoreTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlUsingCoreTest.java
index 3ea65cc..82c7a47 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlUsingCoreTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlUsingCoreTest.java
@@ -57,6 +57,11 @@ public class QueueControlUsingCoreTest extends QueueControlTest {
          }
 
          @Override
+         public long countMessages() throws Exception {
+            return (Long) proxy.invokeOperation(Long.class, "countMessages");
+         }
+
+         @Override
          public boolean expireMessage(final long messageID) throws Exception {
             return (Boolean) proxy.invokeOperation("expireMessage", messageID);
          }
@@ -385,6 +390,16 @@ public class QueueControlUsingCoreTest extends QueueControlTest {
             return compositeDatas;
          }
 
+         @Override
+         public CompositeData[] browse(int page, int pageSize) throws Exception {
+            Map map = (Map) proxy.invokeOperation("browse", page, pageSize);
+            CompositeData[] compositeDatas = (CompositeData[]) map.get(CompositeData.class.getName());
+            if (compositeDatas == null) {
+               compositeDatas = new CompositeData[0];
+            }
+            return compositeDatas;
+         }
+
 
          @Override
          public CompositeData[] browse(String filter) throws Exception {