-
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
Add changes to block calls in cat shards, indices and segments based on dynamic limit settings #15986
Changes from all commits
454e2dd
399fb59
7a7ae4b
66c962b
ab80b7f
773fd8b
3e7bca2
23b9c64
ed9d8c6
4e732b1
09492e1
ad61a43
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,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); | ||
} | ||
Check warning on line 33 in server/src/main/java/org/opensearch/common/breaker/ResponseLimitBreachedException.java
|
||
|
||
public ResponseLimitBreachedException(String msg, int responseLimit, ResponseLimitSettings.LimitEntity limitEntity) { | ||
super(msg); | ||
this.responseLimit = responseLimit; | ||
this.limitEntity = limitEntity; | ||
} | ||
Check warning on line 39 in server/src/main/java/org/opensearch/common/breaker/ResponseLimitBreachedException.java
|
||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeVInt(responseLimit); | ||
out.writeEnum(limitEntity); | ||
} | ||
Check warning on line 46 in server/src/main/java/org/opensearch/common/breaker/ResponseLimitBreachedException.java
|
||
|
||
public int getResponseLimit() { | ||
return responseLimit; | ||
Check warning on line 49 in server/src/main/java/org/opensearch/common/breaker/ResponseLimitBreachedException.java
|
||
} | ||
|
||
public ResponseLimitSettings.LimitEntity getLimitEntity() { | ||
return limitEntity; | ||
Check warning on line 53 in server/src/main/java/org/opensearch/common/breaker/ResponseLimitBreachedException.java
|
||
} | ||
|
||
@Override | ||
public RestStatus status() { | ||
return RestStatus.TOO_MANY_REQUESTS; | ||
Check warning on line 58 in server/src/main/java/org/opensearch/common/breaker/ResponseLimitBreachedException.java
|
||
} | ||
|
||
@Override | ||
protected void metadataToXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.field("response_limit", responseLimit); | ||
builder.field("limit_entity", limitEntity); | ||
} | ||
Check warning on line 65 in server/src/main/java/org/opensearch/common/breaker/ResponseLimitBreachedException.java
|
||
} |
Uh oh!
There was an error while loading. Please reload this page.