-
Notifications
You must be signed in to change notification settings - Fork 810
SOLR-16738: Refactor special-casing out of AdminHandlersProxy #3991
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
base: main
Are you sure you want to change the base?
SOLR-16738: Refactor special-casing out of AdminHandlersProxy #3991
Conversation
|
Nice direction. |
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'm thinking that support for V2 would be easier if the response type, at least, was a type parameter:
AdminHandlersProxy<R> // R = response type: NamedList, or (extension of) SolrJerseyResponse, or InputStreamResponse (i.e.: metrics)
Then, we would have methods like:
processProxiedResponse(String, R)callRemoteNode(String, SolrRequest<R>)- ...
That might leave a bit more implementation details to the classes extendingAdminHandlersProxy, but we would not have to worry about NamedList responses from V2.
| private static final String PARAM_NODES = "nodes"; | ||
| private static final String PARAM_NODE = "node"; | ||
| protected static final String PARAM_NODES = "nodes"; | ||
| // TODO Move to NormalV1RequestProxy if not used elsewhere when finished |
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.
Actually, the "node" param is only used by the Metrics API, so it would move to PrometheusRequestProxy.
"nodes", plural, is anything except metrics.
| if (cc != null) { | ||
| final var adminProxy = AdminHandlersProxy.create(cc, req, rsp); | ||
| if (adminProxy.shouldProxy()) { | ||
| adminProxy.proxyRequest(); |
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.
proxyRequest() already check if shouldProxy(), and returns a boolean (true if the request is proxied):
if (adminProxy.proxyRequest()) { return; }
| if (cc != null) { | ||
| final var adminProxy = AdminHandlersProxy.create(cc, req, rsp); | ||
| if (adminProxy.shouldProxy()) { | ||
| adminProxy.proxyRequest(); |
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.
proxyRequest() already check if shouldProxy(), and returns a boolean (true if the request is proxied):
if (adminProxy.proxyRequest()) { return; }
| import org.apache.solr.response.SolrQueryResponse; | ||
|
|
||
| // TODO Fix this name | ||
| public class NormalV1RequestProxy extends AdminHandlersProxy { |
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.
Suggestion : V1AdminHandlersRequestProxy or just AdminHandlersRequestProxy (since the abstract is called AdminHandlersProxy, no confusion, I hope)
| return new NormalV1RequestProxy(coreContainer, req, rsp); | ||
| } | ||
|
|
||
| public static SolrRequest<?> createGenericRequest(String apiPath, SolrParams params) { |
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.
Could be abstract. The V2 support will need to create at least a GenericV2SolrRequest, so leave creation of GenericSolrRequest to the "normal v1" implementation.
https://issues.apache.org/jira/browse/SOLR-16738
Description
AdminHandlersProxy, in its current form, is a bit unwieldy to extend to cover our v2 API: it relies on GenericSolrRequest to send requests, assumes a NamedList in several method signatures, assumes certain parameter names as triggers for proxying, and even has special cases for certain "wt" values. To truly support v2-proxying, AdminHandlersProxy would need to be more flexible about parameter names and SolrJ return types.
Solution
This PR refactors AdminHandlersProxy to make it more amendable for use with v2 APIs going forward. The refactor makes the following changes:
o.a.s.handler.admin.proxyTests
Unit tests for AdminHandlersProxy, PrometheusRequestProxy, and NormalV1RequestProxy will be added prior to coming out of "draft" mode.
Checklist
Please review the following and check all that apply:
mainbranch../gradlew check.