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 2015/03/19 08:28:49 UTC
[2/3] camel git commit: CAMEL-8513: Add option to use a larger buffer
size so download is faster
CAMEL-8513: Add option to use a larger buffer size so download is faster
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/897c4167
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/897c4167
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/897c4167
Branch: refs/heads/master
Commit: 897c4167a0c26cceea469e5117ccb38f4c652694
Parents: 6d23c13
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Mar 19 08:28:27 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Mar 19 08:29:58 2015 +0100
----------------------------------------------------------------------
.../camel/component/file/remote/FtpEndpoint.java | 10 ++++++++--
.../camel/component/file/remote/FtpsEndpoint.java | 12 +++++++++---
.../file/remote/RemoteFileConfiguration.java | 15 +++++++++++++++
3 files changed, 32 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/897c4167/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
index f3961b4..b650f3a 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
@@ -87,6 +87,10 @@ public class FtpEndpoint<T extends FTPFile> extends RemoteFileEndpoint<FTPFile>
client = createFtpClient();
}
+ // use configured buffer size which is larger and therefore faster (as the default is no buffer)
+ if (getConfiguration().getReceiveBufferSize() > 0) {
+ client.setBufferSize(getConfiguration().getReceiveBufferSize());
+ }
// set any endpoint configured timeouts
if (getConfiguration().getConnectTimeout() > -1) {
client.setConnectTimeout(getConfiguration().getConnectTimeout());
@@ -126,8 +130,10 @@ public class FtpEndpoint<T extends FTPFile> extends RemoteFileEndpoint<FTPFile>
}
if (log.isDebugEnabled()) {
- log.debug("Created FTPClient [connectTimeout: {}, soTimeout: {}, dataTimeout: {}]: {}",
- new Object[]{client.getConnectTimeout(), getSoTimeout(), dataTimeout, client});
+ log.debug("Created FTPClient [connectTimeout: {}, soTimeout: {}, dataTimeout: {}, bufferSize: {}"
+ + ", receiveDataSocketBufferSize: {}, sendDataSocketBufferSize: {}]: {}",
+ new Object[]{client.getConnectTimeout(), getSoTimeout(), dataTimeout, client.getBufferSize(),
+ client.getReceiveDataSocketBufferSize(), client.getSendDataSocketBufferSize(), client});
}
FtpOperations operations = new FtpOperations(client, getFtpClientConfig());
http://git-wip-us.apache.org/repos/asf/camel/blob/897c4167/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java
index 53f7bc7..471eaee 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java
@@ -136,7 +136,7 @@ public class FtpsEndpoint extends FtpEndpoint<FTPFile> {
client.setTrustManager(trustMgrFactory.getTrustManagers()[0]);
}
}
-
+
return client;
}
@@ -150,6 +150,10 @@ public class FtpsEndpoint extends FtpEndpoint<FTPFile> {
client = (FTPSClient) createFtpClient();
}
+ // use configured buffer size which is larger and therefore faster (as the default is no buffer)
+ if (getConfiguration().getReceiveBufferSize() > 0) {
+ client.setBufferSize(getConfiguration().getReceiveBufferSize());
+ }
// set any endpoint configured timeouts
if (getConfiguration().getConnectTimeout() > -1) {
client.setConnectTimeout(getConfiguration().getConnectTimeout());
@@ -188,8 +192,10 @@ public class FtpsEndpoint extends FtpEndpoint<FTPFile> {
}
if (log.isDebugEnabled()) {
- log.debug("Created FTPSClient [connectTimeout: {}, soTimeout: {}, dataTimeout: {}]: {}",
- new Object[]{client.getConnectTimeout(), getSoTimeout(), dataTimeout, client});
+ log.debug("Created FTPClient [connectTimeout: {}, soTimeout: {}, dataTimeout: {}, bufferSize: {}"
+ + ", receiveDataSocketBufferSize: {}, sendDataSocketBufferSize: {}]: {}",
+ new Object[]{client.getConnectTimeout(), getSoTimeout(), dataTimeout, client.getBufferSize(),
+ client.getReceiveDataSocketBufferSize(), client.getSendDataSocketBufferSize(), client});
}
FtpsOperations operations = new FtpsOperations(client, getFtpClientConfig());
http://git-wip-us.apache.org/repos/asf/camel/blob/897c4167/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java
index bc8f89b..b2a9958 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java
@@ -60,6 +60,8 @@ public abstract class RemoteFileConfiguration extends GenericFileConfiguration {
private int timeout = 30000;
@UriParam
private int soTimeout;
+ @UriParam(defaultValue = "32768")
+ private int receiveBufferSize = 32 * 1024;
@UriParam
private boolean throwExceptionOnConnectFailed;
@UriParam
@@ -253,6 +255,19 @@ public abstract class RemoteFileConfiguration extends GenericFileConfiguration {
this.soTimeout = soTimeout;
}
+ public int getReceiveBufferSize() {
+ return receiveBufferSize;
+ }
+
+ /**
+ * The receive (download) buffer size
+ * <p/>
+ * Used only by FTPClient
+ */
+ public void setReceiveBufferSize(int receiveBufferSize) {
+ this.receiveBufferSize = receiveBufferSize;
+ }
+
public boolean isThrowExceptionOnConnectFailed() {
return throwExceptionOnConnectFailed;
}