-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[Segment Replication] Implementing cat/segment_replication API #5718
Changes from 7 commits
2eed8a8
88cf749
888c9b3
ba048a4
69bc392
b062420
1728ae7
b10519e
74a41b0
7752a00
594814e
9e62cd4
b5432bd
2b92c81
5c9f8a7
e022a7e
8b26e2e
dd4f5b1
0e52667
c85e38a
ad1fd5b
2ef7a9f
9a4f09d
1080536
86cf0ae
8ae10c8
9cf580e
b8f7b71
08bc3d6
c1ef1d4
884e6d1
537964f
f120a92
35460e9
fc24661
f64f14c
7d07dc6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
{ | ||
"cat.segment_replication":{ | ||
"documentation":{ | ||
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-segment_replication.html", | ||
"description":"Returns information about index Segment Replication events, both on-going and completed." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how many completed? |
||
}, | ||
"stability":"stable", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Rishikesh1159 Should probably make this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @andrross for catching this. Yes I missed this, it should be |
||
"url":{ | ||
"paths":[ | ||
{ | ||
"path":"/_cat/segment_replication", | ||
"methods":[ | ||
"GET" | ||
] | ||
}, | ||
{ | ||
"path":"/_cat/segment_replication/{index}", | ||
"methods":[ | ||
"GET" | ||
], | ||
"parts":{ | ||
"index":{ | ||
"type":"list", | ||
"description":"Comma-separated list or wildcard expression of index names to limit the returned information" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"params":{ | ||
"format":{ | ||
"type":"string", | ||
"description":"a short version of the Accept header, e.g. json, yaml" | ||
}, | ||
"active_only":{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice |
||
"type":"boolean", | ||
"description":"If `true`, the response only includes ongoing segment replications", | ||
"default":false | ||
}, | ||
"bytes":{ | ||
"type":"enum", | ||
"description":"The unit in which to display byte values", | ||
"options":[ | ||
"b", | ||
"k", | ||
"kb", | ||
"m", | ||
"mb", | ||
"g", | ||
"gb", | ||
"t", | ||
"tb", | ||
"p", | ||
"pb" | ||
] | ||
}, | ||
"detailed":{ | ||
"type":"boolean", | ||
"description":"If `true`, the response includes detailed information about segment replications", | ||
"default":false | ||
}, | ||
"h":{ | ||
"type":"list", | ||
"description":"Comma-separated list of column names to display" | ||
}, | ||
"help":{ | ||
"type":"boolean", | ||
"description":"Return help information", | ||
"default":false | ||
}, | ||
"index":{ | ||
"type":"list", | ||
"description":"Comma-separated list or wildcard expression of index names to limit the returned information" | ||
}, | ||
"s":{ | ||
"type":"list", | ||
"description":"Comma-separated list of column names or column aliases to sort by" | ||
}, | ||
"time":{ | ||
"type":"enum", | ||
"description":"The unit in which to display time values", | ||
"options":[ | ||
"d", | ||
"h", | ||
"m", | ||
"s", | ||
"ms", | ||
"micros", | ||
"nanos" | ||
] | ||
}, | ||
"v":{ | ||
"type":"boolean", | ||
"description":"Verbose mode. Display column headers", | ||
"default":false | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.action.admin.indices.segment_replication; | ||
|
||
import org.opensearch.action.ActionType; | ||
|
||
public class SegmentReplicationAction extends ActionType<SegmentReplicationResponse> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: might need a javadoc/comment here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in latest commit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit - Naming doesn't indicate this is about stats. What about SegmentReplicationStatsAction/Response ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes SegmentReplicationStatsAction makes sense. I will update that in next commit |
||
public static final SegmentReplicationAction INSTANCE = new SegmentReplicationAction(); | ||
public static final String NAME = "indices:monitor/segment_replication"; | ||
|
||
private SegmentReplicationAction() { | ||
super(NAME, SegmentReplicationResponse::new); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.action.admin.indices.segment_replication; | ||
|
||
import org.opensearch.action.support.IndicesOptions; | ||
import org.opensearch.action.support.broadcast.BroadcastRequest; | ||
import org.opensearch.common.Strings; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
|
||
public class SegmentReplicationRequest extends BroadcastRequest<SegmentReplicationRequest> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: javadocs/comments There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in latest commit |
||
private boolean detailed = false; // Provides extra details in the response | ||
private boolean activeOnly = false; // Only reports on active recoveries | ||
|
||
/** | ||
* Constructs a request for segment replication information for all shards | ||
*/ | ||
public SegmentReplicationRequest() { | ||
this(Strings.EMPTY_ARRAY); | ||
} | ||
|
||
public SegmentReplicationRequest(StreamInput in) throws IOException { | ||
super(in); | ||
detailed = in.readBoolean(); | ||
activeOnly = in.readBoolean(); | ||
} | ||
|
||
/** | ||
* Constructs a request for segment replication information for all shards for the given indices | ||
* | ||
* @param indices Comma-separated list of indices about which to gather segment replication information | ||
*/ | ||
public SegmentReplicationRequest(String... indices) { | ||
super(indices, IndicesOptions.STRICT_EXPAND_OPEN_CLOSED); | ||
} | ||
|
||
/** | ||
* True if detailed flag is set, false otherwise. This value if false by default. | ||
* | ||
* @return True if detailed flag is set, false otherwise | ||
*/ | ||
public boolean detailed() { | ||
return detailed; | ||
} | ||
|
||
/** | ||
* Set value of the detailed flag. Detailed requests will contain extra | ||
* information. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be more helpful to mention exactly what this detailed information will be. Could be included in the help message for detailed flag. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure I have added that in latest commit, detailed information will be timing metric of each stage of segment replication event. Sure, I will try to add this in help message in next commit |
||
* | ||
* @param detailed Whether or not to set the detailed flag | ||
*/ | ||
public void detailed(boolean detailed) { | ||
this.detailed = detailed; | ||
} | ||
|
||
/** | ||
* True if activeOnly flag is set, false otherwise. This value is false by default. | ||
* | ||
* @return True if activeOnly flag is set, false otherwise | ||
*/ | ||
public boolean activeOnly() { | ||
return activeOnly; | ||
} | ||
|
||
/** | ||
* Set value of the activeOnly flag. If true, this request will only response with | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: *respond with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in latest commit |
||
* on-going recovery information. | ||
* | ||
* @param activeOnly Whether or not to set the activeOnly flag. | ||
*/ | ||
public void activeOnly(boolean activeOnly) { | ||
this.activeOnly = activeOnly; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeBoolean(detailed); | ||
out.writeBoolean(activeOnly); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.action.admin.indices.segment_replication; | ||
|
||
import org.opensearch.action.support.broadcast.BroadcastOperationRequestBuilder; | ||
import org.opensearch.client.OpenSearchClient; | ||
|
||
public class SegmentReplicationRequestBuilder extends BroadcastOperationRequestBuilder< | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think some javadocs/comments might be useful here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in latest commit |
||
SegmentReplicationRequest, | ||
SegmentReplicationResponse, | ||
SegmentReplicationRequestBuilder> { | ||
|
||
public SegmentReplicationRequestBuilder(OpenSearchClient client, SegmentReplicationAction action) { | ||
super(client, action, new SegmentReplicationRequest()); | ||
} | ||
|
||
public SegmentReplicationRequestBuilder setDetailed(boolean detailed) { | ||
request.detailed(detailed); | ||
return this; | ||
} | ||
|
||
public SegmentReplicationRequestBuilder setActiveOnly(boolean activeOnly) { | ||
request.activeOnly(activeOnly); | ||
return 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.
We should not be including any further links to elasticsearch documentation anymore. This should be redirected to opensearch documentation and if not present, can open an issue in opensearch-project/documentation-website to create the 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.
Thanks @Poojita-Raj for catching this, yes you are right. I have temporarily added url of opensearch documentation for cat recovery API, I will update this once I open an issue with opensearch-project/documentation-website