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

added logstash model for converter #447

Merged
merged 6 commits into from
Oct 25, 2021

Conversation

asifsmohammed
Copy link
Collaborator

@asifsmohammed asifsmohammed commented Oct 18, 2021

Description

Added sub-project data-prepper-logstash-configuration and Logstash model to store the information from Logstash configuration files.

Issues Resolved

Resolve #446

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.

Signed-off-by: Asif Sohail Mohammed <[email protected]>
Copy link
Contributor

@laneholloway laneholloway left a comment

Choose a reason for hiding this comment

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

Please rename the classes to be more explicit about what is being modeled and cleanup the build.gradle file for the data-prepper-logstash-configuration

laneholloway
laneholloway previously approved these changes Oct 19, 2021
dlvenable
dlvenable previously approved these changes Oct 19, 2021
Copy link
Contributor

@laneholloway laneholloway left a comment

Choose a reason for hiding this comment

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

Just add the @since 1.2 on the enum class and I'll approve.

Signed-off-by: Asif Sohail Mohammed <[email protected]>
laneholloway
laneholloway previously approved these changes Oct 20, 2021
Comment on lines 16 to 18
public void setAttributeName(String attributeName) {
this.attributeName = attributeName;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we allowing these objects to be multated? I would recommend we avoid mutation as it is harder to debug. If we can remove the setter functions, please make the attributeValue and attribute name as final.

If we need these setters, plese make the method parameter to the method final. Same is true for the other model objects.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, they should be immutable. Will update the model

dlvenable
dlvenable previously approved these changes Oct 20, 2021
@treddeni-amazon
Copy link

Are we not going to use the builder pattern for creating our model objects?

@asifsmohammed asifsmohammed dismissed stale reviews from dlvenable and laneholloway via c164e17 October 21, 2021 19:13
this.attributeValue = builder.attributeValue;
}

public static class LogstashAttributeBuilder {
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 just call this Builder. Otherwise, we will invoke the builder like so: LogstashAttribute = new LogstashAttribute.LogstashAttributeBuilder().build();

I would also recommend creating a public static method to get the builder so we can avoid having to use new:

public static Builder builder() {
    return new Builder();
}

Then we could just invoke the builder like so:

final LogstashAttribute logstashAttribute = LogstashAttribute.builder()
        .withAttributeValue(attributeValue)
        .withAttributeName("foobar")
        .build();

Copy link
Contributor

Choose a reason for hiding this comment

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

@cmanning09 great advice.

Comment on lines 21 to 22
this.attributeName = builder.attributeName;
this.attributeValue = builder.attributeValue;
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 have any requirements on these values? Can they be null or do we need to enforce non-null?

The same question applies to the other models.

Copy link
Collaborator Author

@asifsmohammed asifsmohammed Oct 22, 2021

Choose a reason for hiding this comment

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

Technically they shouldn't be null, but we might have some section in configuration left empty and we have to use default values.
For example, it can be like
http{
}

But I think we can still add a validate method to enforce non-null

Copy link
Contributor

Choose a reason for hiding this comment

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

@asifsmohammed can you go ahead and add the validation for non-nulls?, please.

Copy link
Member

@dlvenable dlvenable Oct 22, 2021

Choose a reason for hiding this comment

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

In the case of:

http {
}

You should have an empty array of LogstashAttribute in the LogstashPlugin. I'm unsure if the attributeValue can be null or not, but the attributeName should not be null.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've added the non-null validation.

@dlvenable
Copy link
Member

One additional comment:

We know that we want to move our packages to org.opensearch.dataprepper from com.amazon.dataprepper per #344. Most of that work will need to wait until v2.0 so as to not break any existing class.

However, this is a brand new sub-module within Data Prepper. Should we use this new package in here starting now? Or do we just want to change them all in v2.0?

@laneholloway
Copy link
Contributor

laneholloway commented Oct 22, 2021

This is new work, let's go ahead and start the migration to org.opensearch.dataprepper with this. @asifsmohammed, sorry for making this a longer review than normal, but it's a good place to start doing the work.

@laneholloway laneholloway merged commit 8827e55 into opensearch-project:main Oct 25, 2021
@asifsmohammed asifsmohammed deleted the logstash-model branch March 1, 2022 05:16
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.

New Model for Logstash Configuration files
6 participants