@Test void memoryUsageExceedLimitFastFailure() { when(memoryUsage.usage()).thenReturn(10L); when(randomFail.shouldFail()).thenReturn(true); assertThrows(ElasticsearchMemoryHealthy.MemoryUsageExceedFastFailureException.class, () -> monitor.isMemoryHealthy(9L)); }
public boolean isMemoryHealthy(long limitBytes) { final long memoryUsage = this.memoryUsage.usage(); log.debug("Memory usage:{}, limit:{}", memoryUsage, limitBytes); if (memoryUsage < limitBytes) { return true; } else { log.warn("Memory usage:{} exceed limit:{}", memoryUsage, limitBytes); if (randomFail.shouldFail()) { log.warn("Fast failure the current request"); throw new MemoryUsageExceedFastFailureException(); } else { throw new MemoryUsageExceedException(); } } }
ElasticsearchMemoryHealthy { public boolean isMemoryHealthy(long limitBytes) { final long memoryUsage = this.memoryUsage.usage(); log.debug("Memory usage:{}, limit:{}", memoryUsage, limitBytes); if (memoryUsage < limitBytes) { return true; } else { log.warn("Memory usage:{} exceed limit:{}", memoryUsage, limitBytes); if (randomFail.shouldFail()) { log.warn("Fast failure the current request"); throw new MemoryUsageExceedFastFailureException(); } else { throw new MemoryUsageExceedException(); } } } }
ElasticsearchMemoryHealthy { public boolean isMemoryHealthy(long limitBytes) { final long memoryUsage = this.memoryUsage.usage(); log.debug("Memory usage:{}, limit:{}", memoryUsage, limitBytes); if (memoryUsage < limitBytes) { return true; } else { log.warn("Memory usage:{} exceed limit:{}", memoryUsage, limitBytes); if (randomFail.shouldFail()) { log.warn("Fast failure the current request"); throw new MemoryUsageExceedFastFailureException(); } else { throw new MemoryUsageExceedException(); } } } ElasticsearchMemoryHealthy(); @VisibleForTesting  ElasticsearchMemoryHealthy(
      RandomFail randomFail,
      MemoryUsage memoryUsage); }
ElasticsearchMemoryHealthy { public boolean isMemoryHealthy(long limitBytes) { final long memoryUsage = this.memoryUsage.usage(); log.debug("Memory usage:{}, limit:{}", memoryUsage, limitBytes); if (memoryUsage < limitBytes) { return true; } else { log.warn("Memory usage:{} exceed limit:{}", memoryUsage, limitBytes); if (randomFail.shouldFail()) { log.warn("Fast failure the current request"); throw new MemoryUsageExceedFastFailureException(); } else { throw new MemoryUsageExceedException(); } } } ElasticsearchMemoryHealthy(); @VisibleForTesting  ElasticsearchMemoryHealthy(
      RandomFail randomFail,
      MemoryUsage memoryUsage); boolean isMemoryHealthy(long limitBytes); }
ElasticsearchMemoryHealthy { public boolean isMemoryHealthy(long limitBytes) { final long memoryUsage = this.memoryUsage.usage(); log.debug("Memory usage:{}, limit:{}", memoryUsage, limitBytes); if (memoryUsage < limitBytes) { return true; } else { log.warn("Memory usage:{} exceed limit:{}", memoryUsage, limitBytes); if (randomFail.shouldFail()) { log.warn("Fast failure the current request"); throw new MemoryUsageExceedFastFailureException(); } else { throw new MemoryUsageExceedException(); } } } ElasticsearchMemoryHealthy(); @VisibleForTesting  ElasticsearchMemoryHealthy(
      RandomFail randomFail,
      MemoryUsage memoryUsage); boolean isMemoryHealthy(long limitBytes);  }