Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
e321cbb4
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,发现更多精彩内容 >>
提交
e321cbb4
编写于
4月 11, 2014
作者:
J
Jesse Glick
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into BuildTrigger-auth-JENKINS-16956
上级
840bb669
a1cd49b9
变更
22
隐藏空白更改
内联
并排
Showing
22 changed file
with
191 addition
and
84 deletion
+191
-84
changelog.html
changelog.html
+8
-1
cli/src/main/java/hudson/cli/CLI.java
cli/src/main/java/hudson/cli/CLI.java
+3
-3
cli/src/main/java/hudson/cli/Connection.java
cli/src/main/java/hudson/cli/Connection.java
+2
-3
core/src/main/java/hudson/Launcher.java
core/src/main/java/hudson/Launcher.java
+1
-1
core/src/main/java/hudson/TcpSlaveAgentListener.java
core/src/main/java/hudson/TcpSlaveAgentListener.java
+7
-4
core/src/main/java/hudson/cli/CliProtocol.java
core/src/main/java/hudson/cli/CliProtocol.java
+33
-4
core/src/main/java/hudson/cli/CliProtocol2.java
core/src/main/java/hudson/cli/CliProtocol2.java
+10
-1
core/src/main/java/hudson/model/AbstractBuild.java
core/src/main/java/hudson/model/AbstractBuild.java
+6
-10
core/src/main/java/hudson/model/ItemGroupMixIn.java
core/src/main/java/hudson/model/ItemGroupMixIn.java
+1
-0
core/src/main/java/hudson/model/ReconfigurableDescribable.java
...src/main/java/hudson/model/ReconfigurableDescribable.java
+3
-1
core/src/main/java/hudson/model/Run.java
core/src/main/java/hudson/model/Run.java
+8
-5
core/src/main/java/hudson/model/ViewDescriptor.java
core/src/main/java/hudson/model/ViewDescriptor.java
+3
-27
core/src/main/java/hudson/model/listeners/RunListener.java
core/src/main/java/hudson/model/listeners/RunListener.java
+1
-1
core/src/main/java/hudson/slaves/Channels.java
core/src/main/java/hudson/slaves/Channels.java
+5
-6
core/src/main/java/jenkins/model/ParameterizedJobMixIn.java
core/src/main/java/jenkins/model/ParameterizedJobMixIn.java
+2
-2
core/src/main/java/jenkins/model/lazy/LazyBuildMixIn.java
core/src/main/java/jenkins/model/lazy/LazyBuildMixIn.java
+1
-1
core/src/main/java/jenkins/slaves/JnlpSlaveAgentProtocol.java
.../src/main/java/jenkins/slaves/JnlpSlaveAgentProtocol.java
+26
-6
core/src/main/java/jenkins/slaves/JnlpSlaveAgentProtocol2.java
...src/main/java/jenkins/slaves/JnlpSlaveAgentProtocol2.java
+10
-1
core/src/main/java/jenkins/slaves/NioChannelSelector.java
core/src/main/java/jenkins/slaves/NioChannelSelector.java
+43
-0
pom.xml
pom.xml
+1
-1
war/src/main/webapp/WEB-INF/web.xml
war/src/main/webapp/WEB-INF/web.xml
+8
-0
war/src/main/webapp/scripts/hudson-behavior.js
war/src/main/webapp/scripts/hudson-behavior.js
+9
-6
未找到文件。
changelog.html
浏览文件 @
e321cbb4
...
...
@@ -55,7 +55,14 @@ 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=
bug
>
Fixed NPE from view new job name autocompletion since 1.553.
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-22142"
>
issue 22142
</a>
)
<li
class=
'major bug'
>
Deadlocks in concurrent builds under some conditions since 1.556.
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-22560"
>
issue 22560
</a>
)
<li
class=
rfe
>
JNLP slaves are now handled through NIO-based remoting channels for better scalability.
</ul>
</div>
<!--=TRUNK-END=-->
...
...
cli/src/main/java/hudson/cli/CLI.java
浏览文件 @
e321cbb4
...
...
@@ -29,7 +29,7 @@ import hudson.remoting.PingThread;
import
hudson.remoting.Pipe
;
import
hudson.remoting.RemoteInputStream
;
import
hudson.remoting.RemoteOutputStream
;
import
hudson.remoting.Socket
Input
Stream
;
import
hudson.remoting.Socket
Channel
Stream
;
import
hudson.remoting.SocketOutputStream
;
import
javax.crypto.SecretKey
;
...
...
@@ -201,7 +201,7 @@ public class CLI {
}
else
{
s
=
new
Socket
();
s
.
connect
(
clip
.
endpoint
,
3000
);
out
=
new
SocketOutputStream
(
s
);
out
=
SocketChannelStream
.
out
(
s
);
}
closables
.
add
(
new
Closeable
()
{
...
...
@@ -210,7 +210,7 @@ public class CLI {
}
});
Connection
c
=
new
Connection
(
new
SocketInputStream
(
s
),
out
);
Connection
c
=
new
Connection
(
SocketChannelStream
.
in
(
s
),
out
);
switch
(
clip
.
version
)
{
case
1
:
...
...
cli/src/main/java/hudson/cli/Connection.java
浏览文件 @
e321cbb4
...
...
@@ -23,8 +23,7 @@
*/
package
hudson.cli
;
import
hudson.remoting.SocketInputStream
;
import
hudson.remoting.SocketOutputStream
;
import
hudson.remoting.SocketChannelStream
;
import
org.apache.commons.codec.binary.Base64
;
import
javax.crypto.Cipher
;
...
...
@@ -63,7 +62,7 @@ public class Connection {
public
final
DataOutputStream
dout
;
public
Connection
(
Socket
socket
)
throws
IOException
{
this
(
new
SocketInputStream
(
socket
),
new
SocketOutputStream
(
socket
));
this
(
SocketChannelStream
.
in
(
socket
),
SocketChannelStream
.
out
(
socket
));
}
public
Connection
(
InputStream
in
,
OutputStream
out
)
{
...
...
core/src/main/java/hudson/Launcher.java
浏览文件 @
e321cbb4
...
...
@@ -818,7 +818,7 @@ public abstract class Launcher {
* Kill the process when the channel is severed.
*/
@Override
p
rotected
synchronized
void
terminate
(
IOException
e
)
{
p
ublic
synchronized
void
terminate
(
IOException
e
)
{
super
.
terminate
(
e
);
ProcessTree
pt
=
ProcessTree
.
get
();
try
{
...
...
core/src/main/java/hudson/TcpSlaveAgentListener.java
浏览文件 @
e321cbb4
...
...
@@ -32,8 +32,10 @@ import java.io.IOException;
import
java.io.OutputStreamWriter
;
import
java.io.PrintWriter
;
import
java.net.BindException
;
import
java.net.InetSocketAddress
;
import
java.net.ServerSocket
;
import
java.net.Socket
;
import
java.nio.channels.ServerSocketChannel
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
...
...
@@ -55,7 +57,7 @@ import java.util.logging.Logger;
*/
public
final
class
TcpSlaveAgentListener
extends
Thread
{
private
final
ServerSocket
serverSocket
;
private
final
ServerSocket
Channel
serverSocket
;
private
volatile
boolean
shuttingDown
;
public
final
int
configuredPort
;
...
...
@@ -67,7 +69,8 @@ public final class TcpSlaveAgentListener extends Thread {
public
TcpSlaveAgentListener
(
int
port
)
throws
IOException
{
super
(
"TCP slave agent listener port="
+
port
);
try
{
serverSocket
=
new
ServerSocket
(
port
);
serverSocket
=
ServerSocketChannel
.
open
();
serverSocket
.
socket
().
bind
(
new
InetSocketAddress
(
port
));
}
catch
(
BindException
e
)
{
throw
(
BindException
)
new
BindException
(
"Failed to listen on port "
+
port
+
" because it's already in use."
).
initCause
(
e
);
}
...
...
@@ -82,7 +85,7 @@ public final class TcpSlaveAgentListener extends Thread {
* Gets the TCP port number in which we are listening.
*/
public
int
getPort
()
{
return
serverSocket
.
getLocalPort
();
return
serverSocket
.
socket
().
getLocalPort
();
}
@Override
...
...
@@ -90,7 +93,7 @@ public final class TcpSlaveAgentListener extends Thread {
try
{
// the loop eventually terminates when the socket is closed.
while
(
true
)
{
Socket
s
=
serverSocket
.
accept
();
Socket
s
=
serverSocket
.
accept
()
.
socket
()
;
// this prevents a connection from silently terminated by the router in between or the other peer
// and that goes without unnoticed. However, the time out is often very long (for example 2 hours
...
...
core/src/main/java/hudson/cli/CliProtocol.java
浏览文件 @
e321cbb4
...
...
@@ -4,9 +4,13 @@ import hudson.Extension;
import
hudson.model.Computer
;
import
hudson.remoting.Channel
;
import
hudson.remoting.Channel.Mode
;
import
hudson.remoting.ChannelBuilder
;
import
jenkins.AgentProtocol
;
import
jenkins.model.Jenkins
;
import
jenkins.slaves.NioChannelSelector
;
import
org.jenkinsci.remoting.nio.NioChannelHub
;
import
javax.inject.Inject
;
import
java.io.BufferedInputStream
;
import
java.io.BufferedOutputStream
;
import
java.io.BufferedWriter
;
...
...
@@ -23,6 +27,9 @@ import java.net.Socket;
*/
@Extension
public
class
CliProtocol
extends
AgentProtocol
{
@Inject
NioChannelSelector
nio
;
@Override
public
String
getName
()
{
return
"CLI-connect"
;
...
...
@@ -30,13 +37,23 @@ public class CliProtocol extends AgentProtocol {
@Override
public
void
handle
(
Socket
socket
)
throws
IOException
,
InterruptedException
{
new
Handler
(
socket
).
run
();
new
Handler
(
nio
.
getHub
(),
socket
).
run
();
}
protected
static
class
Handler
{
protected
final
NioChannelHub
hub
;
protected
final
Socket
socket
;
/**
* @deprecated as of 1.559
* Use {@link #Handler(NioChannelHub, Socket)}
*/
public
Handler
(
Socket
socket
)
{
this
(
null
,
socket
);
}
public
Handler
(
NioChannelHub
hub
,
Socket
socket
)
{
this
.
hub
=
hub
;
this
.
socket
=
socket
;
}
...
...
@@ -47,9 +64,21 @@ public class CliProtocol extends AgentProtocol {
}
protected
void
runCli
(
Connection
c
)
throws
IOException
,
InterruptedException
{
Channel
channel
=
new
Channel
(
"CLI channel from "
+
socket
.
getInetAddress
(),
Computer
.
threadPoolForRemoting
,
Mode
.
BINARY
,
new
BufferedInputStream
(
c
.
in
),
new
BufferedOutputStream
(
c
.
out
),
null
,
true
,
Jenkins
.
getInstance
().
pluginManager
.
uberClassLoader
);
ChannelBuilder
cb
;
String
name
=
"CLI channel from "
+
socket
.
getInetAddress
();
// Connection can contain cipher wrapper, which can't be NIO-ed.
// if (hub!=null)
// cb = hub.newChannelBuilder(name, Computer.threadPoolForRemoting);
// else
cb
=
new
ChannelBuilder
(
name
,
Computer
.
threadPoolForRemoting
);
Channel
channel
=
cb
.
withMode
(
Mode
.
BINARY
)
.
withRestricted
(
true
)
.
withBaseLoader
(
Jenkins
.
getInstance
().
pluginManager
.
uberClassLoader
)
.
build
(
new
BufferedInputStream
(
c
.
in
),
new
BufferedOutputStream
(
c
.
out
));
channel
.
setProperty
(
CliEntryPoint
.
class
.
getName
(),
new
CliManagerImpl
(
channel
));
channel
.
join
();
}
...
...
core/src/main/java/hudson/cli/CliProtocol2.java
浏览文件 @
e321cbb4
...
...
@@ -2,6 +2,7 @@ package hudson.cli;
import
hudson.Extension
;
import
jenkins.model.Jenkins
;
import
org.jenkinsci.remoting.nio.NioChannelHub
;
import
javax.crypto.SecretKey
;
import
javax.crypto.spec.SecretKeySpec
;
...
...
@@ -28,14 +29,22 @@ public class CliProtocol2 extends CliProtocol {
@Override
public
void
handle
(
Socket
socket
)
throws
IOException
,
InterruptedException
{
new
Handler2
(
socket
).
run
();
new
Handler2
(
nio
.
getHub
(),
socket
).
run
();
}
protected
static
class
Handler2
extends
Handler
{
/**
* @deprecated as of 1.559
* Use {@link #Handler2(NioChannelHub, Socket)}
*/
public
Handler2
(
Socket
socket
)
{
super
(
socket
);
}
public
Handler2
(
NioChannelHub
hub
,
Socket
socket
)
{
super
(
hub
,
socket
);
}
@Override
public
void
run
()
throws
IOException
,
InterruptedException
{
try
{
...
...
core/src/main/java/hudson/model/AbstractBuild.java
浏览文件 @
e321cbb4
...
...
@@ -71,7 +71,6 @@ import java.io.IOException;
import
java.io.InterruptedIOException
;
import
java.io.StringWriter
;
import
java.lang.ref.WeakReference
;
import
java.text.MessageFormat
;
import
java.util.AbstractSet
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
...
...
@@ -156,7 +155,11 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
*/
protected
transient
List
<
Environment
>
buildEnvironments
;
private
transient
LazyBuildMixIn
.
RunMixIn
<
P
,
R
>
runMixIn
;
private
transient
final
LazyBuildMixIn
.
RunMixIn
<
P
,
R
>
runMixIn
=
new
LazyBuildMixIn
.
RunMixIn
<
P
,
R
>()
{
@Override
protected
R
asRun
()
{
return
_this
();
}
};
protected
AbstractBuild
(
P
job
)
throws
IOException
{
super
(
job
);
...
...
@@ -174,14 +177,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
return
getParent
();
}
@Override
public
final
synchronized
LazyBuildMixIn
.
RunMixIn
<
P
,
R
>
getRunMixIn
()
{
if
(
runMixIn
==
null
)
{
runMixIn
=
new
LazyBuildMixIn
.
RunMixIn
<
P
,
R
>()
{
@Override
protected
R
asRun
()
{
return
_this
();
}
};
}
@Override
public
final
LazyBuildMixIn
.
RunMixIn
<
P
,
R
>
getRunMixIn
()
{
return
runMixIn
;
}
...
...
core/src/main/java/hudson/model/ItemGroupMixIn.java
浏览文件 @
e321cbb4
...
...
@@ -108,6 +108,7 @@ public abstract class ItemGroupMixIn {
item
=
(
V
)
Items
.
load
(
parent
,
subdir
);
}
else
{
Logger
.
getLogger
(
ItemGroupMixIn
.
class
.
getName
()
).
log
(
Level
.
WARNING
,
"could not find file "
+
xmlFile
.
getFile
());
continue
;
}
}
else
{
item
.
onLoad
(
parent
,
subdir
.
getName
());
...
...
core/src/main/java/hudson/model/ReconfigurableDescribable.java
浏览文件 @
e321cbb4
...
...
@@ -25,6 +25,8 @@ package hudson.model;
import
hudson.model.Descriptor.FormException
;
import
hudson.slaves.NodeProperty
;
import
javax.annotation.CheckForNull
;
import
javax.annotation.Nonnull
;
import
net.sf.json.JSONObject
;
import
org.kohsuke.stapler.StaplerRequest
;
...
...
@@ -77,5 +79,5 @@ public interface ReconfigurableDescribable<T extends ReconfigurableDescribable<T
* @return
* The new instance. To not to create an instance of a describable, return null.
*/
T
reconfigure
(
StaplerRequest
req
,
JSONObject
form
)
throws
FormException
;
@CheckForNull
T
reconfigure
(
@Nonnull
StaplerRequest
req
,
@CheckForNull
JSONObject
form
)
throws
FormException
;
}
core/src/main/java/hudson/model/Run.java
浏览文件 @
e321cbb4
...
...
@@ -1445,17 +1445,19 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
* @throws IOException
* if we fail to delete.
*/
public
synchronized
void
delete
()
throws
IOException
{
public
void
delete
()
throws
IOException
{
File
rootDir
=
getRootDir
();
if
(!
rootDir
.
isDirectory
())
{
throw
new
IOException
(
this
+
": "
+
rootDir
+
" looks to have already been deleted"
);
}
RunListener
.
fireDeleted
(
this
);
synchronized
(
this
)
{
// avoid holding a lock while calling plugin impls of onDeleted
// if we have a symlink, delete it, too
File
link
=
new
File
(
project
.
getBuildDir
(),
String
.
valueOf
(
getNumber
()));
link
.
delete
();
File
rootDir
=
getRootDir
();
if
(!
rootDir
.
isDirectory
())
{
throw
new
IOException
(
this
+
": "
+
rootDir
+
" looks to have already been deleted"
);
}
File
tmp
=
new
File
(
rootDir
.
getParentFile
(),
'.'
+
rootDir
.
getName
());
if
(
tmp
.
exists
())
{
...
...
@@ -1474,6 +1476,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
LOGGER
.
log
(
FINE
,
"{0}: {1} successfully deleted"
,
new
Object
[]
{
this
,
rootDir
});
removeRunFromParent
();
}
}
@SuppressWarnings
(
"unchecked"
)
// seems this is too clever for Java's type system?
...
...
core/src/main/java/hudson/model/ViewDescriptor.java
浏览文件 @
e321cbb4
...
...
@@ -26,7 +26,8 @@ package hudson.model;
import
hudson.views.ListViewColumn
;
import
hudson.views.ListViewColumnDescriptor
;
import
hudson.views.ViewJobFilter
;
import
jenkins.model.Jenkins
;
import
org.kohsuke.accmod.Restricted
;
import
org.kohsuke.accmod.restrictions.DoNotUse
;
import
org.kohsuke.stapler.QueryParameter
;
import
org.kohsuke.stapler.AncestorInPath
;
...
...
@@ -68,35 +69,10 @@ public abstract class ViewDescriptor extends Descriptor<View> {
protected
ViewDescriptor
()
{
}
@Deprecated
public
AutoCompletionCandidates
doAutoCompleteCopyNewItemFrom
(
final
String
prefix
)
{
final
AutoCompletionCandidates
r
=
new
AutoCompletionCandidates
();
new
ItemVisitor
()
{
@Override
public
void
onItemGroup
(
ItemGroup
<?>
group
)
{
// only dig deep when the path matches what's typed.
// for example, if 'foo/bar' is typed, we want to show 'foo/barcode'
if
(
prefix
.
startsWith
(
group
.
getFullName
()))
super
.
onItemGroup
(
group
);
}
@Override
public
void
onItem
(
Item
i
)
{
if
(
i
.
getFullName
().
startsWith
(
prefix
))
{
r
.
add
((
i
.
getFullName
()));
super
.
onItem
(
i
);
}
}
}.
onItemGroup
(
Jenkins
.
getInstance
());
return
r
;
}
/**
* Auto-completion for the "copy from" field in the new job page.
* @since 1.553
*/
@Restricted
(
DoNotUse
.
class
)
public
AutoCompletionCandidates
doAutoCompleteCopyNewItemFrom
(
@QueryParameter
final
String
value
,
@AncestorInPath
ItemGroup
container
)
{
return
AutoCompletionCandidates
.
ofJobNames
(
TopLevelItem
.
class
,
value
,
container
);
}
...
...
core/src/main/java/hudson/model/listeners/RunListener.java
浏览文件 @
e321cbb4
...
...
@@ -235,7 +235,7 @@ public abstract class RunListener<R extends Run> implements ExtensionPoint {
}
/**
* Fires the {@link #on
Finalized(Run)
} event.
* Fires the {@link #on
Deleted
} event.
*/
public
static
void
fireDeleted
(
Run
r
)
{
for
(
RunListener
l
:
all
())
{
...
...
core/src/main/java/hudson/slaves/Channels.java
浏览文件 @
e321cbb4
...
...
@@ -30,8 +30,7 @@ import hudson.model.Computer;
import
hudson.model.TaskListener
;
import
hudson.remoting.Channel
;
import
hudson.remoting.Launcher
;
import
hudson.remoting.SocketInputStream
;
import
hudson.remoting.SocketOutputStream
;
import
hudson.remoting.SocketChannelStream
;
import
hudson.util.ClasspathBuilder
;
import
hudson.util.JVMBuilder
;
import
hudson.util.StreamCopyThread
;
...
...
@@ -73,7 +72,7 @@ public class Channels {
* Kill the process when the channel is severed.
*/
@Override
p
rotected
synchronized
void
terminate
(
IOException
e
)
{
p
ublic
synchronized
void
terminate
(
IOException
e
)
{
super
.
terminate
(
e
);
try
{
proc
.
kill
();
...
...
@@ -109,7 +108,7 @@ public class Channels {
* Kill the process when the channel is severed.
*/
@Override
p
rotected
synchronized
void
terminate
(
IOException
e
)
{
p
ublic
synchronized
void
terminate
(
IOException
e
)
{
super
.
terminate
(
e
);
proc
.
destroy
();
// the stderr copier should exit by itself
...
...
@@ -205,8 +204,8 @@ public class Channels {
serverSocket
.
close
();
return
forProcess
(
"Channel to "
+
displayName
,
Computer
.
threadPoolForRemoting
,
new
BufferedInputStream
(
new
SocketInputStream
(
s
)),
new
BufferedOutputStream
(
new
SocketOutputStream
(
s
)),
null
,
p
);
new
BufferedInputStream
(
SocketChannelStream
.
in
(
s
)),
new
BufferedOutputStream
(
SocketChannelStream
.
out
(
s
)),
null
,
p
);
}
...
...
core/src/main/java/jenkins/model/ParameterizedJobMixIn.java
浏览文件 @
e321cbb4
...
...
@@ -75,12 +75,12 @@ public abstract class ParameterizedJobMixIn<JobT extends Job<JobT, RunT> & Param
/** @see BuildableItem#scheduleBuild() */
@SuppressWarnings
(
"deprecation"
)
public
final
boolean
scheduleBuild
()
{
return
scheduleBuild
(
Jenkins
.
getInstance
().
getQuietPeriod
(),
new
Cause
.
LegacyCodeCause
());
return
scheduleBuild
(
asJob
().
getQuietPeriod
(),
new
Cause
.
LegacyCodeCause
());
}
/** @see BuildableItem#scheduleBuild(Cause) */
public
final
boolean
scheduleBuild
(
Cause
c
)
{
return
scheduleBuild
(
Jenkins
.
getInstance
().
getQuietPeriod
(),
c
);
return
scheduleBuild
(
asJob
().
getQuietPeriod
(),
c
);
}
/** @see BuildableItem#scheduleBuild(int) */
...
...
core/src/main/java/jenkins/model/lazy/LazyBuildMixIn.java
浏览文件 @
e321cbb4
...
...
@@ -280,7 +280,7 @@ public abstract class LazyBuildMixIn<JobT extends Job<JobT,RunT> & Queue.Task &
/**
* Accompanying helper for the run type.
* Stateful but should be held in a {@code transient} field.
* Stateful but should be held in a {@code transient
final
} field.
*/
public
static
abstract
class
RunMixIn
<
JobT
extends
Job
<
JobT
,
RunT
>
&
Queue
.
Task
&
LazyBuildMixIn
.
LazyLoadingJob
<
JobT
,
RunT
>,
RunT
extends
Run
<
JobT
,
RunT
>
&
LazyLoadingRun
<
JobT
,
RunT
>>
{
...
...
core/src/main/java/jenkins/slaves/JnlpSlaveAgentProtocol.java
浏览文件 @
e321cbb4
...
...
@@ -2,18 +2,18 @@ package jenkins.slaves;
import
hudson.AbortException
;
import
hudson.Extension
;
import
hudson.model.Computer
;
import
hudson.remoting.Channel
;
import
hudson.remoting.Channel.Listener
;
import
hudson.remoting.ChannelBuilder
;
import
hudson.remoting.Engine
;
import
hudson.remoting.SocketInputStream
;
import
hudson.remoting.SocketOutputStream
;
import
hudson.slaves.SlaveComputer
;
import
jenkins.AgentProtocol
;
import
jenkins.model.Jenkins
;
import
jenkins.security.HMACConfidentialKey
;
import
org.jenkinsci.remoting.nio.NioChannelHub
;
import
java.io.BufferedInputStream
;
import
java.io.BufferedOutputStream
;
import
javax.inject.Inject
;
import
java.io.BufferedWriter
;
import
java.io.DataInputStream
;
import
java.io.DataOutputStream
;
...
...
@@ -55,6 +55,9 @@ import java.util.logging.Logger;
*/
@Extension
public
class
JnlpSlaveAgentProtocol
extends
AgentProtocol
{
@Inject
NioChannelSelector
hub
;
@Override
public
String
getName
()
{
return
"JNLP-connect"
;
...
...
@@ -62,10 +65,11 @@ public class JnlpSlaveAgentProtocol extends AgentProtocol {
@Override
public
void
handle
(
Socket
socket
)
throws
IOException
,
InterruptedException
{
new
Handler
(
socket
).
run
();
new
Handler
(
hub
.
getHub
(),
socket
).
run
();
}
protected
static
class
Handler
{
protected
final
NioChannelHub
hub
;
protected
final
Socket
socket
;
/**
...
...
@@ -82,7 +86,16 @@ public class JnlpSlaveAgentProtocol extends AgentProtocol {
*/
protected
final
PrintWriter
out
;
/**
* @deprecated as of 1.559
* Use {@link #Handler(NioChannelHub, Socket)}
*/
public
Handler
(
Socket
socket
)
throws
IOException
{
this
(
null
,
socket
);
}
public
Handler
(
NioChannelHub
hub
,
Socket
socket
)
throws
IOException
{
this
.
hub
=
hub
;
this
.
socket
=
socket
;
in
=
new
DataInputStream
(
socket
.
getInputStream
());
out
=
new
PrintWriter
(
new
BufferedWriter
(
new
OutputStreamWriter
(
socket
.
getOutputStream
(),
"UTF-8"
)),
true
);
...
...
@@ -121,7 +134,14 @@ public class JnlpSlaveAgentProtocol extends AgentProtocol {
logw
.
println
(
"JNLP agent connected from "
+
socket
.
getInetAddress
());
try
{
computer
.
setChannel
(
new
BufferedInputStream
(
new
SocketInputStream
(
socket
)),
new
BufferedOutputStream
(
new
SocketOutputStream
(
socket
)),
log
,
ChannelBuilder
cb
;
if
(
hub
==
null
)
cb
=
new
ChannelBuilder
(
nodeName
,
Computer
.
threadPoolForRemoting
);
else
cb
=
hub
.
newChannelBuilder
(
nodeName
,
Computer
.
threadPoolForRemoting
);
computer
.
setChannel
(
cb
.
withHeaderStream
(
log
).
build
(
socket
),
log
,
new
Listener
()
{
@Override
public
void
onClosed
(
Channel
channel
,
IOException
cause
)
{
...
...
core/src/main/java/jenkins/slaves/JnlpSlaveAgentProtocol2.java
浏览文件 @
e321cbb4
...
...
@@ -7,6 +7,7 @@ import hudson.remoting.Channel;
import
hudson.remoting.Engine
;
import
hudson.slaves.SlaveComputer
;
import
jenkins.model.Jenkins
;
import
org.jenkinsci.remoting.nio.NioChannelHub
;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
...
...
@@ -40,14 +41,22 @@ public class JnlpSlaveAgentProtocol2 extends JnlpSlaveAgentProtocol {
@Override
public
void
handle
(
Socket
socket
)
throws
IOException
,
InterruptedException
{
new
Handler2
(
socket
).
run
();
new
Handler2
(
hub
.
getHub
(),
socket
).
run
();
}
protected
static
class
Handler2
extends
Handler
{
/**
* @deprecated as of 1.559
* Use {@link #Handler2(NioChannelHub, Socket)}
*/
public
Handler2
(
Socket
socket
)
throws
IOException
{
super
(
socket
);
}
public
Handler2
(
NioChannelHub
hub
,
Socket
socket
)
throws
IOException
{
super
(
hub
,
socket
);
}
/**
* Handles JNLP slave agent connection request (v2 protocol)
*/
...
...
core/src/main/java/jenkins/slaves/NioChannelSelector.java
0 → 100644
浏览文件 @
e321cbb4
package
jenkins.slaves
;
import
hudson.Extension
;
import
hudson.model.Computer
;
import
org.jenkinsci.remoting.nio.NioChannelHub
;
import
java.io.IOException
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
/**
* Singleton holder of {@link NioChannelHub}
*
* @author Kohsuke Kawaguchi
*/
@Extension
public
class
NioChannelSelector
{
private
NioChannelHub
hub
;
public
NioChannelSelector
()
{
try
{
if
(!
DISABLED
)
{
this
.
hub
=
new
NioChannelHub
(
Computer
.
threadPoolForRemoting
);
Computer
.
threadPoolForRemoting
.
submit
(
hub
);
}
}
catch
(
IOException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"Failed to launch NIO hub"
,
e
);
this
.
hub
=
null
;
DISABLED
=
true
;
}
}
public
NioChannelHub
getHub
()
{
return
hub
;
}
/**
* Escape hatch to disable use of NIO.
*/
public
static
boolean
DISABLED
=
Boolean
.
getBoolean
(
NioChannelSelector
.
class
.
getName
()+
".disabled"
);
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
NioChannelSelector
.
class
.
getName
());
}
pom.xml
浏览文件 @
e321cbb4
...
...
@@ -172,7 +172,7 @@ THE SOFTWARE.
<dependency>
<groupId>
org.jenkins-ci.main
</groupId>
<artifactId>
remoting
</artifactId>
<version>
2.3
7
</version>
<version>
2.3
9
</version>
</dependency>
<dependency>
...
...
war/src/main/webapp/WEB-INF/web.xml
浏览文件 @
e321cbb4
...
...
@@ -160,6 +160,14 @@ THE SOFTWARE.
<role-name>
*
</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>
other
</web-resource-name>
<url-pattern>
/*
</url-pattern>
</web-resource-collection>
<!-- no security constraint -->
</security-constraint>
<login-config>
<auth-method>
FORM
</auth-method>
...
...
war/src/main/webapp/scripts/hudson-behavior.js
浏览文件 @
e321cbb4
...
...
@@ -1814,6 +1814,7 @@ function buildFormTree(form) {
}
var
p
;
var
r
;
var
type
=
e
.
getAttribute
(
"
type
"
);
if
(
type
==
null
)
type
=
""
;
switch
(
type
.
toLowerCase
())
{
...
...
@@ -1861,15 +1862,17 @@ function buildFormTree(form) {
break
;
case
"
radio
"
:
if
(
!
e
.
checked
)
break
;
while
(
e
.
name
.
substring
(
0
,
8
)
==
'
removeme
'
)
e
.
name
=
e
.
name
.
substring
(
e
.
name
.
indexOf
(
'
_
'
,
8
)
+
1
);
r
=
0
;
while
(
e
.
name
.
substring
(
r
,
r
+
8
)
==
'
removeme
'
)
r
=
e
.
name
.
indexOf
(
'
_
'
,
r
+
8
)
+
1
;
p
=
findParent
(
e
);
if
(
e
.
groupingNode
)
{
p
=
findParent
(
e
);
addProperty
(
p
,
e
.
name
,
e
.
formDom
=
{
value
:
e
.
value
});
break
;
addProperty
(
p
,
e
.
name
.
substring
(
r
),
e
.
formDom
=
{
value
:
e
.
value
}
);
}
else
{
addProperty
(
p
,
e
.
name
.
substring
(
r
),
e
.
value
)
;
}
break
;
// otherwise fall through
default
:
p
=
findParent
(
e
);
addProperty
(
p
,
e
.
name
,
e
.
value
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录