-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add changes to block calls in cat shards, indices and segments based on dynamic limit settings #15986
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
Merged
shwetathareja
merged 12 commits into
opensearch-project:main
from
sumitasr:draft_changes_15954
Oct 3, 2024
Merged
Add changes to block calls in cat shards, indices and segments based on dynamic limit settings #15986
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
454e2dd
Add changes to block calls in cat shards, indices and segments based …
sumitasr 399fb59
Fail fast during catShardsLimit check in cat shards action run
sumitasr 7a7ae4b
Merge remote-tracking branch 'origin/main' into draft_changes_15954
sumitasr 66c962b
Merge branch 'main' into draft_changes_15954
sumitasr ab80b7f
Refactor code to handle review comments and introduce new exception
sumitasr 773fd8b
Merge branch 'main' into draft_changes_15954
sumitasr 3e7bca2
Remove unncessary debug statement and fix exception registeration
sumitasr 23b9c64
Merge branch 'main' into draft_changes_15954
sumitasr ed9d8c6
Refactor code, rebase with pagination PR merge and add relevant changes
sumitasr 4e732b1
Modify exception message values and add unit tests
sumitasr 09492e1
Fix Forbidden annotation use: org.junit.Test
sumitasr ad61a43
Merge branch 'main' into draft_changes_15954
sumitasr 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
66 changes: 66 additions & 0 deletions
66
server/src/main/java/org/opensearch/common/breaker/ResponseLimitBreachedException.java
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* 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.common.breaker; | ||
|
||
import org.opensearch.OpenSearchException; | ||
import org.opensearch.core.common.io.stream.StreamInput; | ||
import org.opensearch.core.common.io.stream.StreamOutput; | ||
import org.opensearch.core.rest.RestStatus; | ||
import org.opensearch.core.xcontent.XContentBuilder; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Thrown when api response breaches threshold limit. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class ResponseLimitBreachedException extends OpenSearchException { | ||
|
||
private final int responseLimit; | ||
private final ResponseLimitSettings.LimitEntity limitEntity; | ||
|
||
public ResponseLimitBreachedException(StreamInput in) throws IOException { | ||
super(in); | ||
responseLimit = in.readVInt(); | ||
limitEntity = in.readEnum(ResponseLimitSettings.LimitEntity.class); | ||
} | ||
|
||
public ResponseLimitBreachedException(String msg, int responseLimit, ResponseLimitSettings.LimitEntity limitEntity) { | ||
super(msg); | ||
this.responseLimit = responseLimit; | ||
this.limitEntity = limitEntity; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeVInt(responseLimit); | ||
out.writeEnum(limitEntity); | ||
} | ||
|
||
public int getResponseLimit() { | ||
return responseLimit; | ||
} | ||
|
||
public ResponseLimitSettings.LimitEntity getLimitEntity() { | ||
return limitEntity; | ||
} | ||
|
||
@Override | ||
public RestStatus status() { | ||
return RestStatus.TOO_MANY_REQUESTS; | ||
} | ||
|
||
@Override | ||
protected void metadataToXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.field("response_limit", responseLimit); | ||
builder.field("limit_entity", limitEntity); | ||
} | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.