goiri commented on code in PR #5420:
URL: https://github.com/apache/hadoop/pull/5420#discussion_r1149515622


##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/FederationInterceptorREST.java:
##########
@@ -254,44 +253,59 @@ private DefaultRequestInterceptorREST 
createInterceptorForSubCluster(
     String interceptorClassName = conf.get(
         YarnConfiguration.ROUTER_WEBAPP_DEFAULT_INTERCEPTOR_CLASS,
         YarnConfiguration.DEFAULT_ROUTER_WEBAPP_DEFAULT_INTERCEPTOR_CLASS);
-    DefaultRequestInterceptorREST interceptorInstance = null;
+
+    DefaultRequestInterceptorREST interceptorInstance;
     try {
       Class<?> interceptorClass = conf.getClassByName(interceptorClassName);
-      if (DefaultRequestInterceptorREST.class
-          .isAssignableFrom(interceptorClass)) {
-        interceptorInstance = (DefaultRequestInterceptorREST) ReflectionUtils
-            .newInstance(interceptorClass, conf);
+      if 
(DefaultRequestInterceptorREST.class.isAssignableFrom(interceptorClass)) {
+        interceptorInstance =
+            (DefaultRequestInterceptorREST) 
ReflectionUtils.newInstance(interceptorClass, conf);
         String userName = getUser().getUserName();
         interceptorInstance.init(userName);
       } else {
-        throw new YarnRuntimeException(
-            "Class: " + interceptorClassName + " not instance of "
-                + DefaultRequestInterceptorREST.class.getCanonicalName());
+        throw new YarnRuntimeException("Class: " + interceptorClassName + " 
not instance of "
+            + DefaultRequestInterceptorREST.class.getCanonicalName());
       }
     } catch (ClassNotFoundException e) {
-      throw new YarnRuntimeException(
-          "Could not instantiate ApplicationMasterRequestInterceptor: "
-              + interceptorClassName,
-          e);
+      throw new YarnRuntimeException("Could not instantiate 
ApplicationMasterRequestInterceptor: " +
+          interceptorClassName, e);
     }
 
-    String webAppAddresswithScheme =
-        WebAppUtils.getHttpSchemePrefix(this.getConf()) + webAppAddress;
-    interceptorInstance.setWebAppAddress(webAppAddresswithScheme);
+    String webAppAddressWithScheme = WebAppUtils.getHttpSchemePrefix(conf) + 
webAppAddress;
+    interceptorInstance.setWebAppAddress(webAppAddressWithScheme);
     interceptorInstance.setSubClusterId(subClusterId);
     interceptors.put(subClusterId, interceptorInstance);
     return interceptorInstance;
   }
 
+  protected DefaultRequestInterceptorREST getOrCreateInterceptorForSubCluster(
+      SubClusterInfo subClusterInfo) {
+    if (subClusterInfo != null) {
+      final SubClusterId subClusterId = subClusterInfo.getSubClusterId();
+      final String webServiceAddress = subClusterInfo.getRMWebServiceAddress();
+      return getOrCreateInterceptorForSubCluster(subClusterId, 
webServiceAddress);
+    }
+    return null;
+  }
+
+  protected DefaultRequestInterceptorREST getOrCreateInterceptorByAppId(String 
appId)
+      throws YarnException {
+    SubClusterInfo subClusterInfo = getHomeSubClusterInfoByAppId(appId);

Review Comment:
   Why not doing the validation of the appId here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to