RetriesExhaustedException(String msg, Map<String, MutableLong> counters, Throwable cause) { super(msg + getRootCauseCountersAsString(counters), cause); }
@Test public void testRetryTwice() throws Exception { SolrQuery query = getDefaultQuery(); solrServer.query(query); FailingSolrServer failingSolrServer = new FailingSolrServer(solrServer); SolrClient solr = new RetryingSolrServer(failingSolrServer, getRetryTwicePolicyFactory(), getMetricsFacade()); try { solr.query(query); fail(); } catch (RetriesExhaustedException e) { Assert.assertTrue(e.getCause() instanceof FailingSolrServer.InjectedSolrServerException); Assert.assertEquals(3, failingSolrServer.getNumRequests()); Assert.assertEquals(3, failingSolrServer.getNumInjectedFailures()); LOG.info("RetriesExhaustedException.getMessage(): " + e.getMessage()); } }
@Test public void testRetryOfBadRequest() throws Exception { SolrInputDocument doc = new SolrInputDocument(); // bad doc is missing 'id' field // without RetryingSolrServer try { solrServer.add(doc); fail(); } catch (SolrException e) { assertEquals(ErrorCode.BAD_REQUEST.code, e.code()); } // RetryingSolrServer, retry twice CountingSolrServer countingSolrServer = new CountingSolrServer(solrServer); SolrClient solr = new RetryingSolrServer(countingSolrServer, getRetryTwicePolicyFactory(), getMetricsFacade()); try { solr.add(doc); fail(); } catch (RetriesExhaustedException e) { Assert.assertEquals(3, countingSolrServer.getNumRequests()); Assert.assertTrue(e.getCause() instanceof SolrException); SolrException sex = (SolrException) e.getCause(); Assert.assertEquals(ErrorCode.BAD_REQUEST.code, sex.code()); } }
throw new RetriesExhaustedException( "Performed " + totalRetryCount + " retries across " + totalRequestCount + " client requests. Gave up because the last " + retryCount + " retries across " + secs
@Test public void testNoRetries() throws Exception { SolrQuery query = getDefaultQuery(); solrServer.query(query); FailingSolrServer failingSolrServer = new FailingSolrServer(solrServer); SolrClient solr = new RetryingSolrServer(failingSolrServer, getNoRetryPolicyFactory(), getMetricsFacade()); try { solr.query(query); fail(); } catch (RetriesExhaustedException e) { assertTrue(e.getCause() instanceof FailingSolrServer.InjectedSolrServerException); Assert.assertEquals(1, failingSolrServer.getNumRequests()); Assert.assertEquals(1, failingSolrServer.getNumInjectedFailures()); } }
fail(); } catch (RetriesExhaustedException e) { assertTrue(e.getCause() instanceof FailingSolrServer.InjectedSolrServerException); Assert.assertEquals(1, failingSolrServer.getNumRequests()); Assert.assertEquals(1, failingSolrServer.getNumInjectedFailures());