You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2008/09/15 18:30:33 UTC
svn commit: r695535 - in /activemq/camel/trunk/components/camel-ftp/src:
main/java/org/apache/camel/component/file/remote/
test/java/org/apache/camel/component/file/remote/
Author: davsclaus
Date: Mon Sep 15 09:30:31 2008
New Revision: 695535
URL: http://svn.apache.org/viewvc?rev=695535&view=rev
Log:
CAMEL-903: timestamp checking for new ftp files to download is disabled by default now. Its not reliable across FTP servers. Clocks for client and server could be out-of-time and FTP servers only return time as HH:mm not with seconds. Timestamp check will be removed in Camel 2.0
Modified:
activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java
activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java
activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNonExclusiveReadTest.java
Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java?rev=695535&r1=695534&r2=695535&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java Mon Sep 15 09:30:31 2008
@@ -165,9 +165,18 @@
log.trace("Polling file: " + ftpFile);
}
- long ts = ftpFile.getTimestamp().getTimeInMillis();
- // TODO do we need to adjust the TZ? can we?
- if (ts > lastPollTime && isMatched(ftpFile)) {
+ // if using last polltime for timestamp matcing (to be removed in Camel 2.0)
+ boolean timestampMatched = true;
+ if (isTimestamp()) {
+ // TODO do we need to adjust the TZ? can we?
+ long ts = ftpFile.getTimestamp().getTimeInMillis();
+ timestampMatched = ts > lastPollTime;
+ if (log.isTraceEnabled()) {
+ log.trace("The file is to old + " + ftpFile + ". lastPollTime=" + lastPollTime + " > fileTimestamp=" + ts);
+ }
+ }
+
+ if (timestampMatched && isMatched(ftpFile)) {
String fullFileName = getFullFileName(ftpFile);
// is we use excluse read then acquire the exclusive read (waiting until we got it)
Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java?rev=695535&r1=695534&r2=695535&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java Mon Sep 15 09:30:31 2008
@@ -26,6 +26,8 @@
public abstract class RemoteFileConsumer<T extends RemoteFileExchange> extends ScheduledPollConsumer<T> {
protected final transient Log log = LogFactory.getLog(getClass());
protected RemoteFileEndpoint<T> endpoint;
+
+ // @deprecated lastPollTime to be removed in Camel 2.0
protected long lastPollTime;
protected boolean recursive;
@@ -37,6 +39,7 @@
protected String moveNamePostfix;
protected String excludedNamePrefix;
protected String excludedNamePostfix;
+ private boolean timestamp;
public RemoteFileConsumer(RemoteFileEndpoint<T> endpoint, Processor processor) {
super(endpoint, processor);
@@ -195,4 +198,20 @@
public void setExcludedNamePostfix(String excludedNamePostfix) {
this.excludedNamePostfix = excludedNamePostfix;
}
+
+ /**
+ * @deprecated the timestamp feature will be removed in Camel 2.0
+ */
+ public boolean isTimestamp() {
+ return timestamp;
+ }
+
+ /**
+ * Sets wether polling should use last poll timestamp for filtering only new files.
+ * @deprecated the timestamp feature will be removed in Camel 2.0
+ */
+ public void setTimestamp(boolean timestamp) {
+ this.timestamp = timestamp;
+ }
+
}
Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java?rev=695535&r1=695534&r2=695535&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java Mon Sep 15 09:30:31 2008
@@ -162,10 +162,18 @@
log.trace("Polling file: " + sftpFile);
}
- long ts = sftpFile.getAttrs().getMTime() * 1000L;
+ // if using last polltime for timestamp matcing (to be removed in Camel 2.0)
+ boolean timestampMatched = true;
+ if (isTimestamp()) {
+ // TODO do we need to adjust the TZ? can we?
+ long ts = sftpFile.getAttrs().getMTime() * 1000L;
+ timestampMatched = ts > lastPollTime;
+ if (log.isTraceEnabled()) {
+ log.trace("The file is to old + " + sftpFile + ". lastPollTime=" + lastPollTime + " > fileTimestamp=" + ts);
+ }
+ }
- // TODO do we need to adjust the TZ? can we?
- if (ts > lastPollTime && isMatched(sftpFile)) {
+ if (timestampMatched && isMatched(sftpFile)) {
String fullFileName = getFullFileName(sftpFile);
// is we use excluse read then acquire the exclusive read (waiting until we got it)
Modified: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNonExclusiveReadTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNonExclusiveReadTest.java?rev=695535&r1=695534&r2=695535&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNonExclusiveReadTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNonExclusiveReadTest.java Mon Sep 15 09:30:31 2008
@@ -32,7 +32,8 @@
private static final Log LOG = LogFactory.getLog(FromFtpExclusiveReadTest.class);
private int port = 20027;
- private String ftpUrl = "ftp://admin@localhost:" + port + "/slowfile?password=admin&consumer.exclusiveReadLock=false&consumer.delay=500";
+ private String ftpUrl = "ftp://admin@localhost:" + port + "/slowfile?password=admin" +
+ "&consumer.exclusiveReadLock=false&consumer.delay=500&consumer.timestamp=true";
public int getPort() {
return port;