-
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 API for clearing file cache on search nodes
Signed-off-by: Kunal Kotwani <kkotwani@amazon.com>
- Loading branch information
1 parent
d984f50
commit 0664b6b
Showing
16 changed files
with
519 additions
and
1 deletion.
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
19 changes: 19 additions & 0 deletions
19
rest-api-spec/src/main/resources/rest-api-spec/api/nodes.clear_filecache.json
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,19 @@ | ||
{ | ||
"nodes.clear_filecache":{ | ||
"documentation":{ | ||
"url": "https://opensearch.org/docs/latest/opensearch/rest-api/filecache#clear", | ||
"description":"Clears all file caches for one or more search capable nodes." | ||
}, | ||
"stability":"experimental", | ||
"url":{ | ||
"paths":[ | ||
{ | ||
"path":"/_filecache/clear", | ||
"methods":[ | ||
"POST" | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} |
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
68 changes: 68 additions & 0 deletions
68
.../org/opensearch/action/admin/cluster/node/filecache/clear/ClearNodeFileCacheResponse.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,68 @@ | ||
/* | ||
* 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.cluster.node.filecache.clear; | ||
|
||
import org.opensearch.action.support.nodes.BaseNodeResponse; | ||
import org.opensearch.cluster.node.DiscoveryNode; | ||
import org.opensearch.cluster.node.DiscoveryNodeRole; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
import org.opensearch.core.xcontent.ToXContentFragment; | ||
import org.opensearch.core.xcontent.XContentBuilder; | ||
|
||
import java.io.IOException; | ||
|
||
public class ClearNodeFileCacheResponse extends BaseNodeResponse implements ToXContentFragment { | ||
|
||
boolean cleared; | ||
|
||
long count; | ||
|
||
protected ClearNodeFileCacheResponse(StreamInput in) throws IOException { | ||
super(in); | ||
cleared = in.readBoolean(); | ||
count = in.readLong(); | ||
} | ||
|
||
public ClearNodeFileCacheResponse(DiscoveryNode discoveryNode, boolean cleared, long count) { | ||
super(discoveryNode); | ||
this.cleared = cleared; | ||
this.count = count; | ||
} | ||
|
||
public boolean isCleared() { | ||
return cleared; | ||
} | ||
|
||
public long getCount() { | ||
return count; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeBoolean(cleared); | ||
out.writeLong(count); | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.field("name", getNode().getName()); | ||
|
||
builder.startArray("roles"); | ||
for (DiscoveryNodeRole role : getNode().getRoles()) { | ||
builder.value(role.roleName()); | ||
} | ||
builder.endArray(); | ||
|
||
builder.field("cleared", cleared); | ||
builder.field("item_count", count); | ||
return builder; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...a/org/opensearch/action/admin/cluster/node/filecache/clear/ClearNodesFileCacheAction.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,26 @@ | ||
/* | ||
* 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.cluster.node.filecache.clear; | ||
|
||
import org.opensearch.action.ActionType; | ||
|
||
/** | ||
* Transport action for clearing filecache on nodes | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class ClearNodesFileCacheAction extends ActionType<ClearNodesFileCacheResponse> { | ||
|
||
public static final ClearNodesFileCacheAction INSTANCE = new ClearNodesFileCacheAction(); | ||
public static final String NAME = "cluster:admin/nodes/filecache/clear"; | ||
|
||
private ClearNodesFileCacheAction() { | ||
super(NAME, ClearNodesFileCacheResponse::new); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
.../org/opensearch/action/admin/cluster/node/filecache/clear/ClearNodesFileCacheRequest.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,36 @@ | ||
/* | ||
* 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.cluster.node.filecache.clear; | ||
|
||
import org.opensearch.action.support.nodes.BaseNodesRequest; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Request object for clearing filecache on nodes | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class ClearNodesFileCacheRequest extends BaseNodesRequest<ClearNodesFileCacheRequest> { | ||
|
||
public ClearNodesFileCacheRequest() { | ||
super((String[]) null); | ||
} | ||
|
||
public ClearNodesFileCacheRequest(StreamInput in) throws IOException { | ||
super(in); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
...org/opensearch/action/admin/cluster/node/filecache/clear/ClearNodesFileCacheResponse.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,63 @@ | ||
/* | ||
* 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.cluster.node.filecache.clear; | ||
|
||
import org.opensearch.action.FailedNodeException; | ||
import org.opensearch.action.support.nodes.BaseNodesResponse; | ||
import org.opensearch.cluster.ClusterName; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
import org.opensearch.core.xcontent.ToXContentFragment; | ||
import org.opensearch.core.xcontent.XContentBuilder; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
/** | ||
* The response of a clear filecache action. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class ClearNodesFileCacheResponse extends BaseNodesResponse<ClearNodeFileCacheResponse> implements ToXContentFragment { | ||
|
||
ClearNodesFileCacheResponse(StreamInput in) throws IOException { | ||
super(in); | ||
} | ||
|
||
ClearNodesFileCacheResponse( | ||
ClusterName clusterName, | ||
List<ClearNodeFileCacheResponse> clearNodeFileCachResponses, | ||
List<FailedNodeException> failures | ||
) { | ||
super(clusterName, clearNodeFileCachResponses, failures); | ||
} | ||
|
||
@Override | ||
protected List<ClearNodeFileCacheResponse> readNodesFrom(StreamInput in) throws IOException { | ||
return in.readList(ClearNodeFileCacheResponse::new); | ||
} | ||
|
||
@Override | ||
protected void writeNodesTo(StreamOutput out, List<ClearNodeFileCacheResponse> clearNodeFileCacheResponse) throws IOException { | ||
out.writeList(clearNodeFileCacheResponse); | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject("nodes"); | ||
for (ClearNodeFileCacheResponse clearNodeFileCacheResponse : getNodes()) { | ||
builder.startObject(clearNodeFileCacheResponse.getNode().getId()); | ||
clearNodeFileCacheResponse.toXContent(builder, params); | ||
builder.endObject(); | ||
} | ||
builder.endObject(); | ||
|
||
return builder; | ||
} | ||
} |
Oops, something went wrong.