CAMEL-9808: Enable configuration of bulk requests

Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f6586d03
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f6586d03
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f6586d03

Branch: refs/heads/master
Commit: f6586d0390598ee82567c5da4ca9b37ccc8bc381
Parents: 08e8d26
Author: Thomas Küstermann <thoku...@outlook.com>
Authored: Mon Apr 4 13:05:36 2016 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Mon Apr 4 15:16:35 2016 +0200

----------------------------------------------------------------------
 .../file/remote/SftpConfiguration.java          | 14 ++++++++++++++
 .../component/file/remote/SftpOperations.java   | 20 ++++++++++++++++++++
 2 files changed, 34 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f6586d03/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConfiguration.java
----------------------------------------------------------------------
diff --git 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConfiguration.java
 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConfiguration.java
index 737ee10..7e740ae 100644
--- 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConfiguration.java
+++ 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConfiguration.java
@@ -65,6 +65,8 @@ public class SftpConfiguration extends 
RemoteFileConfiguration {
     private String preferredAuthentications;
     @UriParam(defaultValue = "WARN")
     private LoggingLevel jschLoggingLevel = LoggingLevel.WARN;
+    @UriParam(label="advanced", description="Specifies how many requests may 
be outstanding at any one time.")
+    private Integer bulkRequests;
 
     public SftpConfiguration() {
         setProtocol("sftp");
@@ -269,4 +271,16 @@ public class SftpConfiguration extends 
RemoteFileConfiguration {
     public void setJschLoggingLevel(LoggingLevel jschLoggingLevel) {
         this.jschLoggingLevel = jschLoggingLevel;
     }
+    
+    /**
+     * Specifies how many requests may be outstanding at any one time. 
Increasing this value may
+     * slightly improve file transfer speed but will increase memory usage.
+     */
+    public void setBulkRequests(Integer bulkRequests) {
+               this.bulkRequests = bulkRequests;
+       }
+    
+    public Integer getBulkRequests() {
+               return bulkRequests;
+       }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/f6586d03/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
----------------------------------------------------------------------
diff --git 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
index bd25fb0..ea17aeb 100644
--- 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
+++ 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
@@ -161,8 +161,28 @@ public class SftpOperations implements 
RemoteFileOperations<ChannelSftp.LsEntry>
             }
         }
 
+        configureBulkRequests();
+        
         return true;
     }
+    
+    private void configureBulkRequests() {
+       try {
+               tryConfigureBulkRequests();
+       } catch (JSchException e) {
+               throw new GenericFileOperationFailedException("Failed to 
configure number of bulk requests", e);
+       }
+    }
+    
+    private void tryConfigureBulkRequests() throws JSchException {
+       Integer bulkRequests = endpoint.getConfiguration().getBulkRequests();
+       
+       if (bulkRequests != null) {
+               LOG.trace("configuring channel to use up to {} bulk 
request(s)", bulkRequests);
+               
+               channel.setBulkRequests(bulkRequests);
+       }
+    }
 
     protected Session createSession(final RemoteFileConfiguration 
configuration) throws JSchException {
         final JSch jsch = new JSch();

Reply via email to