-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create PIT API #2745
Merged
Bukhtawar
merged 29 commits into
opensearch-project:feature/point_in_time
from
bharath-techie:createpit
May 19, 2022
Merged
Create PIT API #2745
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
469738f
create pit changes
bharath-techie 0d1f337
Merge branch 'main' of https://github.com/opensearch-project/OpenSear…
bharath-techie 751c320
two phase create pit
bharath-techie eba05e5
Adding unit tests
bharath-techie 130a597
addressing review comments
bharath-techie c6f9398
Merge branch 'main' of https://github.com/opensearch-project/OpenSear…
bharath-techie 87ec605
fixing ci, adding tests and java docs
bharath-techie f8f6367
Segregating create pit logic into separate controller
bharath-techie 0fcd1df
Adding cleanup logic if create pit fails
bharath-techie 3002c20
Merge branch 'opensearch-project:main' into createpit
bharath-techie 1f6f466
Addressing comments
bharath-techie de5c4e4
Merge branch 'createpit' of github.com:bharath-techie/OpenSearch into…
bharath-techie 3359986
Addressing review comments
bharath-techie 232179e
Merge branch 'main' of https://github.com/opensearch-project/OpenSear…
bharath-techie 730afa8
Adding java docs
bharath-techie 4747018
Addressing comments and making pit naming uniform
bharath-techie 7340feb
Changes to include rest high level client tests and addressing comments
bharath-techie eec2480
Addressing comments
bharath-techie b87f0fd
Merge branch 'main' of https://github.com/opensearch-project/OpenSear…
bharath-techie 939fafc
Addressing comments
bharath-techie 02c7537
Addressing comments
bharath-techie c6cef2b
Addressing comments
bharath-techie bd0105c
addressing comments
bharath-techie 35d8cc4
addressing comments
bharath-techie 11c5195
addressing comments
bharath-techie 471a64a
addressing comments
bharath-techie 47bb3e7
Merge branch 'main' of https://github.com/opensearch-project/OpenSear…
bharath-techie c28762e
fixing broken tests
bharath-techie f272405
Merge branch 'main' of https://github.com/opensearch-project/OpenSear…
bharath-techie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
58 changes: 58 additions & 0 deletions
58
client/rest-high-level/src/test/java/org/opensearch/client/PitIT.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,58 @@ | ||
/* | ||
* 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.client; | ||
|
||
import org.apache.http.client.methods.HttpPost; | ||
import org.apache.http.client.methods.HttpPut; | ||
import org.junit.Before; | ||
import org.opensearch.action.search.CreatePitRequest; | ||
import org.opensearch.action.search.CreatePitResponse; | ||
import org.opensearch.common.unit.TimeValue; | ||
|
||
import java.io.IOException; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
/** | ||
* Tests point in time API with rest high level client | ||
*/ | ||
public class PitIT extends OpenSearchRestHighLevelClientTestCase { | ||
|
||
@Before | ||
public void indexDocuments() throws IOException { | ||
Request doc1 = new Request(HttpPut.METHOD_NAME, "/index/_doc/1"); | ||
doc1.setJsonEntity("{\"type\":\"type1\", \"id\":1, \"num\":10, \"num2\":50}"); | ||
client().performRequest(doc1); | ||
Request doc2 = new Request(HttpPut.METHOD_NAME, "/index/_doc/2"); | ||
doc2.setJsonEntity("{\"type\":\"type1\", \"id\":2, \"num\":20, \"num2\":40}"); | ||
client().performRequest(doc2); | ||
Request doc3 = new Request(HttpPut.METHOD_NAME, "/index/_doc/3"); | ||
doc3.setJsonEntity("{\"type\":\"type1\", \"id\":3, \"num\":50, \"num2\":35}"); | ||
client().performRequest(doc3); | ||
Request doc4 = new Request(HttpPut.METHOD_NAME, "/index/_doc/4"); | ||
doc4.setJsonEntity("{\"type\":\"type2\", \"id\":4, \"num\":100, \"num2\":10}"); | ||
client().performRequest(doc4); | ||
Request doc5 = new Request(HttpPut.METHOD_NAME, "/index/_doc/5"); | ||
doc5.setJsonEntity("{\"type\":\"type2\", \"id\":5, \"num\":100, \"num2\":10}"); | ||
client().performRequest(doc5); | ||
client().performRequest(new Request(HttpPost.METHOD_NAME, "/_refresh")); | ||
} | ||
|
||
public void testCreatePit() throws IOException { | ||
CreatePitRequest pitRequest = new CreatePitRequest(new TimeValue(1, TimeUnit.DAYS), true, "index"); | ||
CreatePitResponse pitResponse = execute(pitRequest, highLevelClient()::createPit, highLevelClient()::createPitAsync); | ||
assertTrue(pitResponse.getId() != null); | ||
assertEquals(1, pitResponse.getTotalShards()); | ||
assertEquals(1, pitResponse.getSuccessfulShards()); | ||
assertEquals(0, pitResponse.getFailedShards()); | ||
assertEquals(0, pitResponse.getSkippedShards()); | ||
} | ||
/** | ||
* Todo: add deletion logic and test cluster settings | ||
*/ | ||
} |
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
43 changes: 43 additions & 0 deletions
43
rest-api-spec/src/main/resources/rest-api-spec/api/create_pit.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,43 @@ | ||
{ | ||
"create_pit":{ | ||
"documentation":{ | ||
"url":"https://opensearch.org/docs/latest/opensearch/rest-api/point_in_time/", | ||
"description":"Creates point in time context." | ||
}, | ||
"stability":"stable", | ||
"url":{ | ||
"paths":[ | ||
{ | ||
"path":"/{index}/_search/point_in_time", | ||
"methods":[ | ||
"POST" | ||
], | ||
"parts":{ | ||
"index":{ | ||
"type":"list", | ||
"description":"A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"params":{ | ||
"allow_partial_pit_creation":{ | ||
"type":"boolean", | ||
"description":"Allow if point in time can be created with partial failures" | ||
}, | ||
"keep_alive":{ | ||
"type":"string", | ||
"description":"Specify the keep alive for point in time" | ||
}, | ||
"preference":{ | ||
"type":"string", | ||
"description":"Specify the node or shard the operation should be performed on (default: random)" | ||
}, | ||
"routing":{ | ||
"type":"list", | ||
"description":"A comma-separated list of specific routing values" | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API response says cancellable, can this be cancelled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The perform request async flow does support cancelling the operation.