Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
ffb5b650
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,发现更多精彩内容 >>
提交
ffb5b650
编写于
9月 23, 2014
作者:
K
Kohsuke Kawaguchi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Switched from annotation based scheme to a function based scheme.
上级
59456c73
变更
44
展开全部
隐藏空白更改
内联
并排
Showing
44 changed file
with
247 addition
and
251 deletion
+247
-251
core/src/main/java/hudson/EnvVars.java
core/src/main/java/hudson/EnvVars.java
+2
-3
core/src/main/java/hudson/FilePath.java
core/src/main/java/hudson/FilePath.java
+97
-47
core/src/main/java/hudson/Launcher.java
core/src/main/java/hudson/Launcher.java
+4
-7
core/src/main/java/hudson/cli/CLICommand.java
core/src/main/java/hudson/cli/CLICommand.java
+4
-8
core/src/main/java/hudson/cli/CommandDuringBuild.java
core/src/main/java/hudson/cli/CommandDuringBuild.java
+2
-3
core/src/main/java/hudson/cli/InstallToolCommand.java
core/src/main/java/hudson/cli/InstallToolCommand.java
+2
-6
core/src/main/java/hudson/cli/util/ScriptLoader.java
core/src/main/java/hudson/cli/util/ScriptLoader.java
+2
-4
core/src/main/java/hudson/logging/LogRecorder.java
core/src/main/java/hudson/logging/LogRecorder.java
+2
-3
core/src/main/java/hudson/model/AbstractItem.java
core/src/main/java/hudson/model/AbstractItem.java
+2
-2
core/src/main/java/hudson/model/Computer.java
core/src/main/java/hudson/model/Computer.java
+4
-7
core/src/main/java/hudson/model/Slave.java
core/src/main/java/hudson/model/Slave.java
+3
-6
core/src/main/java/hudson/node_monitors/ArchitectureMonitor.java
...c/main/java/hudson/node_monitors/ArchitectureMonitor.java
+2
-3
core/src/main/java/hudson/node_monitors/DiskSpaceMonitorDescriptor.java
...java/hudson/node_monitors/DiskSpaceMonitorDescriptor.java
+2
-3
core/src/main/java/hudson/node_monitors/ResponseTimeMonitor.java
...c/main/java/hudson/node_monitors/ResponseTimeMonitor.java
+3
-7
core/src/main/java/hudson/node_monitors/SwapSpaceMonitor.java
.../src/main/java/hudson/node_monitors/SwapSpaceMonitor.java
+2
-4
core/src/main/java/hudson/node_monitors/TemporarySpaceMonitor.java
...main/java/hudson/node_monitors/TemporarySpaceMonitor.java
+2
-2
core/src/main/java/hudson/os/solaris/ZFSProvisioner.java
core/src/main/java/hudson/os/solaris/ZFSProvisioner.java
+4
-4
core/src/main/java/hudson/security/AbstractPasswordBasedSecurityRealm.java
...a/hudson/security/AbstractPasswordBasedSecurityRealm.java
+2
-4
core/src/main/java/hudson/slaves/ChannelPinger.java
core/src/main/java/hudson/slaves/ChannelPinger.java
+2
-4
core/src/main/java/hudson/slaves/ConnectionActivityMonitor.java
...rc/main/java/hudson/slaves/ConnectionActivityMonitor.java
+2
-5
core/src/main/java/hudson/slaves/SlaveComputer.java
core/src/main/java/hudson/slaves/SlaveComputer.java
+9
-18
core/src/main/java/hudson/tasks/ArtifactArchiver.java
core/src/main/java/hudson/tasks/ArtifactArchiver.java
+2
-1
core/src/main/java/hudson/tasks/Fingerprinter.java
core/src/main/java/hudson/tasks/Fingerprinter.java
+2
-1
core/src/main/java/hudson/tasks/Maven.java
core/src/main/java/hudson/tasks/Maven.java
+2
-1
core/src/main/java/hudson/tasks/Shell.java
core/src/main/java/hudson/tasks/Shell.java
+2
-4
core/src/main/java/hudson/tasks/junit/JUnitParser.java
core/src/main/java/hudson/tasks/junit/JUnitParser.java
+3
-2
core/src/main/java/hudson/tasks/test/DefaultTestResultParserImpl.java
...n/java/hudson/tasks/test/DefaultTestResultParserImpl.java
+2
-2
core/src/main/java/hudson/tools/JDKInstaller.java
core/src/main/java/hudson/tools/JDKInstaller.java
+3
-5
core/src/main/java/hudson/tools/ZipExtractionInstaller.java
core/src/main/java/hudson/tools/ZipExtractionInstaller.java
+2
-2
core/src/main/java/hudson/util/RemotingDiagnostics.java
core/src/main/java/hudson/util/RemotingDiagnostics.java
+5
-9
core/src/main/java/jenkins/security/MasterToSlave.java
core/src/main/java/jenkins/security/MasterToSlave.java
+0
-25
core/src/main/java/jenkins/security/MasterToSlaveCallable.java
...src/main/java/jenkins/security/MasterToSlaveCallable.java
+9
-2
core/src/main/java/jenkins/security/NotReallyRoleSensitiveCallable.java
...java/jenkins/security/NotReallyRoleSensitiveCallable.java
+21
-0
core/src/main/java/jenkins/security/SlaveToMaster.java
core/src/main/java/jenkins/security/SlaveToMaster.java
+0
-26
core/src/main/java/jenkins/security/SlaveToMasterCallable.java
...src/main/java/jenkins/security/SlaveToMasterCallable.java
+9
-2
core/src/main/java/jenkins/slaves/StandardOutputSwapper.java
core/src/main/java/jenkins/slaves/StandardOutputSwapper.java
+2
-4
core/src/main/java/jenkins/util/VirtualFile.java
core/src/main/java/jenkins/util/VirtualFile.java
+4
-2
core/src/test/java/hudson/LauncherTest.java
core/src/test/java/hudson/LauncherTest.java
+3
-1
core/src/test/java/hudson/os/SUTester.java
core/src/test/java/hudson/os/SUTester.java
+2
-1
core/src/test/java/hudson/util/ProcessTreeTest.java
core/src/test/java/hudson/util/ProcessTreeTest.java
+2
-1
test/src/test/java/hudson/ProcTest.java
test/src/test/java/hudson/ProcTest.java
+2
-3
test/src/test/java/hudson/logging/LogRecorderManagerTest.java
.../src/test/java/hudson/logging/LogRecorderManagerTest.java
+2
-1
test/src/test/java/hudson/slaves/JNLPLauncherTest.java
test/src/test/java/hudson/slaves/JNLPLauncherTest.java
+2
-4
test/src/test/java/jenkins/security/DefaultFilePathFilterTest.java
...test/java/jenkins/security/DefaultFilePathFilterTest.java
+12
-2
未找到文件。
core/src/main/java/hudson/EnvVars.java
浏览文件 @
ffb5b650
...
...
@@ -26,7 +26,7 @@ package hudson;
import
hudson.remoting.Callable
;
import
hudson.remoting.VirtualChannel
;
import
hudson.util.CaseInsensitiveComparator
;
import
jenkins.security.MasterToSlave
;
import
jenkins.security.MasterToSlave
Callable
;
import
java.io.File
;
import
java.io.IOException
;
...
...
@@ -213,8 +213,7 @@ public class EnvVars extends TreeMap<String,String> {
return
channel
.
call
(
new
GetEnvVars
());
}
@MasterToSlave
private
static
final
class
GetEnvVars
implements
Callable
<
EnvVars
,
RuntimeException
>
{
private
static
final
class
GetEnvVars
extends
MasterToSlaveCallable
<
EnvVars
,
RuntimeException
>
{
public
EnvVars
call
()
{
return
new
EnvVars
(
EnvVars
.
masterEnvVars
);
}
...
...
core/src/main/java/hudson/FilePath.java
浏览文件 @
ffb5b650
此差异已折叠。
点击以展开。
core/src/main/java/hudson/Launcher.java
浏览文件 @
ffb5b650
...
...
@@ -38,7 +38,7 @@ import hudson.remoting.VirtualChannel;
import
hudson.util.StreamCopyThread
;
import
hudson.util.ArgumentListBuilder
;
import
hudson.util.ProcessTree
;
import
jenkins.security.MasterToSlave
;
import
jenkins.security.MasterToSlave
Callable
;
import
org.apache.commons.io.input.NullInputStream
;
import
java.io.BufferedOutputStream
;
...
...
@@ -888,8 +888,7 @@ public abstract class Launcher {
getChannel
().
call
(
new
KillTask
(
modelEnvVars
));
}
@MasterToSlave
private
static
final
class
KillTask
implements
Callable
<
Void
,
RuntimeException
>
{
private
static
final
class
KillTask
extends
MasterToSlaveCallable
<
Void
,
RuntimeException
>
{
private
final
Map
<
String
,
String
>
modelEnvVars
;
public
KillTask
(
Map
<
String
,
String
>
modelEnvVars
)
{
...
...
@@ -964,8 +963,7 @@ public abstract class Launcher {
IOTriplet
getIOtriplet
();
}
@MasterToSlave
private
static
class
RemoteLaunchCallable
implements
Callable
<
RemoteProcess
,
IOException
>
{
private
static
class
RemoteLaunchCallable
extends
MasterToSlaveCallable
<
RemoteProcess
,
IOException
>
{
private
final
List
<
String
>
cmd
;
private
final
boolean
[]
masks
;
private
final
String
[]
env
;
...
...
@@ -1035,8 +1033,7 @@ public abstract class Launcher {
private
static
final
long
serialVersionUID
=
1L
;
}
@MasterToSlave
private
static
class
RemoteChannelLaunchCallable
implements
Callable
<
OutputStream
,
IOException
>
{
private
static
class
RemoteChannelLaunchCallable
extends
MasterToSlaveCallable
<
OutputStream
,
IOException
>
{
private
final
String
[]
cmd
;
private
final
Pipe
out
;
private
final
String
workDir
;
...
...
core/src/main/java/hudson/cli/CLICommand.java
浏览文件 @
ffb5b650
...
...
@@ -36,8 +36,7 @@ import hudson.remoting.Channel;
import
hudson.remoting.ChannelProperty
;
import
hudson.security.CliAuthenticator
;
import
hudson.security.SecurityRealm
;
import
jenkins.security.MasterToSlave
;
import
jenkins.security.SlaveToMaster
;
import
jenkins.security.MasterToSlaveCallable
;
import
org.acegisecurity.Authentication
;
import
org.acegisecurity.BadCredentialsException
;
import
org.acegisecurity.context.SecurityContext
;
...
...
@@ -361,8 +360,7 @@ public abstract class CLICommand implements ExtensionPoint, Cloneable {
return
checkChannel
().
call
(
new
GetSystemProperty
(
name
));
}
@MasterToSlave
private
static
final
class
GetSystemProperty
implements
Callable
<
String
,
IOException
>
{
private
static
final
class
GetSystemProperty
extends
MasterToSlaveCallable
<
String
,
IOException
>
{
private
final
String
name
;
private
GetSystemProperty
(
String
name
)
{
...
...
@@ -391,8 +389,7 @@ public abstract class CLICommand implements ExtensionPoint, Cloneable {
}
}
@MasterToSlave
@SlaveToMaster
private
static
final
class
GetCharset
implements
Callable
<
String
,
IOException
>
{
private
static
final
class
GetCharset
extends
MasterToSlaveCallable
<
String
,
IOException
>
{
public
String
call
()
throws
IOException
{
return
Charset
.
defaultCharset
().
name
();
}
...
...
@@ -407,8 +404,7 @@ public abstract class CLICommand implements ExtensionPoint, Cloneable {
return
checkChannel
().
call
(
new
GetEnvironmentVariable
(
name
));
}
@MasterToSlave
private
static
final
class
GetEnvironmentVariable
implements
Callable
<
String
,
IOException
>
{
private
static
final
class
GetEnvironmentVariable
extends
MasterToSlaveCallable
<
String
,
IOException
>
{
private
final
String
name
;
private
GetEnvironmentVariable
(
String
name
)
{
...
...
core/src/main/java/hudson/cli/CommandDuringBuild.java
浏览文件 @
ffb5b650
...
...
@@ -28,7 +28,7 @@ import jenkins.model.Jenkins;
import
hudson.model.Job
;
import
hudson.model.Run
;
import
hudson.remoting.Callable
;
import
jenkins.security.MasterToSlave
;
import
jenkins.security.MasterToSlave
Callable
;
import
org.kohsuke.args4j.CmdLineException
;
import
java.io.IOException
;
...
...
@@ -82,8 +82,7 @@ public abstract class CommandDuringBuild extends CLICommand {
/**
* Gets the environment variables that points to the build being executed.
*/
@MasterToSlave
private
static
final
class
GetCharacteristicEnvironmentVariables
implements
Callable
<
String
[],
IOException
>
{
private
static
final
class
GetCharacteristicEnvironmentVariables
extends
MasterToSlaveCallable
<
String
[],
IOException
>
{
public
String
[]
call
()
throws
IOException
{
return
new
String
[]
{
System
.
getenv
(
"JOB_NAME"
),
...
...
core/src/main/java/hudson/cli/InstallToolCommand.java
浏览文件 @
ffb5b650
...
...
@@ -31,10 +31,7 @@ import hudson.model.AbstractProject;
import
hudson.model.Run
;
import
hudson.model.Executor
;
import
hudson.model.Node
;
import
hudson.model.EnvironmentSpecific
;
import
hudson.model.Item
;
import
hudson.remoting.Callable
;
import
hudson.slaves.NodeSpecific
;
import
hudson.util.EditDistance
;
import
hudson.util.StreamTaskListener
;
import
hudson.tools.ToolDescriptor
;
...
...
@@ -44,7 +41,7 @@ import java.util.List;
import
java.util.ArrayList
;
import
java.io.IOException
;
import
jenkins.security.MasterToSlave
;
import
jenkins.security.MasterToSlave
Callable
;
import
org.kohsuke.args4j.Argument
;
/**
...
...
@@ -129,8 +126,7 @@ public class InstallToolCommand extends CLICommand {
return
0
;
}
@MasterToSlave
private
static
final
class
BuildIDs
implements
Callable
<
BuildIDs
,
IOException
>
{
private
static
final
class
BuildIDs
extends
MasterToSlaveCallable
<
BuildIDs
,
IOException
>
{
String
job
,
number
,
id
;
public
BuildIDs
call
()
throws
IOException
{
...
...
core/src/main/java/hudson/cli/util/ScriptLoader.java
浏览文件 @
ffb5b650
package
hudson.cli.util
;
import
hudson.AbortException
;
import
hudson.remoting.Callable
;
import
jenkins.security.MasterToSlave
;
import
jenkins.security.MasterToSlaveCallable
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.IOUtils
;
...
...
@@ -17,8 +16,7 @@ import java.net.URL;
*
* @author vjuranek
*/
@MasterToSlave
public
class
ScriptLoader
implements
Callable
<
String
,
IOException
>
{
public
class
ScriptLoader
extends
MasterToSlaveCallable
<
String
,
IOException
>
{
private
final
String
script
;
...
...
core/src/main/java/hudson/logging/LogRecorder.java
浏览文件 @
ffb5b650
...
...
@@ -42,7 +42,7 @@ import hudson.slaves.ComputerListener;
import
hudson.util.CopyOnWriteList
;
import
hudson.util.RingBufferLogHandler
;
import
hudson.util.XStream2
;
import
jenkins.security.MasterToSlave
;
import
jenkins.security.MasterToSlave
Callable
;
import
net.sf.json.JSONObject
;
import
org.kohsuke.stapler.DataBoundConstructor
;
import
org.kohsuke.stapler.StaplerRequest
;
...
...
@@ -161,8 +161,7 @@ public class LogRecorder extends AbstractModelObject implements Saveable {
}
@MasterToSlave
private
static
final
class
SetLevel
implements
Callable
<
Void
,
Error
>
{
private
static
final
class
SetLevel
extends
MasterToSlaveCallable
<
Void
,
Error
>
{
/** known loggers (kept per slave), to avoid GC */
@SuppressWarnings
(
"MismatchedQueryAndUpdateOfCollection"
)
private
static
final
Set
<
Logger
>
loggers
=
new
HashSet
<
Logger
>();
private
final
String
name
;
...
...
core/src/main/java/hudson/model/AbstractItem.java
浏览文件 @
ffb5b650
...
...
@@ -34,7 +34,6 @@ import hudson.cli.declarative.CLIMethod;
import
hudson.cli.declarative.CLIResolver
;
import
hudson.model.listeners.ItemListener
;
import
hudson.model.listeners.SaveableListener
;
import
hudson.remoting.Callable
;
import
hudson.security.AccessControlled
;
import
hudson.security.Permission
;
import
hudson.security.ACL
;
...
...
@@ -44,6 +43,7 @@ import hudson.util.AtomicFileWriter;
import
hudson.util.IOException2
;
import
hudson.util.IOUtils
;
import
jenkins.model.Jenkins
;
import
jenkins.security.NotReallyRoleSensitiveCallable
;
import
org.acegisecurity.Authentication
;
import
org.apache.tools.ant.taskdefs.Copy
;
import
org.apache.tools.ant.types.FileSet
;
...
...
@@ -216,7 +216,7 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
// the test to see if the project already exists or not needs to be done in escalated privilege
// to avoid overwriting
ACL
.
impersonate
(
ACL
.
SYSTEM
,
new
Callable
<
Void
,
IOException
>()
{
ACL
.
impersonate
(
ACL
.
SYSTEM
,
new
NotReallyRoleSensitive
Callable
<
Void
,
IOException
>()
{
final
Authentication
user
=
Jenkins
.
getAuthentication
();
@Override
public
Void
call
()
throws
IOException
{
...
...
core/src/main/java/hudson/model/Computer.java
浏览文件 @
ffb5b650
...
...
@@ -58,7 +58,7 @@ import hudson.util.RemotingDiagnostics.HeapDump;
import
hudson.util.RunList
;
import
hudson.util.Futures
;
import
jenkins.model.Jenkins
;
import
jenkins.security.MasterToSlave
;
import
jenkins.security.MasterToSlave
Callable
;
import
org.kohsuke.args4j.Argument
;
import
org.kohsuke.args4j.CmdLineException
;
import
org.kohsuke.stapler.StaplerRequest
;
...
...
@@ -1025,8 +1025,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
oneOffExecutors
.
remove
(
e
);
}
@MasterToSlave
private
static
class
ListPossibleNames
implements
Callable
<
List
<
String
>,
IOException
>
{
private
static
class
ListPossibleNames
extends
MasterToSlaveCallable
<
List
<
String
>,
IOException
>
{
public
List
<
String
>
call
()
throws
IOException
{
List
<
String
>
names
=
new
ArrayList
<
String
>();
...
...
@@ -1056,8 +1055,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
private
static
final
long
serialVersionUID
=
1L
;
}
@MasterToSlave
private
static
class
GetFallbackName
implements
Callable
<
String
,
IOException
>
{
private
static
class
GetFallbackName
extends
MasterToSlaveCallable
<
String
,
IOException
>
{
public
String
call
()
throws
IOException
{
return
System
.
getProperty
(
"host.name"
);
}
...
...
@@ -1146,8 +1144,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
w
.
close
();
}
@MasterToSlave
private
static
final
class
DumpExportTableTask
implements
Callable
<
String
,
IOException
>
{
private
static
final
class
DumpExportTableTask
extends
MasterToSlaveCallable
<
String
,
IOException
>
{
public
String
call
()
throws
IOException
{
StringWriter
sw
=
new
StringWriter
();
PrintWriter
pw
=
new
PrintWriter
(
sw
);
...
...
core/src/main/java/hudson/model/Slave.java
浏览文件 @
ffb5b650
...
...
@@ -58,7 +58,7 @@ import javax.servlet.ServletException;
import
hudson.util.TimeUnit2
;
import
jenkins.model.Jenkins
;
import
jenkins.security.MasterToSlave
;
import
jenkins.security.MasterToSlave
Callable
;
import
jenkins.slaves.WorkspaceLocator
;
import
org.apache.commons.io.IOUtils
;
...
...
@@ -439,8 +439,7 @@ public abstract class Slave extends Node implements Serializable {
* <li>When it's read on this side as a return value, it morphs itself into {@link ClockDifference}.
* </ol>
*/
@MasterToSlave
private
static
final
class
GetClockDifference1
implements
Callable
<
ClockDifference
,
IOException
>
{
private
static
final
class
GetClockDifference1
extends
MasterToSlaveCallable
<
ClockDifference
,
IOException
>
{
public
ClockDifference
call
()
{
// this method must be being invoked locally, which means the clock is in sync
return
new
ClockDifference
(
0
);
...
...
@@ -453,8 +452,7 @@ public abstract class Slave extends Node implements Serializable {
private
static
final
long
serialVersionUID
=
1L
;
}
@MasterToSlave
private
static
final
class
GetClockDifference2
implements
Callable
<
GetClockDifference3
,
IOException
>
{
private
static
final
class
GetClockDifference2
extends
MasterToSlaveCallable
<
GetClockDifference3
,
IOException
>
{
/**
* Capture the time on the master when this object is sent to remote, which is when
* {@link GetClockDifference1#writeReplace()} is run.
...
...
@@ -468,7 +466,6 @@ public abstract class Slave extends Node implements Serializable {
private
static
final
long
serialVersionUID
=
1L
;
}
@MasterToSlave
private
static
final
class
GetClockDifference3
implements
Serializable
{
private
final
long
remoteTime
=
System
.
currentTimeMillis
();
private
final
long
startTime
;
...
...
core/src/main/java/hudson/node_monitors/ArchitectureMonitor.java
浏览文件 @
ffb5b650
...
...
@@ -26,7 +26,7 @@ package hudson.node_monitors;
import
hudson.model.Computer
;
import
hudson.remoting.Callable
;
import
hudson.Extension
;
import
jenkins.security.MasterToSlave
;
import
jenkins.security.MasterToSlave
Callable
;
import
net.sf.json.JSONObject
;
import
org.kohsuke.stapler.StaplerRequest
;
...
...
@@ -57,8 +57,7 @@ public class ArchitectureMonitor extends NodeMonitor {
/**
* Obtains the string that represents the architecture.
*/
@MasterToSlave
private
static
class
GetArchTask
implements
Callable
<
String
,
IOException
>
{
private
static
class
GetArchTask
extends
MasterToSlaveCallable
<
String
,
IOException
>
{
public
String
call
()
{
String
os
=
System
.
getProperty
(
"os.name"
);
String
arch
=
System
.
getProperty
(
"os.arch"
);
...
...
core/src/main/java/hudson/node_monitors/DiskSpaceMonitorDescriptor.java
浏览文件 @
ffb5b650
...
...
@@ -23,8 +23,7 @@
*/
package
hudson.node_monitors
;
import
hudson.FilePath.FileCallable
;
import
hudson.model.Computer
;
import
hudson.FilePath.MasterToSlaveFileCallable
;
import
hudson.remoting.VirtualChannel
;
import
hudson.Util
;
import
hudson.slaves.OfflineCause
;
...
...
@@ -159,7 +158,7 @@ public abstract class DiskSpaceMonitorDescriptor extends AbstractAsyncNodeMonito
private
static
final
long
serialVersionUID
=
2L
;
}
protected
static
final
class
GetUsableSpace
implements
FileCallable
<
DiskSpace
>
{
protected
static
final
class
GetUsableSpace
extends
MasterToSlave
FileCallable
<
DiskSpace
>
{
public
GetUsableSpace
()
{}
@IgnoreJRERequirement
public
DiskSpace
invoke
(
File
f
,
VirtualChannel
channel
)
throws
IOException
{
...
...
core/src/main/java/hudson/node_monitors/ResponseTimeMonitor.java
浏览文件 @
ffb5b650
...
...
@@ -32,8 +32,7 @@ import hudson.remoting.Future;
import
hudson.util.ClockDifference
;
import
hudson.util.TimeUnit2
;
import
hudson.util.IOException2
;
import
jenkins.security.MasterToSlave
;
import
jenkins.security.SlaveToMaster
;
import
jenkins.security.MasterToSlaveCallable
;
import
net.sf.json.JSONObject
;
import
org.kohsuke.stapler.StaplerRequest
;
...
...
@@ -94,8 +93,7 @@ public class ResponseTimeMonitor extends NodeMonitor {
}
};
@MasterToSlave
private
static
final
class
Step1
implements
Callable
<
Data
,
IOException
>
{
private
static
final
class
Step1
extends
MasterToSlaveCallable
<
Data
,
IOException
>
{
private
Data
cur
;
private
Step1
(
Data
cur
)
{
...
...
@@ -114,8 +112,7 @@ public class ResponseTimeMonitor extends NodeMonitor {
private
static
final
long
serialVersionUID
=
1L
;
}
@MasterToSlave
private
static
final
class
Step2
implements
Callable
<
Step3
,
IOException
>
{
private
static
final
class
Step2
extends
MasterToSlaveCallable
<
Step3
,
IOException
>
{
private
final
Data
cur
;
private
final
long
start
=
System
.
currentTimeMillis
();
...
...
@@ -131,7 +128,6 @@ public class ResponseTimeMonitor extends NodeMonitor {
private
static
final
long
serialVersionUID
=
1L
;
}
@SlaveToMaster
private
static
final
class
Step3
implements
Serializable
{
private
final
Data
cur
;
private
final
long
start
;
...
...
core/src/main/java/hudson/node_monitors/SwapSpaceMonitor.java
浏览文件 @
ffb5b650
...
...
@@ -27,8 +27,7 @@ import hudson.Util;
import
hudson.Extension
;
import
hudson.model.Computer
;
import
jenkins.model.Jenkins
;
import
hudson.remoting.Callable
;
import
jenkins.security.MasterToSlave
;
import
jenkins.security.MasterToSlaveCallable
;
import
net.sf.json.JSONObject
;
import
org.jvnet.hudson.MemoryMonitor
;
import
org.jvnet.hudson.MemoryUsage
;
...
...
@@ -98,8 +97,7 @@ public class SwapSpaceMonitor extends NodeMonitor {
/**
* Obtains the string that represents the architecture.
*/
@MasterToSlave
private
static
class
MonitorTask
implements
Callable
<
MemoryUsage
,
IOException
>
{
private
static
class
MonitorTask
extends
MasterToSlaveCallable
<
MemoryUsage
,
IOException
>
{
public
MemoryUsage
call
()
throws
IOException
{
MemoryMonitor
mm
;
try
{
...
...
core/src/main/java/hudson/node_monitors/TemporarySpaceMonitor.java
浏览文件 @
ffb5b650
...
...
@@ -25,7 +25,7 @@ package hudson.node_monitors;
import
hudson.Extension
;
import
hudson.FilePath
;
import
hudson.FilePath.FileCallable
;
import
hudson.FilePath.
MasterToSlave
FileCallable
;
import
hudson.Functions
;
import
hudson.model.Computer
;
import
hudson.remoting.Callable
;
...
...
@@ -82,7 +82,7 @@ public class TemporarySpaceMonitor extends AbstractDiskSpaceMonitor {
return
null
;
}
protected
static
final
class
GetTempSpace
implements
FileCallable
<
DiskSpace
>
{
protected
static
final
class
GetTempSpace
extends
MasterToSlave
FileCallable
<
DiskSpace
>
{
@IgnoreJRERequirement
public
DiskSpace
invoke
(
File
f
,
VirtualChannel
channel
)
throws
IOException
{
try
{
...
...
core/src/main/java/hudson/os/solaris/ZFSProvisioner.java
浏览文件 @
ffb5b650
...
...
@@ -23,13 +23,13 @@
*/
package
hudson.os.solaris
;
import
hudson.FilePath.MasterToSlaveFileCallable
;
import
hudson.FileSystemProvisioner
;
import
hudson.FilePath
;
import
hudson.WorkspaceSnapshot
;
import
hudson.FileSystemProvisionerDescriptor
;
import
hudson.Extension
;
import
hudson.remoting.VirtualChannel
;
import
hudson.FilePath.FileCallable
;
import
hudson.model.AbstractBuild
;
import
hudson.model.TaskListener
;
import
hudson.model.AbstractProject
;
...
...
@@ -52,7 +52,7 @@ public class ZFSProvisioner extends FileSystemProvisioner implements Serializabl
private
final
String
rootDataset
;
public
ZFSProvisioner
(
Node
node
)
throws
IOException
,
InterruptedException
{
rootDataset
=
node
.
getRootPath
().
act
(
new
FileCallable
<
String
>()
{
rootDataset
=
node
.
getRootPath
().
act
(
new
MasterToSlave
FileCallable
<
String
>()
{
private
static
final
long
serialVersionUID
=
-
2142349338699797436L
;
public
String
invoke
(
File
f
,
VirtualChannel
channel
)
throws
IOException
{
...
...
@@ -68,7 +68,7 @@ public class ZFSProvisioner extends FileSystemProvisioner implements Serializabl
public
void
prepareWorkspace
(
AbstractBuild
<?,?>
build
,
FilePath
ws
,
final
TaskListener
listener
)
throws
IOException
,
InterruptedException
{
final
String
name
=
build
.
getProject
().
getFullName
();
ws
.
act
(
new
FileCallable
<
Void
>()
{
ws
.
act
(
new
MasterToSlave
FileCallable
<
Void
>()
{
private
static
final
long
serialVersionUID
=
2129531727963121198L
;
public
Void
invoke
(
File
f
,
VirtualChannel
channel
)
throws
IOException
{
...
...
@@ -87,7 +87,7 @@ public class ZFSProvisioner extends FileSystemProvisioner implements Serializabl
}
public
void
discardWorkspace
(
AbstractProject
<?,
?>
project
,
FilePath
ws
)
throws
IOException
,
InterruptedException
{
ws
.
act
(
new
FileCallable
<
Void
>()
{
ws
.
act
(
new
MasterToSlave
FileCallable
<
Void
>()
{
private
static
final
long
serialVersionUID
=
1916618107019257530L
;
public
Void
invoke
(
File
f
,
VirtualChannel
channel
)
throws
IOException
{
...
...
core/src/main/java/hudson/security/AbstractPasswordBasedSecurityRealm.java
浏览文件 @
ffb5b650
...
...
@@ -4,9 +4,8 @@ import groovy.lang.Binding;
import
hudson.FilePath
;
import
hudson.cli.CLICommand
;
import
jenkins.model.Jenkins
;
import
hudson.remoting.Callable
;
import
hudson.util.spring.BeanBuilder
;
import
jenkins.security.MasterToSlave
;
import
jenkins.security.MasterToSlave
Callable
;
import
org.acegisecurity.Authentication
;
import
org.acegisecurity.AuthenticationException
;
import
org.acegisecurity.AuthenticationManager
;
...
...
@@ -141,8 +140,7 @@ public abstract class AbstractPasswordBasedSecurityRealm extends SecurityRealm i
/**
* Asks for the password.
*/
@MasterToSlave
private
static
class
InteractivelyAskForPassword
implements
Callable
<
String
,
IOException
>
{
private
static
class
InteractivelyAskForPassword
extends
MasterToSlaveCallable
<
String
,
IOException
>
{
@IgnoreJRERequirement
public
String
call
()
throws
IOException
{
Console
console
=
System
.
console
();
...
...
core/src/main/java/hudson/slaves/ChannelPinger.java
浏览文件 @
ffb5b650
...
...
@@ -28,10 +28,9 @@ import hudson.FilePath;
import
hudson.model.Computer
;
import
hudson.model.Slave
;
import
hudson.model.TaskListener
;
import
hudson.remoting.Callable
;
import
hudson.remoting.Channel
;
import
hudson.remoting.PingThread
;
import
jenkins.security.MasterToSlave
;
import
jenkins.security.MasterToSlave
Callable
;
import
java.io.IOException
;
import
java.util.concurrent.atomic.AtomicBoolean
;
...
...
@@ -86,8 +85,7 @@ public class ChannelPinger extends ComputerListener {
setUpPingForChannel
(
channel
,
pingInterval
);
}
@MasterToSlave
private
static
class
SetUpRemotePing
implements
Callable
<
Void
,
IOException
>
{
private
static
class
SetUpRemotePing
extends
MasterToSlaveCallable
<
Void
,
IOException
>
{
private
static
final
long
serialVersionUID
=
-
2702219700841759872L
;
private
int
pingInterval
;
public
SetUpRemotePing
(
int
pingInterval
)
{
...
...
core/src/main/java/hudson/slaves/ConnectionActivityMonitor.java
浏览文件 @
ffb5b650
...
...
@@ -30,10 +30,8 @@ import hudson.model.Computer;
import
hudson.util.TimeUnit2
;
import
hudson.remoting.VirtualChannel
;
import
hudson.remoting.Channel
;
import
hudson.remoting.Callable
;
import
hudson.Extension
;
import
jenkins.security.MasterToSlave
;
import
jenkins.security.SlaveToMaster
;
import
jenkins.security.SlaveToMasterCallable
;
import
java.io.IOException
;
import
java.util.logging.Logger
;
...
...
@@ -104,8 +102,7 @@ public class ConnectionActivityMonitor extends AsyncPeriodicWork {
public
boolean
enabled
=
Boolean
.
getBoolean
(
ConnectionActivityMonitor
.
class
.
getName
()+
".enabled"
);
private
static
final
PingCommand
PING_COMMAND
=
new
PingCommand
();
@MasterToSlave
@SlaveToMaster
private
static
final
class
PingCommand
implements
Callable
<
Void
,
RuntimeException
>
{
private
static
final
class
PingCommand
extends
SlaveToMasterCallable
<
Void
,
RuntimeException
>
{
public
Void
call
()
throws
RuntimeException
{
return
null
;
}
...
...
core/src/main/java/hudson/slaves/SlaveComputer.java
浏览文件 @
ffb5b650
...
...
@@ -72,8 +72,7 @@ import javax.crypto.spec.IvParameterSpec;
import
javax.crypto.spec.SecretKeySpec
;
import
javax.servlet.RequestDispatcher
;
import
jenkins.model.Jenkins
;
import
jenkins.security.MasterToSlave
;
import
jenkins.security.SlaveToMaster
;
import
jenkins.security.MasterToSlaveCallable
;
import
jenkins.slaves.JnlpSlaveAgentProtocol
;
import
org.kohsuke.stapler.StaplerRequest
;
import
org.kohsuke.stapler.StaplerResponse
;
...
...
@@ -401,8 +400,7 @@ public class SlaveComputer extends Computer {
return
channel
.
call
(
new
LoadingTime
(
true
));
}
@MasterToSlave
@SlaveToMaster
static
class
LoadingCount
implements
Callable
<
Integer
,
RuntimeException
>
{
static
class
LoadingCount
extends
MasterToSlaveCallable
<
Integer
,
RuntimeException
>
{
private
final
boolean
resource
;
LoadingCount
(
boolean
resource
)
{
this
.
resource
=
resource
;
...
...
@@ -413,15 +411,13 @@ public class SlaveComputer extends Computer {
}
}
@MasterToSlave
static
class
LoadingPrefetchCacheCount
implements
Callable
<
Integer
,
RuntimeException
>
{
static
class
LoadingPrefetchCacheCount
extends
MasterToSlaveCallable
<
Integer
,
RuntimeException
>
{
@Override
public
Integer
call
()
{
return
Channel
.
current
().
classLoadingPrefetchCacheCount
.
get
();
}
}
@MasterToSlave
static
class
LoadingTime
implements
Callable
<
Long
,
RuntimeException
>
{
static
class
LoadingTime
extends
MasterToSlaveCallable
<
Long
,
RuntimeException
>
{
private
final
boolean
resource
;
LoadingTime
(
boolean
resource
)
{
this
.
resource
=
resource
;
...
...
@@ -716,22 +712,19 @@ public class SlaveComputer extends Computer {
private
static
final
Logger
logger
=
Logger
.
getLogger
(
SlaveComputer
.
class
.
getName
());
@MasterToSlave
private
static
final
class
SlaveVersion
implements
Callable
<
String
,
IOException
>
{
private
static
final
class
SlaveVersion
extends
MasterToSlaveCallable
<
String
,
IOException
>
{
public
String
call
()
throws
IOException
{
try
{
return
Launcher
.
VERSION
;
}
catch
(
Throwable
ex
)
{
return
"< 1.335"
;
}
// Older slave.jar won't have VERSION
}
}
@MasterToSlave
@SlaveToMaster
private
static
final
class
DetectOS
implements
Callable
<
Boolean
,
IOException
>
{
private
static
final
class
DetectOS
extends
MasterToSlaveCallable
<
Boolean
,
IOException
>
{
public
Boolean
call
()
throws
IOException
{
return
File
.
pathSeparatorChar
==
':'
;
}
}
@MasterToSlave
@SlaveToMaster
private
static
final
class
DetectDefaultCharset
implements
Callable
<
String
,
IOException
>
{
private
static
final
class
DetectDefaultCharset
extends
MasterToSlaveCallable
<
String
,
IOException
>
{
public
String
call
()
throws
IOException
{
return
Charset
.
defaultCharset
().
name
();
}
...
...
@@ -748,8 +741,7 @@ public class SlaveComputer extends Computer {
static
final
RingBufferLogHandler
SLAVE_LOG_HANDLER
=
new
RingBufferLogHandler
();
}
@MasterToSlave
private
static
class
SlaveInitializer
implements
Callable
<
Void
,
RuntimeException
>
{
private
static
class
SlaveInitializer
extends
MasterToSlaveCallable
<
Void
,
RuntimeException
>
{
public
Void
call
()
{
// avoid double installation of the handler. JNLP slaves can reconnect to the master multiple times
// and each connection gets a different RemoteClassLoader, so we need to evict them by class name,
...
...
@@ -796,8 +788,7 @@ public class SlaveComputer extends Computer {
return
null
;
}
@MasterToSlave
private
static
class
SlaveLogFetcher
implements
Callable
<
List
<
LogRecord
>,
RuntimeException
>
{
private
static
class
SlaveLogFetcher
extends
MasterToSlaveCallable
<
List
<
LogRecord
>,
RuntimeException
>
{
public
List
<
LogRecord
>
call
()
{
return
new
ArrayList
<
LogRecord
>(
SLAVE_LOG_HANDLER
.
getView
());
}
...
...
core/src/main/java/hudson/tasks/ArtifactArchiver.java
浏览文件 @
ffb5b650
...
...
@@ -24,6 +24,7 @@
package
hudson.tasks
;
import
hudson.FilePath
;
import
hudson.FilePath.MasterToSlaveFileCallable
;
import
hudson.Launcher
;
import
hudson.Util
;
import
hudson.Extension
;
...
...
@@ -169,7 +170,7 @@ public class ArtifactArchiver extends Recorder {
return
true
;
}
private
static
final
class
ListFiles
implements
FilePath
.
FileCallable
<
Map
<
String
,
String
>>
{
private
static
final
class
ListFiles
extends
MasterToSlave
FileCallable
<
Map
<
String
,
String
>>
{
private
static
final
long
serialVersionUID
=
1
;
private
final
String
includes
,
excludes
;
ListFiles
(
String
includes
,
String
excludes
)
{
...
...
core/src/main/java/hudson/tasks/Fingerprinter.java
浏览文件 @
ffb5b650
...
...
@@ -28,6 +28,7 @@ import hudson.EnvVars;
import
hudson.Extension
;
import
hudson.FilePath
;
import
hudson.FilePath.FileCallable
;
import
hudson.FilePath.MasterToSlaveFileCallable
;
import
hudson.Launcher
;
import
hudson.Util
;
import
hudson.matrix.MatrixConfiguration
;
...
...
@@ -220,7 +221,7 @@ public class Fingerprinter extends Recorder implements Serializable, DependencyD
return
;
}
List
<
Record
>
records
=
ws
.
act
(
new
FileCallable
<
List
<
Record
>>()
{
List
<
Record
>
records
=
ws
.
act
(
new
MasterToSlave
FileCallable
<
List
<
Record
>>()
{
public
List
<
Record
>
invoke
(
File
baseDir
,
VirtualChannel
channel
)
throws
IOException
{
List
<
Record
>
results
=
new
ArrayList
<
Record
>();
...
...
core/src/main/java/hudson/tasks/Maven.java
浏览文件 @
ffb5b650
...
...
@@ -24,6 +24,7 @@
package
hudson.tasks
;
import
hudson.Extension
;
import
hudson.FilePath.MasterToSlaveFileCallable
;
import
hudson.Launcher
;
import
hudson.Functions
;
import
hudson.EnvVars
;
...
...
@@ -219,7 +220,7 @@ public class Maven extends Builder {
* Looks for <tt>pom.xlm</tt> or <tt>project.xml</tt> to determine the maven executable
* name.
*/
private
static
final
class
DecideDefaultMavenCommand
implements
FileCallable
<
String
>
{
private
static
final
class
DecideDefaultMavenCommand
extends
MasterToSlave
FileCallable
<
String
>
{
private
static
final
long
serialVersionUID
=
-
2327576423452215146L
;
// command line arguments.
private
final
String
arguments
;
...
...
core/src/main/java/hudson/tasks/Shell.java
浏览文件 @
ffb5b650
...
...
@@ -28,12 +28,11 @@ import hudson.Functions;
import
hudson.Util
;
import
hudson.Extension
;
import
hudson.model.AbstractProject
;
import
hudson.remoting.Callable
;
import
hudson.remoting.VirtualChannel
;
import
hudson.util.FormValidation
;
import
java.io.IOException
;
import
jenkins.security.MasterToSlave
;
import
jenkins.security.MasterToSlave
Callable
;
import
net.sf.json.JSONObject
;
import
org.kohsuke.stapler.DataBoundConstructor
;
import
org.kohsuke.stapler.StaplerRequest
;
...
...
@@ -195,8 +194,7 @@ public class Shell extends CommandInterpreter {
return
FormValidation
.
validateExecutable
(
value
);
}
@MasterToSlave
private
static
final
class
Shellinterpreter
implements
Callable
<
String
,
IOException
>
{
private
static
final
class
Shellinterpreter
extends
MasterToSlaveCallable
<
String
,
IOException
>
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
core/src/main/java/hudson/tasks/junit/JUnitParser.java
浏览文件 @
ffb5b650
...
...
@@ -23,6 +23,7 @@
*/
package
hudson.tasks.junit
;
import
hudson.FilePath.MasterToSlaveFileCallable
;
import
hudson.model.TaskListener
;
import
hudson.tasks.test.TestResultParser
;
import
hudson.model.AbstractBuild
;
...
...
@@ -87,8 +88,8 @@ public class JUnitParser extends TestResultParser {
return
workspace
.
act
(
new
ParseResultCallable
(
testResultLocations
,
buildTime
,
timeOnMaster
,
keepLongStdio
));
}
private
static
final
class
ParseResultCallable
implement
s
FilePath
.
FileCallable
<
TestResult
>
{
private
static
final
class
ParseResultCallable
extend
s
MasterToSlave
FileCallable
<
TestResult
>
{
private
final
long
buildTime
;
private
final
String
testResults
;
private
final
long
nowMaster
;
...
...
core/src/main/java/hudson/tasks/test/DefaultTestResultParserImpl.java
浏览文件 @
ffb5b650
...
...
@@ -25,7 +25,7 @@ package hudson.tasks.test;
import
hudson.AbortException
;
import
hudson.FilePath
;
import
hudson.FilePath.FileCallable
;
import
hudson.FilePath.
MasterToSlave
FileCallable
;
import
hudson.Launcher
;
import
hudson.Util
;
import
hudson.model.AbstractBuild
;
...
...
@@ -74,7 +74,7 @@ public abstract class DefaultTestResultParserImpl extends TestResultParser imple
@Override
public
TestResult
parse
(
final
String
testResultLocations
,
final
AbstractBuild
build
,
final
Launcher
launcher
,
final
TaskListener
listener
)
throws
InterruptedException
,
IOException
{
return
build
.
getWorkspace
().
act
(
new
FileCallable
<
TestResult
>()
{
return
build
.
getWorkspace
().
act
(
new
MasterToSlave
FileCallable
<
TestResult
>()
{
final
boolean
ignoreTimestampCheck
=
IGNORE_TIMESTAMP_CHECK
;
// so that the property can be set on the master
final
long
buildTime
=
build
.
getTimestamp
().
getTimeInMillis
();
final
long
nowMaster
=
System
.
currentTimeMillis
();
...
...
core/src/main/java/hudson/tools/JDKInstaller.java
浏览文件 @
ffb5b650
...
...
@@ -40,7 +40,7 @@ import hudson.util.FormValidation;
import
hudson.util.HttpResponses
;
import
hudson.util.Secret
;
import
jenkins.model.Jenkins
;
import
jenkins.security.MasterToSlave
;
import
jenkins.security.MasterToSlave
Callable
;
import
net.sf.json.JSONObject
;
import
org.apache.commons.httpclient.Cookie
;
import
org.apache.commons.httpclient.HttpClient
;
...
...
@@ -502,8 +502,7 @@ public class JDKInstaller extends ToolInstaller {
throw
new
DetectionFailedException
(
"Unknown CPU name: "
+
arch
);
}
@MasterToSlave
static
class
GetCurrentPlatform
implements
Callable
<
Platform
,
DetectionFailedException
>
{
static
class
GetCurrentPlatform
extends
MasterToSlaveCallable
<
Platform
,
DetectionFailedException
>
{
private
static
final
long
serialVersionUID
=
1L
;
public
Platform
call
()
throws
DetectionFailedException
{
return
current
();
...
...
@@ -565,8 +564,7 @@ public class JDKInstaller extends ToolInstaller {
throw
new
DetectionFailedException
(
"Unknown CPU architecture: "
+
arch
);
}
@MasterToSlave
static
class
GetCurrentCPU
implements
Callable
<
CPU
,
DetectionFailedException
>
{
static
class
GetCurrentCPU
extends
MasterToSlaveCallable
<
CPU
,
DetectionFailedException
>
{
private
static
final
long
serialVersionUID
=
1L
;
public
CPU
call
()
throws
DetectionFailedException
{
return
current
();
...
...
core/src/main/java/hudson/tools/ZipExtractionInstaller.java
浏览文件 @
ffb5b650
...
...
@@ -26,7 +26,7 @@ package hudson.tools;
import
hudson.Extension
;
import
hudson.FilePath
;
import
hudson.FilePath.FileCallable
;
import
hudson.FilePath.
MasterToSlave
FileCallable
;
import
hudson.ProxyConfiguration
;
import
hudson.Util
;
import
hudson.Functions
;
...
...
@@ -119,7 +119,7 @@ public class ZipExtractionInstaller extends ToolInstaller {
* Sets execute permission on all files, since unzip etc. might not do this.
* Hackish, is there a better way?
*/
static
class
ChmodRecAPlusX
implements
FileCallable
<
Void
>
{
static
class
ChmodRecAPlusX
extends
MasterToSlave
FileCallable
<
Void
>
{
private
static
final
long
serialVersionUID
=
1L
;
public
Void
invoke
(
File
d
,
VirtualChannel
channel
)
throws
IOException
{
if
(!
Functions
.
isWindows
())
...
...
core/src/main/java/hudson/util/RemotingDiagnostics.java
浏览文件 @
ffb5b650
...
...
@@ -34,7 +34,7 @@ import hudson.remoting.DelegatingCallable;
import
hudson.remoting.Future
;
import
hudson.remoting.VirtualChannel
;
import
hudson.security.AccessControlled
;
import
jenkins.security.MasterToSlave
;
import
jenkins.security.MasterToSlave
Callable
;
import
org.codehaus.groovy.control.CompilerConfiguration
;
import
org.codehaus.groovy.control.customizers.ImportCustomizer
;
import
org.kohsuke.stapler.StaplerRequest
;
...
...
@@ -71,8 +71,7 @@ public final class RemotingDiagnostics {
return
channel
.
call
(
new
GetSystemProperties
());
}
@MasterToSlave
private
static
final
class
GetSystemProperties
implements
Callable
<
Map
<
Object
,
Object
>,
RuntimeException
>
{
private
static
final
class
GetSystemProperties
extends
MasterToSlaveCallable
<
Map
<
Object
,
Object
>,
RuntimeException
>
{
public
Map
<
Object
,
Object
>
call
()
{
return
new
TreeMap
<
Object
,
Object
>(
System
.
getProperties
());
}
...
...
@@ -91,8 +90,7 @@ public final class RemotingDiagnostics {
return
channel
.
callAsync
(
new
GetThreadDump
());
}
@MasterToSlave
private
static
final
class
GetThreadDump
implements
Callable
<
Map
<
String
,
String
>,
RuntimeException
>
{
private
static
final
class
GetThreadDump
extends
MasterToSlaveCallable
<
Map
<
String
,
String
>,
RuntimeException
>
{
public
Map
<
String
,
String
>
call
()
{
Map
<
String
,
String
>
r
=
new
LinkedHashMap
<
String
,
String
>();
try
{
...
...
@@ -122,8 +120,7 @@ public final class RemotingDiagnostics {
return
channel
.
call
(
new
Script
(
script
));
}
@MasterToSlave
private
static
final
class
Script
implements
DelegatingCallable
<
String
,
RuntimeException
>
{
private
static
final
class
Script
extends
MasterToSlaveCallable
<
String
,
RuntimeException
>
implements
DelegatingCallable
<
String
,
RuntimeException
>
{
private
final
String
script
;
private
transient
ClassLoader
cl
;
...
...
@@ -205,8 +202,7 @@ public final class RemotingDiagnostics {
}
}
@MasterToSlave
private
static
class
GetHeapDump
implements
Callable
<
FilePath
,
IOException
>
{
private
static
class
GetHeapDump
extends
MasterToSlaveCallable
<
FilePath
,
IOException
>
{
public
FilePath
call
()
throws
IOException
{
final
File
hprof
=
File
.
createTempFile
(
"hudson-heapdump"
,
"hprof"
);
hprof
.
delete
();
...
...
core/src/main/java/jenkins/security/MasterToSlave.java
已删除
100644 → 0
浏览文件 @
59456c73
package
jenkins.security
;
import
hudson.remoting.Callable
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Inherited
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.Target
;
import
static
java
.
lang
.
annotation
.
ElementType
.
TYPE
;
import
static
java
.
lang
.
annotation
.
RetentionPolicy
.
RUNTIME
;
/**
* Annotates {@link Callable} that this callable is meant to be run on the slave.
*
* @author Kohsuke Kawaguchi
* @see SlaveToMaster
* @since 1.THU
*/
@Retention
(
RUNTIME
)
@Target
(
TYPE
)
@Inherited
@Documented
public
@interface
MasterToSlave
{
}
core/src/main/java/jenkins/security/MasterToSlaveCallable.java
浏览文件 @
ffb5b650
package
jenkins.security
;
import
hudson.remoting.Callable
;
import
org.jenkinsci.remoting.Role
;
import
java.util.Collection
;
/**
* Convenient {@link Callable}
with {@link MasterToSlave} to create anonymous Callable class
.
* Convenient {@link Callable}
meant to be run on slave
.
*
* @author Kohsuke Kawaguchi
* @since 1.THU
*/
@MasterToSlave
public
abstract
class
MasterToSlaveCallable
<
V
,
T
extends
Throwable
>
implements
Callable
<
V
,
T
>
{
@Override
public
Collection
<
Role
>
getRecipients
()
{
return
Roles
.
FOR_SLAVE
;
}
private
static
final
long
serialVersionUID
=
1L
;
}
core/src/main/java/jenkins/security/NotReallyRoleSensitiveCallable.java
0 → 100644
浏览文件 @
ffb5b650
package
jenkins.security
;
import
hudson.remoting.Callable
;
import
org.jenkinsci.remoting.Role
;
import
java.util.Collection
;
/**
* {@link Callable} adapter for situations where Callable is not used for remoting but
* just as a convenient function that has parameterized return value and exception type.
*
* @author Kohsuke Kawaguchi
* @since 1.THU
*/
public
abstract
class
NotReallyRoleSensitiveCallable
<
V
,
T
extends
Throwable
>
implements
Callable
<
V
,
T
>
{
@Override
public
final
Collection
<
Role
>
getRecipients
()
{
// not meant to be used where this matters
throw
new
UnsupportedOperationException
();
}
}
core/src/main/java/jenkins/security/SlaveToMaster.java
已删除
100644 → 0
浏览文件 @
59456c73
package
jenkins.security
;
import
hudson.remoting.Callable
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Inherited
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.Target
;
import
static
java
.
lang
.
annotation
.
ElementType
.*;
import
static
java
.
lang
.
annotation
.
RetentionPolicy
.*;
/**
* Annotates {@link Callable} that are meant for the slave to execute on the master.
*
* @author Kohsuke Kawaguchi
* @see MasterToSlave
* @see CallableDirectionChecker
* @since 1.THU
*/
@Retention
(
RUNTIME
)
@Target
(
TYPE
)
@Inherited
@Documented
public
@interface
SlaveToMaster
{
}
core/src/main/java/jenkins/security/SlaveToMasterCallable.java
浏览文件 @
ffb5b650
package
jenkins.security
;
import
hudson.remoting.Callable
;
import
org.jenkinsci.remoting.Role
;
import
java.util.Collection
;
/**
* Convenient {@link Callable}
with {@link SlaveToMaster} to create anonymous Callable class
.
* Convenient {@link Callable}
that are meant to run on the master (sent by slave/CLI/etc)
.
*
* @author Kohsuke Kawaguchi
* @since 1.THU
*/
@SlaveToMaster
public
abstract
class
SlaveToMasterCallable
<
V
,
T
extends
Throwable
>
implements
Callable
<
V
,
T
>
{
@Override
public
Collection
<
Role
>
getRecipients
()
{
return
Roles
.
FOR_MASTER
;
}
private
static
final
long
serialVersionUID
=
1L
;
}
core/src/main/java/jenkins/slaves/StandardOutputSwapper.java
浏览文件 @
ffb5b650
...
...
@@ -4,12 +4,11 @@ import hudson.Extension;
import
hudson.FilePath
;
import
hudson.model.Computer
;
import
hudson.model.TaskListener
;
import
hudson.remoting.Callable
;
import
hudson.remoting.Channel
;
import
hudson.remoting.StandardOutputStream
;
import
hudson.slaves.ComputerListener
;
import
hudson.util.jna.GNUCLibrary
;
import
jenkins.security.MasterToSlave
;
import
jenkins.security.MasterToSlave
Callable
;
import
java.io.File
;
import
java.io.FileDescriptor
;
...
...
@@ -36,8 +35,7 @@ public class StandardOutputSwapper extends ComputerListener {
}
}
@MasterToSlave
private
static
final
class
ChannelSwapper
implements
Callable
<
Boolean
,
Exception
>
{
private
static
final
class
ChannelSwapper
extends
MasterToSlaveCallable
<
Boolean
,
Exception
>
{
public
Boolean
call
()
throws
Exception
{
if
(
File
.
pathSeparatorChar
==
';'
)
return
false
;
// Windows
...
...
core/src/main/java/jenkins/util/VirtualFile.java
浏览文件 @
ffb5b650
...
...
@@ -39,6 +39,8 @@ import java.util.ArrayList;
import
java.util.List
;
import
javax.annotation.Nonnull
;
import
static
hudson
.
FilePath
.
MasterToSlaveFileCallable
;
/**
* Abstraction over {@link File}, {@link FilePath}, or other items such as network resources or ZIP entries.
* Assumed to be read-only and makes very limited assumptions, just enough to display content and traverse directories.
...
...
@@ -334,7 +336,7 @@ public abstract class VirtualFile implements Comparable<VirtualFile> {
}
};
}
private
static
final
class
Scanner
implements
FilePath
.
FileCallable
<
String
[]>
{
private
static
final
class
Scanner
extends
MasterToSlave
FileCallable
<
String
[]>
{
private
final
String
glob
;
Scanner
(
String
glob
)
{
this
.
glob
=
glob
;
...
...
@@ -351,7 +353,7 @@ public abstract class VirtualFile implements Comparable<VirtualFile> {
}
}
private
static
final
class
Readable
implements
FilePath
.
FileCallable
<
Boolean
>
{
private
static
final
class
Readable
extends
MasterToSlave
FileCallable
<
Boolean
>
{
@Override
public
Boolean
invoke
(
File
f
,
VirtualChannel
channel
)
throws
IOException
,
InterruptedException
{
return
f
.
canRead
();
}
...
...
core/src/test/java/hudson/LauncherTest.java
浏览文件 @
ffb5b650
...
...
@@ -31,6 +31,8 @@ import hudson.util.ProcessTree;
import
hudson.util.StreamTaskListener
;
import
hudson.remoting.Callable
;
import
java.io.ByteArrayOutputStream
;
import
jenkins.security.MasterToSlaveCallable
;
import
org.apache.commons.io.FileUtils
;
import
org.jvnet.hudson.test.Bug
;
...
...
@@ -74,7 +76,7 @@ public class LauncherTest extends ChannelTestCase {
}
}
private
static
final
Callable
<
Object
,
RuntimeException
>
NOOP
=
new
Callable
<
Object
,
RuntimeException
>()
{
private
static
final
Callable
<
Object
,
RuntimeException
>
NOOP
=
new
MasterToSlave
Callable
<
Object
,
RuntimeException
>()
{
public
Object
call
()
throws
RuntimeException
{
return
null
;
}
...
...
core/src/test/java/hudson/os/SUTester.java
浏览文件 @
ffb5b650
...
...
@@ -2,6 +2,7 @@ package hudson.os;
import
hudson.remoting.Callable
;
import
hudson.util.StreamTaskListener
;
import
jenkins.security.MasterToSlaveCallable
;
import
java.io.FileOutputStream
;
...
...
@@ -10,7 +11,7 @@ import java.io.FileOutputStream;
*/
public
class
SUTester
{
public
static
void
main
(
String
[]
args
)
throws
Throwable
{
SU
.
execute
(
StreamTaskListener
.
fromStdout
(),
"kohsuke"
,
"bogus"
,
new
Callable
<
Object
,
Throwable
>()
{
SU
.
execute
(
StreamTaskListener
.
fromStdout
(),
"kohsuke"
,
"bogus"
,
new
MasterToSlave
Callable
<
Object
,
Throwable
>()
{
public
Object
call
()
throws
Throwable
{
System
.
out
.
println
(
"Touching /tmp/x"
);
new
FileOutputStream
(
"/tmp/x"
).
close
();
...
...
core/src/test/java/hudson/util/ProcessTreeTest.java
浏览文件 @
ffb5b650
...
...
@@ -5,6 +5,7 @@ import hudson.remoting.Callable;
import
hudson.remoting.VirtualChannel
;
import
hudson.util.ProcessTree.OSProcess
;
import
hudson.util.ProcessTree.ProcessCallable
;
import
jenkins.security.MasterToSlaveCallable
;
import
java.io.IOException
;
import
java.io.Serializable
;
...
...
@@ -35,7 +36,7 @@ public class ProcessTreeTest extends ChannelTestCase {
t
.
p
.
act
(
new
ProcessCallableImpl
());
}
private
static
class
MyCallable
implements
Callable
<
Tag
,
IOException
>,
Serializable
{
private
static
class
MyCallable
extends
MasterToSlaveCallable
<
Tag
,
IOException
>
implements
Serializable
{
public
Tag
call
()
throws
IOException
{
Tag
t
=
new
Tag
();
t
.
tree
=
ProcessTree
.
get
();
...
...
test/src/test/java/hudson/ProcTest.java
浏览文件 @
ffb5b650
...
...
@@ -3,13 +3,12 @@ package hudson;
import
hudson.Launcher.LocalLauncher
;
import
hudson.Launcher.RemoteLauncher
;
import
hudson.Proc.RemoteProc
;
import
hudson.remoting.Callable
;
import
hudson.remoting.Future
;
import
hudson.remoting.Pipe
;
import
hudson.remoting.VirtualChannel
;
import
hudson.slaves.DumbSlave
;
import
hudson.util.IOUtils
;
import
hudson.util.StreamTaskListener
;
import
jenkins.security.MasterToSlaveCallable
;
import
org.jvnet.hudson.test.Bug
;
import
org.jvnet.hudson.test.HudsonTestCase
;
...
...
@@ -70,7 +69,7 @@ public class ProcTest extends HudsonTestCase {
return
ch
;
}
private
static
class
ChannelFiller
implements
Callable
<
Void
,
IOException
>
{
private
static
class
ChannelFiller
extends
MasterToSlave
Callable
<
Void
,
IOException
>
{
private
final
OutputStream
o
;
private
ChannelFiller
(
OutputStream
o
)
{
...
...
test/src/test/java/hudson/logging/LogRecorderManagerTest.java
浏览文件 @
ffb5b650
...
...
@@ -23,6 +23,7 @@
*/
package
hudson.logging
;
import
jenkins.security.MasterToSlaveCallable
;
import
org.jvnet.hudson.test.Url
;
import
com.gargoylesoftware.htmlunit.html.HtmlPage
;
import
com.gargoylesoftware.htmlunit.html.HtmlForm
;
...
...
@@ -109,7 +110,7 @@ public class LogRecorderManagerTest {
assertFalse
(
text
,
text
.
contains
(
"msg #4"
));
}
private
static
final
class
Log
implements
Callable
<
Boolean
,
Error
>
{
private
static
final
class
Log
extends
MasterToSlave
Callable
<
Boolean
,
Error
>
{
private
final
Level
level
;
private
final
String
logger
;
private
final
String
message
;
...
...
test/src/test/java/hudson/slaves/JNLPLauncherTest.java
浏览文件 @
ffb5b650
...
...
@@ -35,8 +35,7 @@ import hudson.remoting.Callable;
import
hudson.remoting.Which
;
import
hudson.util.ArgumentListBuilder
;
import
jenkins.security.MasterToSlave
;
import
jenkins.security.SlaveToMaster
;
import
jenkins.security.SlaveToMasterCallable
;
import
org.jvnet.hudson.test.HudsonTestCase
;
import
org.jvnet.hudson.test.TestExtension
;
...
...
@@ -156,8 +155,7 @@ public class JNLPLauncherTest extends HudsonTestCase {
return
c
;
}
@MasterToSlave
@SlaveToMaster
private
static
class
NoopTask
implements
Callable
<
String
,
RuntimeException
>
{
private
static
class
NoopTask
extends
SlaveToMasterCallable
<
String
,
RuntimeException
>
{
public
String
call
()
{
return
"done"
;
}
...
...
test/src/test/java/jenkins/security/DefaultFilePathFilterTest.java
浏览文件 @
ffb5b650
...
...
@@ -28,6 +28,9 @@ import hudson.FilePath;
import
hudson.model.Slave
;
import
hudson.remoting.Callable
;
import
java.io.File
;
import
java.util.Collection
;
import
org.jenkinsci.remoting.Role
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.*;
import
org.junit.Rule
;
...
...
@@ -51,7 +54,7 @@ public class DefaultFilePathFilterTest {
// good
}
assertFalse
(
reverse
.
exists
());
System
.
setProperty
(
DefaultFilePathFilter
.
BYPASS_PROP
,
"true"
)
;
DefaultFilePathFilter
.
BYPASS
=
true
;
s
.
getChannel
().
call
(
new
ReverseCallable
(
reverse
));
assertTrue
(
reverse
.
exists
());
assertEquals
(
"goodbye"
,
reverse
.
readToString
());
...
...
@@ -66,6 +69,10 @@ public class DefaultFilePathFilterTest {
assertFalse
(
p
.
isRemote
());
return
p
.
readToString
();
}
@Override
public
Collection
<
Role
>
getRecipients
()
{
return
null
;
// simulate legacy Callable impls
}
}
private
static
class
ReverseCallable
implements
Callable
<
Void
,
Exception
>
{
...
...
@@ -78,6 +85,9 @@ public class DefaultFilePathFilterTest {
p
.
write
(
"goodbye"
,
null
);
return
null
;
}
@Override
public
Collection
<
Role
>
getRecipients
()
{
return
null
;
// simulate legacy Callable impls
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录