slfan1989 commented on code in PR #4594:
URL: https://github.com/apache/hadoop/pull/4594#discussion_r926208922
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterClientRMService.java:
##########
@@ -507,42 +480,25 @@ protected Map<String, RequestInterceptorChainWrapper>
getPipelines() {
@VisibleForTesting
protected ClientRequestInterceptor createRequestInterceptorChain() {
Configuration conf = getConfig();
+ ClientRequestInterceptor pipeline = null;
+ ClientMethod remoteMethod = null;
+ try {
+ remoteMethod = new ClientMethod("setNextInterceptor",
+ new Class[]{ClientRequestInterceptor.class}, new Object[]{null});
- List<String> interceptorClassNames = getInterceptorClassNames(conf);
+ pipeline = RouterServerUtil.createRequestInterceptorChain(conf,
+ YarnConfiguration.ROUTER_CLIENTRM_INTERCEPTOR_CLASS_PIPELINE,
+ YarnConfiguration.DEFAULT_ROUTER_CLIENTRM_INTERCEPTOR_CLASS,
+ remoteMethod, ClientRequestInterceptor.class);
- ClientRequestInterceptor pipeline = null;
- ClientRequestInterceptor current = null;
- for (String interceptorClassName : interceptorClassNames) {
- try {
- Class<?> interceptorClass = conf.getClassByName(interceptorClassName);
- if (ClientRequestInterceptor.class.isAssignableFrom(interceptorClass))
{
- ClientRequestInterceptor interceptorInstance =
- (ClientRequestInterceptor) 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 "
- + ClientRequestInterceptor.class.getCanonicalName());
- }
- } catch (ClassNotFoundException e) {
+ if (pipeline == null) {
throw new YarnRuntimeException(
- "Could not instantiate ApplicationClientRequestInterceptor: "
- + 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
Review Comment:
I will refactor this part of the code.
--
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]