opensearch-sdk-java
opensearch-sdk-java copied to clipboard
[FEATURE] Add ability to pass ClusterStateRequest object when requesting Cluster State
Is your feature request related to a problem?
Current SDK implementation of getting cluster state is implemented with defaults in the ExtensionRequest fetching the state from the ClusterService:
TransportResponse handleExtensionRequest(ExtensionRequest extensionRequest) throws Exception {
switch (extensionRequest.getRequestType()) {
case REQUEST_EXTENSION_CLUSTER_STATE:
return new ClusterStateResponse(clusterService.getClusterName(), clusterService.state(), false);
This does not work for use cases where the specific values to be returned are configured, such as in the AD Plugin:
ClusterStateRequest clusterStateRequest = new ClusterStateRequest()
.clear()
.indices(AnomalyDetectionIndices.ALL_AD_RESULTS_INDEX_PATTERN)
.metadata(true)
.local(true)
.indicesOptions(IndicesOptions.strictExpand());
adminClient.cluster().state(clusterStateRequest, ActionListener.wrap(clusterStateResponse -> {
What solution would you like?
Either create a new transport action or modify the existing cluster state request action to take a ClusterStateRequest object as a parameter. The RestClusterStateAction class can probably called using the opensearch-java client with little overhead.
What alternatives have you considered?
Improving RestHighLevelClient to handle this case. Not desirable as it's on a path for deprecation.
Do you have any additional context?
This is part of the AnomalyDetectionIndices component in the AD plugin.
The
RestClusterStateActionclass can probably called using theopensearch-javaclient with little overhead.
No, it can't. Don't even try. I did, and failed gloriously. See #667
There's a TransportAction and the requests are writeable. This is trivial using transport.