Skip to content

Commit 44ee92f

Browse files
committed
update changes
1 parent 51991e0 commit 44ee92f

File tree

13 files changed

+396
-59
lines changed

13 files changed

+396
-59
lines changed

.github/workflows/gradle-check.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ jobs:
9494
### Gradle Check (Jenkins) Run Completed with:
9595
* **RESULT:** ${{ env.result }} :x:
9696
* **FAILURES:**
97+
```
9798
${{ env.test_failures }}
99+
```
98100
* **URL:** ${{ env.workflow_url }}
99101
* **CommitID:** ${{ env.pr_from_sha }}
100102
Please examine the workflow log, locate, and copy-paste the failure below, then iterate to green.

.idea/runConfigurations/Debug_OpenSearch.xml

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/rest-high-level/src/main/java/org/opensearch/client/RequestConverters.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,7 @@
5353
import org.opensearch.action.get.GetRequest;
5454
import org.opensearch.action.get.MultiGetRequest;
5555
import org.opensearch.action.index.IndexRequest;
56-
import org.opensearch.action.search.ClearScrollRequest;
57-
import org.opensearch.action.search.CreatePitRequest;
58-
import org.opensearch.action.search.DeletePitRequest;
59-
import org.opensearch.action.search.MultiSearchRequest;
60-
import org.opensearch.action.search.SearchRequest;
61-
import org.opensearch.action.search.SearchScrollRequest;
56+
import org.opensearch.action.search.*;
6257
import org.opensearch.action.support.ActiveShardCount;
6358
import org.opensearch.action.support.IndicesOptions;
6459
import org.opensearch.action.support.WriteRequest;
@@ -502,6 +497,11 @@ static Request getAllPits() {
502497
return new Request(HttpGet.METHOD_NAME, "/_search/point_in_time/_all");
503498
}
504499

500+
static Request updatePit(UpdatePitRequest updatePitRequest) throws IOException {
501+
Request request = new Request(HttpDelete.METHOD_NAME, "/_search/point_in_time");
502+
request.setEntity(createEntity(updatePitRequest, REQUEST_BODY_CONTENT_TYPE));
503+
return request;
504+
}
505505
static Request multiSearch(MultiSearchRequest multiSearchRequest) throws IOException {
506506
Request request = new Request(HttpPost.METHOD_NAME, "/_msearch");
507507

client/rest-high-level/src/main/java/org/opensearch/client/RestHighLevelClient.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,7 @@
5757
import org.opensearch.action.get.MultiGetResponse;
5858
import org.opensearch.action.index.IndexRequest;
5959
import org.opensearch.action.index.IndexResponse;
60-
import org.opensearch.action.search.ClearScrollRequest;
61-
import org.opensearch.action.search.ClearScrollResponse;
62-
import org.opensearch.action.search.CreatePitRequest;
63-
import org.opensearch.action.search.CreatePitResponse;
64-
import org.opensearch.action.search.DeletePitRequest;
65-
import org.opensearch.action.search.DeletePitResponse;
66-
import org.opensearch.action.search.GetAllPitNodesResponse;
67-
import org.opensearch.action.search.MultiSearchRequest;
68-
import org.opensearch.action.search.MultiSearchResponse;
69-
import org.opensearch.action.search.SearchRequest;
70-
import org.opensearch.action.search.SearchResponse;
71-
import org.opensearch.action.search.SearchScrollRequest;
60+
import org.opensearch.action.search.*;
7261
import org.opensearch.action.support.master.AcknowledgedResponse;
7362
import org.opensearch.action.update.UpdateRequest;
7463
import org.opensearch.action.update.UpdateResponse;
@@ -1403,6 +1392,16 @@ public final Cancellable getAllPitsAsync(RequestOptions options, ActionListener<
14031392
);
14041393
}
14051394

