Skip to content

Commit

Permalink
Bug 62925 - Add support for ThreadDump to the JMeter non-GUI
Browse files Browse the repository at this point in the history
Bugzilla Id: 62925

git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1846859 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
pmouawad committed Nov 18, 2018
1 parent dbdf8cf commit 3611cd4
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
23 changes: 23 additions & 0 deletions bin/threaddump.cmd
@@ -0,0 +1,23 @@
@echo off

rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

rem Ask the JMeter client to perform a ThreadDump

rem P1 = command port for JMeter instance (defaults to 4445)

java -cp %~dp0ApacheJMeter.jar org.apache.jmeter.util.ShutdownClient ThreadDump %*
pause
24 changes: 24 additions & 0 deletions bin/threaddump.sh
@@ -0,0 +1,24 @@
#!/bin/sh

## 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.

# Ask the JMeter client to perform a ThreadDump

# P1 = command port for JMeter instance (defaults to 4445)

DIRNAME="$(dirname "$0")"

java -cp "${DIRNAME}/ApacheJMeter.jar" org.apache.jmeter.util.ShutdownClient ThreadDump "$@"
6 changes: 5 additions & 1 deletion src/core/org/apache/jmeter/JMeter.java
Expand Up @@ -107,6 +107,7 @@
import org.apache.jorphan.util.HeapDumper;
import org.apache.jorphan.util.JMeterException;
import org.apache.jorphan.util.JOrphanUtils;
import org.apache.jorphan.util.ThreadDumper;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.config.Configurator;
import org.slf4j.Logger;
Expand Down Expand Up @@ -1419,7 +1420,7 @@ public void run() {

private static void waitForSignals(final List<JMeterEngine> engines, DatagramSocket socket) {
byte[] buf = new byte[80];
System.out.println("Waiting for possible Shutdown/StopTestNow/Heapdump message on port "+socket.getLocalPort());//NOSONAR
System.out.println("Waiting for possible Shutdown/StopTestNow/HeapDump/ThreadDump message on port "+socket.getLocalPort());//NOSONAR
DatagramPacket request = new DatagramPacket(buf, buf.length);
try {
while(true) {
Expand All @@ -1444,6 +1445,9 @@ private static void waitForSignals(final List<JMeterEngine> engines, DatagramSoc
case "HeapDump" :
HeapDumper.dumpHeap();
break;
case "ThreadDump" :
ThreadDumper.threadDump();
break;
default:
System.out.println("Command: "+command+" not recognised ");//NOSONAR
}
Expand Down
1 change: 1 addition & 0 deletions xdocs/changes.xml
Expand Up @@ -122,6 +122,7 @@ of previous time slot as a base. Starting with this version, each time slot is i
<li><bug>62752</bug>Add to Documentation: <code>ctx.getThreadNum()</code> is zero-based while <code>${__threadNum}</code> is one-based</li>
<li><pr>411</pr>Use <code>SHA-1</code> instead of <code>SHA1</code> in <code>org.apache.jmeter.save.SaveService</code>. Contributed by Paco (paco.xu at daocloud.io)</li>
<li><bug>62914</bug>Add a hint in Thread Group UI about duration of test</li>
<li><bug>62925</bug>Add support for ThreadDump to the JMeter non-GUI</li>
</ul>

<ch_section>Non-functional changes</ch_section>
Expand Down

0 comments on commit 3611cd4

Please sign in to comment.