You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by th...@apache.org on 2014/05/14 09:12:07 UTC

svn commit: r1594494 - in /oodt/trunk: CHANGES.txt crawler/src/main/java/org/apache/oodt/cas/crawl/action/MoveFile.java

Author: thomas
Date: Wed May 14 07:12:07 2014
New Revision: 1594494

URL: http://svn.apache.org/r1594494
Log:
Fix for OODT-674: Solution provided by Chris Schollar

Modified:
    oodt/trunk/CHANGES.txt
    oodt/trunk/crawler/src/main/java/org/apache/oodt/cas/crawl/action/MoveFile.java

Modified: oodt/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/oodt/trunk/CHANGES.txt?rev=1594494&r1=1594493&r2=1594494&view=diff
==============================================================================
--- oodt/trunk/CHANGES.txt (original)
+++ oodt/trunk/CHANGES.txt Wed May 14 07:12:07 2014
@@ -4,6 +4,8 @@ Apache OODT Change Log
 Release 0.7 - Current Development
 ---------------------------------
 
+* OODT-674 MoveDatafileToFailureDir fails to move files off an NFS mounted directory (thomas)
+
 * OODT-662 Upgrade cog-jglobus dependency in protocol-ftp (lewismc)
 
 * OODT-668 ProductQueryServlet will now rename zip attachments with proper ".zip" extension,

Modified: oodt/trunk/crawler/src/main/java/org/apache/oodt/cas/crawl/action/MoveFile.java
URL: http://svn.apache.org/viewvc/oodt/trunk/crawler/src/main/java/org/apache/oodt/cas/crawl/action/MoveFile.java?rev=1594494&r1=1594493&r2=1594494&view=diff
==============================================================================
--- oodt/trunk/crawler/src/main/java/org/apache/oodt/cas/crawl/action/MoveFile.java (original)
+++ oodt/trunk/crawler/src/main/java/org/apache/oodt/cas/crawl/action/MoveFile.java Wed May 14 07:12:07 2014
@@ -28,6 +28,10 @@ import org.apache.oodt.cas.metadata.Meta
 //Spring imports
 import org.springframework.beans.factory.annotation.Required;
 
+//File.Utils import to handle NFS mounted directories
+import org.apache.commons.io.FileUtils;
+
+
 /**
  * Moves a {@link Product} file as a reponse to a Crawler lifecycle phase
  * 
@@ -61,7 +65,15 @@ public class MoveFile extends CrawlerAct
             toFile.getParentFile().mkdirs();
          LOG.log(Level.INFO, "Moving file " + srcFile.getAbsolutePath()
                + " to " + toFile.getAbsolutePath());
-         return srcFile.renameTo(toFile);
+         if(!srcFile.renameTo(toFile)) {//If the file failed to copy
+        	 LOG.log(Level.INFO, "Moving failed, possibly because ingest dir is nfs mounted. Retrying to move " + srcFile.getAbsolutePath()
+                     + " to " + toFile.getAbsolutePath());
+        	 FileUtils.copyFileToDirectory(srcFile, toFile.getParentFile());
+        	 FileUtils.forceDelete(srcFile); //Need to delete the old file
+        	 return true; //File copied on second attempt
+         }
+         else
+        	 return true; //File copied
       } catch (Exception e) {
          throw new CrawlerActionException("Failed to move file from " + mvFile
                + " to " + this.toDir + " : " + e.getMessage());