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

Commit

Permalink
Fixed Checkstyle and Log4j
Browse files Browse the repository at this point in the history
  • Loading branch information
Apex Dev authored and prasannapramod committed Apr 20, 2017
1 parent 294f45c commit 1e916f3
Show file tree
Hide file tree
Showing 29 changed files with 753 additions and 122 deletions.
20 changes: 20 additions & 0 deletions examples/fileIO/pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

Expand Down
20 changes: 20 additions & 0 deletions examples/fileIO/src/assemble/appPackage.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
<!--
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.
-->
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -11,8 +30,8 @@
public class BytesFileWriter extends AbstractFileOutputOperator<byte[]>
{
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<byte[]> savedLines = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
/**
* 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;
import java.io.IOException;
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;

/**
Expand All @@ -26,7 +45,8 @@ public class FileReader extends AbstractFileInputOperator<String>
/**
* 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
Expand Down Expand Up @@ -74,7 +94,7 @@ public void endWindow()
@Override
public void emitTuples()
{
if ( ! stop ) { // normal processing
if (!stop) { // normal processing
super.emitTuples();
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -16,7 +35,8 @@ public class FileWriter extends AbstractFileOutputOperator<String>
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

Expand Down Expand Up @@ -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);
Expand All @@ -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));
}

Expand All @@ -93,7 +113,7 @@ public void processTuple(String tuple)
@Override
public void endWindow()
{
if ( ! eof ) {
if (!eof) {
return;
}

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
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;

import com.datatorrent.api.DAG;
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
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -17,7 +36,8 @@ public class ThroughputBasedReader extends AbstractThroughputFileInputOperator<b
/**
* 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 = ')';
private static final int DEFAULT_BLOCK_SIZE = 1024 * 64;

@OutputPortFieldAnnotation(optional = false)
Expand Down Expand Up @@ -120,7 +140,7 @@ public void setBlockSize(int blockSize)

/**
* Gets number of blocks to emit per window
*
*
* @return
*/
public int getBlockThreshold()
Expand All @@ -130,7 +150,7 @@ public int getBlockThreshold()

/**
* Sets number of blocks to emit per window
*
*
* @param blockThreshold
*/
public void setBlockThreshold(int blockThreshold)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
/**
* 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.fileIOMultiDir;

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 com.datatorrent.lib.io.fs.FileReaderMultiDir;
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
{

Expand Down
Loading

0 comments on commit 1e916f3

Please sign in to comment.