@Override public ClearIndicesCacheResponse get() { Profiler profiler = Profiler.createIfTrace(EsClient.LOGGER).start(); try { return super.execute().actionGet(); } catch (Exception e) { throw new IllegalStateException(String.format("Fail to execute %s", toString()), e); } finally { if (profiler.isTraceEnabled()) { profiler.stopTrace(toString()); } } }
@Test public void get_with_string_timeout_is_not_yet_implemented() { try { es.client().prepareClearCache().get("1"); fail(); } catch (Exception e) { assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented"); } }
private void clearLookupCache(String viewUuid) { try { esClient.prepareClearCache() .setQueryCache(true) .get(); } catch (Exception e) { throw new IllegalStateException(String.format("Unable to clear lookup cache of view '%s'", viewUuid), e); } }
@Test public void to_string() { assertThat(es.client().prepareClearCache().toString()).isEqualTo("ES clear cache request"); assertThat(es.client().prepareClearCache("rules").toString()).isEqualTo("ES clear cache request on indices 'rules'"); assertThat(es.client().prepareClearCache().setFields("key").toString()).isEqualTo("ES clear cache request on fields 'key'"); assertThat(es.client().prepareClearCache().setFieldDataCache(true).toString()).isEqualTo("ES clear cache request with field data cache"); assertThat(es.client().prepareClearCache().setRequestCache(true).toString()).isEqualTo("ES clear cache request with request cache"); }
@Override public ClearIndicesCacheRequestBuilder prepareClearCache(String... indices) { return new ClearIndicesCacheRequestBuilder(this, ClearIndicesCacheAction.INSTANCE).setIndices(indices); }
@Override public ClearIndicesCacheRequestBuilder newRequestBuilder(ElasticsearchClient client) { return new ClearIndicesCacheRequestBuilder(client, this); } }
@Override public ClearIndicesCacheRequestBuilder prepareClearCache(String... indices) { return new ClearIndicesCacheRequestBuilder(this, ClearIndicesCacheAction.INSTANCE).setIndices(indices); }
@Override public ClearIndicesCacheRequestBuilder newRequestBuilder(ElasticsearchClient client) { return new ClearIndicesCacheRequestBuilder(client, this); } }
@Override public ClearIndicesCacheRequestBuilder prepareClearCache(String... indices) { return new ClearIndicesCacheRequestBuilder(this, ClearIndicesCacheAction.INSTANCE).setIndices(indices); }
public void clearIndexes() { Loggers.get(getClass()).info("Truncate Elasticsearch indices"); try { esClient.prepareClearCache().get(); for (String index : esClient.prepareState().get().getState().getMetaData().getConcreteAllIndices()) { clearIndex(new IndexType(index, index)); } } catch (Exception e) { throw new IllegalStateException("Unable to clear indexes", e); } }
@Override public ClearIndicesCacheRequestBuilder newRequestBuilder(ElasticsearchClient client) { return new ClearIndicesCacheRequestBuilder(client, this); } }
private void clearLookupCache(String viewUuid) { try { esClient.prepareClearCache() .setQueryCache(true) .get(); } catch (Exception e) { throw new IllegalStateException(String.format("Unable to clear lookup cache of view '%s'", viewUuid), e); } }
@Test public void execute_should_throw_an_unsupported_operation_exception() { try { es.client().prepareClearCache().execute(); fail(); } catch (Exception e) { assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous"); } }
@Override public ClearIndicesCacheRequestBuilder prepareClearCache(String... indices) { return new ClearIndicesCacheRequestBuilder(this, ClearIndicesCacheAction.INSTANCE).setIndices(indices); }
@Test public void get_with_time_value_timeout_is_not_yet_implemented() { try { es.client().prepareClearCache().get(TimeValue.timeValueMinutes(1)); fail(); } catch (Exception e) { assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented"); } }
@Override public ClearIndicesCacheRequestBuilder newRequestBuilder(ElasticsearchClient client) { return new ClearIndicesCacheRequestBuilder(client, this); } }
@Override public ClearIndicesCacheResponse get() { Profiler profiler = Profiler.createIfTrace(EsClient.LOGGER).start(); try { return super.execute().actionGet(); } catch (Exception e) { throw new IllegalStateException(String.format("Fail to execute %s", toString()), e); } finally { if (profiler.isTraceEnabled()) { profiler.stopTrace(toString()); } } }
@Test public void no_trace_logs() { logTester.setLevel(LoggerLevel.DEBUG); ClearIndicesCacheRequestBuilder requestBuilder = es.client().prepareClearCache(); requestBuilder.get(); assertThat(logTester.logs()).isEmpty(); }
@Override public ClearIndicesCacheRequestBuilder newRequestBuilder(ElasticsearchClient client) { return new ClearIndicesCacheRequestBuilder(client, this); } }
@BeforeMethod public void clearCache() throws ExecutionException, InterruptedException { client.admin().indices().prepareClearCache().execute().get(); }