flume-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject git commit: FLUME-1872: SpoolingDirectorySource doesn't delete tracker file when deletePolicy is immediate
Date Fri, 25 Jan 2013 21:51:32 GMT
Updated Branches:
  refs/heads/flume-1.4 a4c86933d -> 6d5ef28ec


FLUME-1872: SpoolingDirectorySource doesn't delete tracker file when deletePolicy is immediate

(Mike Percy via Brock Noland)


Project: http://git-wip-us.apache.org/repos/asf/flume/repo
Commit: http://git-wip-us.apache.org/repos/asf/flume/commit/6d5ef28e
Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/6d5ef28e
Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/6d5ef28e

Branch: refs/heads/flume-1.4
Commit: 6d5ef28ecfa1c6141c7869facb70a53c7557fa8d
Parents: a4c8693
Author: Brock Noland <brock@apache.org>
Authored: Fri Jan 25 15:50:07 2013 -0600
Committer: Brock Noland <brock@apache.org>
Committed: Fri Jan 25 15:51:06 2013 -0600

----------------------------------------------------------------------
 .../avro/ReliableSpoolingFileEventReader.java      |    2 +
 .../avro/TestReliableSpoolingFileEventReader.java  |   31 +++++++++++++--
 2 files changed, 29 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flume/blob/6d5ef28e/flume-ng-core/src/main/java/org/apache/flume/client/avro/ReliableSpoolingFileEventReader.java
----------------------------------------------------------------------
diff --git a/flume-ng-core/src/main/java/org/apache/flume/client/avro/ReliableSpoolingFileEventReader.java
b/flume-ng-core/src/main/java/org/apache/flume/client/avro/ReliableSpoolingFileEventReader.java
index 28df24c..37f0ee1 100644
--- a/flume-ng-core/src/main/java/org/apache/flume/client/avro/ReliableSpoolingFileEventReader.java
+++ b/flume-ng-core/src/main/java/org/apache/flume/client/avro/ReliableSpoolingFileEventReader.java
@@ -371,6 +371,8 @@ public class ReliableSpoolingFileEventReader implements ReliableEventReader
{
     if (!fileToDelete.delete()) {
       throw new IOException("Unable to delete spool file: " + fileToDelete);
     }
+    // now we no longer need the meta file
+    deleteMetaFile();
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/flume/blob/6d5ef28e/flume-ng-core/src/test/java/org/apache/flume/client/avro/TestReliableSpoolingFileEventReader.java
----------------------------------------------------------------------
diff --git a/flume-ng-core/src/test/java/org/apache/flume/client/avro/TestReliableSpoolingFileEventReader.java
b/flume-ng-core/src/test/java/org/apache/flume/client/avro/TestReliableSpoolingFileEventReader.java
index 31ecf8e..9d708c1 100644
--- a/flume-ng-core/src/test/java/org/apache/flume/client/avro/TestReliableSpoolingFileEventReader.java
+++ b/flume-ng-core/src/test/java/org/apache/flume/client/avro/TestReliableSpoolingFileEventReader.java
@@ -93,11 +93,30 @@ public class TestReliableSpoolingFileEventReader {
 
   }
 
-  // FIXME: implement ignore pattern test
-  @Ignore
   @Test
-  public void testIgnorePattern() {
-    ReliableSpoolingFileEventReader parser;
+  public void testIgnorePattern() throws IOException {
+    ReliableEventReader reader = new ReliableSpoolingFileEventReader.Builder()
+        .spoolDirectory(WORK_DIR)
+        .ignorePattern("^file2$")
+        .deletePolicy(DeletePolicy.IMMEDIATE.toString())
+        .build();
+
+    List<File> before = listFiles(WORK_DIR);
+    Assert.assertEquals("Expected 5, not: " + before, 5, before.size());
+
+    List<Event> events;
+    do {
+      events = reader.readEvents(10);
+      reader.commit();
+    } while (!events.isEmpty());
+
+    List<File> after = listFiles(WORK_DIR);
+    Assert.assertEquals("Expected 1, not: " + after, 1, after.size());
+    Assert.assertEquals("file2", after.get(0).getName());
+    List<File> trackerFiles = listFiles(new File(WORK_DIR,
+        SpoolDirectorySourceConfigurationConstants.DEFAULT_TRACKER_DIR));
+    Assert.assertEquals("Expected 0, not: " + trackerFiles, 0,
+        trackerFiles.size());
   }
 
   @Test
@@ -163,6 +182,10 @@ public class TestReliableSpoolingFileEventReader {
 
     List<File> after = listFiles(WORK_DIR);
     Assert.assertEquals("Expected 0, not: " + after, 0, after.size());
+    List<File> trackerFiles = listFiles(new File(WORK_DIR,
+        SpoolDirectorySourceConfigurationConstants.DEFAULT_TRACKER_DIR));
+    Assert.assertEquals("Expected 0, not: " + trackerFiles, 0,
+        trackerFiles.size());
   }
 
   private static List<File> listFiles(File dir) {


Mime
View raw message