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

Opensearch connection related changes for #1985,2264. #2716

Conversation

mallikagogoi7
Copy link
Contributor

Description

Opensearch connection related changes for #1985,2264.

Issues Resolved

Resolved #1985

Check List

  • New functionality includes testing.
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

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.


package org.opensearch.dataprepper.plugins.source.opensearch;

public class SourceInfo {
Copy link
Contributor

Choose a reason for hiding this comment

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

From an initial look at this PR, let's rename to ClusterInfo. I think this represent more of what this object is trying to capture. Source has separate meaning in DataPrepper and I believe it makes sense to make this more related to OpenSearch/Elasticsearch.

this.osVersion = osVersion;
}

public Boolean getHealthStatus() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Health for a cluster can only be red, yellow, & green. Let's update this to reflect that status type.

* @throws ParseException
* This method will check health of the source. if green or yellow and then it can be used for further processing
*/
public SourceInfo checkStatus(final OpenSearchSourceConfiguration openSearchSourceConfiguration, final SourceInfo sourceInfo) throws IOException, ParseException {
Copy link
Contributor

Choose a reason for hiding this comment

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

This method name does not make align with the return object. I would recommend renaming to some thing that aligns with the function of the method. Perhaps: getClusterInfo

Comment on lines +10 to +12
private String osVersion;

private String dataSource;
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's make these two fields final. They should not change through the lifecycle of these cluster.

* @return
* This method will help to identify the source information eg(opensearch,elasticsearch)
*/
public String getSourceInfo(final OpenSearchSourceConfiguration openSearchSourceConfiguration) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this method? I would think we would need one method in this provider to build a ClusterInfo object. The object should be re-usable.

this.osVersion = osVersion;
}

public Boolean getHealthStatus() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Additionally, Should this Cluster object make API's calls to actually fetch the Health of the cluster instead of relying on the provider to handle this?.

@mallikagogoi7 would you mine putting out a skeleton / boilerplate PR for this work? I think we can collaborate on class design here to improve the code structure. Thanks!

import java.util.List;


public class PrepareConnection {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need a separate class for this that needs to be instantiated? I think we possibly use static method here to create clients.

startProcess(openSearchSourceConfiguration,buffer);
}

private void startProcess(final OpenSearchSourceConfiguration openSearchSourceConfiguration,final Buffer<Record<Event>> buffer) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would recommend pulling out the business logic in this class into a separate service. That way this main class can construct all the required classes and execution can happen separately. This will help with unit testing down the road as well as we can inject mocks for classes which create connections to external resources. Let me know if you have questions on this.

@mallikagogoi7
Copy link
Contributor Author

Closing this PR and creating new PR as per the feedback received related to package structure and we have raised a new PR with boiler plate code 2734

@mallikagogoi7 mallikagogoi7 deleted the feature_PrepareConnection branch May 24, 2023 07:54
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.

OpenSearch source plugin
3 participants