Skip to content

Commit

Permalink
Merge pull request #93 from jenkinsci/jenkins-37031
Browse files Browse the repository at this point in the history
[FIXED JENKINS-37031] tcpSlaveAgentListener should publish supported agent protocols to speed up connection setup
  • Loading branch information
stephenc committed Aug 6, 2016
2 parents 53c8860 + d54c886 commit 802fb13
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main/java/hudson/remoting/Engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import javax.annotation.CheckForNull;
import javax.annotation.concurrent.NotThreadSafe;
Expand Down Expand Up @@ -214,6 +216,7 @@ public void run() {
Throwable firstError=null;
String host=null;
String port=null;
Set<String> agentProtocolNames = null;
SSLSocketFactory sslSocketFactory = getSSLSocketFactory();

for (URL url : candidateUrls) {
Expand Down Expand Up @@ -247,6 +250,16 @@ public void run() {
}
host = con.getHeaderField("X-Jenkins-JNLP-Host"); // controlled by hudson.TcpSlaveAgentListener.hostName
if (host == null) host=url.getHost();
String names = con.getHeaderField("X-Jenkins-Agent-Protocols");
if (names != null) {
agentProtocolNames = new HashSet<String>();
for (String name: names.split(",")) {
name = name.trim();
if (!name.isEmpty()) {
agentProtocolNames.add(name);
}
}
}
} finally {
con.disconnect();
}
Expand Down Expand Up @@ -277,6 +290,10 @@ public void run() {
events.status("Protocol " + protocol.getName() + " is not enabled, skipping");
continue;
}
if (agentProtocolNames != null && !agentProtocolNames.contains(protocol.getName())) {
events.status("Server reports protocol " + protocol.getName() + " not supported, skipping");
continue;
}
triedAtLeastOneProtocol = true;
events.status("Trying protocol: " + protocol.getName());
try {
Expand Down

0 comments on commit 802fb13

Please sign in to comment.