activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From martyntay...@apache.org
Subject [1/2] activemq-artemis git commit: ARTEMIS-1350 - Added close button to console for client objs
Date Fri, 18 Aug 2017 13:00:26 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master a5722d96c -> 507176c6c


ARTEMIS-1350 - Added close button to console for client objs

https://issues.apache.org/jira/browse/ARTEMIS-1350


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

Branch: refs/heads/master
Commit: 4ee9580e694e10788862870faa046d38be1c937f
Parents: a5722d9
Author: Andy Taylor <andy.tayls67@gmail.com>
Authored: Fri Aug 18 10:43:30 2017 +0100
Committer: Martyn Taylor <mtaylor@redhat.com>
Committed: Fri Aug 18 13:55:37 2017 +0100

----------------------------------------------------------------------
 .../core/management/ActiveMQServerControl.java  | 18 ++++++
 .../main/webapp/plugin/html/connections.html    | 21 ++++++-
 .../src/main/webapp/plugin/html/consumers.html  | 21 +++++++
 .../src/main/webapp/plugin/html/sessions.html   | 25 +++++++-
 .../src/main/webapp/plugin/js/connections.js    | 19 +++++-
 .../src/main/webapp/plugin/js/consumers.js      | 18 ++++++
 .../src/main/webapp/plugin/js/sessions.js       | 19 +++++-
 .../impl/ActiveMQServerControlImpl.java         | 64 ++++++++++++++++++++
 .../core/server/ActiveMQMessageBundle.java      |  3 +
 .../ActiveMQServerControlUsingCoreTest.java     | 15 +++++
 10 files changed, 217 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4ee9580e/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java
