-
Notifications
You must be signed in to change notification settings - Fork 1.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
Implementing pagination for _cat/indices API #14718
Open
gargharsh3134
wants to merge
9
commits into
opensearch-project:main
Choose a base branch
from
gargharsh3134:catIndicesPaginationPR
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,249
−230
Open
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0cfb0e9
Implementing pagination for _cat/indices
d665722
Adding RestIndicesListAction along with RestListAction changes
60eefd6
Combining the doList and doCat methods and adding UTs
2bc80f0
Merge branch 'main' into catIndicesPaginationPR
f1b5016
Added paginated query request and response classes and removed page t…
0621975
Removing queryStartTime from IndexStrategyToken
3bedc82
Refactoring strategy to simplify generating list of requested indices
9aebdce
Adding AbstractListAction and renaming pagination related classes
8a39c52
Merge branch 'main' into catIndicesPaginationPR
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,11 +40,13 @@ | |
import org.opensearch.rest.BaseRestHandler; | ||
import org.opensearch.rest.BytesRestResponse; | ||
import org.opensearch.rest.RestRequest; | ||
import org.opensearch.rest.pagination.PaginatedQueryRequest; | ||
|
||
import java.io.IOException; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
import static org.opensearch.rest.action.cat.RestTable.buildHelpWidths; | ||
|
@@ -57,9 +59,11 @@ | |
*/ | ||
public abstract class AbstractCatAction extends BaseRestHandler { | ||
|
||
protected PaginatedQueryRequest paginatedQueryRequest; | ||
|
||
protected abstract RestChannelConsumer doCatRequest(RestRequest request, NodeClient client); | ||
|
||
protected abstract void documentation(StringBuilder sb); | ||
public abstract void documentation(StringBuilder sb); | ||
|
||
protected abstract Table getTableWithHeader(RestRequest request); | ||
|
||
|
@@ -85,6 +89,10 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC | |
channel.sendResponse(new BytesRestResponse(RestStatus.OK, BytesRestResponse.TEXT_CONTENT_TYPE, bytesOutput.bytes())); | ||
}; | ||
} else { | ||
if (isActionPaginated()) { | ||
this.paginatedQueryRequest = validateAndGetPaginationMetadata(request); | ||
assert Objects.nonNull(paginatedQueryRequest) : "paginatedQueryRequest can not be null for paginated queries"; | ||
} | ||
return doCatRequest(request, client); | ||
} | ||
} | ||
|
@@ -98,4 +106,23 @@ protected Set<String> responseParams() { | |
return RESPONSE_PARAMS; | ||
} | ||
|
||
/** | ||
* | ||
* @return boolean denoting whether the RestAction will output paginated responses or not. | ||
* Is kept false by default, every paginated action to override and return true. | ||
*/ | ||
public boolean isActionPaginated() { | ||
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. would it make sense to add AbstractListAction instead of adding in AbstractCatAction as list are separate APIs anyway. 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. Updated in the revision. |
||
return false; | ||
} | ||
|
||
/** | ||
* | ||
* @return Metadata that can be extracted out from the rest request. Each paginated action to override and provide | ||
* its own implementation. Query params supported by the action specific to pagination along with the respective validations, | ||
* should be added here. | ||
*/ | ||
protected PaginatedQueryRequest validateAndGetPaginationMetadata(RestRequest restRequest) { | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 do we want to change AbstractCatAction at all? we can keep the changes in AbstractListAction?
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.
Added AbstractListAction which is now extending AbstractCatAction as discussed, please see if it resolves the concern now.