Skip to content

Commit 8a2afca

Browse files
author
Ajay Kumar Movva
committed
Merge branch 'main' of https://github.com/ajaymovva/OpenSearch into feature/pit_stats
Signed-off-by: Ajay Kumar Movva <[email protected]>
2 parents f46f7eb + 6f23300 commit 8a2afca

31 files changed

+808
-108
lines changed

.ci/bwcVersions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ BWC_VERSION:
4848
- "2.1.0"
4949
- "2.1.1"
5050
- "2.2.0"
51+
- "2.3.0"

buildSrc/src/main/java/org/opensearch/gradle/test/DistroTestPlugin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@
7575
import java.util.stream.Stream;
7676

7777
public class DistroTestPlugin implements Plugin<Project> {
78-
private static final String SYSTEM_JDK_VERSION = "11.0.15+10";
78+
private static final String SYSTEM_JDK_VERSION = "11.0.16+8";
7979
private static final String SYSTEM_JDK_VENDOR = "adoptium";
80-
private static final String GRADLE_JDK_VERSION = "17.0.3+7";
80+
private static final String GRADLE_JDK_VERSION = "17.0.4+8";
8181
private static final String GRADLE_JDK_VENDOR = "adoptium";
8282

8383
// all distributions used by distro tests. this is temporary until tests are per distribution

buildSrc/version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ opensearch = 3.0.0
22
lucene = 9.3.0
33

44
bundled_jdk_vendor = adoptium
5-
bundled_jdk = 17.0.3+7
5+
bundled_jdk = 17.0.4+8
66

77

88

server/src/main/java/org/opensearch/Version.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public class Version implements Comparable<Version>, ToXContentFragment {
9595
public static final Version V_2_1_0 = new Version(2010099, org.apache.lucene.util.Version.LUCENE_9_2_0);
9696
public static final Version V_2_1_1 = new Version(2010199, org.apache.lucene.util.Version.LUCENE_9_2_0);
9797
public static final Version V_2_2_0 = new Version(2020099, org.apache.lucene.util.Version.LUCENE_9_3_0);
98+
public static final Version V_2_3_0 = new Version(2030099, org.apache.lucene.util.Version.LUCENE_9_3_0);
9899
public static final Version V_3_0_0 = new Version(3000099, org.apache.lucene.util.Version.LUCENE_9_3_0);
99100
public static final Version CURRENT = V_3_0_0;
100101

server/src/main/java/org/opensearch/action/ActionModule.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,14 @@
234234
import org.opensearch.action.search.ClearScrollAction;
235235
import org.opensearch.action.search.CreatePitAction;
236236
import org.opensearch.action.search.DeletePitAction;
237+
import org.opensearch.action.search.GetAllPitsAction;
237238
import org.opensearch.action.search.MultiSearchAction;
238239
import org.opensearch.action.search.SearchAction;
239240
import org.opensearch.action.search.SearchScrollAction;
240241
import org.opensearch.action.search.TransportClearScrollAction;
241242
import org.opensearch.action.search.TransportCreatePitAction;
242243
import org.opensearch.action.search.TransportDeletePitAction;
244+
import org.opensearch.action.search.TransportGetAllPitsAction;
243245
import org.opensearch.action.search.TransportMultiSearchAction;
244246
import org.opensearch.action.search.TransportSearchAction;
245247
import org.opensearch.action.search.TransportSearchScrollAction;
@@ -663,6 +665,7 @@ public <Request extends ActionRequest, Response extends ActionResponse> void reg
663665

664666
// point in time actions
665667
actions.register(CreatePitAction.INSTANCE, TransportCreatePitAction.class);
668+
actions.register(GetAllPitsAction.INSTANCE, TransportGetAllPitsAction.class);
666669
actions.register(DeletePitAction.INSTANCE, TransportDeletePitAction.class);
667670

668671
return unmodifiableMap(actions.getRegistry());
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
/*
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* The OpenSearch Contributors require contributions made to
6+
* this file be licensed under the Apache-2.0 license or a
7+
* compatible open source license.
8+
*/
9+
10+
package org.opensearch.action.search;
11+
12+
import org.opensearch.action.support.nodes.BaseNodeRequest;
13+
import org.opensearch.common.io.stream.StreamInput;
14+
import org.opensearch.common.io.stream.StreamOutput;
15+
16+
import java.io.IOException;
17+
18+
/**
19+
* Inner node get all pits request
20+
*/
21+
public class GetAllPitNodeRequest extends BaseNodeRequest {
22+
23+
public GetAllPitNodeRequest() {
24+
super();
25+
}
26+
27+
public GetAllPitNodeRequest(StreamInput in) throws IOException {
28+
super(in);
29+
}
30+
31+
@Override
32+
public void writeTo(StreamOutput out) throws IOException {
33+
super.writeTo(out);
34+
}
35+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
/*
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* The OpenSearch Contributors require contributions made to
6+
* this file be licensed under the Apache-2.0 license or a
7+
* compatible open source license.
8+
*/
9+
10+
package org.opensearch.action.search;
11+
12+
import org.opensearch.action.support.nodes.BaseNodeResponse;
13+
import org.opensearch.cluster.node.DiscoveryNode;
14+
import org.opensearch.common.io.stream.StreamInput;
15+
import org.opensearch.common.io.stream.StreamOutput;
16+
import org.opensearch.common.xcontent.ToXContentFragment;
17+
import org.opensearch.common.xcontent.XContentBuilder;
18+
19+
import java.io.IOException;
20+
import java.util.Collections;
21+
import java.util.List;
22+
23+
/**
24+
* Inner node get all pits response
25+
*/
26+
public class GetAllPitNodeResponse extends BaseNodeResponse implements ToXContentFragment {
27+
28+
/**
29+
* List of active PITs in the associated node
30+
*/
31+
private final List<ListPitInfo> pitInfos;
32+
33+
public GetAllPitNodeResponse(DiscoveryNode node, List<ListPitInfo> pitInfos) {
34+
super(node);
35+
if (pitInfos == null) {
36+
throw new IllegalArgumentException("Pits info cannot be null");
37+
}
38+
this.pitInfos = Collections.unmodifiableList(pitInfos);
39+
}
40+
41+
public GetAllPitNodeResponse(StreamInput in) throws IOException {
42+
super(in);
43+
this.pitInfos = Collections.unmodifiableList(in.readList(ListPitInfo::new));
44+
}
45+
46+
public List<ListPitInfo> getPitInfos() {
47+
return pitInfos;
48+
}
49+
50+
@Override
51+
public void writeTo(StreamOutput out) throws IOException {
52+
super.writeTo(out);
53+
out.writeList(pitInfos);
54+
}
55+
56+
@Override
57+
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
58+
builder.startObject();
59+
builder.field("node", this.getNode().getName());
60+
builder.startArray("pitInfos");
61+
for (ListPitInfo pit : pitInfos) {
62+
pit.toXContent(builder, params);
63+
}
64+
65+
builder.endArray();
66+
builder.endObject();
67+
return builder;
68+
}
69+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
package org.opensearch.action.search;
10+
11+
import org.opensearch.action.support.nodes.BaseNodesRequest;
12+
import org.opensearch.cluster.node.DiscoveryNode;
13+
import org.opensearch.common.inject.Inject;
14+
import org.opensearch.common.io.stream.StreamInput;
15+
import org.opensearch.common.io.stream.StreamOutput;
16+
17+
import java.io.IOException;
18+
19+
/**
20+
* Request to get all active PIT IDs from all nodes of cluster
21+
*/
22+
public class GetAllPitNodesRequest extends BaseNodesRequest<GetAllPitNodesRequest> {
23+
24+
@Inject
25+
public GetAllPitNodesRequest(DiscoveryNode... concreteNodes) {
26+
super(concreteNodes);
27+
}
28+
29+
public GetAllPitNodesRequest(StreamInput in) throws IOException {
30+
super(in);
31+
}
32+
33+
@Override
34+
public void writeTo(StreamOutput out) throws IOException {
35+
super.writeTo(out);
36+
}
37+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
package org.opensearch.action.search;
10+
11+
import org.opensearch.action.FailedNodeException;
12+
import org.opensearch.action.support.nodes.BaseNodesResponse;
13+
import org.opensearch.cluster.ClusterName;
14+
import org.opensearch.common.io.stream.StreamInput;
15+
import org.opensearch.common.io.stream.StreamOutput;
16+
import org.opensearch.common.xcontent.ToXContentObject;
17+
import org.opensearch.common.xcontent.XContentBuilder;
18+
19+
import java.io.IOException;
20+
import java.util.ArrayList;
21+
import java.util.Collections;
22+
import java.util.HashSet;
23+
import java.util.List;
24+
import java.util.Set;
25+
import java.util.stream.Collectors;
26+
27+
/**
28+
* This class transforms active PIT objects from all nodes to unique PIT objects
29+
*/
30+
public class GetAllPitNodesResponse extends BaseNodesResponse<GetAllPitNodeResponse> implements ToXContentObject {
31+
32+
/**
33+
* List of unique PITs across all nodes
34+
*/
35+
private final Set<ListPitInfo> pitInfos = new HashSet<>();
36+
37+
public GetAllPitNodesResponse(StreamInput in) throws IOException {
38+
super(in);
39+
}
40+
41+
public GetAllPitNodesResponse(
42+
ClusterName clusterName,
43+
List<GetAllPitNodeResponse> getAllPitNodeResponse,
44+
List<FailedNodeException> failures
45+
) {
46+
super(clusterName, getAllPitNodeResponse, failures);
47+
Set<String> uniquePitIds = new HashSet<>();
48+
pitInfos.addAll(
49+
getAllPitNodeResponse.stream()
50+
.flatMap(p -> p.getPitInfos().stream().filter(t -> uniquePitIds.add(t.getPitId())))
51+
.collect(Collectors.toList())
52+
);
53+
}
54+
55+
@Override
56+
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
57+
builder.startObject();
58+
builder.startArray("pitInfos");
59+
for (ListPitInfo pit : pitInfos) {
60+
pit.toXContent(builder, params);
61+
}
62+
builder.endArray();
63+
builder.endObject();
64+
return builder;
65+
}
66+
67+
@Override
68+
public List<GetAllPitNodeResponse> readNodesFrom(StreamInput in) throws IOException {
69+
return in.readList(GetAllPitNodeResponse::new);
70+
}
71+
72+
@Override
73+
public void writeNodesTo(StreamOutput out, List<GetAllPitNodeResponse> nodes) throws IOException {
74+
out.writeList(nodes);
75+
}
76+
77+
public List<ListPitInfo> getPitInfos() {
78+
return Collections.unmodifiableList(new ArrayList<>(pitInfos));
79+
}
80+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
package org.opensearch.action.search;
10+
11+
import org.opensearch.action.ActionType;
12+
13+
/**
14+
* Action type for listing all PIT reader contexts
15+
*/
16+
public class GetAllPitsAction extends ActionType<GetAllPitNodesResponse> {
17+
public static final GetAllPitsAction INSTANCE = new GetAllPitsAction();
18+
public static final String NAME = "indices:data/read/point_in_time/readall";
19+
20+
private GetAllPitsAction() {
21+
super(NAME, GetAllPitNodesResponse::new);
22+
}
23+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
package org.opensearch.action.search;
10+
11+
import org.opensearch.common.io.stream.StreamInput;
12+
import org.opensearch.common.io.stream.StreamOutput;
13+
import org.opensearch.common.io.stream.Writeable;
14+
import org.opensearch.common.xcontent.ToXContentFragment;
15+
import org.opensearch.common.xcontent.XContentBuilder;
16+
17+
import java.io.IOException;
18+
19+
/**
20+
* This holds information about pit reader context such as pit id and creation time
21+
*/
22+
public class ListPitInfo implements ToXContentFragment, Writeable {
23+
private final String pitId;
24+
private final long creationTime;
25+
private final long keepAlive;
26+
27+
public ListPitInfo(String pitId, long creationTime, long keepAlive) {
28+
this.pitId = pitId;
29+
this.creationTime = creationTime;
30+
this.keepAlive = keepAlive;
31+
}
32+
33+
public ListPitInfo(StreamInput in) throws IOException {
34+
this.pitId = in.readString();
35+
this.creationTime = in.readLong();
36+
this.keepAlive = in.readLong();
37+
}
38+
39+
@Override
40+
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
41+
builder.startObject();
42+
builder.field("pitId", pitId);
43+
builder.field("creationTime", creationTime);
44+
builder.field("keepAlive", keepAlive);
45+
builder.endObject();
46+
return builder;
47+
}
48+
49+
public String getPitId() {
50+
return pitId;
51+
}
52+
53+
public long getCreationTime() {
54+
return creationTime;
55+
}
56+
57+
@Override
58+
public void writeTo(StreamOutput out) throws IOException {
59+
out.writeString(pitId);
60+
out.writeLong(creationTime);
61+
out.writeLong(keepAlive);
62+
}
63+
}

0 commit comments

Comments
 (0)