Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
1fe73753
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,发现更多精彩内容 >>
提交
1fe73753
编写于
3月 25, 2015
作者:
S
Stephen Connolly
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Document the terminatedBy methods
上级
b341589b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
56 addition
and
10 deletion
+56
-10
core/src/main/java/hudson/model/Computer.java
core/src/main/java/hudson/model/Computer.java
+54
-8
core/src/main/java/hudson/model/Executor.java
core/src/main/java/hudson/model/Executor.java
+2
-2
未找到文件。
core/src/main/java/hudson/model/Computer.java
浏览文件 @
1fe73753
...
...
@@ -45,6 +45,7 @@ import hudson.security.AccessControlled;
import
hudson.security.Permission
;
import
hudson.security.PermissionGroup
;
import
hudson.security.PermissionScope
;
import
hudson.slaves.AbstractCloudSlave
;
import
hudson.slaves.ComputerLauncher
;
import
hudson.slaves.ComputerListener
;
import
hudson.slaves.NodeProperty
;
...
...
@@ -65,6 +66,7 @@ import jenkins.util.ContextResettingExecutorService;
import
jenkins.security.MasterToSlaveCallable
;
import
org.kohsuke.args4j.Argument
;
import
org.kohsuke.args4j.CmdLineException
;
import
org.kohsuke.stapler.Stapler
;
import
org.kohsuke.stapler.StaplerRequest
;
import
org.kohsuke.stapler.StaplerResponse
;
import
org.kohsuke.stapler.QueryParameter
;
...
...
@@ -176,19 +178,54 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
protected
final
Object
statusChangeLock
=
new
Object
();
private
transient
final
List
<
RuntimeException
>
terminatedBy
=
Collections
.
synchronizedList
(
new
ArrayList
<
RuntimeException
>());
/**
* Keeps track of stack traces to track the tremination requests for this computer.
*
* @since 1.FIXME
* @see Executor#resetWorkUnit(String)
*/
private
transient
final
List
<
TerminationRequest
>
terminatedBy
=
Collections
.
synchronizedList
(
new
ArrayList
<
TerminationRequest
>());
/**
* This method captures the information of a request to terminate a computer instance. Method is public as
* it needs to be called from {@link AbstractCloudSlave} and {@link jenkins.model.Nodes}. In general you should
* not need to call this method directly, however if implementing a custom node type or a different path
* for removing nodes, it may make sense to call this method in order to capture the originating request.
*
* @since 1.FIXME
*/
public
void
recordTermination
()
{
try
{
throw
new
RuntimeException
(
String
.
format
(
"Termination requested by %s"
,
Thread
.
currentThread
()));
}
catch
(
RuntimeException
e
)
{
terminatedBy
.
add
(
e
);
StaplerRequest
request
=
Stapler
.
getCurrentRequest
();
if
(
request
!=
null
)
{
terminatedBy
.
add
(
new
TerminationRequest
(
String
.
format
(
"Termination requested by %s [id=%d] from HTTP request for %s"
,
Thread
.
currentThread
(),
Thread
.
currentThread
().
getId
(),
request
.
getRequestURL
()
)
));
}
else
{
terminatedBy
.
add
(
new
TerminationRequest
(
String
.
format
(
"Termination requested by %s [id=%d]"
,
Thread
.
currentThread
(),
Thread
.
currentThread
().
getId
()
)
));
}
}
public
List
<
RuntimeException
>
getTerminatedBy
()
{
return
new
ArrayList
<
RuntimeException
>(
terminatedBy
);
/**
* Returns the list of captured termination requests for this Computer. This method is used by {@link Executor}
* to provide details on why a Computer was removed in-between work being scheduled against the {@link Executor}
* and the {@link Executor} starting to execute the task.
*
* @return the (possibly empty) list of termination requests.
* @see Executor#resetWorkUnit(String)
* @since 1.FIXME
*/
public
List
<
TerminationRequest
>
getTerminatedBy
()
{
return
new
ArrayList
<
TerminationRequest
>(
terminatedBy
);
}
public
Computer
(
Node
node
)
{
...
...
@@ -1517,6 +1554,15 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
}
public
static
class
TerminationRequest
extends
RuntimeException
{
public
TerminationRequest
()
{
}
public
TerminationRequest
(
String
message
)
{
super
(
message
);
}
}
public
static
final
PermissionGroup
PERMISSIONS
=
new
PermissionGroup
(
Computer
.
class
,
Messages
.
_Computer_Permissions_Title
());
public
static
final
Permission
CONFIGURE
=
new
Permission
(
PERMISSIONS
,
"Configure"
,
Messages
.
_Computer_ConfigurePermission_Description
(),
Permission
.
CONFIGURE
,
PermissionScope
.
COMPUTER
);
/**
...
...
core/src/main/java/hudson/model/Executor.java
浏览文件 @
1fe73753
...
...
@@ -233,8 +233,8 @@ public class Executor extends Thread implements ModelObject {
pw
.
print
(
"No termination trace available."
);
}
else
{
pw
.
println
(
"Termination trace follows:"
);
for
(
RuntimeException
terminator
:
owner
.
getTerminatedBy
())
{
terminator
.
printStackTrace
(
pw
);
for
(
Computer
.
TerminationRequest
request
:
owner
.
getTerminatedBy
())
{
request
.
printStackTrace
(
pw
);
}
}
}
finally
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录