Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
f9f030db
J
jenkins
项目概览
LinuxSuRen
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f9f030db
编写于
2月 28, 2011
作者:
K
Kohsuke Kawaguchi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
thread dump now reports all the threads from all the slaves, not just
the master.
上级
3676f0e5
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
62 addition
and
6 deletion
+62
-6
changelog.html
changelog.html
+2
-1
core/src/main/java/hudson/model/Hudson.java
core/src/main/java/hudson/model/Hudson.java
+33
-0
core/src/main/java/hudson/util/RemotingDiagnostics.java
core/src/main/java/hudson/util/RemotingDiagnostics.java
+8
-0
core/src/main/resources/hudson/model/Hudson/threadDump.jelly
core/src/main/resources/hudson/model/Hudson/threadDump.jelly
+10
-4
remoting/src/main/java/hudson/remoting/AsyncFutureImpl.java
remoting/src/main/java/hudson/remoting/AsyncFutureImpl.java
+9
-1
未找到文件。
changelog.html
浏览文件 @
f9f030db
...
...
@@ -58,7 +58,8 @@ Upcoming changes</a>
<!-- Record your changes in the trunk here. -->
<div
id=
"trunk"
style=
"display:none"
>
<!--=TRUNK-BEGIN=-->
<ul
class=
image
>
<li
class=
>
<li
class=
rfe
>
thread dump now reports all the threads from all the slaves, not just the master.
</ul>
</div>
<!--=TRUNK-END=-->
...
...
core/src/main/java/hudson/model/Hudson.java
浏览文件 @
f9f030db
...
...
@@ -189,6 +189,7 @@ import java.io.FileFilter;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
import
java.net.BindException
;
import
java.net.URL
;
import
java.nio.charset.Charset
;
...
...
@@ -2631,6 +2632,38 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
rsp
.
sendRedirect2
(
"threadDump"
);
}
/**
* Obtains the thread dump of all slaves (including the master.)
*
* <p>
* Since this is for diagnostics, it has a built-in precautionary measure against hang slaves.
*/
public
Map
<
String
,
Map
<
String
,
String
>>
getAllThreadDumps
()
throws
IOException
,
InterruptedException
{
checkPermission
(
ADMINISTER
);
// issue the requests all at once
Map
<
String
,
Future
<
Map
<
String
,
String
>>>
future
=
new
HashMap
<
String
,
Future
<
Map
<
String
,
String
>>>();
for
(
Computer
c
:
getComputers
())
{
future
.
put
(
c
.
getName
(),
RemotingDiagnostics
.
getThreadDumpAsync
(
c
.
getChannel
()));
}
// if the result isn't available in 5 sec, ignore that.
// this is a precaution against hang nodes
long
endTime
=
System
.
currentTimeMillis
()
+
5000
;
Map
<
String
,
Map
<
String
,
String
>>
r
=
new
HashMap
<
String
,
Map
<
String
,
String
>>();
for
(
Entry
<
String
,
Future
<
Map
<
String
,
String
>>>
e
:
future
.
entrySet
())
{
try
{
r
.
put
(
e
.
getKey
(),
e
.
getValue
().
get
(
endTime
-
System
.
currentTimeMillis
(),
TimeUnit
.
MILLISECONDS
));
}
catch
(
Exception
x
)
{
StringWriter
sw
=
new
StringWriter
();
x
.
printStackTrace
(
new
PrintWriter
(
sw
,
true
));
r
.
put
(
e
.
getKey
(),
Collections
.
singletonMap
(
"Failed to retrieve thread dump"
,
sw
.
toString
()));
}
}
return
r
;
}
public
synchronized
Item
doCreateItem
(
StaplerRequest
req
,
StaplerResponse
rsp
)
throws
IOException
,
ServletException
{
return
itemGroupMixIn
.
createTopLevelItem
(
req
,
rsp
);
}
...
...
core/src/main/java/hudson/util/RemotingDiagnostics.java
浏览文件 @
f9f030db
...
...
@@ -27,8 +27,10 @@ import groovy.lang.GroovyShell;
import
hudson.FilePath
;
import
hudson.Functions
;
import
hudson.model.Hudson
;
import
hudson.remoting.AsyncFutureImpl
;
import
hudson.remoting.Callable
;
import
hudson.remoting.DelegatingCallable
;
import
hudson.remoting.Future
;
import
hudson.remoting.VirtualChannel
;
import
hudson.security.AccessControlled
;
import
org.kohsuke.stapler.StaplerRequest
;
...
...
@@ -78,6 +80,12 @@ public final class RemotingDiagnostics {
return
channel
.
call
(
new
GetThreadDump
());
}
public
static
Future
<
Map
<
String
,
String
>>
getThreadDumpAsync
(
VirtualChannel
channel
)
throws
IOException
,
InterruptedException
{
if
(
channel
==
null
)
return
new
AsyncFutureImpl
<
Map
<
String
,
String
>>(
Collections
.
singletonMap
(
"N/A"
,
"offline"
));
return
channel
.
callAsync
(
new
GetThreadDump
());
}
private
static
final
class
GetThreadDump
implements
Callable
<
Map
<
String
,
String
>,
RuntimeException
>
{
public
Map
<
String
,
String
>
call
()
{
Map
<
String
,
String
>
r
=
new
LinkedHashMap
<
String
,
String
>();
...
...
core/src/main/resources/hudson/model/Hudson/threadDump.jelly
浏览文件 @
f9f030db
<!--
The MIT License
Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi, Tom Huybrechts
Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi, Tom Huybrechts
, CloudBees, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
...
...
@@ -31,9 +31,15 @@ THE SOFTWARE.
<l:main-panel>
<h1>${%Thread Dump}</h1>
<j:forEach var="t" items="${it.toComputer().getThreadDump().entrySet()}">
<h2>${t.key}</h2>
<pre>${t.value}</pre>
<j:forEach var="e" items="${it.getAllThreadDumps().entrySet()}" varStatus="loop">
<j:if test="${!loop.first}">
<hr style="margin-bottom:6em"/>
</j:if>
<h1>${e.key}</h1>
<j:forEach var="t" items="${e.value.entrySet()}">
<h2>${t.key}</h2>
<pre>${t.value}</pre>
</j:forEach>
</j:forEach>
</l:main-panel>
</l:layout>
...
...
remoting/src/main/java/hudson/remoting/AsyncFutureImpl.java
浏览文件 @
f9f030db
/*
* The MIT License
*
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
, CloudBees, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
...
...
@@ -48,6 +48,14 @@ public class AsyncFutureImpl<V> implements Future<V> {
private
Throwable
problem
;
private
boolean
cancelled
;
public
AsyncFutureImpl
()
{}
public
AsyncFutureImpl
(
V
value
)
{
set
(
value
);
}
public
AsyncFutureImpl
(
Throwable
value
)
{
set
(
value
);
}
public
boolean
cancel
(
boolean
mayInterruptIfRunning
)
{
return
false
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录