autumnust commented on a change in pull request #2701: GOBBLIN-846: Enhance 
LogCopier service to handle continuous YARN log …
URL: https://github.com/apache/incubator-gobblin/pull/2701#discussion_r312161512
 
 

 ##########
 File path: 
gobblin-utility/src/main/java/org/apache/gobblin/util/logs/LogCopier.java
 ##########
 @@ -536,14 +521,15 @@ private void copyChangesOfLogFile(Path srcFile, Path 
destFile) throws IOExceptio
 
       try (Closer closer = Closer.create()) {
         fsDataInputStream = 
closer.register(LogCopier.this.srcFs.open(srcFile));
-        // Seek to the the most recent position if it is available
-        LOGGER.debug(String.format("Reading log file %s from position %d", 
srcFile, this.currentPos));
-        fsDataInputStream.seek(this.currentPos);
         BufferedReader srcLogFileReader = closer.register(
             new BufferedReader(new InputStreamReader(fsDataInputStream, 
ConfigurationKeys.DEFAULT_CHARSET_ENCODING)));
 
-        FSDataOutputStream outputStream = 
LogCopier.this.destFs.exists(destFile)
-            ? LogCopier.this.destFs.append(destFile) : 
LogCopier.this.destFs.create(destFile);
+        //If file already exists, delete and re-copy the file.
+        if (LogCopier.this.destFs.exists(destFile)) {
+          LogCopier.this.destFs.delete(destFile, false);
+        }
+
+        FSDataOutputStream outputStream = 
LogCopier.this.destFs.create(destFile);
 
 Review comment:
   This call seems creating an entry in namenode directly. Based my previous 
comment on race condition, if that happens, two threads are copying bytes into 
the same `destFile`. Then is that a problem if we see existed file and then 
delete-followed-by-recopy ? 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to