ApplicationMetricsRetriever extends AbstractComponent { static Duration timeout(int clients, int numThreads) { Duration timeout = Duration.ofSeconds(Long.max(MIN_TIMEOUT.toSeconds(), 20 * clients / numThreads)); return timeout.compareTo(MAX_TIMEOUT) > 0 ? MAX_TIMEOUT : timeout; } @Inject  ApplicationMetricsRetriever(MetricsNodesConfig nodesConfig); @Override void deconstruct(); Map<Node, List<MetricsPacket>> getMetrics(); Map<Node, List<MetricsPacket>> getMetrics(ConsumerId consumer);  }
@Test public void test_timeout_calculation() { assertEquals(MIN_TIMEOUT, timeout(1, 1)); assertEquals(MIN_TIMEOUT, timeout(MAX_THREADS, MAX_THREADS)); assertEquals(Duration.ofSeconds(100), timeout(100, MAX_THREADS)); assertEquals(Duration.ofSeconds(200), timeout(200, MAX_THREADS)); assertEquals(MAX_TIMEOUT, timeout(240, MAX_THREADS)); }