void healthCheckPing(final long threshold, NodeHealthChecker healthChecker) { int oldState, newState; for (; ; ) { oldState = this.state; if ((oldState & ACTIVE_PING) != 0) { // There is already a ping active return; } newState = oldState | ACTIVE_PING; if (stateUpdater.compareAndSet(this, oldState, newState)) { break; } } NodePingUtil.internalPingNode( this, new NodePingUtil.PingCallback() { @Override public void completed() { clearActivePing(); } @Override public void failed() { if (healthCheckFailed() == threshold) { // Remove using the executor task pool ioThread .getWorker() .execute( new Runnable() { @Override public void run() { container.removeNode(Node.this, true); clearActivePing(); } }); } else { clearActivePing(); } } }, healthChecker, ioThread, bufferPool, container.getClient(), container.getXnioSsl(), OptionMap.EMPTY); }
/** * Async ping from the user * * @param exchange the http server exchange * @param callback the ping callback */ void ping(final HttpServerExchange exchange, final NodePingUtil.PingCallback callback) { NodePingUtil.pingNode(this, exchange, callback); }