Skip to content

Create pit service layer changes#3921

Merged
Bukhtawar merged 7 commits intoopensearch-project:mainfrom
bharath-techie:createpitservice
Jul 19, 2022
Merged

Create pit service layer changes#3921
Bukhtawar merged 7 commits intoopensearch-project:mainfrom
bharath-techie:createpitservice

Conversation

@bharath-techie
Copy link
Copy Markdown
Contributor

@bharath-techie bharath-techie commented Jul 15, 2022

Signed-off-by: Bharathwaj G bharath78910@gmail.com

Description

Create point in time changes - merging the service layer changes as part of this PR and Rest changes will come in as part of separate PR.

Reference PR - Already reviewed create PIT API PR in feature branch -> #2745

Issues Resolved

#1147

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jul 15, 2022

Codecov Report

❌ Patch coverage is 64.37008% with 181 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.44%. Comparing base (07775ff) to head (8067e7b).
⚠️ Report is 4768 commits behind head on main.

Files with missing lines Patch % Lines
...rg/opensearch/action/search/CreatePitResponse.java 14.14% 85 Missing ⚠️
...org/opensearch/action/search/CreatePitRequest.java 36.84% 47 Missing and 1 partial ⚠️
...earch/action/search/PitSearchContextIdForNode.java 0.00% 13 Missing ⚠️
.../opensearch/action/search/CreatePitController.java 88.37% 9 Missing and 1 partial ⚠️
...main/java/org/opensearch/search/SearchService.java 82.75% 7 Missing and 3 partials ⚠️
...pensearch/index/shard/SearchOperationListener.java 75.00% 4 Missing ⚠️
...java/org/opensearch/action/search/SearchUtils.java 50.00% 2 Missing and 1 partial ⚠️
.../org/opensearch/client/support/AbstractClient.java 0.00% 2 Missing ⚠️
.../main/java/org/opensearch/index/IndexSettings.java 66.66% 2 Missing ⚠️
...va/org/opensearch/search/DefaultSearchContext.java 71.42% 0 Missing and 2 partials ⚠️
... and 1 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #3921      +/-   ##
============================================
- Coverage     70.57%   70.44%   -0.14%     
+ Complexity    56679    56676       -3     
============================================
  Files          4563     4573      +10     
  Lines        272755   273255     +500     
  Branches      40040    40076      +36     
============================================
- Hits         192505   192500       -5     
- Misses        64014    64469     +455     
- Partials      16236    16286      +50     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bharath-techie bharath-techie marked this pull request as ready for review July 15, 2022 12:03
@bharath-techie bharath-techie requested review from a team and reta as code owners July 15, 2022 12:03
Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

@Bukhtawar
Copy link
Copy Markdown
Contributor

/cc: @sachinpkale for review

Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

@Bukhtawar
Copy link
Copy Markdown
Contributor

/cc : @sachinpkale for help with review

private final String clusterAlias;

SearchContextIdForNode(@Nullable String clusterAlias, String node, ShardSearchContextId searchContextId) {
public SearchContextIdForNode(@Nullable String clusterAlias, String node, ShardSearchContextId searchContextId) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it made public? All the new classes are in the same package, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed it

Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

Comment on lines +63 to +71
public CreatePitController(
CreatePitRequest request,
SearchTransportService searchTransportService,
ClusterService clusterService,
TransportSearchAction transportSearchAction,
NamedWriteableRegistry namedWriteableRegistry,
Task task,
ActionListener<CreatePitResponse> listener
) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets create a singleton CreatePitController and remove the CreatePitRequest from the constructor, it should be a part of execute request part

* This setting will help validate the max keep alive that can be set during creation or extension for a PIT reader context
*/
public static final Setting<TimeValue> MAX_PIT_KEEPALIVE_SETTING = Setting.positiveTimeSetting(
"pit.max_keep_alive",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets use point_in_time everywhere to be consistent

Comment on lines +112 to +114
protected AtomicLong getLastAccessTime() {
return lastAccessTime;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just return lastAccessTime.get() that way its immutable?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use this method to update the last access time

getLastAccessTime().updateAndGet(curr -> Math.max(curr, nowInMillis()));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a violation of the GET API

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay agreed, made the change to just update in base class.

/**
* Get connection lookup listener for list of clusters passed
*/
public static StepListener<BiFunction<String, String, DiscoveryNode>> getConnectionLookupListener(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look generic enough, espl that it is in a utility class. Can we have it return a plain ActionListener instead

@bharath-techie bharath-techie force-pushed the createpitservice branch 2 times, most recently from bf4c4ee to 6963b68 Compare July 19, 2022 06:49
@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
final StepListener<BiFunction<String, String, DiscoveryNode>> lookupListener = new StepListener<>();

if (clusters.isEmpty()) {
lookupListener.onResponse((cluster, nodeId) -> state.getNodes().get(nodeId));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my understanding what is this call supposed to do

Copy link
Copy Markdown
Contributor Author

@bharath-techie bharath-techie Jul 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this is a a predicate which will give the node info given the cluster alias and node id.

  • if clusters are empty, we will just give the node info from the current cluster state
  • otherwise we will use remote cluster service to collect nodes from all clusters mentioned and return the node based on cluster alias and node id

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But aren't we calling the onResponse instead of overriding the onResponse for the listener like

new ActionListener() {
  public void onResponse() {
  blah
 }
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is step listener, we will return the listener and the callers will do whenComplete() to perform action after the node lookup. This is technically a synchronous flow since caller will wait for whenComplete .

public method1 {
    Listener listener = getConnListener();
    listener.whenComplete(do something);
}

@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

try {
listener.onNewPitContext(readerContext);
} catch (Exception e) {
logger.warn("onNewPitContext listener failed", e);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note single listener failure will abort all other listeners as well. Is this expected?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but since we only log and not throw exception , It will not abort other listeners right?

int sliceLimit = indexService.getIndexSettings().getMaxSlicesPerPit();
int numSlices = sliceBuilder.getMax();
if (numSlices > sliceLimit) {
throw new IllegalArgumentException(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we throw OpenSearchRejectedException which should result in 429 instead of 5xx

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i checked the enum, it does show 429 but that corresponds to "too many requests", should we still go ahead ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants