首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Glassfish v3 -如何获取/分析线程转储?

Glassfish v3 -如何获取/分析线程转储?
EN

Stack Overflow用户
提问于 2012-02-08 18:33:44
回答 2查看 5.4K关注 0票数 3

我试图为我的应用程序获取/分析一个线程转储,该应用程序运行在Linux机器上的Glassfish 3.1.1中。我遇到了两种方法。

  1. 在Glassfish管理控制台中的命令行
  2. 上运行kill -QUIT <pid>,转到公共任务服务器(Admin ) -> General选项卡。单击"JVM报表“并从”查看“下拉框中选择”线程转储“。

这两个线程转储的结果是不同的。杀死方法生成一个文件(/domains/domain 1/log/jvm.log),该文件是XML (hotspot_log),具有以下结构:

代码语言:javascript
复制
<?xml version='1.0' encoding='UTF-8'?>
<hotspot_log version='160 1' process='9426' time_ms='1328662710633'>
    <vm_version>
        <name>Java HotSpot(TM) 64-Bit Server VM</name>
        <release>17.0-b16</release>
        <info>
            Java HotSpot(TM) 64-Bit Server VM (17.0-b16) for linux-amd64 JRE (1.6.0_21-b06),
            built on Jun 22 2010 01:10:00 by &quot;java_re&quot; with gcc 3.2.2
            (SuSE Linux)
        </info>
    </vm_version>
    <vm_arguments>
        <args>
            -XX:+UnlockDiagnosticVMOptions -XX:MaxPermSize=192m -XX:NewRatio=2 -XX:+LogVMOutput

            ... SNIP ...

        </args>
        <command>

            ... SNIP ...

        </command>
        <launcher>
            SUN_STANDARD
        </launcher>
        <properties>
            java.vm.specification.version=1.0

            ... SNIP ...

        </properties>
    </vm_arguments>
    <tty>
        <writer thread='1085897024' />
        <dependency_failed type='unique_concrete_method'
            x='java/lang/ThreadLocal getMap (Ljava/lang/Thread;)Ljava/lang/ThreadLocal$ThreadLocalMap;'
            witness='java/lang/InheritableThreadLocal' stamp='1.955' />
        <dependency_failed type='unique_concrete_method'
            x='java/lang/ThreadLocal getMap (Ljava/lang/Thread;)Ljava/lang/ThreadLocal$ThreadLocalMap;'
            witness='java/lang/InheritableThreadLocal' stamp='1.955' />
        <dependency_failed type='unique_concrete_method'
            x='java/lang/ThreadLocal getMap (Ljava/lang/Thread;)Ljava/lang/ThreadLocal$ThreadLocalMap;'
            witness='java/lang/InheritableThreadLocal' stamp='1.955' />
        <dependency_failed type='unique_concrete_method'
            x='java/lang/ThreadLocal getMap (Ljava/lang/Thread;)Ljava/lang/ThreadLocal$ThreadLocalMap;'
            witness='java/lang/InheritableThreadLocal' stamp='1.955' />

        ... SNIP ...

        <writer thread='1106913600' />
        2012-02-08 09:54:18
        Full thread dump Java HotSpot(TM) 64-Bit Server VM (17.0-b16 mixed mode):

        &quot;pool-28-thread-1&quot; prio=10 tid=0x00002aaae959c800 nid=0x28d5
        runnable [0x0000000049da0000]
        java.lang.Thread.State: RUNNABLE
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(SocketInputStream.java:129)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
        - locked &lt;0x00002aaab547d7f0&gt; (a java.io.BufferedInputStream)
        at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
        at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
        at

    ... SNIP ...

请注意,结束标记

代码语言:javascript
复制
    </tty>
</hotspot_log>

档案里不见了。,有人知道为什么吗?

通过管理控制台完成的转储生成具有以下格式的报告:

代码语言:javascript
复制
server

View:

