private boolean coolOffPeriodExpired(Map.Entry<InetSocketAddress, Long> blacklistedEntry) { long backoffTimeMillis = TimeUnit.SECONDS.toMillis(config.unresponsiveHostBackoffTimeSeconds()); return blacklistedEntry.getValue() + backoffTimeMillis < System.currentTimeMillis(); }
@Override public int unresponsiveHostBackoffTimeSeconds() { return chooseConfig(CassandraKeyValueServiceRuntimeConfig::unresponsiveHostBackoffTimeSeconds, config.unresponsiveHostBackoffTimeSeconds()); }
@Before public void setup() { config = mock(CassandraKeyValueServiceConfig.class); when(config.poolRefreshIntervalSeconds()).thenReturn(POOL_REFRESH_INTERVAL_SECONDS); when(config.timeBetweenConnectionEvictionRunsSeconds()).thenReturn(TIME_BETWEEN_EVICTION_RUNS_SECONDS); when(config.unresponsiveHostBackoffTimeSeconds()).thenReturn(UNRESPONSIVE_HOST_BACKOFF_SECONDS); blacklist = new Blacklist(config); doAnswer(invocation -> poolServers.add(getInvocationAddress(invocation))).when(cassandra).addPool(any()); doAnswer(invocation -> poolServers.remove(getInvocationAddress(invocation))).when(cassandra).removePool(any()); doAnswer(invocation -> poolServers.stream().collect( Collectors.toMap(x -> x, x -> mock(CassandraClientPoolingContainer.class)))).when(cassandra).getPools(); when(config.socketTimeoutMillis()).thenReturn(1); }
private boolean coolOffPeriodExpired(Map.Entry<InetSocketAddress, Long> blacklistedEntry) { long backoffTimeMillis = TimeUnit.SECONDS.toMillis(config.unresponsiveHostBackoffTimeSeconds()); return blacklistedEntry.getValue() + backoffTimeMillis < System.currentTimeMillis(); }
@Override public int unresponsiveHostBackoffTimeSeconds() { return chooseConfig(CassandraKeyValueServiceRuntimeConfig::unresponsiveHostBackoffTimeSeconds, config.unresponsiveHostBackoffTimeSeconds()); }