Repository: knox Updated Branches: refs/heads/master a4c263f06 -> 4df0672d1
KNOX-1093 - replaced retryRequest with failoverRequest and removed un-used retry variables/method Signed-off-by: Phil Zampino <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/knox/repo Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/4df0672d Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/4df0672d Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/4df0672d Branch: refs/heads/master Commit: 4df0672d1abb1cebcbc288b4fa1b1c7594a576a4 Parents: a4c263f Author: MatthewSharp <[email protected]> Authored: Thu Sep 27 10:18:40 2018 -0400 Committer: Phil Zampino <[email protected]> Committed: Thu Sep 27 12:34:07 2018 -0400 ---------------------------------------------------------------------- .../hdfs/dispatch/AbstractHdfsHaDispatch.java | 33 +------------------- 1 file changed, 1 insertion(+), 32 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/knox/blob/4df0672d/gateway-service-webhdfs/src/main/java/org/apache/knox/gateway/hdfs/dispatch/AbstractHdfsHaDispatch.java ---------------------------------------------------------------------- diff --git a/gateway-service-webhdfs/src/main/java/org/apache/knox/gateway/hdfs/dispatch/AbstractHdfsHaDispatch.java b/gateway-service-webhdfs/src/main/java/org/apache/knox/gateway/hdfs/dispatch/AbstractHdfsHaDispatch.java index 12e9f09..595c784 100644 --- a/gateway-service-webhdfs/src/main/java/org/apache/knox/gateway/hdfs/dispatch/AbstractHdfsHaDispatch.java +++ b/gateway-service-webhdfs/src/main/java/org/apache/knox/gateway/hdfs/dispatch/AbstractHdfsHaDispatch.java @@ -41,12 +41,9 @@ import java.util.concurrent.atomic.AtomicInteger; public abstract class AbstractHdfsHaDispatch extends HdfsHttpClientDispatch { private static final String FAILOVER_COUNTER_ATTRIBUTE = "dispatch.ha.failover.counter"; - private static final String RETRY_COUNTER_ATTRIBUTE = "dispatch.ha.retry.counter"; private static final WebHdfsMessages LOG = MessagesFactory.get(WebHdfsMessages.class); private int maxFailoverAttempts = HaServiceConfigConstants.DEFAULT_MAX_FAILOVER_ATTEMPTS; private int failoverSleep = HaServiceConfigConstants.DEFAULT_FAILOVER_SLEEP; - private int maxRetryAttempts = HaServiceConfigConstants.DEFAULT_MAX_RETRY_ATTEMPTS; - private int retrySleep = HaServiceConfigConstants.DEFAULT_RETRY_SLEEP; private HaProvider haProvider; public AbstractHdfsHaDispatch() throws ServletException { @@ -60,8 +57,6 @@ public abstract class AbstractHdfsHaDispatch extends HdfsHttpClientDispatch { HaServiceConfig serviceConfig = haProvider.getHaDescriptor().getServiceConfig(getResourceRole()); maxFailoverAttempts = serviceConfig.getMaxFailoverAttempts(); failoverSleep = serviceConfig.getFailoverSleep(); - maxRetryAttempts = serviceConfig.getMaxRetryAttempts(); - retrySleep = serviceConfig.getRetrySleep(); } } @@ -87,7 +82,7 @@ public abstract class AbstractHdfsHaDispatch extends HdfsHttpClientDispatch { failoverRequest(outboundRequest, inboundRequest, outboundResponse, inboundResponse, e); } catch (SafeModeException e) { LOG.errorReceivedFromSafeModeNode(e); - retryRequest(outboundRequest, inboundRequest, outboundResponse, inboundResponse, e); + failoverRequest(outboundRequest, inboundRequest, outboundResponse, inboundResponse, e); } catch (IOException e) { LOG.errorConnectingToServer(outboundRequest.getURI().toString(), e); failoverRequest(outboundRequest, inboundRequest, outboundResponse, inboundResponse, e); @@ -146,30 +141,4 @@ public abstract class AbstractHdfsHaDispatch extends HdfsHttpClientDispatch { } } - private void retryRequest(HttpUriRequest outboundRequest, HttpServletRequest inboundRequest, HttpServletResponse outboundResponse, HttpResponse inboundResponse, Exception exception) throws IOException { - LOG.retryingRequest(outboundRequest.getURI().toString()); - AtomicInteger counter = (AtomicInteger) inboundRequest.getAttribute(RETRY_COUNTER_ATTRIBUTE); - if (counter == null) { - counter = new AtomicInteger(0); - } - inboundRequest.setAttribute(RETRY_COUNTER_ATTRIBUTE, counter); - if (counter.incrementAndGet() <= maxRetryAttempts) { - if (retrySleep > 0) { - try { - Thread.sleep(retrySleep); - } catch (InterruptedException e) { - LOG.retrySleepFailed(getResourceRole(), e); - } - } - executeRequest(outboundRequest, inboundRequest, outboundResponse); - } else { - LOG.maxRetryAttemptsReached(maxRetryAttempts, getResourceRole(), outboundRequest.getURI().toString()); - if (inboundResponse != null) { - writeOutboundResponse(outboundRequest, inboundRequest, outboundResponse, inboundResponse); - } else { - throw new IOException(exception); - } - } - } - } \ No newline at end of file
