Resolution: Description:
========
We have a File Poller starter process for monitoring a directory/file which is updated by an FTP client. If a newly uploaded file is very large or the FTP transfer pace is slow, we have to wait for processing until it is fully transferred.
Environment:
=========
Windows 2003 Server , Windows 2008 server
RHEL Linux
Resolution:
=======
The strategy is different for Windows and Linux:
Linux: The "LastModifiedTime" of a file is dynamic as the file transfer occurs. The file transfer is completed if the current LastModifiedTime and the LastModifiedTime of some seconds before are the same. Note that there may be extreme case when the FTP transferring is paused for seconds and as a result the LastModifiedTime is the same during this period but actually is not yet finished.
Windows: The "LastModifiedTime" of a file stays unchanged. It is the time when the file was created on the file system. Consequently, we cannot use the same strategy as Linux. Use the following Java code to verify that the specified file is not accessed by other process.
File f = new File(fileName);
File f2 = new File(fileName);
isWriteable = f.renameTo(f2);
If the f.renameTo(f2) return false, it indicates that the FTP client is stilling updating the file. If the result is true, the FTP transfer is completed.
Attachments:
=========
my.process ( you can find the detailed process for the purpose of this KB)