@Test(dependsOnMethods = {"indicatesShouldRetryOnGenericIOException", "createsRetriesMetricInRegistry"}) public void recordsRetryMetric() { final MetricRegistry registry = new MetricRegistry(); final MantaHttpRequestRetryHandler retryHandler = new MantaHttpRequestRetryHandler(1, new MantaClientMetricConfiguration(UUID.randomUUID(), registry)); final Optional<Meter> maybeMeter = registry.getMeters(FILTER_RETRY_METRIC).values().stream().findFirst(); assertTrue(maybeMeter.isPresent()); assertEquals(maybeMeter.get().getCount(), 0, "meter should have zero samples"); retryHandler.retryRequest(new IOException("something went wrong"), 1, new HttpClientContext()); assertEquals(maybeMeter.get().getCount(), 1, "meter should have one sample"); retryHandler.retryRequest(new IOException("something else went wrong"), 1, new HttpClientContext()); assertEquals(maybeMeter.get().getCount(), 2, "meter should have two samples"); }
@Override public boolean retryRequest(final IOException exception, final int executionCount, final HttpContext context) { notNull(context, "HTTP context cannot be null"); if (neverRetry(context)) { return false; } final boolean toBeRetried = super.retryRequest(exception, executionCount, context); if (logger.isDebugEnabled()) { if (toBeRetried) { String msg = String.format("Request failed, %d/%d retry.", executionCount, getRetryCount()); logger.debug(msg, exception); } else { logger.debug("Request failed, unable to retry.", exception); } } if (toBeRetried && retries != null) { retries.mark(); } return toBeRetried; }
MantaHttpRequestRetryHandler extends DefaultHttpRequestRetryHandler implements HttpContextRetryCancellation { @Override public boolean retryRequest(final IOException exception, final int executionCount, final HttpContext context) { notNull(context, "HTTP context cannot be null"); if (neverRetry(context)) { return false; } final boolean toBeRetried = super.retryRequest(exception, executionCount, context); if (logger.isDebugEnabled()) { if (toBeRetried) { String msg = String.format("Request failed, %d/%d retry.", executionCount, getRetryCount()); logger.debug(msg, exception); } else { logger.debug("Request failed, unable to retry.", exception); } } if (toBeRetried && retries != null) { retries.mark(); } return toBeRetried; } }
MantaHttpRequestRetryHandler extends DefaultHttpRequestRetryHandler implements HttpContextRetryCancellation { @Override public boolean retryRequest(final IOException exception, final int executionCount, final HttpContext context) { notNull(context, "HTTP context cannot be null"); if (neverRetry(context)) { return false; } final boolean toBeRetried = super.retryRequest(exception, executionCount, context); if (logger.isDebugEnabled()) { if (toBeRetried) { String msg = String.format("Request failed, %d/%d retry.", executionCount, getRetryCount()); logger.debug(msg, exception); } else { logger.debug("Request failed, unable to retry.", exception); } } if (toBeRetried && retries != null) { retries.mark(); } return toBeRetried; } @Deprecated  MantaHttpRequestRetryHandler(final ConfigContext config);  MantaHttpRequestRetryHandler(final int retryCount);  MantaHttpRequestRetryHandler(final int retryCount, final MantaClientMetricConfiguration metricConfig); }
MantaHttpRequestRetryHandler extends DefaultHttpRequestRetryHandler implements HttpContextRetryCancellation { @Override public boolean retryRequest(final IOException exception, final int executionCount, final HttpContext context) { notNull(context, "HTTP context cannot be null"); if (neverRetry(context)) { return false; } final boolean toBeRetried = super.retryRequest(exception, executionCount, context); if (logger.isDebugEnabled()) { if (toBeRetried) { String msg = String.format("Request failed, %d/%d retry.", executionCount, getRetryCount()); logger.debug(msg, exception); } else { logger.debug("Request failed, unable to retry.", exception); } } if (toBeRetried && retries != null) { retries.mark(); } return toBeRetried; } @Deprecated  MantaHttpRequestRetryHandler(final ConfigContext config);  MantaHttpRequestRetryHandler(final int retryCount);  MantaHttpRequestRetryHandler(final int retryCount, final MantaClientMetricConfiguration metricConfig); @Override boolean retryRequest(final IOException exception,
                                final int executionCount,
                                final HttpContext context); }
MantaHttpRequestRetryHandler extends DefaultHttpRequestRetryHandler implements HttpContextRetryCancellation { @Override public boolean retryRequest(final IOException exception, final int executionCount, final HttpContext context) { notNull(context, "HTTP context cannot be null"); if (neverRetry(context)) { return false; } final boolean toBeRetried = super.retryRequest(exception, executionCount, context); if (logger.isDebugEnabled()) { if (toBeRetried) { String msg = String.format("Request failed, %d/%d retry.", executionCount, getRetryCount()); logger.debug(msg, exception); } else { logger.debug("Request failed, unable to retry.", exception); } } if (toBeRetried && retries != null) { retries.mark(); } return toBeRetried; } @Deprecated  MantaHttpRequestRetryHandler(final ConfigContext config);  MantaHttpRequestRetryHandler(final int retryCount);  MantaHttpRequestRetryHandler(final int retryCount, final MantaClientMetricConfiguration metricConfig); @Override boolean retryRequest(final IOException exception,
                                final int executionCount,
                                final HttpContext context); @Deprecated
    static final String CONTEXT_ATTRIBUTE_MANTA_RETRY_DISABLE; static final String METRIC_NAME_RETRIES; }