private void pollElasticSearch() {
        try {
            LOGGER.debug("Attempting to connect to Elasticsearch via: {0}", client);
            // Do Health request
            final ClusterHealthRequest healthRequest = new ClusterHealthRequest();
            // Health request will time out after 5s, and we will try again after the scheduled period via
            // the schedulerService.
            healthRequest.timeout(new TimeValue(periodSecs, TimeUnit.SECONDS));
            final ClusterHealthResponse healthResponse = client.cluster()
                .health(healthRequest, RequestOptions.DEFAULT);

            if (!healthResponse.isTimedOut()) {
                long pollingTimeMeasure = System.currentTimeMillis() - startTime;
                LOGGER.debug("Took {0} milliseconds to successfully poll Elasticsearch", pollingTimeMeasure);
                cancelImmediately(true);
            }
        } catch (ElasticsearchException e) {
            LOGGER.error("Fatal error when attempting to connect to Elasticsearch", e);
            latestException = e;
            cancelImmediately(false);
        } catch (SSLException ssle) {
            LOGGER.error(ssle, "Fatal SSL/TLS connection occurred when connecting to Elasticsearch. "
                + "Underlying SSL/TLS config will likely need to be resolved before retrying): {0}",
                ssle.getMessage());
            latestException = new UncheckedIOException(ssle);
            cancelImmediately(false);
        } catch (IOException ioe) {
            LOGGER.info("Unable to reach Elasticsearch (with error: {0}). "
                    + "Retry will be attempted in {1} seconds.",
                ioe.getMessage(), periodSecs);
            latestException = new UncheckedIOException(ioe);
        }
    }
Block calling thread until Elasticsearch can be reached successfully, the timeout period is exceeded,
or a fatal error occurs.

@throws FailedPollingException if Elasticsearch can not be reached, which wraps a range of checked
     and unchecked exceptions. {@link FailedPollingException#getCause()} contains the wrapped
     exception.
common/es/src/main/java/io/apiman/common/es/util/EsConnectionPoller.java