forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Bharathwaj G <[email protected]>
- Loading branch information
1 parent
0b3a32c
commit 4d8345e
Showing
11 changed files
with
550 additions
and
40 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
36 changes: 35 additions & 1 deletion
36
server/src/main/java/org/opensearch/action/search/GetAllPitNodeRequest.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 |
---|---|---|
@@ -1,2 +1,36 @@ | ||
package org.opensearch.action.search;public class GetAllPitNodeRequest { | ||
/* | ||
* 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.search; | ||
|
||
import org.opensearch.action.support.nodes.BaseNodeRequest; | ||
import org.opensearch.common.inject.Inject; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
|
||
public class GetAllPitNodeRequest extends BaseNodeRequest { | ||
GetAllPitNodesRequest request; | ||
|
||
@Inject | ||
public GetAllPitNodeRequest(GetAllPitNodesRequest request) { | ||
this.request = request; | ||
} | ||
|
||
public GetAllPitNodeRequest(StreamInput in) throws IOException { | ||
super(in); | ||
request = new GetAllPitNodesRequest(in); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
request.writeTo(out); | ||
} | ||
} |
68 changes: 67 additions & 1 deletion
68
server/src/main/java/org/opensearch/action/search/GetAllPitNodeResponse.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 |
---|---|---|
@@ -1,2 +1,68 @@ | ||
package org.opensearch.action.search;public class GetAllPitNodeResponse { | ||
/* | ||
* 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.search; | ||
|
||
import org.opensearch.action.support.nodes.BaseNodeResponse; | ||
import org.opensearch.cluster.node.DiscoveryNode; | ||
import org.opensearch.common.inject.Inject; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
import org.opensearch.common.xcontent.ToXContentFragment; | ||
import org.opensearch.common.xcontent.XContentBuilder; | ||
|
||
import java.io.IOException; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
/** | ||
* Response which holds information about all PIT contexts in a node | ||
*/ | ||
public class GetAllPitNodeResponse extends BaseNodeResponse implements ToXContentFragment { | ||
|
||
private List<ListPitInfo> pitsInfo; | ||
|
||
@Inject | ||
public GetAllPitNodeResponse(StreamInput in, List<ListPitInfo> pitsInfo) throws IOException { | ||
super(in); | ||
this.pitsInfo = pitsInfo; | ||
} | ||
|
||
public GetAllPitNodeResponse(DiscoveryNode node, List<ListPitInfo> pitsInfo) { | ||
super(node); | ||
this.pitsInfo = pitsInfo; | ||
} | ||
|
||
public GetAllPitNodeResponse(StreamInput in) throws IOException { | ||
super(in); | ||
this.pitsInfo = Collections.unmodifiableList(in.readList(ListPitInfo::new)); | ||
} | ||
|
||
public List<ListPitInfo> getPitsInfo() { | ||
return pitsInfo; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeList(pitsInfo); | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(); | ||
builder.startArray("pitsInfo"); | ||
for (ListPitInfo pit : pitsInfo) { | ||
pit.toXContent(builder, params); | ||
} | ||
builder.endArray(); | ||
builder.endObject(); | ||
return builder; | ||
} | ||
|
||
} |
36 changes: 35 additions & 1 deletion
36
server/src/main/java/org/opensearch/action/search/GetAllPitNodesRequest.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 |
---|---|---|
@@ -1,2 +1,36 @@ | ||
package org.opensearch.action.search;public class GetAllPitNodesRequest { | ||
/* | ||
* 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.search; | ||
|
||
import org.opensearch.action.support.nodes.BaseNodesRequest; | ||
import org.opensearch.cluster.node.DiscoveryNode; | ||
import org.opensearch.common.inject.Inject; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Request to get all active PIT IDs in set of nodes | ||
*/ | ||
public class GetAllPitNodesRequest extends BaseNodesRequest<GetAllPitNodesRequest> { | ||
@Inject | ||
public GetAllPitNodesRequest(DiscoveryNode... concreteNodes) { | ||
super(concreteNodes); | ||
} | ||
|
||
public GetAllPitNodesRequest(StreamInput in) throws IOException { | ||
super(in); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
} | ||
} |
74 changes: 73 additions & 1 deletion
74
server/src/main/java/org/opensearch/action/search/GetAllPitNodesResponse.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 |
---|---|---|
@@ -1,2 +1,74 @@ | ||
package org.opensearch.action.search;public class GetAllPitNodesResponse { | ||
/* | ||
* 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.search; | ||
|
||
import org.opensearch.action.FailedNodeException; | ||
import org.opensearch.action.support.nodes.BaseNodesResponse; | ||
import org.opensearch.cluster.ClusterName; | ||
import org.opensearch.common.inject.Inject; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
import org.opensearch.common.xcontent.ToXContentObject; | ||
import org.opensearch.common.xcontent.XContentBuilder; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
public class GetAllPitNodesResponse extends BaseNodesResponse<GetAllPitNodeResponse> implements ToXContentObject { | ||
List<ListPitInfo> pitsInfo = new ArrayList<>(); | ||
|
||
@Inject | ||
public GetAllPitNodesResponse(StreamInput in) throws IOException { | ||
super(in); | ||
} | ||
|
||
public GetAllPitNodesResponse( | ||
ClusterName clusterName, | ||
List<GetAllPitNodeResponse> getAllPitNodeRespons, | ||
List<FailedNodeException> failures | ||
) { | ||
super(clusterName, getAllPitNodeRespons, failures); | ||
Set<String> uniquePitIds = new HashSet<>(); | ||
pitsInfo.addAll( | ||
getAllPitNodeRespons.stream() | ||
.flatMap(p -> p.getPitsInfo().stream().filter(t -> uniquePitIds.add(t.getPitId()))) | ||
.collect(Collectors.toList()) | ||
); | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(); | ||
builder.startArray("pitsInfo"); | ||
for (ListPitInfo pit : pitsInfo) { | ||
pit.toXContent(builder, params); | ||
} | ||
builder.endArray(); | ||
builder.endObject(); | ||
return builder; | ||
} | ||
|
||
@Override | ||
public List<GetAllPitNodeResponse> readNodesFrom(StreamInput in) throws IOException { | ||
return in.readList(GetAllPitNodeResponse::new); | ||
} | ||
|
||
@Override | ||
public void writeNodesTo(StreamOutput out, List<GetAllPitNodeResponse> nodes) throws IOException { | ||
out.writeList(nodes); | ||
} | ||
|
||
public List<ListPitInfo> getPITIDs() { | ||
return new ArrayList<>(pitsInfo); | ||
} | ||
} |
23 changes: 22 additions & 1 deletion
23
server/src/main/java/org/opensearch/action/search/GetAllPitsAction.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 |
---|---|---|
@@ -1,2 +1,23 @@ | ||
package org.opensearch.action.search;public class GetAllPitsAction { | ||
/* | ||
* 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.search; | ||
|
||
import org.opensearch.action.ActionType; | ||
|
||
/** | ||
* Action type for listing all PIT reader contexts | ||
*/ | ||
public class GetAllPitsAction extends ActionType<GetAllPitNodesResponse> { | ||
public static final GetAllPitsAction INSTANCE = new GetAllPitsAction(); | ||
public static final String NAME = "indices:data/readall/pit"; | ||
|
||
private GetAllPitsAction() { | ||
super(NAME, GetAllPitNodesResponse::new); | ||
} | ||
} |
58 changes: 57 additions & 1 deletion
58
server/src/main/java/org/opensearch/action/search/ListPitInfo.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 |
---|---|---|
@@ -1,2 +1,58 @@ | ||
package org.opensearch.action.search;public class ListPitInfo { | ||
/* | ||
* 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.search; | ||
|
||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
import org.opensearch.common.io.stream.Writeable; | ||
import org.opensearch.common.xcontent.ToXContentFragment; | ||
import org.opensearch.common.xcontent.XContentBuilder; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* This holds information about pit reader context such as pit id and creation time | ||
*/ | ||
public class ListPitInfo implements ToXContentFragment, Writeable { | ||
private final String pitId; | ||
private final long creationTime; | ||
|
||
public ListPitInfo(String pitId, long creationTime) { | ||
this.pitId = pitId; | ||
this.creationTime = creationTime; | ||
} | ||
|
||
public ListPitInfo(StreamInput in) throws IOException { | ||
this.pitId = in.readString(); | ||
this.creationTime = in.readLong(); | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(); | ||
builder.field("pitId", pitId); | ||
builder.field("creationTime", creationTime); | ||
builder.endObject(); | ||
return builder; | ||
} | ||
|
||
public String getPitId() { | ||
return pitId; | ||
} | ||
|
||
public long getCreationTime() { | ||
return creationTime; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeString(pitId); | ||
out.writeLong(creationTime); | ||
} | ||
} |
Oops, something went wrong.