Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

APEXMALHAR-2379 Validation of attributes for AbstractFileOutputOperat… #530

Merged

Conversation

francisf
Copy link
Contributor

@francisf francisf commented Jan 2, 2017

…or, regex on name instead of path

@bhupeshchawda please review

@tweise
Copy link
Contributor

tweise commented Jan 2, 2017

Why is this not done using the javax.validation constraint annotations ?

@@ -366,6 +367,9 @@ public int getScanIntervalMillis()
*/
public void setScanIntervalMillis(int scanIntervalMillis)
{
if (scanIntervalMillis < 0) {
throw new IllegalArgumentException("scanIntervalMillis should be greater than or equal to 0.");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add the validation annotation to scanIntervalMillis, instead fixing it in setter method ?

@@ -384,6 +388,9 @@ public int getEmitBatchSize()
*/
public void setEmitBatchSize(int emitBatchSize)
{
if (emitBatchSize <= 0) {
throw new IllegalArgumentException("emitBatchSize should be greater than 0.");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add the validation annotation to emitBatchSize, instead fixing it in setter method ?

@@ -994,6 +1001,9 @@ public int getMaxRetryCount()
*/
public void setMaxRetryCount(int maxRetryCount)
{
if (maxRetryCount < 0) {
throw new IllegalArgumentException("maxRetryCount should be greater than or equal to 0.");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tweise @chaithu14
I took the change in https://github.com/apache/apex-malhar/blob/master/library/src/main/java/org/apache/apex/malhar/lib/fs/FSRecordReader.java#L158

I had tried the @min constraint annotation, which throws a constraint violation exception if the values are invalid in the properties.xml (bean validation). However, I do not see it throwing exceptions during the setting of the property of the operator when the application is running. Please let me know if I have misunderstood something here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Are talking about dynamic property changes ? If yes, I think we need to fix it up in core.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@chaithu14 agreed. Will raise a ticket for the same on APEXCORE. Can the existing changes be merged? I've added the @ Min constraint annotation so that it can be picked up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -117,7 +117,7 @@ public void testSinglePartiton() throws Exception
oper.output.setSink(sink);

oper.setDirectory(testMeta.dir);
oper.getScanner().setFilePatternRegexp(".*file[\\d]");
oper.getScanner().setFilePatternRegexp("((?!target).)*file[\\d]");
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add some tests?

@francisf francisf force-pushed the APEXMALHAR-2379_Negative_vals,regex_file branch 2 times, most recently from 6a56456 to 6ada96b Compare January 6, 2017 12:11
…or, regex on name instead of path, added @ Min constraint annotation
@francisf francisf force-pushed the APEXMALHAR-2379_Negative_vals,regex_file branch from 6ada96b to 16b15c2 Compare January 9, 2017 07:07
@chaithu14
Copy link
Contributor

Looks good to me.

@asfgit asfgit merged commit 16b15c2 into apache:master Jan 10, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants