camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [camel] 09/11: CAMEL-12127: camel-ftp - Add option to turn on logging of transfer activity. Lets also see it in the JMX consumer so we can monitor when it last downloaded something.
Date Mon, 08 Jan 2018 10:20:55 GMT
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 0fcbcb53969e72e8f20669d68cbef5c029e31aea
Author: Claus Ibsen <claus.ibsen@gmail.com>
AuthorDate: Mon Jan 8 09:02:33 2018 +0100

    CAMEL-12127: camel-ftp - Add option to turn on logging of transfer activity. Lets also
see it in the JMX consumer so we can monitor when it last downloaded something.
---
 .../remote/DefaultFtpClientActivityListener.java    | 21 ++++++++++++++-------
 .../file/remote/FtpClientActivityListener.java      |  5 +++++
 .../camel/component/file/remote/FtpOperations.java  |  2 ++
 3 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/DefaultFtpClientActivityListener.java
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/DefaultFtpClientActivityListener.java
index 8907fe4..4b45403 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/DefaultFtpClientActivityListener.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/DefaultFtpClientActivityListener.java
@@ -26,14 +26,14 @@ public class DefaultFtpClientActivityListener implements FtpClientActivityListen
     private final CamelLogger logger;
     private final String host;
     private final boolean verbose;
-    private boolean download;
+    private boolean download = true;
 
-    private volatile String fileName;
-    private volatile String lastLogActivity;
-    private volatile String lastVerboseLogActivity;
-    private volatile long lastLogActivityTimestamp = -1;
-    private volatile long lastVerboseLogActivityTimestamp = -1;
-    private volatile long transferredBytes;
+    private String fileName;
+    private String lastLogActivity;
+    private String lastVerboseLogActivity;
+    private long lastLogActivityTimestamp = -1;
+    private long lastVerboseLogActivityTimestamp = -1;
+    private long transferredBytes;
 
     public DefaultFtpClientActivityListener(CamelLogger logger, boolean verbose, String host)
{
         this.logger = logger;
@@ -42,14 +42,21 @@ public class DefaultFtpClientActivityListener implements FtpClientActivityListen
     }
 
     @Override
+    public void setDownload(boolean download) {
+        this.download = download;
+    }
+
+    @Override
     public void setRemoteFileName(String fileName) {
         this.fileName = fileName;
     }
 
+    @Override
     public String getLastLogActivity() {
         return lastLogActivity;
     }
 
+    @Override
     public long getLastLogActivityTimestamp() {
         return lastLogActivityTimestamp;
     }
diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpClientActivityListener.java
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpClientActivityListener.java
index 0764b4d..07bb0e8 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpClientActivityListener.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpClientActivityListener.java
@@ -31,6 +31,11 @@ public interface FtpClientActivityListener extends CopyStreamListener {
 
     long getLastVerboseLogActivityTimestamp();
 
+    /**
+     * Whether in download or upload mode
+     */
+    void setDownload(boolean download);
+
     void setRemoteFileName(String fileName);
 
     void onGeneralError(String host, String errorMessage);
diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
index 770e19d..ea3dc1d 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
@@ -353,6 +353,7 @@ public class FtpOperations implements RemoteFileOperations<FTPFile>
{
 
     public boolean retrieveFile(String name, Exchange exchange) throws GenericFileOperationFailedException
{
         // store the name of the file to download on the listener
+        clientActivityListener.setDownload(true);
         clientActivityListener.setRemoteFileName(name);
         clientActivityListener.onBeginDownloading(endpoint.getConfiguration().remoteServerInformation(),
name);
 
@@ -561,6 +562,7 @@ public class FtpOperations implements RemoteFileOperations<FTPFile>
{
         name = endpoint.getConfiguration().normalizePath(name);
 
         // store the name of the file to upload on the listener
+        clientActivityListener.setDownload(false);
         clientActivityListener.setRemoteFileName(name);
         clientActivityListener.onBeginUploading(endpoint.getConfiguration().remoteServerInformation(),
name);
 

-- 
To stop receiving notification emails like this one, please contact
"commits@camel.apache.org" <commits@camel.apache.org>.

Mime
View raw message