Review Board 1.7.22


FLUME-1726. SpoolingFileLineReader must close the reader before renaming.

Review Request #8124 - Created Nov. 19, 2012 and updated

Hari Shreedharan
FLUME-1726
Reviewers
Flume
flume-git
Moved the reader.close call before the rename calls. 

 
flume-ng-core/src/main/java/org/apache/flume/client/avro/SpoolingFileLineReader.java
Revision b37b730 New Change
[20] 225 lines
[+20] [+] private void retireCurrentFile() throws IOException {
226

    
   
226

   
227
    String currPath = currentFile.get().getFile().getAbsolutePath();
227
    String currPath = currentFile.get().getFile().getAbsolutePath();
228
    String newPath = currPath + completedSuffix;
228
    String newPath = currPath + completedSuffix;
229
    logger.info("Preparing to move file " + currPath + " to " + newPath);
229
    logger.info("Preparing to move file " + currPath + " to " + newPath);
230

    
   
230

   

    
   
231
    currentFile.get().reader.close();
231
    File newFile = new File(currPath);
232
    File newFile = new File(currPath);
232

    
   
233

   
233
    // Verify that spooling assumptions hold
234
    // Verify that spooling assumptions hold
234
    if (newFile.lastModified() != currentFile.get().getLastModified()) {
235
    if (newFile.lastModified() != currentFile.get().getLastModified()) {
235
      String message = "File has been modified since being read: " + currPath;
236
      String message = "File has been modified since being read: " + currPath;
[+20] [20] 43 lines
[+20] private void retireCurrentFile() throws IOException {
279
            ". This will likely cause duplicate events. Please verify that " +
280
            ". This will likely cause duplicate events. Please verify that " +
280
            "flume has sufficient permissions to perform these operations.";
281
            "flume has sufficient permissions to perform these operations.";
281
        throw new FlumeException(message);
282
        throw new FlumeException(message);
282
      }
283
      }
283
    }
284
    }
284
    currentFile.get().reader.close();

   
285
  }
285
  }
286

    
   
286

   
287
  /**
287
  /**
288
   * Find and open the oldest file in the chosen directory. If two or more
288
   * Find and open the oldest file in the chosen directory. If two or more
289
   * files are equally old, the file name with lower lexicographical value is
289
   * files are equally old, the file name with lower lexicographical value is
[+20] [20] 72 lines
  1. flume-ng-core/src/main/java/org/apache/flume/client/avro/SpoolingFileLineReader.java: Loading...