From fc234b1df959e96e1ca97ee98d364d39c87bfaaa Mon Sep 17 00:00:00 2001 From: Apex Dev Date: Tue, 18 Apr 2017 13:40:22 -0700 Subject: [PATCH] APEXMALHAR-2462 Fixed Checkstyle and Log4j Properties. --- examples/jdbc/pom.xml | 20 +++++++++ examples/jdbc/src/assemble/appPackage.xml | 20 +++++++++ .../examples/FileToJdbcApp/CustomParser.java | 26 +++++------ .../examples/FileToJdbcApp/FileReader.java | 23 +++++++++- .../FileToJdbcApp/FileToJdbcCsvParser.java | 30 ++++++++++--- .../FileToJdbcApp/FileToJdbcCustomParser.java | 37 ++++++++++++---- .../examples/FileToJdbcApp/PojoEvent.java | 18 ++++++++ .../JdbcIngest/JdbcPollerApplication.java | 18 ++++++++ .../apex/examples/JdbcIngest/PojoEvent.java | 18 ++++++++ .../examples/JdbcToJdbc/JdbcToJdbcApp.java | 2 +- .../apex/examples/JdbcToJdbc/PojoEvent.java | 18 ++++++++ .../META-INF/properties-FileToJdbcApp.xml | 20 +++++++++ .../META-INF/properties-JdbcToJdbcApp.xml | 20 +++++++++ .../META-INF/properties-PollJdbcToHDFSApp.xml | 20 +++++++++ .../properties-SimpleJdbcToHDFSApp.xml | 20 +++++++++ .../FileToJdbcApp/ApplicationTest.java | 44 ++++++++++++++----- .../examples/JdbcIngest/JdbcInputAppTest.java | 4 +- .../JdbcIngest/JdbcPollerApplicationTest.java | 22 +++++++++- .../examples/JdbcToJdbc/ApplicationTest.java | 17 ++++++- .../examples/JdbcToJdbc/JdbcOperatorTest.java | 7 ++- ...cApp.sql => example-FileToJdbcApp-sql.txt} | 0 ...cIngest.sql => example-JdbcIngest-sql.txt} | 0 ...cToJdbc.sql => example-JdbcToJdbc-sql.txt} | 0 .../jdbc/src/test/resources/log4j.properties | 21 +++++++++ .../src/test/resources/test-FileToJdbcApp.xml | 20 +++++++++ 25 files changed, 396 insertions(+), 49 deletions(-) rename examples/jdbc/src/test/resources/{example-FileToJdbcApp.sql => example-FileToJdbcApp-sql.txt} (100%) rename examples/jdbc/src/test/resources/{example-JdbcIngest.sql => example-JdbcIngest-sql.txt} (100%) rename examples/jdbc/src/test/resources/{example-JdbcToJdbc.sql => example-JdbcToJdbc-sql.txt} (100%) diff --git a/examples/jdbc/pom.xml b/examples/jdbc/pom.xml index b697a689c5..b01028a669 100644 --- a/examples/jdbc/pom.xml +++ b/examples/jdbc/pom.xml @@ -1,4 +1,24 @@ + 4.0.0 diff --git a/examples/jdbc/src/assemble/appPackage.xml b/examples/jdbc/src/assemble/appPackage.xml index 7ad071c69f..a8708074a2 100644 --- a/examples/jdbc/src/assemble/appPackage.xml +++ b/examples/jdbc/src/assemble/appPackage.xml @@ -1,3 +1,23 @@ + diff --git a/examples/jdbc/src/main/java/org/apache/apex/examples/FileToJdbcApp/CustomParser.java b/examples/jdbc/src/main/java/org/apache/apex/examples/FileToJdbcApp/CustomParser.java index a22acc98a0..d5fc509d58 100755 --- a/examples/jdbc/src/main/java/org/apache/apex/examples/FileToJdbcApp/CustomParser.java +++ b/examples/jdbc/src/main/java/org/apache/apex/examples/FileToJdbcApp/CustomParser.java @@ -18,15 +18,14 @@ */ package org.apache.apex.examples.FileToJdbcApp; +import java.util.regex.Pattern; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.datatorrent.api.Context.OperatorContext; import com.datatorrent.api.DefaultInputPort; import com.datatorrent.api.DefaultOutputPort; import com.datatorrent.api.annotation.OutputPortFieldAnnotation; import com.datatorrent.common.util.BaseOperator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.regex.Pattern; // parse input line into pojo event public class CustomParser extends BaseOperator @@ -42,12 +41,11 @@ public class CustomParser extends BaseOperator @OutputPortFieldAnnotation(optional = false) public final transient DefaultOutputPort output = new DefaultOutputPort<>(); - public final transient DefaultInputPort - input = new DefaultInputPort() { - - @Override - public void process(String line) - { + public final transient DefaultInputPort input = new DefaultInputPort() + { + @Override + public void process(String line) + { // use custom regex to split line into words final String[] words = regexPattern.split(line); @@ -70,14 +68,16 @@ public void process(String line) pojo.setAmount(0); } output.emit(pojo); - } + } }; - public String getRegexStr() { + public String getRegexStr() + { return this.regexStr; } - public void setRegexStr(String regex) { + public void setRegexStr(String regex) + { this.regexStr = regex; } diff --git a/examples/jdbc/src/main/java/org/apache/apex/examples/FileToJdbcApp/FileReader.java b/examples/jdbc/src/main/java/org/apache/apex/examples/FileToJdbcApp/FileReader.java index 4065a5fc83..89515f70e5 100755 --- a/examples/jdbc/src/main/java/org/apache/apex/examples/FileToJdbcApp/FileReader.java +++ b/examples/jdbc/src/main/java/org/apache/apex/examples/FileToJdbcApp/FileReader.java @@ -1,10 +1,29 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.apache.apex.examples.FileToJdbcApp; -import com.datatorrent.api.DefaultOutputPort; import org.apache.apex.malhar.lib.fs.LineByLineFileInputOperator; -public class FileReader extends LineByLineFileInputOperator{ +import com.datatorrent.api.DefaultOutputPort; +public class FileReader extends LineByLineFileInputOperator +{ /** * output in bytes to match CsvParser input type */ diff --git a/examples/jdbc/src/main/java/org/apache/apex/examples/FileToJdbcApp/FileToJdbcCsvParser.java b/examples/jdbc/src/main/java/org/apache/apex/examples/FileToJdbcApp/FileToJdbcCsvParser.java index d60b275756..be1db6b50a 100755 --- a/examples/jdbc/src/main/java/org/apache/apex/examples/FileToJdbcApp/FileToJdbcCsvParser.java +++ b/examples/jdbc/src/main/java/org/apache/apex/examples/FileToJdbcApp/FileToJdbcCsvParser.java @@ -1,3 +1,21 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.apache.apex.examples.FileToJdbcApp; import java.util.List; @@ -19,10 +37,11 @@ import static java.sql.Types.VARCHAR; @ApplicationAnnotation(name = "FileToJdbcCsvParser") -public class FileToJdbcCsvParser implements StreamingApplication{ - +public class FileToJdbcCsvParser implements StreamingApplication +{ @Override - public void populateDAG(DAG dag, Configuration configuration) { + public void populateDAG(DAG dag, Configuration configuration) + { // create operators FileReader fileReader = dag.addOperator("FileReader", FileReader.class); CsvParser csvParser = dag.addOperator("CsvParser", CsvParser.class); @@ -45,9 +64,10 @@ public void populateDAG(DAG dag, Configuration configuration) { * This method can be modified to have field mappings based on used defined * class */ - private List addFieldInfos() { + private List addFieldInfos() + { List fieldInfos = Lists.newArrayList(); - fieldInfos.add(new JdbcFieldInfo("ACCOUNT_NO", "accountNumber", JdbcFieldInfo.SupportType.INTEGER , INTEGER)); + fieldInfos.add(new JdbcFieldInfo("ACCOUNT_NO", "accountNumber", JdbcFieldInfo.SupportType.INTEGER, INTEGER)); fieldInfos.add(new JdbcFieldInfo("NAME", "name", JdbcFieldInfo.SupportType.STRING, VARCHAR)); fieldInfos.add(new JdbcFieldInfo("AMOUNT", "amount", JdbcFieldInfo.SupportType.INTEGER, INTEGER)); return fieldInfos; diff --git a/examples/jdbc/src/main/java/org/apache/apex/examples/FileToJdbcApp/FileToJdbcCustomParser.java b/examples/jdbc/src/main/java/org/apache/apex/examples/FileToJdbcApp/FileToJdbcCustomParser.java index 42d1d235fb..037ca51063 100755 --- a/examples/jdbc/src/main/java/org/apache/apex/examples/FileToJdbcApp/FileToJdbcCustomParser.java +++ b/examples/jdbc/src/main/java/org/apache/apex/examples/FileToJdbcApp/FileToJdbcCustomParser.java @@ -1,24 +1,45 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.apache.apex.examples.FileToJdbcApp; +import java.util.List; + +import org.apache.hadoop.conf.Configuration; + +import com.google.common.collect.Lists; + import com.datatorrent.api.DAG; import com.datatorrent.api.StreamingApplication; import com.datatorrent.api.annotation.ApplicationAnnotation; import com.datatorrent.lib.db.jdbc.JdbcFieldInfo; import com.datatorrent.lib.db.jdbc.JdbcPOJOInsertOutputOperator; import com.datatorrent.lib.db.jdbc.JdbcTransactionalStore; -import com.google.common.collect.Lists; -import org.apache.hadoop.conf.Configuration; - -import java.util.List; import static java.sql.Types.INTEGER; import static java.sql.Types.VARCHAR; @ApplicationAnnotation(name = "FileToJdbcCustomParser") -public class FileToJdbcCustomParser implements StreamingApplication{ - +public class FileToJdbcCustomParser implements StreamingApplication +{ @Override - public void populateDAG(DAG dag, Configuration configuration) { + public void populateDAG(DAG dag, Configuration configuration) + { // create operators FileReader fileReader = dag.addOperator("FileReader", FileReader.class); CustomParser customParser = dag.addOperator("CustomParser", CustomParser.class); @@ -41,7 +62,7 @@ public void populateDAG(DAG dag, Configuration configuration) { private List addFieldInfos() { List fieldInfos = Lists.newArrayList(); - fieldInfos.add(new JdbcFieldInfo("ACCOUNT_NO", "accountNumber", JdbcFieldInfo.SupportType.INTEGER , INTEGER)); + fieldInfos.add(new JdbcFieldInfo("ACCOUNT_NO", "accountNumber", JdbcFieldInfo.SupportType.INTEGER, INTEGER)); fieldInfos.add(new JdbcFieldInfo("NAME", "name", JdbcFieldInfo.SupportType.STRING, VARCHAR)); fieldInfos.add(new JdbcFieldInfo("AMOUNT", "amount", JdbcFieldInfo.SupportType.INTEGER, INTEGER)); return fieldInfos; diff --git a/examples/jdbc/src/main/java/org/apache/apex/examples/FileToJdbcApp/PojoEvent.java b/examples/jdbc/src/main/java/org/apache/apex/examples/FileToJdbcApp/PojoEvent.java index 6de92744bc..2ce2d9f6d0 100755 --- a/examples/jdbc/src/main/java/org/apache/apex/examples/FileToJdbcApp/PojoEvent.java +++ b/examples/jdbc/src/main/java/org/apache/apex/examples/FileToJdbcApp/PojoEvent.java @@ -1,3 +1,21 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.apache.apex.examples.FileToJdbcApp; public class PojoEvent diff --git a/examples/jdbc/src/main/java/org/apache/apex/examples/JdbcIngest/JdbcPollerApplication.java b/examples/jdbc/src/main/java/org/apache/apex/examples/JdbcIngest/JdbcPollerApplication.java index de47ef4cfe..4f351ef194 100644 --- a/examples/jdbc/src/main/java/org/apache/apex/examples/JdbcIngest/JdbcPollerApplication.java +++ b/examples/jdbc/src/main/java/org/apache/apex/examples/JdbcIngest/JdbcPollerApplication.java @@ -1,3 +1,21 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.apache.apex.examples.JdbcIngest; import java.util.List; diff --git a/examples/jdbc/src/main/java/org/apache/apex/examples/JdbcIngest/PojoEvent.java b/examples/jdbc/src/main/java/org/apache/apex/examples/JdbcIngest/PojoEvent.java index be366b6ac3..5a6646428a 100644 --- a/examples/jdbc/src/main/java/org/apache/apex/examples/JdbcIngest/PojoEvent.java +++ b/examples/jdbc/src/main/java/org/apache/apex/examples/JdbcIngest/PojoEvent.java @@ -1,3 +1,21 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.apache.apex.examples.JdbcIngest; public class PojoEvent diff --git a/examples/jdbc/src/main/java/org/apache/apex/examples/JdbcToJdbc/JdbcToJdbcApp.java b/examples/jdbc/src/main/java/org/apache/apex/examples/JdbcToJdbc/JdbcToJdbcApp.java index e85e4affe9..53a41eaa5a 100644 --- a/examples/jdbc/src/main/java/org/apache/apex/examples/JdbcToJdbc/JdbcToJdbcApp.java +++ b/examples/jdbc/src/main/java/org/apache/apex/examples/JdbcToJdbc/JdbcToJdbcApp.java @@ -84,7 +84,7 @@ private List addJdbcFieldInfos() fieldInfos.add(new com.datatorrent.lib.db.jdbc.JdbcFieldInfo("AMOUNT", "amount", SupportType.INTEGER,0)); return fieldInfos; } - + /** * This method can be modified to have field mappings based on used defined * class diff --git a/examples/jdbc/src/main/java/org/apache/apex/examples/JdbcToJdbc/PojoEvent.java b/examples/jdbc/src/main/java/org/apache/apex/examples/JdbcToJdbc/PojoEvent.java index 0abf74d8d2..f40d9302a9 100644 --- a/examples/jdbc/src/main/java/org/apache/apex/examples/JdbcToJdbc/PojoEvent.java +++ b/examples/jdbc/src/main/java/org/apache/apex/examples/JdbcToJdbc/PojoEvent.java @@ -1,3 +1,21 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.apache.apex.examples.JdbcToJdbc; public class PojoEvent diff --git a/examples/jdbc/src/main/resources/META-INF/properties-FileToJdbcApp.xml b/examples/jdbc/src/main/resources/META-INF/properties-FileToJdbcApp.xml index 29b911b5e0..53374fc7a8 100755 --- a/examples/jdbc/src/main/resources/META-INF/properties-FileToJdbcApp.xml +++ b/examples/jdbc/src/main/resources/META-INF/properties-FileToJdbcApp.xml @@ -1,4 +1,24 @@ + dt.operator.JdbcOutput.prop.store.databaseDriver diff --git a/examples/jdbc/src/main/resources/META-INF/properties-JdbcToJdbcApp.xml b/examples/jdbc/src/main/resources/META-INF/properties-JdbcToJdbcApp.xml index d9199c67e3..b32f8cc58e 100644 --- a/examples/jdbc/src/main/resources/META-INF/properties-JdbcToJdbcApp.xml +++ b/examples/jdbc/src/main/resources/META-INF/properties-JdbcToJdbcApp.xml @@ -1,4 +1,24 @@ + diff --git a/examples/jdbc/src/main/resources/META-INF/properties-SimpleJdbcToHDFSApp.xml b/examples/jdbc/src/main/resources/META-INF/properties-SimpleJdbcToHDFSApp.xml index 589dbcda5f..a57dcf735b 100644 --- a/examples/jdbc/src/main/resources/META-INF/properties-SimpleJdbcToHDFSApp.xml +++ b/examples/jdbc/src/main/resources/META-INF/properties-SimpleJdbcToHDFSApp.xml @@ -1,4 +1,24 @@ + dt.operator.JdbcOutput.prop.store.databaseDriver