-
Notifications
You must be signed in to change notification settings - Fork 25.2k
HLRC: Add ILM Status to HLRC #33283
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: Add ILM Status to HLRC #33283
Conversation
Adds support for the Index Lifecycle Management Status to the Java High-Level Rest Client. Relates to elastic#33100
Pinging @elastic/es-core-infra |
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 comments renaming these methods/classes, I'm in favor of:
- LifecycleManagementStatusResponse
lifecycleManagementStatus(...)
* @param request the request with user defined timeouts. | ||
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized | ||
*/ | ||
public StatusILMResponse StatusILM(TimedRequest request, RequestOptions options) throws IOException { |
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 these should be LifecycleManagementStatusResponse
, rather than using the ILM in method/class names
Also, the method name is StatusILM
and we don't capitalize any of our method names
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.
Also, the method name is StatusILM and we don't capitalize any of our method names
oops didn't meant to capitalize the method name. (kinda surprised that check style didn't catch that). will fix.
I think these should be LifecycleManagementStatusResponse, rather than using the ILM in method/class names
I tend to agree, but was matching the start/stopILM here: https://github.com/elastic/elasticsearch/tree/index-lifecycle/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/indexlifecycle
Should I rename those too ?
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized | ||
* @param listener the listener to be notified upon request completion | ||
*/ | ||
public void StatusILMAsync(TimedRequest request, RequestOptions options, |
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.
Same here about naming and capitalization
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.
oops ... IDE find and replace gone wild. will fix.
} | ||
} | ||
|
||
// generated |
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 don't think we need these generated 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.
I can remove them. FWIW, I generally put these in here as a way to signal nothing special here, so no tests, and if changes are made need to re-generate.
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.
Left some comments.
* @param request the request with user defined timeouts. | ||
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized | ||
*/ | ||
public StatusILMResponse StatusILM(TimedRequest request, RequestOptions options) throws IOException { |
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.
Method names should start with a lowercase letter, so this should be statusILM
.
Or maybe getILMStatus
? statusILM
doesn't make much sense seeing it for the first time - there's no verb there.
Lee beat me to it and left better feedback, see his comment instead.
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized | ||
* @param listener the listener to be notified upon request completion | ||
*/ | ||
public void StatusILMAsync(TimedRequest request, RequestOptions options, |
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.
As above re: method names.
/** | ||
* Enum representing the different modes that Index Lifecycle Service can operate in. | ||
*/ | ||
public enum OperationMode { |
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.
#33250 moves the existing OperationMode
class into o.e.client.indexlifecycle
- you may want to wait until that gets merged (should be later today) and use that one instead of having this as an inner class.
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! ... will wait till that gets merged and update accordingly.
Response statusResponse = client().performRequest(statusReq); | ||
String statusResponseString = EntityUtils.toString(statusResponse.getEntity()); | ||
assertEquals("{\"operation_mode\":\"RUNNING\"}", statusResponseString); | ||
TimedRequest statusRequest = new TimedRequest(); |
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.
While I get the logic behind why you did it this way, I think generic classes make more sense for responses than requests. As a user of the HLRC, this feels really strange - even if GetILMStatusRequest
would be an extra class that doesn't really add anything, I think having separate classes for each request type is the way to go. I could be wrong though, I'd like to hear others' input on this.
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 don't have a strong opinion beyond consistency in the API.
Perhaps we should allow a no-arg method in the client that creates the request for them. However, that also creates inconsistency (unless you create a bunch of new methods).
I'd like to hear others' input on this.
..same
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 Could you weigh in on this?
|
||
public class StatusILMResponseTests extends ESTestCase { | ||
|
||
public void testClientServerStatuses() { |
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.
Using the shared class would let you get rid of this test, too.
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.
will wait for #33250 to use shared class.
* Fixed incorrect method uppercase * Renamed statsILM -> lifecycleManagementStatus * removed "generated" comments
Changes pushed:
TODO (this PR):
TODO (not in this PR):
@hub-cap [1] @colings86 [2] |
@jakelandis #33250 has been merged into |
@@ -1241,6 +1241,18 @@ static Request stopILM(StopILMRequest stopILMRequest) { | |||
return request; | |||
} | |||
|
|||
static Request statusILM(TimedRequest ilmStatusRequest){ |
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.
Can we make this lifecycleManagementStatus
to match the method in the client?
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 missed this one. done.
LGTM, pending @hub-cap's input on specialized vs generic requests. |
If we create a request and we ever want to add things to it, then it will not require a breaking contract change. It also gives us a chance to rename TimedRequest if its scope changes one day. It might even be worth making it abstract to ensure we dont use it this way. what do yall think? |
@hub-cap - good point. I will add the specific the request to this PR and change TimedRequest to abstract. |
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 3 comments but they are very minor, otherwise LGTM
"operation_mode", a -> new LifecycleManagementStatusResponse((String) a[0])); | ||
|
||
static { | ||
PARSER.declareString(ConstructingObjectParser.constructorArg(), new ParseField("operation_mode")); |
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.
Can you put the ParseField
into a class private var and then use it in the parser (so we don't accidentally typo/change it in the future)
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.
moved "operation_mode" to a static final string (not exactly the ask, but i believe same outcome)
} | ||
|
||
//package private for testing | ||
LifecycleManagementStatusResponse(String operationMode) { |
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 this should take an OperationMode
to push the conversion into the caller, rather than doing it in the constructor (it seems cleaner to me that way).
This is just my personal preference though, so up to you if you want to change 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.
leaving as-is
static OperationMode fromString(String string) { | ||
return EnumSet.allOf(OperationMode.class).stream() | ||
.filter(e -> string.equalsIgnoreCase(e.name())).findFirst() | ||
.orElseThrow(() -> new IllegalArgumentException(String.format(Locale.ENGLISH, "%s is not a valid operation_mode", string))); |
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 use Locale.ROOT
for as many things as we can, rather than the English locale here
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.
done
Thanks for the reviews! will merge once CI turns green. |
jenkins test this please |
Adds support for the Index Lifecycle Management Status to the Java High-Level Rest Client. Relates to elastic#33100
Adds support for the Index Lifecycle Management Status to the Java
High-Level Rest Client.
Relates to #33100
Notes to reviewer(s):
AcknowledgedResponse
in terms of not creating typed request/response when not needed.