Skip to content
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 service layer changes #3921

Merged
merged 7 commits into from
Jul 19, 2022

Conversation

bharath-techie
Copy link
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
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@codecov-commenter
Copy link

codecov-commenter commented Jul 15, 2022

Codecov Report

Merging #3921 (5d8ec6b) into main (07775ff) will increase coverage by 0.13%.
The diff coverage is 64.44%.

@@             Coverage Diff              @@
##               main    #3921      +/-   ##
============================================
+ Coverage     70.57%   70.70%   +0.13%     
- Complexity    56679    56892     +213     
============================================
  Files          4563     4573      +10     
  Lines        272755   273256     +501     
  Branches      40040    40076      +36     
============================================
+ Hits         192505   193219     +714     
+ Misses        64014    63800     -214     
- Partials      16236    16237       +1     
Impacted Files Coverage Δ
...ark/time/NanoTimeVsCurrentTimeMillisBenchmark.java 0.00% <ø> (ø)
...a/org/opensearch/painless/antlr/PainlessLexer.java 68.18% <ø> (ø)
.../org/opensearch/painless/antlr/PainlessParser.java 68.43% <ø> (ø)
...earch/action/search/PitSearchContextIdForNode.java 0.00% <0.00%> (ø)
...ensearch/action/search/SearchContextIdForNode.java 94.44% <ø> (ø)
...er/src/main/java/org/opensearch/client/Client.java 40.00% <ø> (ø)
.../org/opensearch/client/support/AbstractClient.java 35.21% <0.00%> (+0.07%) ⬆️
...rg/opensearch/common/settings/ClusterSettings.java 91.89% <ø> (ø)
...pensearch/common/settings/IndexScopedSettings.java 100.00% <ø> (ø)
...rg/opensearch/action/search/CreatePitResponse.java 14.14% <14.14%> (ø)
... and 517 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6d7a152...5d8ec6b. Read the comment docs.

@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
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@Bukhtawar
Copy link
Collaborator

/cc: @sachinpkale for review

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

Gradle Check (Jenkins) Run Completed with:

@Bukhtawar
Copy link
Collaborator

/cc : @sachinpkale for help with review

@@ -50,7 +50,7 @@ public final class SearchContextIdForNode implements Writeable {
private final ShardSearchContextId searchContextId;
private final String clusterAlias;

SearchContextIdForNode(@Nullable String clusterAlias, String node, ShardSearchContextId searchContextId) {
public SearchContextIdForNode(@Nullable String clusterAlias, String node, ShardSearchContextId searchContextId) {
Copy link
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
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
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
@github-actions
Copy link
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
Collaborator

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
Collaborator

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
Collaborator

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
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
Collaborator

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
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
Collaborator

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
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
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
Collaborator

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
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
Collaborator

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
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
Contributor

Gradle Check (Jenkins) Run Completed with:

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

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
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
Collaborator

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
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
Collaborator

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
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
@github-actions
Copy link
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