@Test void healthyWithRetry() { when(memoryMonitor.isMemoryHealthy(anyLong())).thenThrow( ElasticsearchMemoryHealthy.MemoryUsageExceedException.class).thenReturn(true); ElasticsearchResourceMonitor resourceMonitor = new ElasticsearchResourceMonitor(settings, memoryMonitor); assertTrue(resourceMonitor.isHealthy()); verify(memoryMonitor, times(2)).isMemoryHealthy(anyLong()); }
@Override public boolean isHealthy() { try { ByteSizeValue limit = settings.getSettingValue(Settings.Key.PPL_QUERY_MEMORY_LIMIT); Supplier<Boolean> booleanSupplier = Retry.decorateSupplier(retry, () -> memoryMonitor .isMemoryHealthy(limit.getBytes())); return booleanSupplier.get(); } catch (Exception e) { return false; } }
ElasticsearchResourceMonitor extends ResourceMonitor { @Override public boolean isHealthy() { try { ByteSizeValue limit = settings.getSettingValue(Settings.Key.PPL_QUERY_MEMORY_LIMIT); Supplier<Boolean> booleanSupplier = Retry.decorateSupplier(retry, () -> memoryMonitor .isMemoryHealthy(limit.getBytes())); return booleanSupplier.get(); } catch (Exception e) { return false; } } }
ElasticsearchResourceMonitor extends ResourceMonitor { @Override public boolean isHealthy() { try { ByteSizeValue limit = settings.getSettingValue(Settings.Key.PPL_QUERY_MEMORY_LIMIT); Supplier<Boolean> booleanSupplier = Retry.decorateSupplier(retry, () -> memoryMonitor .isMemoryHealthy(limit.getBytes())); return booleanSupplier.get(); } catch (Exception e) { return false; } } ElasticsearchResourceMonitor(
      Settings settings,
      ElasticsearchMemoryHealthy memoryMonitor); }
ElasticsearchResourceMonitor extends ResourceMonitor { @Override public boolean isHealthy() { try { ByteSizeValue limit = settings.getSettingValue(Settings.Key.PPL_QUERY_MEMORY_LIMIT); Supplier<Boolean> booleanSupplier = Retry.decorateSupplier(retry, () -> memoryMonitor .isMemoryHealthy(limit.getBytes())); return booleanSupplier.get(); } catch (Exception e) { return false; } } ElasticsearchResourceMonitor(
      Settings settings,
      ElasticsearchMemoryHealthy memoryMonitor); @Override boolean isHealthy(); }
ElasticsearchResourceMonitor extends ResourceMonitor { @Override public boolean isHealthy() { try { ByteSizeValue limit = settings.getSettingValue(Settings.Key.PPL_QUERY_MEMORY_LIMIT); Supplier<Boolean> booleanSupplier = Retry.decorateSupplier(retry, () -> memoryMonitor .isMemoryHealthy(limit.getBytes())); return booleanSupplier.get(); } catch (Exception e) { return false; } } ElasticsearchResourceMonitor(
      Settings settings,
      ElasticsearchMemoryHealthy memoryMonitor); @Override boolean isHealthy();  }