Skip to content

Commit

Permalink
[JENKINS-35190] Added some logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed May 27, 2016
1 parent c0cf331 commit 1fc3c93
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/hudson/remoting/PingThread.java
Expand Up @@ -32,6 +32,7 @@
import java.util.logging.Logger;

import static java.util.concurrent.TimeUnit.MILLISECONDS;
import java.util.logging.Level;

/**
* Periodically perform a ping.
Expand Down Expand Up @@ -101,15 +102,18 @@ public void run() {
}

private void ping() throws IOException, InterruptedException {
LOGGER.log(Level.FINE, "pinging {0}", channel.getName());
Future<?> f = channel.callAsync(new Ping());
long start = System.currentTimeMillis();

long end = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(timeout);
long remaining = end - System.nanoTime();

do {
LOGGER.log(Level.FINE, "waiting {0}s on {1}", new Object[] {TimeUnit.NANOSECONDS.toSeconds(remaining), channel.getName()});
try {
f.get(Math.max(1,remaining),TimeUnit.NANOSECONDS);
LOGGER.log(Level.FINE, "ping succeeded on {0}", channel.getName());
return;
} catch (ExecutionException e) {
if (e.getCause() instanceof RequestAbortedException)
Expand Down

0 comments on commit 1fc3c93

Please sign in to comment.