public RetryPolicyFactory parse(Config retryPolicyConfig) { final Config boundedExponentialBackoffRetryConfig = new Configs().getConfig(retryPolicyConfig, BOUNDED_EXPONENTIAL_BACKOFF_RETRY_NAME); final long baseSleepTime = new Configs() .getNanoseconds(boundedExponentialBackoffRetryConfig, "baseSleepTime", TimeUnit.MILLISECONDS.toNanos(125)); final long maxSleepTime = new Configs() .getNanoseconds(boundedExponentialBackoffRetryConfig, "maxSleepTime", TimeUnit.SECONDS.toNanos(10)); final int maxRetries = new Configs() .getInt(boundedExponentialBackoffRetryConfig, "maxRetries", 100); final long maxElapsedTime = new Configs() .getNanoseconds(boundedExponentialBackoffRetryConfig, "maxElapsedTime", TimeUnit.SECONDS.toNanos(3 * 60)); LOG.debug("Parsed retry policy BoundedExponentialBackoffRetry with " + "baseSleepTime:{}, maxSleepTime:{}, maxRetries:{}, maxElapsedTime:{}", new Object[]{baseSleepTime, maxSleepTime, maxRetries, maxElapsedTime}); if (maxRetries <= 0 || maxElapsedTime <= 0) { return null; } return new DefaultRetryPolicyFactory( new FlexibleBoundedExponentialBackoffRetry(baseSleepTime, maxSleepTime, maxRetries, maxElapsedTime)); }
@Test public void testRetries() throws Exception { new DefaultRetryPolicyFactory(); SolrQuery query = getDefaultQuery(); FailingSolrServer failingSolrServer = new FailingSolrServer(solrServer); SolrClient solr = new RetryingSolrServer( failingSolrServer, new DefaultRetryPolicyFactory(new FlexibleBoundedExponentialBackoffRetry( TimeUnit.MILLISECONDS.toNanos(1), TimeUnit.MILLISECONDS.toNanos(1000),