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

New Design with createComponent extension point #8

Merged

Conversation

owaiskazi19
Copy link
Member

@owaiskazi19 owaiskazi19 commented May 9, 2022

Signed-off-by: Owais Kazi [email protected]

Description

Part of opensearch-project/OpenSearch#2981
Also, resolves #6

Note: Build will fail as this PR has dependency on opensearch-project/OpenSearch#3265.

Issues Resolved

List any issues this PR will resolve, e.g. Closes [...].

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.

@owaiskazi19 owaiskazi19 force-pushed the draft-createComponent branch from 63c65f2 to c1070df Compare May 31, 2022 18:58
@owaiskazi19 owaiskazi19 marked this pull request as ready for review May 31, 2022 21:49
@owaiskazi19 owaiskazi19 requested a review from a team May 31, 2022 21:49
@owaiskazi19 owaiskazi19 changed the title Draft createComponent extension point createComponent extension point May 31, 2022
joshpalis
joshpalis previously approved these changes Jun 1, 2022
@owaiskazi19 owaiskazi19 self-assigned this Jun 1, 2022
@owaiskazi19 owaiskazi19 changed the title createComponent extension point New Design with createComponent extension point Jun 10, 2022
@owaiskazi19 owaiskazi19 force-pushed the draft-createComponent branch from dca68bc to 102a416 Compare June 14, 2022 21:30

public class ClusterSettingResponseHandler implements TransportResponseHandler<ClusterSettingsResponse> {
private static final Logger logger = LogManager.getLogger(ClusterSettingResponseHandler.class);
final CountDownLatch inProgressLatch = new CountDownLatch(1);
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to be package private to be read outside this class? If not, it should be private (same question/comment elsewhere in this PR.)

Copy link
Member

Choose a reason for hiding this comment

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

What is the purpose of this object, it doesn't seem to be impacted flow of control? Here is a stack overflow answer about CountDownLatch's usage.

Copy link
Member Author

Choose a reason for hiding this comment

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

src/main/java/org/opensearch/sdk/ExtensionsRunner.java Outdated Show resolved Hide resolved
private static ExtensionSettings extensionSettings = null;
private DiscoveryNode opensearchNode = null;
TransportService transportService = null;
Copy link
Member

@dbwiddis dbwiddis Jun 15, 2022

Choose a reason for hiding this comment

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

We are still using a TransportService argument in other methods like startTransportService(). I see in this comment it's "available when needed" but there is no getter for it and we are not ever using it.

It happens to be "available" package private, but is that intentional? Given that you've added a public setter for it, should it be private with a getter since otherwise we're setting it and forgetting it (other than perhaps the reference to it from a reachability perspective)?

Also, this same variable name is used as a local variable later in createTransportService() and main(). That's not a good idea.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call! Made transportService private and created a getter for the same.

src/main/java/org/opensearch/sdk/ExtensionsRunner.java Outdated Show resolved Hide resolved
src/main/java/org/opensearch/sdk/ExtensionsRunner.java Outdated Show resolved Hide resolved
@owaiskazi19 owaiskazi19 requested a review from dbwiddis June 17, 2022 00:13
Copy link
Member

@dbwiddis dbwiddis left a comment

Choose a reason for hiding this comment

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

TLDR: I'm not sure what the right answer is with TransportService, but I don't think what we have is it.

That pesky TransportService instance variable needs a bit more careful thought and handling here. You're both setting it and returning it with the create() method, and elsewhere using both effects (return and instance) interchangeably.

If we need to keep the same API (with a return value from create*() and an argument to start*()) then we should find a more consistent way to work within those constraints (perhaps not have the instance variable and require the user to create and then pass it).

@owaiskazi19 owaiskazi19 requested a review from dbwiddis June 21, 2022 21:22
@owaiskazi19 owaiskazi19 force-pushed the draft-createComponent branch from a47512e to ebeda8a Compare June 21, 2022 21:53
@joshpalis joshpalis self-requested a review June 22, 2022 22:43
Copy link
Member

@saratvemulapalli saratvemulapalli left a comment

Choose a reason for hiding this comment

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

I did one pass, tiny comments so far.


@Override
public void handleResponse(ClusterSettingsResponse response) {
logger.info("received {}", response);
Copy link
Member

Choose a reason for hiding this comment

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

Lets make this log at debug level?

Copy link
Member

@saratvemulapalli saratvemulapalli left a comment

Choose a reason for hiding this comment

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

WIth adding API support for createComponent, can you add unit tests ?

@owaiskazi19
Copy link
Member Author

WIth adding API support for createComponent, can you add unit tests ?

Abstracted into APIs. Will add tests together as a part of #25

Copy link
Member

@saratvemulapalli saratvemulapalli left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of the comments.
Looks like CI is failing, like due to change not merged to feature/extensions branch on OpenSearch?

@owaiskazi19
Copy link
Member Author

owaiskazi19 commented Jun 27, 2022

Thanks for taking care of the comments. Looks like CI is failing, like due to change not merged to feature/extensions branch on OpenSearch?

Yes. Build will fail as this PR has dependency on opensearch-project/OpenSearch#3265.

Update: PR got merged and the build passed.

dbwiddis
dbwiddis previously approved these changes Jun 29, 2022
Copy link
Member

@dbwiddis dbwiddis left a comment

Choose a reason for hiding this comment

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

Approved but I really want some placeholder (comment, TODO, log warning, something) about making sure the opensearchNode isn't null before using it. Go ahead and add as an addition for a later issue if needed, just don't want it forgotten.

@owaiskazi19 owaiskazi19 merged commit c825b83 into opensearch-project:main Jun 29, 2022
@dbwiddis dbwiddis mentioned this pull request Jul 12, 2022
8 tasks
kokibas pushed a commit to kokibas/opensearch-sdk-java that referenced this pull request Mar 17, 2023
* Draft createComponent extension point

Signed-off-by: Owais Kazi <[email protected]>

* Resolved issue of transport stopped

Signed-off-by: Owais Kazi <[email protected]>

* Decoupled response handler to separate classes

Signed-off-by: Owais Kazi <[email protected]>

* Addressed PR Comments

Signed-off-by: Owais Kazi <[email protected]>

* Removed CountDown Latch

Signed-off-by: Owais Kazi <[email protected]>

* Refactoring and PR comments

Signed-off-by: Owais Kazi <[email protected]>

* Addressed PR Comments

Signed-off-by: Owais Kazi <[email protected]>

* Abstracted send request to APIs

Signed-off-by: Owais Kazi <[email protected]>

* Added comment for OpenSearchNode

Signed-off-by: Owais Kazi <[email protected]>
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.

[BUG] Implement a mechanism to add OpenSearch node to ConnectionManager Map
5 participants