-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add changes to block calls in cat shards, indices and segments based …
…on dynamic limit settings (#15986) (#16235) Signed-off-by: Sumit Bansal <[email protected]>
- Loading branch information
1 parent
b79d2cf
commit 4e5b7e5
Showing
17 changed files
with
636 additions
and
11 deletions.
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
66 changes: 66 additions & 0 deletions
66
server/src/main/java/org/opensearch/common/breaker/ResponseLimitBreachedException.java
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 |
---|---|---|
@@ -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.