From 35e5a9f42048297ce06d4a882cccfccfc1b4a7f7 Mon Sep 17 00:00:00 2001 From: Apex Dev Date: Wed, 19 Apr 2017 19:41:54 -0700 Subject: [PATCH] APEXMALHAR-2468 Fixed Checkstyle and Log4j --- examples/fileIO/pom.xml | 20 ++++ examples/fileIO/src/assemble/appPackage.xml | 20 ++++ .../apex/examples/fileIO/Application.java | 26 ++++- .../apex/examples/fileIO/BytesFileWriter.java | 23 ++++- .../apex/examples/fileIO/FileReader.java | 32 +++++-- .../apex/examples/fileIO/FileWriter.java | 30 +++++- .../fileIO/ThroughputBasedApplication.java | 23 ++++- .../fileIO/ThroughputBasedReader.java | 26 ++++- .../examples/fileIOMultiDir/Application.java | 28 ++++-- .../examples/fileIOMultiDir/FileReader.java | 28 +++++- .../fileIOMultiDir/FileReaderMultiDir.java | 96 ++++++++++++++----- .../examples/fileIOMultiDir/FileWriter.java | 30 +++++- .../examples/fileIOSimple/Application.java | 29 +++++- .../fileIOSimple/FileOutputOperator.java | 32 ++++++- .../apex/examples/fileOutput/Application.java | 21 +++- .../apex/examples/fileOutput/FileWriter.java | 32 ++++++- .../fileOutput/SequenceGenerator.java | 44 ++++++++- .../resources/META-INF/properties-FileIO.xml | 20 ++++ .../properties-ThroughputBasedFileIO.xml | 20 ++++ .../META-INF/properties-fileIO-multiDir.xml | 20 ++++ .../META-INF/properties-fileIOSimple.xml | 20 ++++ .../META-INF/properties-fileOutput.xml | 20 ++++ .../main/resources/unused-log4j.properties | 19 ++++ .../apex/examples/fileIO/ApplicationTest.java | 37 +++++-- .../ThroughputBasedApplicationTest.java | 27 +++++- .../fileIOMultiDir/ApplicationTest.java | 54 ++++++++--- .../fileIOSimple/ApplicationTest.java | 41 ++++++-- .../examples/fileOutput/ApplicationTest.java | 36 +++++-- .../src/test/resources/log4j.properties | 21 ++++ 29 files changed, 753 insertions(+), 122 deletions(-) diff --git a/examples/fileIO/pom.xml b/examples/fileIO/pom.xml index 812af59be2..e069acc6f3 100644 --- a/examples/fileIO/pom.xml +++ b/examples/fileIO/pom.xml @@ -1,4 +1,24 @@ + 4.0.0 diff --git a/examples/fileIO/src/assemble/appPackage.xml b/examples/fileIO/src/assemble/appPackage.xml index 7ad071c69f..a8708074a2 100644 --- a/examples/fileIO/src/assemble/appPackage.xml +++ b/examples/fileIO/src/assemble/appPackage.xml @@ -1,3 +1,23 @@ + diff --git a/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/Application.java b/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/Application.java index 2edac4bfb4..1831767f5d 100644 --- a/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/Application.java +++ b/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/Application.java @@ -1,17 +1,33 @@ /** - * Put your copyright and license info here. + * 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.fileIO; import org.apache.hadoop.conf.Configuration; -import com.datatorrent.api.annotation.ApplicationAnnotation; -import com.datatorrent.api.StreamingApplication; import com.datatorrent.api.DAG; +import com.datatorrent.api.StreamingApplication; +import com.datatorrent.api.annotation.ApplicationAnnotation; -import static com.datatorrent.api.Context.PortContext.*; +import static com.datatorrent.api.Context.PortContext.PARTITION_PARALLEL; -@ApplicationAnnotation(name="FileIO") +@ApplicationAnnotation(name = "FileIO") public class Application implements StreamingApplication { diff --git a/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/BytesFileWriter.java b/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/BytesFileWriter.java index fa9ea6512a..6484c1e80a 100644 --- a/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/BytesFileWriter.java +++ b/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/BytesFileWriter.java @@ -1,3 +1,22 @@ +/** + * 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.fileIO; import java.util.ArrayList; @@ -11,8 +30,8 @@ public class BytesFileWriter extends AbstractFileOutputOperator { private static final transient Logger LOG = LoggerFactory.getLogger(BytesFileWriter.class); - private static final char START_FILE = ThroughputBasedReader.START_FILE, - FINISH_FILE = ThroughputBasedReader.FINISH_FILE; + private static final char START_FILE = ThroughputBasedReader.START_FILE; + private static final char FINISH_FILE = ThroughputBasedReader.FINISH_FILE; private String fileName; // current file name private boolean eof; private transient ArrayList savedLines = new ArrayList<>(); diff --git a/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/FileReader.java b/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/FileReader.java index e83ba21caf..f38bacf5e7 100644 --- a/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/FileReader.java +++ b/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/FileReader.java @@ -1,3 +1,22 @@ +/** + * 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.fileIO; import java.io.BufferedReader; @@ -5,14 +24,14 @@ import java.io.InputStream; import java.io.InputStreamReader; -import com.datatorrent.api.Context; -import org.apache.hadoop.fs.Path; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.datatorrent.api.annotation.OutputPortFieldAnnotation; +import org.apache.hadoop.fs.Path; + +import com.datatorrent.api.Context; import com.datatorrent.api.DefaultOutputPort; +import com.datatorrent.api.annotation.OutputPortFieldAnnotation; import com.datatorrent.lib.io.fs.AbstractFileInputOperator; /** @@ -26,7 +45,8 @@ public class FileReader extends AbstractFileInputOperator /** * prefix for file start and finish control tuples */ - public static final char START_FILE = '(', FINISH_FILE = ')'; + public static final char START_FILE = '('; + public static final char FINISH_FILE = ')'; /** * output port for file data @@ -74,7 +94,7 @@ public void endWindow() @Override public void emitTuples() { - if ( ! stop ) { // normal processing + if (!stop) { // normal processing super.emitTuples(); return; } diff --git a/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/FileWriter.java b/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/FileWriter.java index 16da820e87..0e0c1d18cc 100644 --- a/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/FileWriter.java +++ b/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/FileWriter.java @@ -1,3 +1,22 @@ +/** + * 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.fileIO; import java.util.ArrayList; @@ -16,7 +35,8 @@ public class FileWriter extends AbstractFileOutputOperator private static final Logger LOG = LoggerFactory.getLogger(FileWriter.class); private static final String CHARSET_NAME = "UTF-8"; private static final String NL = System.lineSeparator(); - private static final char START_FILE = FileReader.START_FILE, FINISH_FILE = FileReader.FINISH_FILE; + private static final char START_FILE = FileReader.START_FILE; + private static final char FINISH_FILE = FileReader.FINISH_FILE; private String fileName; // current file name @@ -50,7 +70,7 @@ private void processControlTuple(final String tuple) fileName = tuple.substring(1); // if we have saved lines, process them - if ( ! savedLines.isEmpty() ) { + if (!savedLines.isEmpty()) { LOG.debug("Processing {} saved lines", savedLines.size()); for (String line : savedLines) { processTuple(line); @@ -67,7 +87,7 @@ private void processControlTuple(final String tuple) String name = tuple.substring(0, last); // sanity check : should match what we got with start control tuple - if (null == fileName || ! fileName.equals(name)) { + if (null == fileName || !fileName.equals(name)) { throw new RuntimeException(String.format("Error: fileName = %s != %s = tuple", fileName, tuple)); } @@ -93,7 +113,7 @@ public void processTuple(String tuple) @Override public void endWindow() { - if ( ! eof ) { + if (!eof) { return; } @@ -121,7 +141,7 @@ protected byte[] getBytesForTuple(String line) { LOG.debug("getBytesForTuple: line.length = {}", line.length()); - byte result[] = null; + byte[] result = null; try { result = (line + NL).getBytes(CHARSET_NAME); } catch (Exception e) { diff --git a/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/ThroughputBasedApplication.java b/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/ThroughputBasedApplication.java index 15e3081870..001e9c939b 100644 --- a/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/ThroughputBasedApplication.java +++ b/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/ThroughputBasedApplication.java @@ -1,6 +1,23 @@ -package org.apache.apex.examples.fileIO; +/** + * 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. + */ -import static com.datatorrent.api.Context.PortContext.PARTITION_PARALLEL; +package org.apache.apex.examples.fileIO; import org.apache.hadoop.conf.Configuration; @@ -8,6 +25,8 @@ import com.datatorrent.api.StreamingApplication; import com.datatorrent.api.annotation.ApplicationAnnotation; +import static com.datatorrent.api.Context.PortContext.PARTITION_PARALLEL; + @ApplicationAnnotation(name = "ThroughputBasedFileIO") public class ThroughputBasedApplication implements StreamingApplication { diff --git a/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/ThroughputBasedReader.java b/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/ThroughputBasedReader.java index ad1e257879..c8fb9c4aa2 100644 --- a/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/ThroughputBasedReader.java +++ b/examples/fileIO/src/main/java/org/apache/apex/examples/fileIO/ThroughputBasedReader.java @@ -1,3 +1,22 @@ +/** + * 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.fileIO; import java.io.File; @@ -17,7 +36,8 @@ public class ThroughputBasedReader extends AbstractThroughputFileInputOperator>> definePartitions } // compute first and last indices of partitions for each directory - final int numDirs = directories.length, numParCounts = partitionCounts.length; + final int numDirs = directories.length; + final int numParCounts = partitionCounts.length; final int[] sliceFirstIndex = new int[numDirs]; LOG.info("definePartitions: prevCount = {}, directories.length = {}, " + - "partitionCounts.length = {}", prevCount, numDirs, numParCounts); + "partitionCounts.length = {}", prevCount, numDirs, numParCounts); int nPartitions = 0; // desired number of partitions @@ -143,21 +158,21 @@ public Collection>> definePartitions SlicedDirectoryScanner sds = (SlicedDirectoryScanner)scanner; List scanners = sds.partition(nPartitions, directories, - partitionCounts); + partitionCounts); // return value: new list of partitions (includes old list) List>> newPartitions // = Lists.newArrayListWithExpectedSize(totalCount); - = new ArrayList(nPartitions); + = new ArrayList(nPartitions); // parallel list of storage managers Collection newManagers // = Lists.newArrayListWithExpectedSize(totalCount); - = new ArrayList(nPartitions); + = new ArrayList(nPartitions); // setup new partitions LOG.info("definePartitions: setting up {} new partitoins with {} monitored directories", - nPartitions, numDirs); + nPartitions, numDirs); final WindowDataManager ism = getWindowDataManager(); @@ -171,8 +186,7 @@ public Collection>> definePartitions for (int i = first; i < last; ++i) { AbstractFileInputOperator oper = cloneObject(kryo, this); oper.setDirectory(dir); - //oper.setpIndex(i); - SlicedDirectoryScanner scn = (SlicedDirectoryScanner) scanners.get(i); + SlicedDirectoryScanner scn = (SlicedDirectoryScanner)scanners.get(i); scn.setStartIndex(first); scn.setEndIndex(last); scn.setDirectory(dir); @@ -200,7 +214,9 @@ public static class SlicedDirectoryScanner extends AbstractFileInputOperator.Dir // DirectoryScanner since it is private and has no accessors defined; we also use // it differently here. // - int startIndex, endIndex, pIndex; + int startIndex; + int endIndex; + int pIndex; // the monitored directory String directory; @@ -210,9 +226,8 @@ public static class SlicedDirectoryScanner extends AbstractFileInputOperator.Dir // dirs -- list of monitored directories, one per slice // pCounts -- number of partitions in each slice // - private List partition(int total, - String[] dirs, - int[] pCounts) { + private List partition(int total, String[] dirs, int[] pCounts) + { ArrayList partitions = new ArrayList(total); for (int i = 0; i < total; i++) { final SlicedDirectoryScanner that = new SlicedDirectoryScanner(); @@ -240,8 +255,8 @@ protected boolean acceptFile(String filePathStr) mod += sliceSize; } LOG.debug("partitionIndex = {}, startIndex = {}, endIndex = {}, sliceSize = {}, " + - "filePathStr = {}, hashcode = {}, mod = {}", - pIndex, startIndex, endIndex, sliceSize, filePathStr, i, mod); + "filePathStr = {}, hashcode = {}, mod = {}", + pIndex, startIndex, endIndex, sliceSize, filePathStr, i, mod); if ((startIndex + mod) != pIndex) { return false; @@ -260,14 +275,45 @@ protected boolean acceptFile(String filePathStr) } // acceptFile // getters and setters - public String getDirectory() { return directory; } - public void setDirectory(String v) { directory = v; } - public int getStartIndex() { return startIndex; } - public void setStartIndex(int v) { startIndex = v; } - public int getEndIndex() { return endIndex; } - public void setEndIndex(int v) { endIndex = v; } - public int getpIndex() { return pIndex; } - public void setpIndex(int v) { pIndex = v; } + public String getDirectory() + { + return directory; + } + + public void setDirectory(String v) + { + directory = v; + } + + public int getStartIndex() + { + return startIndex; + } + + public void setStartIndex(int v) + { + startIndex = v; + } + + public int getEndIndex() + { + return endIndex; + } + + public void setEndIndex(int v) + { + endIndex = v; + } + + public int getpIndex() + { + return pIndex; + } + + public void setpIndex(int v) + { + pIndex = v; + } } // SlicedDirectoryScanner diff --git a/examples/fileIO/src/main/java/org/apache/apex/examples/fileIOMultiDir/FileWriter.java b/examples/fileIO/src/main/java/org/apache/apex/examples/fileIOMultiDir/FileWriter.java index 971fc3d8d7..0e79cbc095 100644 --- a/examples/fileIO/src/main/java/org/apache/apex/examples/fileIOMultiDir/FileWriter.java +++ b/examples/fileIO/src/main/java/org/apache/apex/examples/fileIOMultiDir/FileWriter.java @@ -1,3 +1,22 @@ +/** + * 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.fileIOMultiDir; import java.util.ArrayList; @@ -16,7 +35,8 @@ public class FileWriter extends AbstractFileOutputOperator private static final Logger LOG = LoggerFactory.getLogger(FileWriter.class); private static final String CHARSET_NAME = "UTF-8"; private static final String NL = System.lineSeparator(); - private static final char START_FILE = FileReader.START_FILE, FINISH_FILE = FileReader.FINISH_FILE; + private static final char START_FILE = FileReader.START_FILE; + private static final char FINISH_FILE = FileReader.FINISH_FILE; private String fileName; // current file name @@ -50,7 +70,7 @@ private void processControlTuple(final String tuple) fileName = tuple.substring(1); // if we have saved lines, process them - if ( ! savedLines.isEmpty() ) { + if (!savedLines.isEmpty()) { LOG.debug("Processing {} saved lines", savedLines.size()); for (String line : savedLines) { processTuple(line); @@ -67,7 +87,7 @@ private void processControlTuple(final String tuple) String name = tuple.substring(0, last); // sanity check : should match what we got with start control tuple - if (null == fileName || ! fileName.equals(name)) { + if (null == fileName || !fileName.equals(name)) { throw new RuntimeException(String.format("Error: fileName = %s != %s = tuple", fileName, tuple)); } @@ -93,7 +113,7 @@ public void processTuple(String tuple) @Override public void endWindow() { - if ( ! eof ) { + if (!eof) { return; } @@ -121,7 +141,7 @@ protected byte[] getBytesForTuple(String line) { LOG.debug("getBytesForTuple: line.length = {}", line.length()); - byte result[] = null; + byte[] result = null; try { result = (line + NL).getBytes(CHARSET_NAME); } catch (Exception e) { diff --git a/examples/fileIO/src/main/java/org/apache/apex/examples/fileIOSimple/Application.java b/examples/fileIO/src/main/java/org/apache/apex/examples/fileIOSimple/Application.java index 65b84381dd..550186e665 100644 --- a/examples/fileIO/src/main/java/org/apache/apex/examples/fileIOSimple/Application.java +++ b/examples/fileIO/src/main/java/org/apache/apex/examples/fileIOSimple/Application.java @@ -1,16 +1,35 @@ +/** + * 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.fileIOSimple; import org.apache.apex.malhar.lib.fs.LineByLineFileInputOperator; import org.apache.hadoop.conf.Configuration; -import com.datatorrent.api.annotation.ApplicationAnnotation; -import com.datatorrent.api.StreamingApplication; import com.datatorrent.api.DAG; +import com.datatorrent.api.StreamingApplication; +import com.datatorrent.api.annotation.ApplicationAnnotation; /** * Simple application illustrating file input-output */ -@ApplicationAnnotation(name="SimpleFileIO") +@ApplicationAnnotation(name = "SimpleFileIO") public class Application implements StreamingApplication { @@ -19,9 +38,9 @@ public void populateDAG(DAG dag, Configuration conf) { // create operators LineByLineFileInputOperator in = dag.addOperator("input", - new LineByLineFileInputOperator()); + new LineByLineFileInputOperator()); FileOutputOperator out = dag.addOperator("output", - new FileOutputOperator()); + new FileOutputOperator()); // configure operators in.setDirectory("/tmp/SimpleFileIO/input-dir"); out.setFilePath("/tmp/SimpleFileIO/output-dir"); diff --git a/examples/fileIO/src/main/java/org/apache/apex/examples/fileIOSimple/FileOutputOperator.java b/examples/fileIO/src/main/java/org/apache/apex/examples/fileIOSimple/FileOutputOperator.java index 4c02ea5b3b..e11921239c 100644 --- a/examples/fileIO/src/main/java/org/apache/apex/examples/fileIOSimple/FileOutputOperator.java +++ b/examples/fileIO/src/main/java/org/apache/apex/examples/fileIOSimple/FileOutputOperator.java @@ -1,3 +1,22 @@ +/** + * 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.fileIOSimple; import javax.validation.constraints.NotNull; @@ -38,7 +57,7 @@ protected String getFileName(String tuple) @Override protected byte[] getBytesForTuple(String line) { - byte result[] = null; + byte[] result = null; try { result = (line + NL).getBytes(CHARSET_NAME); } catch (Exception e) { @@ -48,6 +67,13 @@ protected byte[] getBytesForTuple(String line) } // getters and setters - public String getFileName() { return fileName; } - public void setFileName(String v) { fileName = v; } + public String getFileName() + { + return fileName; + } + + public void setFileName(String v) + { + fileName = v; + } } diff --git a/examples/fileIO/src/main/java/org/apache/apex/examples/fileOutput/Application.java b/examples/fileIO/src/main/java/org/apache/apex/examples/fileOutput/Application.java index 904e3abb62..4cdba22a66 100644 --- a/examples/fileIO/src/main/java/org/apache/apex/examples/fileOutput/Application.java +++ b/examples/fileIO/src/main/java/org/apache/apex/examples/fileOutput/Application.java @@ -1,3 +1,22 @@ +/** + * 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.fileOutput; import org.apache.hadoop.conf.Configuration; @@ -6,7 +25,7 @@ import com.datatorrent.api.StreamingApplication; import com.datatorrent.api.annotation.ApplicationAnnotation; -@ApplicationAnnotation(name="fileOutput") +@ApplicationAnnotation(name = "fileOutput") public class Application implements StreamingApplication { diff --git a/examples/fileIO/src/main/java/org/apache/apex/examples/fileOutput/FileWriter.java b/examples/fileIO/src/main/java/org/apache/apex/examples/fileOutput/FileWriter.java index b8d00a01c7..1ec6cfb44a 100644 --- a/examples/fileIO/src/main/java/org/apache/apex/examples/fileOutput/FileWriter.java +++ b/examples/fileIO/src/main/java/org/apache/apex/examples/fileOutput/FileWriter.java @@ -1,3 +1,22 @@ +/** + * 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.fileOutput; import java.util.Arrays; @@ -46,7 +65,7 @@ protected String getFileName(Long[] tuple) @Override protected byte[] getBytesForTuple(Long[] pair) { - byte result[] = null; + byte[] result = null; try { result = (Arrays.toString(pair) + NL).getBytes(CHARSET_NAME); } catch (Exception e) { @@ -57,6 +76,13 @@ protected byte[] getBytesForTuple(Long[] pair) } // getters and setters - public String getFileName() { return fileName; } - public void setFileName(String v) { fileName = v; } + public String getFileName() + { + return fileName; + } + + public void setFileName(String v) + { + fileName = v; + } } diff --git a/examples/fileIO/src/main/java/org/apache/apex/examples/fileOutput/SequenceGenerator.java b/examples/fileIO/src/main/java/org/apache/apex/examples/fileOutput/SequenceGenerator.java index 759b6fa3f4..34fcd3f80b 100644 --- a/examples/fileIO/src/main/java/org/apache/apex/examples/fileOutput/SequenceGenerator.java +++ b/examples/fileIO/src/main/java/org/apache/apex/examples/fileOutput/SequenceGenerator.java @@ -1,3 +1,22 @@ +/** + * 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.fileOutput; import javax.validation.constraints.Min; @@ -45,7 +64,7 @@ public void setup(OperatorContext context) id = context.getId(); sleepTime = context.getValue(OperatorContext.SPIN_MILLIS); LOG.debug("Leaving setup, id = {}, sleepTime = {}, divisor = {}", - id, sleepTime, divisor); + id, sleepTime, divisor); } @Override @@ -83,8 +102,23 @@ public void emitTuples() // getters and setters - public long getDivisor() { return divisor; } - public void setDivisor(long v) { divisor = v; } - public int getMaxTuples() { return maxTuples; } - public void setMaxTuples(int v) { maxTuples = v; } + public long getDivisor() + { + return divisor; + } + + public void setDivisor(long v) + { + divisor = v; + } + + public int getMaxTuples() + { + return maxTuples; + } + + public void setMaxTuples(int v) + { + maxTuples = v; + } } diff --git a/examples/fileIO/src/main/resources/META-INF/properties-FileIO.xml b/examples/fileIO/src/main/resources/META-INF/properties-FileIO.xml index e99bae5872..3df70043b0 100644 --- a/examples/fileIO/src/main/resources/META-INF/properties-FileIO.xml +++ b/examples/fileIO/src/main/resources/META-INF/properties-FileIO.xml @@ -1,4 +1,24 @@ +