@Test(expected = uk.co.flax.harahachibu.services.DiskSpaceCheckerException.class) public void throwsExceptionWhenServerTimesOut() throws Exception { mockServer.when(request().withPath(ElasticsearchClient.CLUSTER_STATS_ENDPOINT)) .respond(response() .withDelay(TimeUnit.SECONDS, 5) .withBody(new JsonBody(clusterStatsJson)) .withHeaders(new Header("Content-Type", "application/json")) .withStatusCode(HttpServletResponse.SC_OK)); esClient.getClusterStats(); }
public ElasticsearchClusterStats getClusterStats() throws DiskSpaceCheckerException { final ElasticsearchClusterStats stats; if (cacheUpToDate()) { stats = latestStats; } else { stats = getRemoteClusterStats(); synchronized (statsLock) { this.latestStats = stats; this.lastUpdate = System.currentTimeMillis(); } } return stats; }
ElasticsearchClient { public ElasticsearchClusterStats getClusterStats() throws DiskSpaceCheckerException { final ElasticsearchClusterStats stats; if (cacheUpToDate()) { stats = latestStats; } else { stats = getRemoteClusterStats(); synchronized (statsLock) { this.latestStats = stats; this.lastUpdate = System.currentTimeMillis(); } } return stats; } }
ElasticsearchClient { public ElasticsearchClusterStats getClusterStats() throws DiskSpaceCheckerException { final ElasticsearchClusterStats stats; if (cacheUpToDate()) { stats = latestStats; } else { stats = getRemoteClusterStats(); synchronized (statsLock) { this.latestStats = stats; this.lastUpdate = System.currentTimeMillis(); } } return stats; } ElasticsearchClient(Client client, String baseUrl, long cacheMs); }
ElasticsearchClient { public ElasticsearchClusterStats getClusterStats() throws DiskSpaceCheckerException { final ElasticsearchClusterStats stats; if (cacheUpToDate()) { stats = latestStats; } else { stats = getRemoteClusterStats(); synchronized (statsLock) { this.latestStats = stats; this.lastUpdate = System.currentTimeMillis(); } } return stats; } ElasticsearchClient(Client client, String baseUrl, long cacheMs); ElasticsearchClusterStats getClusterStats(); }
ElasticsearchClient { public ElasticsearchClusterStats getClusterStats() throws DiskSpaceCheckerException { final ElasticsearchClusterStats stats; if (cacheUpToDate()) { stats = latestStats; } else { stats = getRemoteClusterStats(); synchronized (statsLock) { this.latestStats = stats; this.lastUpdate = System.currentTimeMillis(); } } return stats; } ElasticsearchClient(Client client, String baseUrl, long cacheMs); ElasticsearchClusterStats getClusterStats();  }