Use abstract runnable in scheduled ping

This commit is contained in:
Simon Willnauer 2015-06-22 09:40:06 +02:00
parent 2e762f078d
commit a45c05d907
1 changed files with 12 additions and 2 deletions

View File

@ -50,6 +50,7 @@ import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.common.util.concurrent.KeyedLock;
import org.elasticsearch.monitor.jvm.JvmInfo;
@ -1122,13 +1123,13 @@ public class NettyTransport extends AbstractLifecycleComponent<Transport> implem
}
}
class ScheduledPing implements Runnable {
class ScheduledPing extends AbstractRunnable {
final CounterMetric successfulPings = new CounterMetric();
final CounterMetric failedPings = new CounterMetric();
@Override
public void run() {
protected void doRun() throws Exception {
if (lifecycle.stoppedOrClosed()) {
return;
}
@ -1156,5 +1157,14 @@ public class NettyTransport extends AbstractLifecycleComponent<Transport> implem
}
threadPool.schedule(pingSchedule, ThreadPool.Names.GENERIC, this);
}
@Override
public void onFailure(Throwable t) {
if (lifecycle.stoppedOrClosed()) {
logger.trace("[{}] failed to send ping transport message", t);
} else {
logger.warn("[{}] failed to send ping transport message", t);
}
}
}
}