提交 a4440f9b 编写于 作者: K Kohsuke Kawaguchi

[JENKINS-11097]

Added more diagnositics about how ping terminated a connection.
上级 f4aec235
......@@ -76,6 +76,9 @@ Upcoming changes</a>
<li class=bug>
Label of the master should be editable if cloud is set up.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-11100">issue 11100</a>)
<li class=rfe>
Improved the error diagnosis by ping-driven connection termination.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-11097">issue 11097</a>)
<li class=rfe>
YUI updated to 2.9
<li class=rfe>
......
......@@ -36,6 +36,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
......@@ -88,8 +89,8 @@ abstract public class FullDuplexHttpChannel {
// so that we can detect dead clients, periodically send something
PingThread ping = new PingThread(channel) {
@Override
protected void onDead() {
LOGGER.info("Duplex-HTTP session " + uuid + " is terminated");
protected void onDead(Throwable diagnosis) {
LOGGER.log(Level.INFO,"Duplex-HTTP session " + uuid + " is terminated",diagnosis);
// this will cause the channel to abort and subsequently clean up
try {
upload.close();
......@@ -98,6 +99,11 @@ abstract public class FullDuplexHttpChannel {
throw new AssertionError(e);
}
}
@Override
protected void onDead() {
onDead(null);
}
};
ping.start();
main(channel);
......
......@@ -37,7 +37,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import java.util.logging.Logger;
import static java.util.logging.Level.SEVERE;
import static java.util.logging.Level.*;
/**
* Establish a periodic ping to keep connections between {@link Slave slaves}
......@@ -102,19 +102,21 @@ public class ChannelPinger extends ComputerListener {
private static void setUpPingForChannel(final Channel channel, int interval) {
final AtomicBoolean isInClosed = new AtomicBoolean(false);
final PingThread t = new PingThread(channel, interval * 60 * 1000) {
protected void onDead() {
protected void onDead(Throwable cause) {
try {
if (isInClosed.get()) {
LOGGER.fine("Ping failed after the channel is already partially closed");
}
else {
LOGGER.info("Ping failed. Terminating the channel.");
channel.close();
LOGGER.log(FINE,"Ping failed after the channel is already partially closed",cause);
} else {
LOGGER.log(INFO,"Ping failed. Terminating the channel.",cause);
channel.close(cause);
}
} catch (IOException e) {
LOGGER.log(SEVERE,"Failed to terminate the channel: ",e);
}
}
protected void onDead() {
onDead(null);
}
};
channel.addListener(new Channel.Listener() {
......
......@@ -143,7 +143,7 @@ THE SOFTWARE.
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>remoting</artifactId>
<version>2.7</version>
<version>2.9</version>
</dependency>
</dependencies>
</dependencyManagement>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册