You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by lh...@apache.org on 2008/12/10 12:39:51 UTC
svn commit: r725057 -
/servicemix/sandbox/lhein/servicemix-vfs/trunk/src/main/java/org/apache/servicemix/vfs/VFSPollingEndpoint.java
Author: lhein
Date: Wed Dec 10 03:39:51 2008
New Revision: 725057
URL: http://svn.apache.org/viewvc?rev=725057&view=rev
Log:
checking for file size changes to skip files being copied at time of polling
Modified:
servicemix/sandbox/lhein/servicemix-vfs/trunk/src/main/java/org/apache/servicemix/vfs/VFSPollingEndpoint.java
Modified: servicemix/sandbox/lhein/servicemix-vfs/trunk/src/main/java/org/apache/servicemix/vfs/VFSPollingEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/sandbox/lhein/servicemix-vfs/trunk/src/main/java/org/apache/servicemix/vfs/VFSPollingEndpoint.java?rev=725057&r1=725056&r2=725057&view=diff
==============================================================================
--- servicemix/sandbox/lhein/servicemix-vfs/trunk/src/main/java/org/apache/servicemix/vfs/VFSPollingEndpoint.java (original)
+++ servicemix/sandbox/lhein/servicemix-vfs/trunk/src/main/java/org/apache/servicemix/vfs/VFSPollingEndpoint.java Wed Dec 10 03:39:51 2008
@@ -186,13 +186,12 @@
}
} finally {
// remove file from set of already processed files
- //workingSet.remove(aFile);
+ workingSet.remove(aFile);
// remove the open exchange
openExchanges.remove(exchange.getExchangeId());
// unlock the file
unlockAsyncFile(aFile);
}
-
} else {
// strange, we don't know this exchange
logger.debug("Received unknown exchange. Will be ignored...");
@@ -280,6 +279,10 @@
* @throws Exception on IO errors
*/
protected void pollFile(final FileObject aFile) throws Exception {
+ // check if file is fully available
+ if (!isFullyAvailable(aFile)) {
+ return;
+ }
// try to add to set of processed files
if (workingSet.add(aFile)) {
if (logger.isDebugEnabled()) {
@@ -356,6 +359,31 @@
}
/**
+ * checks if a file is available
+ *
+ * @param aFile the file to check
+ * @return true if available
+ */
+ private boolean isFullyAvailable(FileObject aFile) {
+ try {
+ if (aFile.getContent() != null) {
+ long size_old = aFile.getContent().getSize();
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ long size_new = aFile.getContent().getSize();
+ return (size_old == size_new);
+ }
+ } catch (Exception ex) {
+ // ignore
+ }
+ // default to true
+ return true;
+ }
+
+ /**
* Specifies if files should be deleted after they are processed. Default
* value is <code>true</code>.
*