1395+
public final UpdatePitResponse updatePit(UpdatePitRequest updatePitRequest, RequestOptions options) throws IOException {
1396+
return performRequestAndParseEntity(
1397+
updatePitRequest,
1398+
RequestConverters::updatePit,
1399+
options,
1400+
UpdatePitResponse::fromXContent,
1401+
emptySet()
1402+
);
1403+
}
1404+
14061405
/**
14071406
* Clears one or more scroll ids using the Clear Scroll API.
14081407
*

client/rest-high-level/src/test/java/org/opensearch/client/PitIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* Tests point in time API with rest high level client
3333
*/
3434
public class PitIT extends OpenSearchRestHighLevelClientTestCase {
35-
35+
//--this is is PITIT
3636
@Before
3737
public void indexDocuments() throws IOException {
3838
Request doc1 = new Request(HttpPut.METHOD_NAME, "/index/_doc/1");

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

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -247,20 +247,7 @@
247247
import org.opensearch.action.ingest.SimulatePipelineTransportAction;
248248
import org.opensearch.action.main.MainAction;
249249
import org.opensearch.action.main.TransportMainAction;
250-
import org.opensearch.action.search.ClearScrollAction;
251-
import org.opensearch.action.search.CreatePitAction;
252-
import org.opensearch.action.search.DeletePitAction;
253-
import org.opensearch.action.search.MultiSearchAction;
254-
import org.opensearch.action.search.GetAllPitsAction;
255-
import org.opensearch.action.search.SearchAction;
256-
import org.opensearch.action.search.SearchScrollAction;
257-
import org.opensearch.action.search.TransportClearScrollAction;
258-
import org.opensearch.action.search.TransportCreatePitAction;
259-
import org.opensearch.action.search.TransportDeletePitAction;
260-
import org.opensearch.action.search.TransportGetAllPitsAction;
261-
import org.opensearch.action.search.TransportMultiSearchAction;
262-
import org.opensearch.action.search.TransportSearchAction;
263-
import org.opensearch.action.search.TransportSearchScrollAction;
250+
import org.opensearch.action.search.*;
264251
import org.opensearch.action.support.ActionFilters;
265252
import org.opensearch.action.support.AutoCreateIndex;
266253
import org.opensearch.action.support.DestructiveOperations;
@@ -699,7 +686,7 @@ public <Request extends ActionRequest, Response extends ActionResponse> void reg
699686
actions.register(DeletePitAction.INSTANCE, TransportDeletePitAction.class);
700687
actions.register(PitSegmentsAction.INSTANCE, TransportPitSegmentsAction.class);
701688
actions.register(GetAllPitsAction.INSTANCE, TransportGetAllPitsAction.class);
702-
689+
// TODO: register the api here
703690
// Remote Store
704691
actions.register(RestoreRemoteStoreAction.INSTANCE, TransportRestoreRemoteStoreAction.class);
705692

@@ -890,6 +877,7 @@ public void initRestHandlers(Supplier<DiscoveryNodes> nodesInCluster) {
890877
registerHandler.accept(new RestGetAllPitsAction(nodesInCluster));
891878
registerHandler.accept(new RestPitSegmentsAction(nodesInCluster));
892879
registerHandler.accept(new RestDeleteDecommissionStateAction());
880+
// TODO: add update api here
893881

894882
for (ActionPlugin plugin : actionPlugins) {
895883
for (RestHandler handler : plugin.getRestHandlers(
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
public class UpdatePitAction extends ActionType<UpdatePitResponse> {
14+
public static final UpdatePitAction INSTANCE = new UpdatePitAction();
15+
public static final String NAME = "indices:data/read/point_in_time/update";
16+
17+
private UpdatePitAction(){
18+
super(NAME, UpdatePitResponse::new);
19+
}
20+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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.ActionRequest;
12+
import org.opensearch.action.ActionRequestValidationException;
13+
import org.opensearch.common.io.stream.StreamInput;
14+
import org.opensearch.common.unit.TimeValue;
15+
import org.opensearch.common.xcontent.ToXContent;
16+
import org.opensearch.common.xcontent.ToXContentObject;
17+
import org.opensearch.common.xcontent.XContentBuilder;
18+
import org.opensearch.common.xcontent.XContentParser;
19+
20+
import java.io.IOException;
21+
import java.util.ArrayList;
22+
import java.util.Arrays;
23+
import java.util.List;
24+
25+
import static org.opensearch.action.ValidateActions.addValidationError;
26+
27+
public class UpdatePitRequest extends ActionRequest implements ToXContentObject {
28+
// TODO: update the pit reqyest to handle not just array
29+
private final List<UpdatePitRequestInfo> updatePitRequests;
30+
31+
public UpdatePitRequest(StreamInput in) throws IOException {
32+
super(in);
33+
int size = in.readVInt();
34+
updatePitRequests = new ArrayList<>();
35+
for(int i=0;i<size;i++){
36+
updatePitRequests.add(new UpdatePitRequestInfo(in));
37+
}
38+
}
39+
40+
public List<UpdatePitRequestInfo> getUpdatePitRequests() {
41+
return updatePitRequests;
42+
}
43+
44+
public UpdatePitRequest(UpdatePitRequestInfo... updatePitRequests){
45+
this.updatePitRequests = (Arrays.asList(updatePitRequests));
46+
}
47+
48+
public UpdatePitRequest(List<UpdatePitRequestInfo> updatePitRequests){
49+
this.updatePitRequests = updatePitRequests;
50+
}
51+
52+
public UpdatePitRequest() {}
53+
54+
55+
@Override
56+
public ActionRequestValidationException validate() {
57+
ActionRequestValidationException validationException = null;
58+
if (keepAlive == null) {
59+
validationException = addValidationError("keep alive not specified", validationException);
60+
}
61+
return validationException;
62+
}
63+
64+
@Override
65+
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
66+
builder.field("keep_alive", keepAlive);
67+
builder.field("pit_id", pit_id);
68+
return builder;
69+
}
70+
71+
public void fromXContent(XContentParser parser) throws IOException {
72+
if(parser.nextToken() != XContentParser.Token.START_OBJECT){
73+
throw new IllegalArgumentException("Malformed content, must start with an object");
74+
} else {
75+
XContentParser.Token token;
76+
String currentFieldName = null;
77+
while((token = parser.nextToken()) != XContentParser.Token.END_OBJECT){
78+
if (token == XContentParser.Token.FIELD_NAME){
79+
currentFieldName = parser.currentName();
80+
} else if("keep_alive".equals(currentFieldName)){
81+
if(token.isValue() == false){
82+
throw new IllegalArgumentException("keep_alive should only contain a time value");
83+
}
84+
keepAlive = TimeValue.parseTimeValue(parser.text(),"keep_alive");
85+
}
86+
87+
}
88+
}
89+
}
90+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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.unit.TimeValue;
14+
15+
import java.io.IOException;
16+
17+
public class UpdatePitRequestInfo {
18+
private final String pitId;
19+
private final TimeValue keepAlive;
20+
21+
public UpdatePitRequestInfo(String pitId, TimeValue keepAlive){
22+
this.pitId = pitId;
23+
this.keepAlive = keepAlive;
24+
}
25+
26+
public UpdatePitRequestInfo(StreamInput in) throws IOException {
27+
pitId = in.readString();
28+
keepAlive = in.readTimeValue();
29+
}
30+
31+
public void writeTo(StreamOutput out) throws IOException {
32+
out.writeString(pitId);
33+
out.writeTimeValue(keepAlive);
34+
}
35+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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.ActionResponse;
12+
import org.opensearch.common.ParseField;
13+
import org.opensearch.common.io.stream.StreamInput;
14+
import org.opensearch.common.io.stream.StreamOutput;
15+
import org.opensearch.common.xcontent.*;
16+
import org.opensearch.rest.RestStatus;
17+
18+
import java.io.IOException;
19+
import java.util.ArrayList;
20+
import java.util.List;
21+
22+
import static org.opensearch.common.xcontent.ConstructingObjectParser.constructorArg;
23+
import static org.opensearch.rest.RestStatus.NOT_FOUND;
24+
import static org.opensearch.rest.RestStatus.OK;
25+
26+
public class UpdatePitResponse extends ActionResponse implements StatusToXContentObject {
27+
private final List<UpdatePitResponseInfo> updatePitResults;
28+
29+
public UpdatePitResponse(List<UpdatePitResponseInfo> updatePitResults){
30+
this.updatePitResults = updatePitResults;
31+
}
32+
public UpdatePitResponse(StreamInput in) throws IOException{
33+
super(in);
34+
int size = in.readVInt();
35+
updatePitResults = new ArrayList<>();
36+
for (int i=0; i < size; i++) {
37+
updatePitResults.add(new UpdatePitResponseInfo(in));
38+
}
39+
}
40+
41+
public List<UpdatePitResponseInfo> getUpdatePitResults() {
42+
return updatePitResults;
43+
}
44+
45+
@Override
46+
public RestStatus status() {
47+
if (updatePitResults.isEmpty()) return NOT_FOUND;
48+
return OK;
49+
}
50+
51+
@Override
52+
public void writeTo(StreamOutput out) throws IOException {
53+
out.writeVInt(updatePitResults.size());
54+
for (UpdatePitResponseInfo updatePitResult : updatePitResults) {
55+
updatePitResult.writeTo(out);
56+
}
57+
}
58+
59+
@Override
60+
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
61+
builder.startObject();
62+
builder.startArray("pits");
63+
for (UpdatePitResponseInfo response: updatePitResults) {
64+
response.toXContent(builder,params);
65+
}
66+
builder.endArray();
67+
builder.endObject();
68+
return builder;
69+
}
70+
71+
private static final ConstructingObjectParser<UpdatePitResponse, Void> PARSER = new ConstructingObjectParser<>(
72+
"update_pit_response",
73+
true,
74+
(Object[] parsedObjects) -> {
75+
@SuppressWarnings("unchecked")
76+
List<UpdatePitResponseInfo> updatePitResponseInfoList = (List<UpdatePitResponseInfo>) parsedObjects[0];
77+
return new UpdatePitResponse(updatePitResponseInfoList);
78+
}
79+
);
80+
81+
static {
82+
PARSER.declareObjectArray(constructorArg(), UpdatePitResponseInfo.PARSER, new ParseField("pits"));
83+
}
84+
85+
public static UpdatePitResponse fromXContent(XContentParser parser) throws IOException {
86+
return PARSER.parse(parser, null);
87+
}
88+
}

0 commit comments

Comments
 (0)