Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
e4b1aab4
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
提交
e4b1aab4
编写于
10月 20, 2015
作者:
S
Stephen Connolly
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FIXED JENKINS-31055] Make Node implement Saveable
- Also tidy up some of the mess logic in both #1866 and #1860
上级
e2517499
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
48 addition
and
16 deletion
+48
-16
changelog.html
changelog.html
+3
-0
core/src/main/java/hudson/model/Computer.java
core/src/main/java/hudson/model/Computer.java
+0
-1
core/src/main/java/hudson/model/Node.java
core/src/main/java/hudson/model/Node.java
+22
-7
core/src/main/java/jenkins/model/Jenkins.java
core/src/main/java/jenkins/model/Jenkins.java
+6
-3
core/src/main/java/jenkins/model/Nodes.java
core/src/main/java/jenkins/model/Nodes.java
+17
-5
未找到文件。
changelog.html
浏览文件 @
e4b1aab4
...
...
@@ -56,6 +56,9 @@ Upcoming changes</a>
<div
id=
"trunk"
style=
"display:none"
>
<!--=TRUNK-BEGIN=-->
<ul
class=
image
>
<li
class=
>
<li
class=
"rfe"
>
Make Node implement Saveable.
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-31055"
>
issue 31055
</a>
)
</ul>
</div>
<!--=TRUNK-END=-->
<h3><a
name=
v1.634
>
What's new in 1.634
</a>
(2015/10/18)
</h3>
...
...
core/src/main/java/hudson/model/Computer.java
浏览文件 @
e4b1aab4
...
...
@@ -695,7 +695,6 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
if
(
node
!=
null
)
{
node
.
setTemporaryOfflineCause
(
offlineCause
);
}
Jenkins
.
getInstance
().
getQueue
().
scheduleMaintenance
();
synchronized
(
statusChangeLock
)
{
statusChangeLock
.
notifyAll
();
}
...
...
core/src/main/java/hudson/model/Node.java
浏览文件 @
e4b1aab4
...
...
@@ -25,7 +25,12 @@
package
hudson.model
;
import
com.infradna.tool.bridge_method_injector.WithBridgeMethods
;
import
hudson.*
;
import
hudson.Extension
;
import
hudson.ExtensionPoint
;
import
hudson.FilePath
;
import
hudson.FileSystemProvisioner
;
import
hudson.Launcher
;
import
hudson.Util
;
import
hudson.model.Descriptor.FormException
;
import
hudson.model.Queue.Task
;
import
hudson.model.labels.LabelAtom
;
...
...
@@ -46,17 +51,15 @@ import hudson.util.DescribableList;
import
hudson.util.EnumConverter
;
import
hudson.util.TagCloud
;
import
hudson.util.TagCloud.WeightFunction
;
import
java.io.IOException
;
import
java.lang.reflect.Type
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.Set
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.logging.Logger
;
import
javax.annotation.CheckForNull
;
import
javax.annotation.Nonnull
;
import
jenkins.model.Jenkins
;
import
jenkins.util.io.OnMaster
;
import
net.sf.json.JSONObject
;
...
...
@@ -65,8 +68,8 @@ import org.jvnet.localizer.Localizable;
import
org.kohsuke.stapler.BindInterceptor
;
import
org.kohsuke.stapler.Stapler
;
import
org.kohsuke.stapler.StaplerRequest
;
import
org.kohsuke.stapler.export.ExportedBean
;
import
org.kohsuke.stapler.export.Exported
;
import
org.kohsuke.stapler.export.ExportedBean
;
/**
* Base type of Jenkins slaves (although in practice, you probably extend {@link Slave} to define a new slave type).
...
...
@@ -88,7 +91,7 @@ import org.kohsuke.stapler.export.Exported;
* @see Computer
*/
@ExportedBean
public
abstract
class
Node
extends
AbstractModelObject
implements
ReconfigurableDescribable
<
Node
>,
ExtensionPoint
,
AccessControlled
,
OnMaster
{
public
abstract
class
Node
extends
AbstractModelObject
implements
ReconfigurableDescribable
<
Node
>,
ExtensionPoint
,
AccessControlled
,
OnMaster
,
Saveable
{
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
Node
.
class
.
getName
());
...
...
@@ -114,6 +117,18 @@ public abstract class Node extends AbstractModelObject implements Reconfigurable
return
holdOffLaunchUntilSave
;
}
/**
* {@inheritDoc}
* @since 1.635
*/
@Override
public
void
save
()
throws
IOException
{
final
Jenkins
jenkins
=
Jenkins
.
getInstance
();
if
(
jenkins
!=
null
)
{
jenkins
.
updateNode
(
this
);
}
}
/**
* Name of this node.
*
...
...
@@ -237,7 +252,7 @@ public abstract class Node extends AbstractModelObject implements Reconfigurable
try
{
if
(
temporaryOfflineCause
!=
cause
)
{
temporaryOfflineCause
=
cause
;
Jenkins
.
getInstance
().
save
();
// Gotta be a better way to do this
save
();
}
}
catch
(
java
.
io
.
IOException
e
)
{
LOGGER
.
warning
(
"Unable to complete save, temporary offline status will not be persisted: "
+
e
.
getMessage
());
...
...
core/src/main/java/jenkins/model/Jenkins.java
浏览文件 @
e4b1aab4
...
...
@@ -147,7 +147,6 @@ import hudson.security.csrf.CrumbIssuer;
import
hudson.slaves.Cloud
;
import
hudson.slaves.ComputerListener
;
import
hudson.slaves.DumbSlave
;
import
hudson.slaves.EphemeralNode
;
import
hudson.slaves.NodeDescriptor
;
import
hudson.slaves.NodeList
;
import
hudson.slaves.NodeProperty
;
...
...
@@ -289,7 +288,6 @@ import java.util.concurrent.ThreadPoolExecutor;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeoutException
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
java.util.concurrent.locks.ReentrantReadWriteLock
;
import
java.util.logging.Level
;
import
java.util.logging.LogRecord
;
import
java.util.logging.Logger
;
...
...
@@ -1752,7 +1750,12 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
}
/**
* Updates an existing {@link Node} on disk.
* Saves an existing {@link Node} on disk, called by {@link Node#save()}. This method is preferred in those cases
* where you need to determine atomically that the node being saved is actually in the list of nodes.
*
* @param n the node to be updated.
* @return {@code true}, if the node was updated. {@code false}, if the node was not in the list of nodes.
* @throws IOException if the node could not be persisted.
* @see Nodes#updateNode
* @since 1.634
*/
...
...
core/src/main/java/jenkins/model/Nodes.java
浏览文件 @
e4b1aab4
...
...
@@ -34,6 +34,7 @@ import hudson.model.Saveable;
import
hudson.model.listeners.SaveableListener
;
import
hudson.slaves.EphemeralNode
;
import
hudson.slaves.OfflineCause
;
import
java.util.concurrent.Callable
;
import
org.kohsuke.accmod.Restricted
;
import
org.kohsuke.accmod.restrictions.NoExternalUse
;
...
...
@@ -157,6 +158,7 @@ public class Nodes implements Saveable {
xmlFile
.
write
(
node
);
SaveableListener
.
fireOnChange
(
this
,
xmlFile
);
}
jenkins
.
getQueue
().
scheduleMaintenance
();
}
/**
...
...
@@ -166,17 +168,27 @@ public class Nodes implements Saveable {
* @param node the node to be updated.
* @return {@code true}, if the node was updated. {@code false}, if the node was not in the list of nodes.
* @throws IOException if the node could not be persisted.
* @since 1.634
*/
public
boolean
updateNode
(
final
@Nonnull
Node
node
)
throws
IOException
{
if
(
node
==
nodes
.
get
(
node
.
getNodeName
()))
{
Queue
.
withLock
(
new
Runnable
()
{
boolean
exists
;
try
{
exists
=
Queue
.
withLock
(
new
Callable
<
Boolean
>()
{
@Override
public
void
run
()
{
jenkins
.
trimLabels
();
public
Boolean
call
()
throws
Exception
{
if
(
node
==
nodes
.
get
(
node
.
getNodeName
()))
{
jenkins
.
trimLabels
();
return
true
;
}
return
false
;
}
});
}
catch
(
Exception
e
)
{
// can never happen
exists
=
false
;
}
if
(
exists
)
{
persistNode
(
node
);
jenkins
.
getQueue
().
scheduleMaintenance
();
return
true
;
}
return
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录