-
Couldn't load subscription status.
- Fork 9.1k
YARN-6572. Refactoring Router services to use common util classes for pipeline creations. #4594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… pipeline creations.
|
💔 -1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
| if (pipeline == null) { | ||
| throw new YarnRuntimeException( | ||
| "RequestInterceptor pipeline is not configured in the system"); | ||
| } catch (IOException | InvocationTargetException | NoSuchMethodException | RuntimeException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point we better catch Exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will refactor this part of the code.
| // add to the map, to ensure thread safe. | ||
| LOG.info("Initializing request processing pipeline for application " | ||
| + "for the user: {}", user); | ||
| + "for the user: {}.", user); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could put the string in a single line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it.
| RMAdminRequestInterceptor pipeline = null; | ||
| ClientMethod remoteMethod = null; | ||
| try { | ||
| remoteMethod = new ClientMethod("setNextInterceptor", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Declare it directly here:
ClientMethod remoteMethod = new ClientMethod("setNextInterceptor",
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it.
| | IllegalAccessException ex) { | ||
| throw new YarnRuntimeException("Create RequestInterceptor Chain error.", ex); | ||
| } | ||
| return pipeline; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that if error we always return exception, can we define the pipeline inside of the try and do the exception returns properly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| */ | ||
| @VisibleForTesting | ||
| protected RESTRequestInterceptor createRequestInterceptorChain() { | ||
| RESTRequestInterceptor pipeline = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is very similar to the other one.
As we are refactoring, can we clean this up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your help reviewing the code, I will continue to refactor this part of the code.
| this.userPipelineMap = Collections.synchronizedMap( | ||
| new LRUCacheHashMap<String, RequestInterceptorChainWrapper>( | ||
| maxCacheSize, true)); | ||
| new LRUCacheHashMap<>(maxCacheSize, true)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it.
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
| package org.apache.hadoop.yarn.server.router.clientrm; | ||
|
|
||
| import java.io.IOException; | ||
| import java.lang.reflect.InvocationTargetException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import java.lang.reflect.InvocationTargetException;:8: Unused import - java.lang.reflect.InvocationTargetException. [UnusedImports]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it.
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
| YarnConfiguration.DEFAULT_ROUTER_WEBAPP_INTERCEPTOR_CLASS, | ||
| RESTRequestInterceptor.class); | ||
| } catch (YarnRuntimeException ex) { | ||
| throw new YarnRuntimeException("Create RequestInterceptor Chain error.", ex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We catch the exception to throw it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will modify the code to remove the try catch.
|
🎊 +1 overall
This message was automatically generated. |
|
@goiri Please help me to review the code again, thank you very much! |
|
🎊 +1 overall
This message was automatically generated. |
|
There are a few unused imports. |
Thanks for the suggestion, I will remove this part. |
|
🎊 +1 overall
This message was automatically generated. |
|
💔 -1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
This reverts commit a7cd76c.
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
@goiri Can you help to merge this pr into trunk branch? Thank you very much! |
|
@goiri Thank you very much for your help reviewing the code! |
… pipeline creations. (apache#4594)
Jira : YARN-6572. Refactoring Router services to use common util classes for pipeline creations.
When reading the code, I found that RouterClientRMService.java, RouterRMAdminService.java, RouterWebServices.java have a lot of repetitive code in the method of calling createRequestInterceptorChain, and I extracted the methods in RouterServerUtil.