knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject knox git commit: KNOX-1244 - YARNUIV2 fix HA support (Sunil Govind via Sandeep More)
Date Fri, 11 May 2018 19:03:03 GMT
Repository: knox
Updated Branches:
  refs/heads/master 86a8ed1bf -> a7d0efc10


KNOX-1244 - YARNUIV2 fix HA support (Sunil Govind via Sandeep More)


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

Branch: refs/heads/master
Commit: a7d0efc10028409bac8f4d997c9a97e4095a1b71
Parents: 86a8ed1
Author: Sandeep More <more@apache.org>
Authored: Fri May 11 15:02:54 2018 -0400
Committer: Sandeep More <more@apache.org>
Committed: Fri May 11 15:02:54 2018 -0400

----------------------------------------------------------------------
 .../services/yarnuiv2/3.0.0/service.xml         |  3 +-
 .../gateway/rm/dispatch/RMUI2HaDispatch.java    | 58 ++++++++++++++++++++
 2 files changed, 59 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/a7d0efc1/gateway-service-definitions/src/main/resources/services/yarnuiv2/3.0.0/service.xml
----------------------------------------------------------------------
diff --git a/gateway-service-definitions/src/main/resources/services/yarnuiv2/3.0.0/service.xml
b/gateway-service-definitions/src/main/resources/services/yarnuiv2/3.0.0/service.xml
index bdbb0e7..1fb1d21 100644
--- a/gateway-service-definitions/src/main/resources/services/yarnuiv2/3.0.0/service.xml
+++ b/gateway-service-definitions/src/main/resources/services/yarnuiv2/3.0.0/service.xml
@@ -56,7 +56,6 @@
         <rewrite apply="YARNUIV2/yarnuiv2/inbound/ws" to="request.url"/>
         <rewrite apply="YARNUIV2/yarnuiv2/headers/outbound" to="response.headers"/>
         <rewrite apply="YARNUIV2/yarnuiv2/outbound/mainpage" to="response.body"/>
-        <dispatch contributor-name="http-client" />
     </route>
     <!-- Resources -->
     <route path="/yarnuiv2/styles/**">
@@ -92,5 +91,5 @@
     </route>
     
   </routes>
-  <dispatch classname="org.apache.knox.gateway.dispatch.PassAllHeadersDispatch"/>
+  <dispatch classname="org.apache.knox.gateway.dispatch.PassAllHeadersDispatch" ha-classname="org.apache.knox.gateway.rm.dispatch.RMUI2HaDispatch"/>
 </service>

http://git-wip-us.apache.org/repos/asf/knox/blob/a7d0efc1/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
new file mode 100644
index 0000000..61e05b7
--- /dev/null
+++ b/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMUI2HaDispatch.java
@@ -0,0 +1,58 @@
+/**
+ * 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;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.knox.gateway.config.Configure;
+import org.apache.knox.gateway.ha.provider.HaProvider;
+import org.apache.knox.gateway.ha.provider.HaServiceConfig;
+
+public class RMUI2HaDispatch extends RMHaBaseDispatcher {
+
+  private static final String RESOURCE_ROLE = "YARNUIV2";
+  private HaProvider haProvider;
+
+  public RMUI2HaDispatch() throws ServletException {
+   super();
+  }
+
+  @Configure
+  public void setHaProvider(HaProvider haProvider) {
+    this.haProvider = haProvider;
+  }
+
+  @Override
+  public void init() {
+    super.init();
+    if (haProvider != null) {
+      super.setResourceRole(RESOURCE_ROLE);
+      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);
+    }
+  }
+}


Mime
View raw message