-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
HLRC: Create server agnostic request and response #32912
Conversation
The HLRC has historically reused the same Request and Response classes that the server module uses. This commit deprecates the use of any server module Request and Response classes, and adds a small bit of validation logic that differs from server slightly, in that it does not assume a check for a null ValidationException class is not enough to determine if validation failed.
* layer has been added to the ReST client, and requests should extend | ||
* {@link org.elasticsearch.protocol.xpack.common.ValidationException} instead of `ActionRequest`. | ||
*/ | ||
@Deprecated |
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.
aren't we deprecating the way that all our current API are implemented?
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.
sadly, yes, if we want to use new server agnostic classes, we have to stop using the old ActionRequest classes.
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 agree with the direction, reusing classes is what got us far relatively quickly in the beginning, but as that becomes harder and harder, it makes little sense to continue doing so especially given that it gets us only to an intermediate result that still depends on server. I think as long as we don't deprecate methods that are already out, and we only deprecate what they use internally, this is ok. Do we also plan on rewriting the currently supported API with this approach sometimes soon?
/** | ||
* @deprecated If creating a new HLRC ReST API call, consider creating new actions instead of reusing server actions. The Validation | ||
* layer has been added to the ReST client, and requests should extend | ||
* {@link org.elasticsearch.protocol.xpack.common.ValidationException} instead of `ActionRequest`. |
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.
the new recommended way requires using classes that sit under xpack packages?
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.
@hub-cap seems that currently, we have only a protocol project for xpack request/responses, if we want rest client to be independent from server, we need to have protocol project for non-xpack classes or probably we can have both xpack and non-xpack classes under the same protocol project.
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.
good catch, i should be moving these to a non xpack, common place. Ill fix that.
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.
@andrershov this point makes me wonder if we should do away with protocol altogether once we fix the existing x-pack classes, and just put all of these request/responses directly in the HLRC. Thoughts cc @javanna ?
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.
looking at this more, I think it probably makes sense to just move them now to HLRC so we can also put the new Validatable in HLRC too. this way its not only x-pack classes.
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 think that anything that is not under xpack packages is fine, I don't mind whether that's a new oss library or within the high-level client directly.
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.
For now Im going to move them into the same jar. If we find a need to put them into a new jar, we can always go that route. Id rather stick to simpler and then do it when we need it. Ive done this in d0ca91c
@elasticmachine test this please |
/** | ||
* @deprecated If creating a new HLRC ReST API call, consider creating new actions instead of reusing server actions. The Validation | ||
* layer has been added to the ReST client, and requests should extend | ||
* {@link org.elasticsearch.protocol.xpack.common.ValidationException} instead of `ActionRequest`. |
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.
Shouldn't this link to ... Validatable
not ... ValidationException
. Same with the other comments
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.
DOH!
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.
fixed in d0ca91c
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've left one comment about naming, but overall looks good to me
/** | ||
* Defines a validation layer for Requests. | ||
*/ | ||
public interface Validatable { |
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 not sure that Validatable is a good name for the base class of client requests. Probably we can name it ClientRequest, so that in the future if we decide that we need to add new methods to client request we would not need to rename 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.
yea but its not about it being a base request. its just the fact that the HLRC does some validation before sending it. Honestly, this is the only thing that ties it to any sort of class hierarchy. Like the response, which has no class hierarchy.
In a subsequent PR I will be moving Validat* back in to protocol, but the plan is to move protocol under the hlrc, rather than in x-pack. |
ok, WRT the Valid* I think the plan is to remove protocol altogether and just put everything in hlrc. It will be in a subsequent PR. |
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 left a question.
* {@link ValidationException} that contains a list of all failed validation. | ||
*/ | ||
default ValidationException validate() { | ||
return new ValidationException(); |
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 not sure about creating a new instance on every invocation of validate. Can we share an empty instance and expect overriding implementations to create an instance if needed?
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.
++, good idea.
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.
pls note I had to remove final in order to facilitate overriding in the ifc and allowing me to not add anything to the list of msgs
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 left another comment.
public interface Validatable { | ||
ValidationException EMPTY_VALIDATION = new ValidationException() { | ||
@Override | ||
public void addValidationError(String error) { } |
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.
That’s dangerous! Maybe throw unsupported?
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.
duh, what a rookie mistake :)
fixed in 8fac65d
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 left one more comment. Please address one way or the other before merging, but no need for another round.
@@ -949,6 +949,11 @@ public final void fieldCapsAsync(FieldCapabilitiesRequest fieldCapabilitiesReque | |||
FieldCapabilitiesResponse::fromXContent, listener, emptySet()); | |||
} | |||
|
|||
/** | |||
* @deprecated If creating a new HLRC ReST API call, consider creating new actions instead of reusing server actions. The Validation | |||
* layer has been added to the ReST client, and requests should extend {@link Validatable} instead of `ActionRequest`. |
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.
Why backticks in the Javadoc instead of using {@link}
or {@code}
? I would tend to the user former here, it will resolve as long as ActionRequest
is on the class `path and then when we reach that glorious day when it isn't, our Javadocs will fail to build and we will know it's time to remove this Javadoc!
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.
rgr, will fix and then merge, ty for the review.
|
||
/** | ||
* @deprecated If creating a new HLRC ReST API call, consider creating new actions instead of reusing server actions. The Validation | ||
* layer has been added to the ReST client, and requests should extend {@link Validatable} instead of `ActionRequest`. |
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.
See my comment about the backticks.
The HLRC has historically reused the same Request and Response classes that the server module uses. This commit deprecates the use of any server module Request and Response classes, and adds a small bit of validation logic that differs from server slightly, in that it does not assume a check for a null ValidationException class is not enough to determine if validation failed.
* 6.x: Introduce mapping version to index metadata (#33147) Move non duplicated actions back into xpack core (#32952) HLRC: Create server agnostic request and response (#32912) Build: forked compiler max memory matches jvmArgs (#33138) * Added breaking change section for GROUP BY behavior: now it considers null or empty values as a separate group/bucket. Previously, they were ignored. * This is part of backporting of #32832 SQL: Enable aggregations to create a separate bucket for missing values (#32832) [TEST] version guard for reload rest-api-spec Fix grammar in contributing docs APM server monitoring (#32515) Support only string `format` in date, root object & date range (#28117) [Rollup] Move toBuilders() methods out of rollup config objects (#32585) Accept Gradle build scan agreement (#30645) Fix forbiddenapis on java 11 (#33116) Run forbidden api checks with runtimeJavaVersion (#32947) Apply publishing to genreate pom (#33094) Fix a mappings update test (#33146) Reload Secure Settings REST specs & docs (#32990) Refactor CachingUsernamePassword realm (#32646)
The HLRC has historically reused the same Request and Response classes
that the server module uses. This commit deprecates the use of any
server module Request and Response classes, and adds a small bit of
validation logic that differs from server slightly, in that it does not
assume a check for a null ValidationException class is not enough to
determine if validation failed.