You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by kr...@apache.org on 2018/10/23 13:10:52 UTC

knox git commit: KNOX-1433 - RMHaBaseDispatcher Class Cleanup - SafeModeException

Repository: knox
Updated Branches:
  refs/heads/master 2bd260120 -> 3f360a77b


KNOX-1433 - RMHaBaseDispatcher Class Cleanup - SafeModeException

Signed-off-by: Kevin Risden <kr...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/3f360a77
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/3f360a77
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/3f360a77

Branch: refs/heads/master
Commit: 3f360a77bd227122dc5fbad0597c2b6e06a22aad
Parents: 2bd2601
Author: Kevin Risden <kr...@apache.org>
Authored: Thu Oct 4 20:26:14 2018 -0400
Committer: Kevin Risden <kr...@apache.org>
Committed: Tue Oct 23 09:08:09 2018 -0400

----------------------------------------------------------------------
 .../gateway/rm/dispatch/RMHaBaseDispatcher.java | 45 --------------------
 .../knox/gateway/rm/dispatch/RMHaDispatch.java  |  2 -
 .../gateway/rm/dispatch/RMUI2HaDispatch.java    |  6 +--
 .../gateway/rm/dispatch/RMUIHaDispatch.java     |  2 -
 .../gateway/rm/dispatch/SafeModeException.java  | 21 ---------
 .../apache/knox/gateway/rm/i18n/RMMessages.java | 12 ------
 6 files changed, 1 insertion(+), 87 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/3f360a77/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMHaBaseDispatcher.java
----------------------------------------------------------------------
diff --git a/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMHaBaseDispatcher.java b/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMHaBaseDispatcher.java
index 69fe1e2..e3770ed 100644
--- a/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMHaBaseDispatcher.java
+++ b/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMHaBaseDispatcher.java
@@ -37,13 +37,10 @@ import java.util.concurrent.atomic.AtomicInteger;
 
 class  RMHaBaseDispatcher extends DefaultDispatch {
     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 String LOCATION = "Location";
     private static final RMMessages LOG = MessagesFactory.get(RMMessages.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 String resourceRole = null;
     private HttpResponse inboundResponse = null;
 
@@ -62,8 +59,6 @@ class  RMHaBaseDispatcher extends DefaultDispatch {
         this.inboundResponse = inboundResponse;
     }
 
-
-
     void setHaProvider(HaProvider haProvider) {
         this.haProvider = haProvider;
     }
@@ -78,14 +73,6 @@ class  RMHaBaseDispatcher extends DefaultDispatch {
         this.failoverSleep = failoverSleep;
     }
 
-    void setMaxRetryAttempts(int maxRetryAttempts) {
-        this.maxRetryAttempts = maxRetryAttempts;
-    }
-
-    void setRetrySleep(int retrySleep) {
-        this.retrySleep = retrySleep;
-    }
-
     void setResourceRole(String resourceRole) {
         this.resourceRole = resourceRole;
     }
@@ -101,9 +88,6 @@ class  RMHaBaseDispatcher extends DefaultDispatch {
         } catch (StandbyException e) {
            LOG.errorReceivedFromStandbyNode(e);
            failoverRequest(outboundRequest, inboundRequest, outboundResponse, inboundResponse, e);
-        } catch (SafeModeException e) {
-           LOG.errorReceivedFromSafeModeNode(e);
-           retryRequest(outboundRequest, inboundRequest, outboundResponse, inboundResponse, e);
         } catch (IOException e) {
            LOG.errorConnectingToServer(outboundRequest.getURI().toString(), e);
            failoverRequest(outboundRequest, inboundRequest, outboundResponse, inboundResponse, e);
@@ -125,9 +109,6 @@ class  RMHaBaseDispatcher extends DefaultDispatch {
           if (body.contains("This is standby RM")) {
              throw new StandbyException();
           }
-          if (body.contains("SafeModeException") || body.contains("RetriableException")) {
-             throw new SafeModeException();
-          }
        }
        super.writeOutboundResponse(outboundRequest, inboundRequest, outboundResponse, inboundResponse);
     }
@@ -193,30 +174,4 @@ class  RMHaBaseDispatcher extends DefaultDispatch {
     private void markFailedURL(String outboundURIs) {
         haProvider.markFailedURL(this.resourceRole, outboundURIs);
     }
-
-    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(this.resourceRole, e);
-             }
-          }
-          executeRequest(outboundRequest, inboundRequest, outboundResponse);
-       } else {
-          LOG.maxRetryAttemptsReached(maxRetryAttempts, this.resourceRole, outboundRequest.getURI().toString());
-          if (inboundResponse != null) {
-             writeOutboundResponse(outboundRequest, inboundRequest, outboundResponse, inboundResponse);
-          } else {
-             throw new IOException(exception);
-          }
-       }
-    }
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/3f360a77/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMHaDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMHaDispatch.java b/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMHaDispatch.java
index 2899f34..17ca574 100644
--- a/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMHaDispatch.java
+++ b/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMHaDispatch.java
@@ -41,8 +41,6 @@ public class RMHaDispatch extends RMHaBaseDispatcher {
        HaServiceConfig serviceConfig = haProvider.getHaDescriptor().getServiceConfig(RESOURCE_ROLE);
        super.setMaxFailoverAttempts( serviceConfig.getMaxFailoverAttempts());
        super.setFailoverSleep( serviceConfig.getFailoverSleep());
-       super.setMaxRetryAttempts( serviceConfig.getMaxRetryAttempts());
-       super.setRetrySleep( serviceConfig.getRetrySleep());
        super.setHaProvider(haProvider);
      }
    }