Full Java Thread Dump Java HotSpot(TM) 64-Bit Server VM 17.0-b16 Sun Microsystems Inc.
Number of threads: 97
Number of daemon threads: 83
Peak live thread count since the Java virtual machine started or peak was reset: 116
Is support for thread contention monitoring available on this JVM? [true]
Is thread contention monitoring enabled? [false]. If false, some thread synchronization statistics are not be available.
Is support for CPU time measurement for any thread available on this JVM? [true]
Is thread CPU time measurement enabled? [true]. If false, thread execution times are not available for any thread.
--------------------------------------------------------------------------------
Thread Execution Information:
-----------------------
Thread "Ejb-Timer-Thread-103" thread-id: 616 thread-state: TIMED_WAITING Waiting on lock: java.util.concurrent.SynchronousQueue$TransferStack@28ee94c8
     at: sun.misc.Unsafe.park(Native Method)
     at: java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:198)
     at: java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:424)
     at: java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:323)
     at: java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:874)
     at: java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:945)
     at: java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
     at: java.lang.Thread.run(Thread.java:619)
Thread Synchronization Statistics:
-----------------------
Number of times this thread was blocked (to enter/reenter a Monitor): 0
Number of times this thread waited for a notification (i.e. it was in WAITING or TIMED_WAITING state): 20
Total CPU time for this thread: 0 seconds 0 nanoseconds.
User-level CPU time for this thread: 0 seconds 0 nanoseconds.
Object Monitors currently held or requested by this thread: []
Ownable Synchronizers (e.g. ReentrantLock and ReentrantReadWriteLock) held by this thread: []
--------------------------------------------------------------------------------
Thread Execution Information:
-----------------------
Thread "RMI TCP Connection(206)-127.0.0.1" thread-id: 613 thread-state: RUNNABLE Running in native
     at: java.net.SocketInputStream.socketRead0(Native Method)
     at: java.net.SocketInputStream.read(SocketInputStream.java:129)
     at: java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
     at: java.io.BufferedInputStream.read(BufferedInputStream.java:237)
     at: java.io.DataInputStream.readUnsignedShort(DataInputStream.java:320)
     at: java.io.DataInputStream.readUTF(DataInputStream.java:572)
     at: java.io.DataInputStream.readUTF(DataInputStream.java:547)
     at: sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:774)
     at: sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
     at: java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
     at: java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
     at: java.lang.Thread.run(Thread.java:619)
Thread Synchronization Statistics:
-----------------------
Number of times this thread was blocked (to enter/reenter a Monitor): 0
Number of times this thread waited for a notification (i.e. it was in WAITING or TIMED_WAITING state): 0
Total CPU time for this thread: 0 seconds 0 nanoseconds.
User-level CPU time for this thread: 0 seconds 0 nanoseconds.
Object Monitors currently held or requested by this thread: []
Ownable Synchronizers (e.g. ReentrantLock and ReentrantReadWriteLock) held by this thread: []
--------------------------------------------------------------------------------

... SNIP ...

No deadlock found

为了分析转储,我尝试了TDA -线程转储分析器(http://java.net/projects/tda/),并发现它将打开XML版本,但在我打开非XML版本之前,它不会在UI中显示(然后两者都会显示)。

为什么格式如此不同?一种比另一种更适合分析?有关系吗?

EN

回答 2

Stack Overflow用户

发布于 2013-05-10 12:28:28

您可以使用以下命令在glassfish v3.1中生成线程转储报告:

asadmin generate-jvm-report --type=thread

参考文献:

http://docs.oracle.com/cd/E18930_01/html/821-2436/ghuvy.html

票数 4
EN

Stack Overflow用户

发布于 2012-02-09 20:04:08

这两种转储格式都很奇怪。我猜Glassfish正在为这些转储请求做一些特定的事情。

尝试,j堆栈,随JDK而来。这是通常张贴在这里提出问题的格式。

转储应该看起来更像这样:

代码语言:javascript
复制
012-02-04 18:00:01
Full thread dump Java HotSpot(TM) 64-Bit Server VM (16.3-b01 mixed mode):

"pool-2-thread-1143" prio=3 tid=0x0000000105419000 nid=0x1fe0 waiting on condition   xfffffffb43dfe000]
  java.lang.Thread.State: TIMED_WAITING (parking)
  at sun.misc.Unsafe.park(Native Method)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9199324

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档