qpid-broker-j git commit: QPID-7886: [Java Broker] Expose ability to get a thread dump from the WMC

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

qpid-broker-j git commit: QPID-7886: [Java Broker] Expose ability to get a thread dump from the WMC

kwall
Repository: qpid-broker-j
Updated Branches:
  refs/heads/master 0e4b9c556 -> 0c180ff35


QPID-7886: [Java Broker] Expose ability to get a thread dump from the WMC

Also added textual preamble to thread dumps, including the current date/time


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/0c180ff3
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/0c180ff3
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/0c180ff3

Branch: refs/heads/master
Commit: 0c180ff357a028c058715972c60e17c1634f1ea8
Parents: 0e4b9c5
Author: Keith Wall <[hidden email]>
Authored: Thu Aug 10 22:26:36 2017 +0100
Committer: Keith Wall <[hidden email]>
Committed: Thu Aug 10 22:28:26 2017 +0100

----------------------------------------------------------------------
 .../qpid/server/model/AbstractContainer.java     |  7 +++++++
 .../plugin/servlet/rest/RestServlet.java         | 14 ++++++--------
 .../java/resources/js/qpid/management/Broker.js  | 19 +++++++++++++++++++
 .../resources/js/qpid/management/Management.js   |  4 ++--
 .../src/main/java/resources/showBroker.html      |  7 +++++++
 5 files changed, 41 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/0c180ff3/broker-core/src/main/java/org/apache/qpid/server/model/AbstractContainer.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/model/AbstractContainer.java b/broker-core/src/main/java/org/apache/qpid/server/model/AbstractContainer.java
index 86e6288..868e933 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/model/AbstractContainer.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/model/AbstractContainer.java
@@ -33,6 +33,7 @@ import java.lang.management.ThreadMXBean;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.nio.charset.Charset;
+import java.time.Instant;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
@@ -360,6 +361,8 @@ public abstract class AbstractContainer<X extends AbstractContainer<X>> extends
         ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
         ThreadInfo[] threadInfos = threadMXBean.dumpAllThreads(true, true);
         StringBuilder threadDump = new StringBuilder();
+        threadDump.append(String.format("Full thread dump captured %s", Instant.now())).append(System.lineSeparator());
+
         for (ThreadInfo threadInfo : threadInfos)
         {
             threadDump.append(getThreadStackTraces(threadInfo));
@@ -388,6 +391,10 @@ public abstract class AbstractContainer<X extends AbstractContainer<X>> extends
         ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
         ThreadInfo[] threadInfos = threadMXBean.dumpAllThreads(true, true);
         StringBuilder threadDump = new StringBuilder();
+        threadDump.append(String.format("Thread dump (names matching '%s') captured %s",
+                                        threadNameFindExpression,
+                                        Instant.now())).append(System.lineSeparator());
+
         Pattern pattern = threadNameFindExpression == null || threadNameFindExpression.equals("") ? null : Pattern.compile(
                 threadNameFindExpression);
         for (ThreadInfo threadInfo : threadInfos)

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/0c180ff3/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
----------------------------------------------------------------------
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
index 5e25894..92f58d5 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
@@ -646,6 +646,12 @@ public class RestServlet extends AbstractServlet
         }
 
         Object returnVal = operation.perform(target, operationArguments);
+        String attachmentFilename = request.getParameter(CONTENT_DISPOSITION_ATTACHMENT_FILENAME_PARAM);
+        if (attachmentFilename != null)
+        {
+            setContentDispositionHeaderIfNecessary(response, attachmentFilename);
+        }
+
         if(returnVal instanceof Content)
         {
             Content content = (Content)returnVal;
@@ -684,14 +690,6 @@ public class RestServlet extends AbstractServlet
                 }
                 returnVal = output;
             }
-
-            String attachmentFilename = request.getParameter(CONTENT_DISPOSITION_ATTACHMENT_FILENAME_PARAM);
-
-            if (attachmentFilename != null)
-            {
-                setContentDispositionHeaderIfNecessary(response, attachmentFilename);
-            }
-
             sendJsonResponse(returnVal, request, response);
         }
     }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/0c180ff3/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js
----------------------------------------------------------------------
diff --git a/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js b/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js
index b7dfa23..68f99f8 100644
--- a/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js
+++ b/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js
@@ -199,6 +199,17 @@ define(["dojo/parser",
                             event.stop(evt);
                         });
 
+                        var brokerDiagnosticsMenu = registry.byNode(query(".brokerDiagnosticsMenu",
+                                                                          contentPane.containerNode)[0]);
+
+                        var hostMenuItems = brokerDiagnosticsMenu.dropDown.getChildren();
+                        var downloadJvmThreadDumpButton = hostMenuItems[0];
+                        downloadJvmThreadDumpButton.on("click", function (evt)
+                        {
+                            that.downloadJvmThreadDump();
+                            event.stop(evt);
+                        });
+
                         var addKeystoreButton = query(".addKeystore", contentPane.containerNode)[0];
                         connect.connect(registry.byNode(addKeystoreButton), "onClick", function (evt)
                         {
@@ -345,6 +356,14 @@ define(["dojo/parser",
             }
         };
 
+        Broker.prototype.downloadJvmThreadDump = function()
+        {
+            var suggestedAttachmentName = encodeURIComponent("QpidBroker_" + this.name + "_ThreadDump.txt");
+            this.management.downloadIntoFrame(this.modelObj, {
+                contentDispositionAttachmentFilename: suggestedAttachmentName
+            }, "getThreadStackTraces");
+        };
+
         Broker.prototype.close = function ()
         {
             updater.remove(this.brokerUpdater);

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/0c180ff3/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Management.js
----------------------------------------------------------------------
diff --git a/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Management.js b/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Management.js
index 703525b..a2af583 100644
--- a/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Management.js
+++ b/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Management.js
@@ -348,9 +348,9 @@ define(["dojo/_base/lang",
 
         // summary:
         //  Downloads current JSON for object specified as modelObj argument into iframe
-        Management.prototype.downloadIntoFrame = function (modelObj, parameters)
+        Management.prototype.downloadIntoFrame = function (modelObj, parameters, operation)
         {
-            var url = this.buildObjectURL(modelObj, parameters);
+            var url = this.buildObjectURL(modelObj, parameters, operation);
             var iframe = document.createElement('iframe');
             iframe.id = "downloader_" + modelObj.name;
             document.body.appendChild(iframe);

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/0c180ff3/broker-plugins/management-http/src/main/java/resources/showBroker.html
----------------------------------------------------------------------
diff --git a/broker-plugins/management-http/src/main/java/resources/showBroker.html b/broker-plugins/management-http/src/main/java/resources/showBroker.html
index cd7f20f..4d0df82 100644
--- a/broker-plugins/management-http/src/main/java/resources/showBroker.html
+++ b/broker-plugins/management-http/src/main/java/resources/showBroker.html
@@ -65,6 +65,13 @@
         <div class="dijitDialogPaneActionBar">
             <button data-dojo-type="dijit.form.Button" class="editBroker">Edit</button>
             <button data-dojo-type="dijit.form.Button" class="restartBroker">Restart</button>
+            <div data-dojo-type="dijit.form.DropDownButton" data-dojo-props="iconClass: 'dijitIconFunction'" class="brokerDiagnosticsMenu">
+                <span>Diagnostics</span>
+                <div data-dojo-type="dijit.Menu">
+                    <div data-dojo-type="dijit.MenuItem"
+                         data-dojo-props="iconClass: 'downloadLogsIcon'">Download JVM thread-dump</div>
+                </div>
+            </div>
         </div>
    </div>
     <br/>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...