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

Migrating to apache commons configuration 1.10 for parsing ETL jobs c… #851

Merged
merged 1 commit into from
Nov 14, 2017

Conversation

ShridharSattur
Copy link
Contributor

Migrating to apache commons configuration 1.10 for Parsing ETL jobs congifuration , It will increase the readability aspect of job configs and also wherehows can leverage apache common configuration features. Below is one of the usage

  1. Instead of providing comma separated values for job properties one can define the same properties in multiple lines
    ex: mysql_db = db1,db2,db3
    with this change we can define it as
    mysql_db = db1
    mysql_db=db2
    mysql_db=db3

@coveralls
Copy link

Coverage Status

Coverage remained the same at 27.444% when pulling 82d2995 on ShridharSattur:commons into ae801c8 on linkedin:master.

@@ -19,6 +19,8 @@ ext.externalDependency = [
"jsoup" : "org.jsoup:jsoup:1.8.3",
"commons_io" : "commons-io:commons-io:2.5",
"commons_lang3" : "org.apache.commons:commons-lang3:3.6",
"commons_codec" : "commons-codec:commons-codec:1.10",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this really needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed now, used it earlier just in case if i had to encode the reader object.

.add(Pattern.compile("\\$(.+)")) // $ENV_VAR
.add(Pattern.compile("\\$\\{(.+)\\}")) // ${ENV_VAR}
.build();
private static final List<Pattern> ENV_VAR_PATTERNS =
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be able to drop this now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes removed it along with method and test

Properties props = new Properties();
Path path = createPropertiesFile(propertyStr);

for (File file : new File(dir).listFiles()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why? Don't you already have the path from the previous line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated it now.

@ShridharSattur ShridharSattur force-pushed the commons branch 2 times, most recently from 81df270 to c758088 Compare November 10, 2017 01:07
@coveralls
Copy link

Coverage Status

Coverage remained the same at 27.444% when pulling c758088 on ShridharSattur:commons into 62b60de on linkedin:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 27.444% when pulling c758088 on ShridharSattur:commons into 62b60de on linkedin:master.

public void testMultipleLinesSameProperties() throws IOException, ConfigurationException {
String dir = "/tmp/";
String propertyStr =
"var1=foo\n" + "var1=foo\n" + "var1=foo\n" + "var2=foo\n" + "var2=foo\n" + "var3=foo\n" + "var1=foo\n"
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 add a few variations to the values

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 have added few tests and enhanced this test.

Copy link
Contributor

Choose a reason for hiding this comment

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

What I meant is not to use "foo" for all values


Assert.assertNotEquals(props, null);
Assert.assertEquals(props.getProperty("var1", ""), "foo,foo,foo,foo");
Assert.assertTrue(props.getProperty("var2").length() > 0);
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 do simple literal value comparison for var2, var3, & var4.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did literal value comparison now.

@@ -30,23 +31,7 @@
public class JobsUtilTest {

@Test
public void testEnvVarResolution() throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

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

May still want to verify that env vars are resolved properly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point , i have added back earlier code which used to resolve environment variable. In my next PR, i'm going to modify resolving environmental variables using apache commons configuration.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 27.444% when pulling b8e4cab on ShridharSattur:commons into 668e631 on linkedin:master.

@ShridharSattur ShridharSattur force-pushed the commons branch 2 times, most recently from 5d84d37 to e00edef Compare November 10, 2017 21:41
@coveralls
Copy link

Coverage Status

Coverage remained the same at 27.444% when pulling e00edef on ShridharSattur:commons into 668e631 on linkedin:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 27.444% when pulling e00edef on ShridharSattur:commons into 668e631 on linkedin:master.

String propertyStr =
"var1=foo\n" + "var1=foo\n" + "var1=foo\n" + "var2=foo\n" + "var2=foo\n" + "var3=foo\n" + "var1=foo\n"
+ "var4=foo\n";
String propertyStr1 = "var5=foo,bar,test,test1\n" + "var5=test2\n";
Copy link
Contributor

Choose a reason for hiding this comment

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

Just append this to propertyStr directly instead of creating another variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

Assert.assertNotEquals(props, null);
Assert.assertEquals(props.getProperty("var1", ""), "foo,foo,foo,foo");
Assert.assertEquals(props.getProperty("var2"), "foo,foo");
Assert.assertEquals(props.getProperty("var3"), props.getProperty("var4"));
Copy link
Contributor

Choose a reason for hiding this comment

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

ssert.assertEquals(props.getProperty("var3"), "foo")
ssert.assertEquals(props.getProperty("var4"), "foo")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it , verified all the literal values now.

public void testMultipleLinesSameProperties() throws IOException, ConfigurationException {
String dir = "/tmp/";
String propertyStr =
"var1=foo\n" + "var1=foo\n" + "var1=foo\n" + "var2=foo\n" + "var2=foo\n" + "var3=foo\n" + "var1=foo\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

What I meant is not to use "foo" for all values

@coveralls
Copy link

Coverage Status

Coverage remained the same at 27.444% when pulling 4b9ea10 on ShridharSattur:commons into 0aa6f79 on linkedin:master.

@mars-lan mars-lan merged commit f1b61d6 into datahub-project:master Nov 14, 2017
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.

3 participants