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"); }
@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"); } }
@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"); } }
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); } }
@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"); } }
@Test public void clear_cache() { ClearIndicesCacheRequestBuilder requestBuilder = es.client().prepareClearCache(); requestBuilder.get(); }
@Test public void trace_logs() { logTester.setLevel(LoggerLevel.TRACE); ClearIndicesCacheRequestBuilder requestBuilder = es.client().prepareClearCache(); requestBuilder.get(); assertThat(logTester.logs()).hasSize(1); }
@Test public void no_trace_logs() { logTester.setLevel(LoggerLevel.DEBUG); ClearIndicesCacheRequestBuilder requestBuilder = es.client().prepareClearCache(); requestBuilder.get(); assertThat(logTester.logs()).isEmpty(); }
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); } }
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); } }