static CassandraRequestExceptionHandler withNoBackoffForTest( Supplier<Integer> maxTriesSameHost, Supplier<Integer> maxTriesTotal, Blacklist blacklist) { return new CassandraRequestExceptionHandler(maxTriesSameHost, maxTriesTotal, blacklist); }
public static CassandraClientPool create(MetricsManager metricsManager, CassandraKeyValueServiceConfig config, Supplier<CassandraKeyValueServiceRuntimeConfig> runtimeConfig, boolean initializeAsync) { Blacklist blacklist = new Blacklist(config); CassandraRequestExceptionHandler exceptionHandler = new CassandraRequestExceptionHandler( () -> runtimeConfig.get().numberOfRetriesOnSameHost(), () -> runtimeConfig.get().numberOfRetriesOnAllHosts(), () -> runtimeConfig.get().conservativeRequestExceptionHandler(), blacklist); CassandraClientPoolImpl cassandraClientPool = new CassandraClientPoolImpl( metricsManager, config, StartupChecks.RUN, exceptionHandler, blacklist); cassandraClientPool.wrapper.initialize(initializeAsync); return cassandraClientPool.wrapper.isInitialized() ? cassandraClientPool : cassandraClientPool.wrapper; }
@Before public void setup() { handlerLegacy = new CassandraRequestExceptionHandler( () -> MAX_RETRIES_PER_HOST, () -> MAX_RETRIES_TOTAL, () -> false, new Blacklist(config)); handlerConservative = new CassandraRequestExceptionHandler( () -> MAX_RETRIES_PER_HOST, () -> MAX_RETRIES_TOTAL, () -> true, new Blacklist(config)); }
static CassandraRequestExceptionHandler withNoBackoffForTest( Supplier<Integer> maxTriesSameHost, Supplier<Integer> maxTriesTotal, Blacklist blacklist) { return new CassandraRequestExceptionHandler(maxTriesSameHost, maxTriesTotal, blacklist); }
@Test public void changingHandlerModeHasNoEffectWithoutGetStrategy() { Exception ex = Iterables.get(TRANSIENT_EXCEPTIONS, 0); CassandraRequestExceptionHandler handler = new CassandraRequestExceptionHandler( () -> MAX_RETRIES_PER_HOST, () -> MAX_RETRIES_TOTAL, this::mutableMode, new Blacklist(config)); CassandraRequestExceptionHandler.RequestExceptionHandlerStrategy conservativeStrategy = handler.getStrategy(); assertTrue(handler.shouldBackoff(ex, handler.getStrategy())); flipMode(); assertTrue(handler.shouldBackoff(ex, conservativeStrategy)); assertFalse(handler.shouldBackoff(ex, handler.getStrategy())); }
public static CassandraClientPool create(MetricsManager metricsManager, CassandraKeyValueServiceConfig config, Supplier<CassandraKeyValueServiceRuntimeConfig> runtimeConfig, boolean initializeAsync) { Blacklist blacklist = new Blacklist(config); CassandraRequestExceptionHandler exceptionHandler = new CassandraRequestExceptionHandler( () -> runtimeConfig.get().numberOfRetriesOnSameHost(), () -> runtimeConfig.get().numberOfRetriesOnAllHosts(), () -> runtimeConfig.get().conservativeRequestExceptionHandler(), blacklist); CassandraClientPoolImpl cassandraClientPool = new CassandraClientPoolImpl( metricsManager, config, StartupChecks.RUN, exceptionHandler, blacklist); cassandraClientPool.wrapper.initialize(initializeAsync); return cassandraClientPool.wrapper.isInitialized() ? cassandraClientPool : cassandraClientPool.wrapper; }