apex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhup...@apache.org
Subject apex-malhar git commit: APEXMALHAR-2224 Fixed GenericFileOutputOperator rotateCall.
Date Wed, 09 Nov 2016 11:17:39 GMT
Repository: apex-malhar
Updated Branches:
  refs/heads/master 278d799b0 -> 0870480a4


APEXMALHAR-2224 Fixed GenericFileOutputOperator rotateCall.


Project: http://git-wip-us.apache.org/repos/asf/apex-malhar/repo
Commit: http://git-wip-us.apache.org/repos/asf/apex-malhar/commit/0870480a
Tree: http://git-wip-us.apache.org/repos/asf/apex-malhar/tree/0870480a
Diff: http://git-wip-us.apache.org/repos/asf/apex-malhar/diff/0870480a

Branch: refs/heads/master
Commit: 0870480a4ebf2c688e775d677c10d010871eb100
Parents: 278d799
Author: Lakshmi Prasanna Velineni <lakshmi@datatorrent.com>
Authored: Sun Oct 9 18:10:57 2016 -0700
Committer: Lakshmi Prasanna Velineni <lakshmi@datatorrent.com>
Committed: Tue Nov 8 09:54:26 2016 -0800

----------------------------------------------------------------------
 .../lib/fs/GenericFileOutputOperator.java       |  4 +++-
 .../lib/fs/GenericFileOutputOperatorTest.java   | 20 ++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/0870480a/library/src/main/java/org/apache/apex/malhar/lib/fs/GenericFileOutputOperator.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/org/apache/apex/malhar/lib/fs/GenericFileOutputOperator.java
b/library/src/main/java/org/apache/apex/malhar/lib/fs/GenericFileOutputOperator.java
index 7db8a15..2ff405d 100644
--- a/library/src/main/java/org/apache/apex/malhar/lib/fs/GenericFileOutputOperator.java
+++ b/library/src/main/java/org/apache/apex/malhar/lib/fs/GenericFileOutputOperator.java
@@ -214,7 +214,9 @@ public class GenericFileOutputOperator<INPUT> extends AbstractSingleFileOutputOp
   protected void rotateCall(String lastFile)
   {
     try {
-      this.rotate(lastFile);
+      if (currentPartTupleCount != 0) {
+        this.rotate(lastFile);
+      }
       currentPartIdleWindows = 0;
       currentPartTupleCount = 0;
     } catch (IOException ex) {

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/0870480a/library/src/test/java/org/apache/apex/malhar/lib/fs/GenericFileOutputOperatorTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/org/apache/apex/malhar/lib/fs/GenericFileOutputOperatorTest.java
b/library/src/test/java/org/apache/apex/malhar/lib/fs/GenericFileOutputOperatorTest.java
index 8b8ed01..f0d2915 100644
--- a/library/src/test/java/org/apache/apex/malhar/lib/fs/GenericFileOutputOperatorTest.java
+++ b/library/src/test/java/org/apache/apex/malhar/lib/fs/GenericFileOutputOperatorTest.java
@@ -127,6 +127,26 @@ public class GenericFileOutputOperatorTest extends AbstractFileOutputOperatorTes
     }
   }
 
+  @Test
+  public void testRotationWithNoData() throws InterruptedException
+  {
+    GenericFileOutputOperator writer = new GenericFileOutputOperator();
+    File dir = new File(testMeta.getDir());
+    writer.setFilePath(testMeta.getDir());
+    writer.setOutputFileName("output.txt");
+    writer.setMaxIdleWindows(5);
+    writer.setAlwaysWriteToTmp(true);
+    writer.setup(testMeta.testOperatorContext);
+
+    for (int i = 0; i < 30; ++i) {
+      writer.beginWindow(i);
+      writer.endWindow();
+    }
+    writer.committed(29);
+    Collection<File> files = FileUtils.listFiles(dir, null, false);
+    Assert.assertEquals("Number of part files", 0, files.size());
+  }
+
   public static void checkOutput(int fileCount, String baseFilePath, String expectedOutput,
boolean checkTmp)
   {
     if (fileCount >= 0) {


Mime
View raw message