private void asyncFlushAndReschedule() { threadPool.executor(ThreadPool.Names.FLUSH).execute(new AbstractRunnable() { @Override public void onRejection(Throwable t) { logger.trace("ignoring EsRejectedExecutionException, shutting down", t); } @Override public void onFailure(Throwable t) { logger.warn("failed to flush shard on translog threshold", t); reschedule(); } @Override protected void doRun() throws Exception { try { indexShard.flush(new FlushRequest()); } catch (IllegalIndexShardStateException e) { // we are being closed, or in created state, ignore } catch (FlushNotAllowedEngineException e) { // ignore this exception, we are not allowed to perform flush } lastFlushTime = threadPool.estimatedTimeInMillis(); reschedule(); } }); } }
@Override protected void doRun() { sendPings(timeout, null, sendPingsHandler); threadPool.schedule(TimeValue.timeValueMillis(timeout.millis() / 2), ThreadPool.Names.GENERIC, new AbstractRunnable() { @Override protected void doRun() throws Exception { sendPings(timeout, TimeValue.timeValueMillis(timeout.millis() / 2), sendPingsHandler); sendPingsHandler.close(); listener.onPing(sendPingsHandler.pingCollection().toArray()); for (DiscoveryNode node : sendPingsHandler.nodeToDisconnect) { logger.trace("[{}] disconnecting from {}", sendPingsHandler.id(), node); transportService.disconnectFromNode(node); } } @Override public void onFailure(Throwable t) { logger.debug("Ping execution failed", t); sendPingsHandler.close(); } }); }