camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1456460 - in /camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote: FtpOperations.java SftpOperations.java
Date Thu, 14 Mar 2013 14:56:01 GMT
Author: davsclaus
Date: Thu Mar 14 14:56:01 2013
New Revision: 1456460

URL: http://svn.apache.org/r1456460
Log:
CAMEL-6164: Added debug logging in camel-ftp how long time it takes to upload a file with
ftp producer

Modified:
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java?rev=1456460&r1=1456459&r2=1456460&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
Thu Mar 14 14:56:01 2013
@@ -38,6 +38,8 @@ import org.apache.camel.component.file.G
 import org.apache.camel.util.FileUtil;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.StopWatch;
+import org.apache.camel.util.TimeUtils;
 import org.apache.commons.net.ftp.FTPClient;
 import org.apache.commons.net.ftp.FTPClientConfig;
 import org.apache.commons.net.ftp.FTPFile;
@@ -548,13 +550,25 @@ public class FtpOperations implements Re
                     is = exchange.getIn().getMandatoryBody(InputStream.class);
                 }
             }
+
+            final StopWatch watch = new StopWatch();
+            boolean answer;
+            log.debug("About to store file: {} using stream: {}", targetName, is);
             if (endpoint.getFileExist() == GenericFileExist.Append) {
                 log.trace("Client appendFile: {}", targetName);
-                return client.appendFile(targetName, is);
+                answer = client.appendFile(targetName, is);
             } else {
                 log.trace("Client storeFile: {}", targetName);
-                return client.storeFile(targetName, is);
+                answer = client.storeFile(targetName, is);
+            }
+            watch.stop();
+            if (log.isDebugEnabled()) {
+                log.debug("Took {} ({} millis) to store file: {} and FTP client returned:
{}",
+                        new Object[]{TimeUtils.printDuration(watch.taken()), watch.taken(),
targetName, answer});
             }
+
+            return answer;
+
         } catch (IOException e) {
             throw new GenericFileOperationFailedException(client.getReplyCode(), client.getReplyString(),
e.getMessage(), e);
         } catch (InvalidPayloadException e) {

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java?rev=1456460&r1=1456459&r2=1456460&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
Thu Mar 14 14:56:01 2013
@@ -47,6 +47,8 @@ import org.apache.camel.util.FileUtil;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
 
+import org.apache.camel.util.StopWatch;
+import org.apache.camel.util.TimeUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -722,6 +724,9 @@ public class SftpOperations implements R
             if (is == null) {
                 is = exchange.getIn().getMandatoryBody(InputStream.class);
             }
+
+            final StopWatch watch = new StopWatch();
+            LOG.debug("About to store file: {} using stream: {}", targetName, is);
             if (endpoint.getFileExist() == GenericFileExist.Append) {
                 LOG.trace("Client appendFile: {}", targetName);
                 channel.put(is, targetName, ChannelSftp.APPEND);
@@ -730,6 +735,11 @@ public class SftpOperations implements R
                 // override is default
                 channel.put(is, targetName);
             }
+            watch.stop();
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Took {} ({} millis) to store file: {} and FTP client returned:
true",
+                        new Object[]{TimeUtils.printDuration(watch.taken()), watch.taken(),
targetName});
+            }
 
             // after storing file, we may set chmod on the file
             String mode = endpoint.getConfiguration().getChmod();



Mime
View raw message