http://git-wip-us.apache.org/repos/asf/knox/blob/3f360a77/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMUI2HaDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMUI2HaDispatch.java b/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMUI2HaDispatch.java
index bc6bbfc..d5adaed 100644
--- a/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMUI2HaDispatch.java
+++ b/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMUI2HaDispatch.java
@@ -16,8 +16,6 @@
  */
 package org.apache.knox.gateway.rm.dispatch;
 
-import javax.servlet.ServletException;
-
 import org.apache.knox.gateway.config.Configure;
 import org.apache.knox.gateway.ha.provider.HaProvider;
 import org.apache.knox.gateway.ha.provider.HaServiceConfig;
@@ -27,7 +25,7 @@ public class RMUI2HaDispatch extends RMHaBaseDispatcher {
   private static final String RESOURCE_ROLE = "YARNUIV2";
   private HaProvider haProvider;
 
-  public RMUI2HaDispatch() throws ServletException {
+  public RMUI2HaDispatch() {
    super();
   }
 
@@ -44,8 +42,6 @@ public class RMUI2HaDispatch extends RMHaBaseDispatcher {
       HaServiceConfig serviceConfig = haProvider.getHaDescriptor().getServiceConfig(RESOURCE_ROLE);
       super.setMaxFailoverAttempts(serviceConfig.getMaxFailoverAttempts());
       super.setFailoverSleep(serviceConfig.getFailoverSleep());
-      super.setMaxRetryAttempts(serviceConfig.getMaxRetryAttempts());
-      super.setRetrySleep(serviceConfig.getRetrySleep());
       super.setHaProvider(haProvider);
     }
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/3f360a77/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMUIHaDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMUIHaDispatch.java b/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMUIHaDispatch.java
index cf7dd12..3ec7d53 100644
--- a/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMUIHaDispatch.java
+++ b/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMUIHaDispatch.java
@@ -46,8 +46,6 @@ public class RMUIHaDispatch extends RMHaBaseDispatcher {
        HaServiceConfig serviceConfig = haProvider.getHaDescriptor().getServiceConfig(RESOURCE_ROLE);
        super.setMaxFailoverAttempts( serviceConfig.getMaxFailoverAttempts());
        super.setFailoverSleep( serviceConfig.getFailoverSleep());
-       super.setMaxRetryAttempts( serviceConfig.getMaxRetryAttempts());
-       super.setRetrySleep( serviceConfig.getRetrySleep());
        super.setHaProvider(haProvider);
      }
    }

http://git-wip-us.apache.org/repos/asf/knox/blob/3f360a77/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/SafeModeException.java
----------------------------------------------------------------------
diff --git a/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/SafeModeException.java b/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/SafeModeException.java
deleted file mode 100644
index 2ecdd46..0000000
--- a/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/SafeModeException.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.knox.gateway.rm.dispatch;
-
-class SafeModeException extends RuntimeException {
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/3f360a77/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/i18n/RMMessages.java
----------------------------------------------------------------------
diff --git a/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/i18n/RMMessages.java b/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/i18n/RMMessages.java
index 029a851..4c7c68b 100644
--- a/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/i18n/RMMessages.java
+++ b/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/i18n/RMMessages.java
@@ -29,18 +29,6 @@ public interface RMMessages extends HaDispatchMessages {
   @Message(level = MessageLevel.INFO, text = "Received an error from a node in Standby: {0}")
    void errorReceivedFromStandbyNode(@StackTrace(level = MessageLevel.DEBUG) Exception e);
 
-  @Message(level = MessageLevel.INFO, text = "Received an error from a node in SafeMode: {0}")
-   void errorReceivedFromSafeModeNode(@StackTrace(level = MessageLevel.DEBUG) Exception e);
-
-  @Message(level = MessageLevel.INFO, text = "Retrying request to a server: {0}")
-   void retryingRequest(String uri);
-
   @Message(level = MessageLevel.INFO, text = "Redirect to {0} because of accessing standby server.")
    void failoverRedirect(String redirect);
-
-  @Message(level = MessageLevel.INFO, text = "Maximum attempts {0} to retry reached for service: {1} at url : {2}")
-   void maxRetryAttemptsReached(int attempts, String service, String url);
-
-  @Message(level = MessageLevel.INFO, text = "Error occurred while trying to sleep for retry : {0} {1}")
-   void retrySleepFailed(String service, @StackTrace(level = MessageLevel.DEBUG) Exception e);
 }