index 4e4fc95..e6fe7f5 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java
@@ -773,6 +773,24 @@ public interface ActiveMQServerControl {
    boolean closeConnectionsForUser(@Parameter(desc = "a user name", name = "userName") String
address) throws Exception;
 
    /**
+    * Closes the connection with the given id.
+    */
+   @Operation(desc = "Closes all the connection with the id", impact = MBeanOperationInfo.INFO)
+   boolean closeConnectionWithID(@Parameter(desc = "The connection ID", name = "ID") String
ID) throws Exception;
+
+   /**
+    * Closes the session with the given id.
+    */
+   @Operation(desc = "Closes the session with the id", impact = MBeanOperationInfo.INFO)
+   boolean closeSessionWithID(String connectionID, String ID) throws Exception;
+
+   /**
+    * Closes the consumer with the given id.
+    */
+   @Operation(desc = "Closes the consumer with the id", impact = MBeanOperationInfo.INFO)
+   boolean closeConsumerWithID(String sessionID, String ID) throws Exception;
+
+   /**
     * Lists all the IDs of the connections connected to this server.
     */
    @Operation(desc = "List all the connection IDs", impact = MBeanOperationInfo.INFO)

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4ee9580e/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/html/connections.html
----------------------------------------------------------------------
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/html/connections.html b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/html/connections.html
index c844ab8..9b3b231 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/html/connections.html
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/html/connections.html
@@ -42,10 +42,29 @@
                     </button>
                 </form>
             </div>
+
+            <div class="pull-right">
+              <form class="form-inline">
+                <button class="btn-danger" ng-disabled="gridOptions.selectedItems.length
== 0"
+                        ng-click="deleteDialog = true"
+                        title="Close the selected Connection">
+                  <i class="icon-remove"></i> Close
+                </button>
+                &nbsp;&nbsp;&nbsp;
+              </form>
+            </div>
         </div>
     </div>
 
-
+    <div hawtio-confirm-dialog="deleteDialog"
+           ok-button-text="Close"
+           on-ok="closeConnection()">
+        <div class="dialog-body">
+          <p>You are about to close the selected connection: {{gridOptions.selectedItems[0].connectionID}}
+          </p>
+          <p>Are you sure you want to continue.</p>
+        </div>
+    </div>
     <div class="row-fluid">
         <div class="gridStyle" ng-grid="gridOptions" ui-grid-resize-columns></div>
     </div>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4ee9580e/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/html/consumers.html
----------------------------------------------------------------------
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/html/consumers.html b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/html/consumers.html
index 296c54d..3258926 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/html/consumers.html
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/html/consumers.html
@@ -44,9 +44,30 @@
                     </button>
                 </form>
             </div>
+
+            <div class="pull-right">
+              <form class="form-inline">
+                <button class="btn-danger" ng-disabled="gridOptions.selectedItems.length
== 0"
+                        ng-click="deleteDialog = true"
+                        title="Close the selected Consumer">
+                  <i class="icon-remove"></i> Close
+                </button>
+                &nbsp;&nbsp;&nbsp;
+              </form>
+            </div>
         </div>
     </div>
 
+    <div hawtio-confirm-dialog="deleteDialog"
+          ok-button-text="Close"
+          on-ok="closeConsumer()">
+       <div class="dialog-body">
+         <p>You are about to close the selected consumer: {{gridOptions.selectedItems[0].id}}
+         </p>
+         <p>Are you sure you want to continue.</p>
+       </div>
+    </div>
+
     <div class="row-fluid">
         <div class="gridStyle" ng-grid="gridOptions" ui-grid-resize-columns></div>
     </div>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4ee9580e/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/html/sessions.html
----------------------------------------------------------------------
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/html/sessions.html b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/html/sessions.html
index f81fd7e..0e03bc4 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/html/sessions.html
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/html/sessions.html
@@ -43,11 +43,32 @@
                     </button>
                 </form>
             </div>
+            <div class="pull-right">
+                <form class="form-inline">
+                    <button class="btn-danger" ng-show="gridOptions.selectedItems.length
== 0"
+                            ng-click="deleteDialog = true"
+                            title="Close the selected Session">
+                        <i class="icon-remove"></i> Close
+                    </button>
+                    &nbsp;&nbsp;&nbsp;
+                </form>
+            </div>
         </div>
     </div>
-
+    <div hawtio-confirm-dialog="deleteDialog"
+          ok-button-text="Close"
+          on-ok="closeSession()">
+       <div class="dialog-body">
+         <p>You are about to close the selected session: {{gridOptions.selectedItems[0].id}}
+         </p>
+         <p>Are you sure you want to continue.</p>
+       </div>
+    </div>
     <div class="row-fluid">
         <div class="gridStyle" ng-grid="gridOptions" ui-grid-resize-columns></div>
     </div>
 
-</div>
\ No newline at end of file
+</div>
+
+
+

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4ee9580e/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/connections.js
----------------------------------------------------------------------
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/connections.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/connections.js
index c362f36..170af8a 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/connections.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/connections.js
@@ -108,7 +108,22 @@ var ARTEMIS = (function(ARTEMIS) {
             artemisConnection.connection = connection.entity;
             $location.path("artemis/sessions");
         };
-
+        $scope.closeConnection = function () {
+            var connectionID = $scope.gridOptions.selectedItems[0].connectionID
+           ARTEMIS.log.info("closing connection: " + connectionID);
+           if (workspace.selection) {
+              var mbean = getBrokerMBean(jolokia);
+              if (mbean) {
+                  jolokia.request({ type: 'exec',
+                     mbean: mbean,
+                     operation: 'closeConnectionWithID(java.lang.String)',
+                     arguments: [connectionID] },
+                     onSuccess($scope.loadTable(), { error: function (response) {
+                        Core.defaultJolokiaErrorHandler("Could not close connection: " +
response);
+                     }}));
+              }
+           }
+        };
         /**
          *  Below here is utility.
          *
@@ -128,7 +143,6 @@ var ARTEMIS = (function(ARTEMIS) {
             directions: ["asc"]
         };
         var refreshed = false;
-
         $scope.gridOptions = {
             selectedItems: [],
             data: 'objects',
@@ -177,6 +191,7 @@ var ARTEMIS = (function(ARTEMIS) {
             Core.notification("error", "Could not retrieve " + objectType + " list from Artemis.");
         }
         function populateTable(response) {
+            $scope.gridOptions.selectedItems.length = 0;
             var data = JSON.parse(response.value);
             $scope.objects = [];
             angular.forEach(data["data"], function (value, idx) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4ee9580e/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/consumers.js
----------------------------------------------------------------------
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/consumers.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/consumers.js
index 8a22fb9..25e206a 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/consumers.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/consumers.js
@@ -134,6 +134,23 @@ var ARTEMIS = (function(ARTEMIS) {
 
         artemisSession.session = null;
 
+       $scope.closeConsumer = function () {
+          var consumerID = $scope.gridOptions.selectedItems[0].id;
+          var sessionID = $scope.gridOptions.selectedItems[0].session;
+          ARTEMIS.log.info("closing session: " + sessionID);
+          if (workspace.selection) {
+             var mbean = getBrokerMBean(jolokia);
+             if (mbean) {
+                jolokia.request({ type: 'exec',
+                   mbean: mbean,
+                   operation: 'closeConsumerWithID(java.lang.String, java.lang.String)',
+                   arguments: [sessionID, consumerID] },
+                   onSuccess($scope.loadTable(), { error: function (response) {
+                      Core.defaultJolokiaErrorHandler("Could not close consumer: " + response);
+                   }}));
+            }
+         }
+       };
         /**
          *  Below here is utility.
          *
@@ -202,6 +219,7 @@ var ARTEMIS = (function(ARTEMIS) {
             Core.notification("error", "Could not retrieve " + objectType + " list from Artemis.");
         }
         function populateTable(response) {
+           $scope.gridOptions.selectedItems.length = 0;
             var data = JSON.parse(response.value);
             $scope.objects = [];
             angular.forEach(data["data"], function (value, idx) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4ee9580e/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/sessions.js
----------------------------------------------------------------------
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/sessions.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/sessions.js
index bf63298..ce661a1 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/sessions.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/sessions.js
@@ -127,7 +127,23 @@ var ARTEMIS = (function(ARTEMIS) {
         artemisSession.connection = null;
         artemisConsumer.consumer = null;
         artemisProducer.producer = null;
-
+        $scope.closeSession = function () {
+           var sessionID = $scope.gridOptions.selectedItems[0].id;
+           var connectionID = $scope.gridOptions.selectedItems[0].connectionID;
+           ARTEMIS.log.info("closing session: " + sessionID);
+           if (workspace.selection) {
+              var mbean = getBrokerMBean(jolokia);
+              if (mbean) {
+                 jolokia.request({ type: 'exec',
+                    mbean: mbean,
+                    operation: 'closeSessionWithID(java.lang.String, java.lang.String)',
+                    arguments: [connectionID, sessionID] },
+                    onSuccess($scope.loadTable(), { error: function (response) {
+                       Core.defaultJolokiaErrorHandler("Could not close session: " + response);
+                    }}));
+             }
+          }
+        };
         /**
          *  Below here is utility.
          *
@@ -196,6 +212,7 @@ var ARTEMIS = (function(ARTEMIS) {
             Core.notification("error", "Could not retrieve " + objectType + " list from Artemis.");
         }
         function populateTable(response) {
+            $scope.gridOptions.selectedItems.length = 0;
             var data = JSON.parse(response.value);
             $scope.objects = [];
             angular.forEach(data["data"], function (value, idx) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4ee9580e/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
index a3773f8..f2aec1c 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
@@ -1534,6 +1534,70 @@ public class ActiveMQServerControlImpl extends AbstractControl implements
Active
    }
 
    @Override
+   public boolean closeConnectionWithID(final String ID) {
+      checkStarted();
+
+      clearIO();
+      try {
+         for (RemotingConnection connection : remotingService.getConnections()) {
+            if (connection.getID().toString().equals(ID)) {
+               remotingService.removeConnection(connection.getID());
+               connection.fail(ActiveMQMessageBundle.BUNDLE.connectionWithIDClosedByManagement(ID));
+               return true;
+            }
+         }
+      } finally {
+         blockOnIO();
+      }
+      return false;
+   }
+
+   @Override
+   public boolean closeSessionWithID(final String connectionID, final String ID) throws Exception
{
+      checkStarted();
+
+      clearIO();
+      try {
+         List<ServerSession> sessions = server.getSessions(connectionID);
+         for (ServerSession session : sessions) {
+            if (session.getName().equals(ID.toString())) {
+               session.close(true);
+               return true;
+            }
+         }
+
+      } finally {
+         blockOnIO();
+      }
+      return false;
+   }
+
+   @Override
+   public boolean closeConsumerWithID(final String sessionID, final String ID) throws Exception
{
+      checkStarted();
+
+      clearIO();
+      try {
+         Set<ServerSession> sessions = server.getSessions();
+         for (ServerSession session : sessions) {
+            if (session.getName().equals(sessionID.toString())) {
+               Set<ServerConsumer> serverConsumers = session.getServerConsumers();
+               for (ServerConsumer serverConsumer : serverConsumers) {
+                  if (serverConsumer.sequentialID() == Long.valueOf(ID)) {
+                     serverConsumer.close(true);
+                     return true;
+                  }
+               }
+            }
+         }
+
+      } finally {
+         blockOnIO();
+      }
+      return false;
+   }
+
+   @Override
    public String[] listConnectionIDs() {
       checkStarted();
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4ee9580e/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java
index 6d571a8..bd0e8cf 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java
@@ -386,6 +386,9 @@ public interface ActiveMQMessageBundle {
    @Message(id = 119119, value = "Disk Capacity is Low, cannot produce more messages.")
    ActiveMQIOErrorException diskBeyondLimit();
 
+   @Message(id = 119120, value = "connection with ID {0} closed by management", format =
Message.Format.MESSAGE_FORMAT)
+   ActiveMQInternalErrorException connectionWithIDClosedByManagement(String ID);
+
    @Message(id = 119200, value = "Maximum Consumer Limit Reached on Queue:(address={0},queue={1})",
format = Message.Format.MESSAGE_FORMAT)
    ActiveMQQueueMaxConsumerLimitReached maxConsumerLimitReachedForQueue(SimpleString address,
SimpleString queueName);
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4ee9580e/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java
index 587cab4..9408fdb 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java
@@ -98,6 +98,21 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
          }
 
          @Override
+         public boolean closeConnectionWithID(String ID) throws Exception {
+            return (Boolean) proxy.invokeOperation("closeConnectionWithID", ID);
+         }
+
+         @Override
+         public boolean closeSessionWithID(String connectionID, String ID) throws Exception
{
+            return (Boolean) proxy.invokeOperation("closeSessionWithID", connectionID, ID);
+         }
+
+         @Override
+         public boolean closeConsumerWithID(String sessionID, String ID) throws Exception
{
+            return (Boolean) proxy.invokeOperation("closeConsumerWithID", sessionID, ID);
+         }
+
+         @Override
          public boolean commitPreparedTransaction(final String transactionAsBase64) throws
Exception {
             return (Boolean) proxy.invokeOperation("commitPreparedTransaction", transactionAsBase64);
          }


Mime
View raw message