slfan1989 commented on code in PR #4594: URL: https://github.com/apache/hadoop/pull/4594#discussion_r926208755
########## hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/rmadmin/RouterRMAdminService.java: ########## @@ -215,43 +190,24 @@ protected Map<String, RequestInterceptorChainWrapper> getPipelines() { @VisibleForTesting protected RMAdminRequestInterceptor createRequestInterceptorChain() { Configuration conf = getConfig(); + RMAdminRequestInterceptor pipeline = null; + ClientMethod remoteMethod = null; + try { + remoteMethod = new ClientMethod("setNextInterceptor", + new Class[]{RMAdminRequestInterceptor.class}, new Object[]{null}); - List<String> interceptorClassNames = getInterceptorClassNames(conf); + pipeline = RouterServerUtil.createRequestInterceptorChain(conf, + YarnConfiguration.ROUTER_RMADMIN_INTERCEPTOR_CLASS_PIPELINE, + YarnConfiguration.DEFAULT_ROUTER_RMADMIN_INTERCEPTOR_CLASS, + remoteMethod, RMAdminRequestInterceptor.class); - RMAdminRequestInterceptor pipeline = null; - RMAdminRequestInterceptor current = null; - for (String interceptorClassName : interceptorClassNames) { - try { - Class<?> interceptorClass = conf.getClassByName(interceptorClassName); - if (RMAdminRequestInterceptor.class - .isAssignableFrom(interceptorClass)) { - RMAdminRequestInterceptor interceptorInstance = - (RMAdminRequestInterceptor) ReflectionUtils - .newInstance(interceptorClass, conf); - if (pipeline == null) { - pipeline = interceptorInstance; - current = interceptorInstance; - continue; - } else { - current.setNextInterceptor(interceptorInstance); - current = interceptorInstance; - } - } else { - throw new YarnRuntimeException( - "Class: " + interceptorClassName + " not instance of " - + RMAdminRequestInterceptor.class.getCanonicalName()); - } - } catch (ClassNotFoundException e) { + if (pipeline == null) { throw new YarnRuntimeException( - "Could not instantiate RMAdminRequestInterceptor: " - + interceptorClassName, - e); + "RequestInterceptor pipeline is not configured in the system."); } - } - - if (pipeline == null) { - throw new YarnRuntimeException( - "RequestInterceptor pipeline is not configured in the system"); + } catch (IOException | InvocationTargetException | NoSuchMethodException | RuntimeException + | IllegalAccessException ex) { + throw new YarnRuntimeException("Create RequestInterceptor Chain error.", ex); } return pipeline; Review Comment: Thank you for your suggestion. I handled different Exceptions in RouterServerUtil#createRequestInterceptorChain, and used YarnRuntimeException to make it easier for the caller to use it. -- 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: common-issues-unsubscr...@hadoop.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org