You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-commits@incubator.apache.org by xa...@apache.org on 2007/07/09 15:06:49 UTC
svn commit: r554675 - in /incubator/ivy/core/trunk: ./
src/java/org/apache/ivy/plugins/repository/ssh/
src/java/org/apache/ivy/util/ src/java/org/apache/ivy/util/url/
Author: xavier
Date: Mon Jul 9 08:06:49 2007
New Revision: 554675
URL: http://svn.apache.org/viewvc?view=rev&rev=554675
Log:
IMPROVEMENT: File buffer increased to 64KB (IVY-551)
Modified:
incubator/ivy/core/trunk/CHANGES.txt
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/Scp.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshRepository.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/util/FileUtil.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java
Modified: incubator/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/CHANGES.txt?view=diff&rev=554675&r1=554674&r2=554675
==============================================================================
--- incubator/ivy/core/trunk/CHANGES.txt (original)
+++ incubator/ivy/core/trunk/CHANGES.txt Mon Jul 9 08:06:49 2007
@@ -55,6 +55,7 @@
- NEW: A checkstyle report is generated (IVY-483) (thanks to Jan Materne)
- NEW: Hide private or specific conf when publishing (IVY-77)
+- IMPROVEMENT: File buffer increased to 64KB (IVY-551)
- IMPROVEMENT: Expose default cache location as an ant property (IVY-563)
- IMPROVEMENT: Expose Ivy variables as Ant Properties (IVY-564)
- IMPROVEMENT: Change default cache location (IVY-530)
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/Scp.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/Scp.java?view=diff&rev=554675&r1=554674&r2=554675
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/Scp.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/Scp.java Mon Jul 9 08:06:49 2007
@@ -285,7 +285,7 @@
private void sendFile(Channel channel, String localFile, String remoteName, String mode)
throws IOException, RemoteScpException {
- byte[] buffer = new byte[8192];
+ byte[] buffer = new byte[64 * 1024];
OutputStream os = new BufferedOutputStream(channel.getOutputStream(), 40000);
InputStream is = new BufferedInputStream(channel.getInputStream(), 512);
@@ -367,7 +367,7 @@
*/
private FileInfo receiveStream(Channel channel, String file, OutputStream targetStream)
throws IOException, RemoteScpException {
- byte[] buffer = new byte[8192];
+ byte[] buffer = new byte[64 * 1024];
OutputStream os = channel.getOutputStream();
InputStream is = channel.getInputStream();
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshRepository.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshRepository.java?view=diff&rev=554675&r1=554674&r2=554675
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshRepository.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshRepository.java Mon Jul 9 08:06:49 2007
@@ -41,6 +41,12 @@
*/
public class SshRepository extends AbstractSshBasedRepository {
+ private static final int BUFFER_SIZE = 64 * 1024;
+
+ private static final String ARGUMENT_PLACEHOLDER = "%arg";
+
+ private static final int POLL_SLEEP_TIME = 500;
+
private char fileSeparator = '/';
private String listCommand = "ls -1";
@@ -49,10 +55,6 @@
private String createDirCommand = "mkdir";
- private final static String ARGUMENT_PLACEHOLDER = "%arg";
-
- private final static int POLL_SLEEP_TIME = 500;
-
/**
* create a new resource with lazy initializing
*/
@@ -118,15 +120,15 @@
throw (IOException) new IOException("Channel connection problems").initCause(e1);
}
- byte[] buffer = new byte[8192];
+ byte[] buffer = new byte[BUFFER_SIZE];
while (true) {
int avail = 0;
while ((avail = stdout.available()) > 0) {
- int len = stdout.read(buffer, 0, (avail > 8191 ? 8192 : avail));
+ int len = stdout.read(buffer, 0, (avail > BUFFER_SIZE - 1 ? BUFFER_SIZE : avail));
strStdout.append(new String(buffer, 0, len));
}
while ((avail = stderr.available()) > 0) {
- int len = stderr.read(buffer, 0, (avail > 8191 ? 8192 : avail));
+ int len = stderr.read(buffer, 0, (avail > BUFFER_SIZE - 1 ? BUFFER_SIZE : avail));
strStderr.append(new String(buffer, 0, len));
}
if (channel.isClosed()) {
@@ -135,15 +137,16 @@
try {
Thread.sleep(POLL_SLEEP_TIME);
} catch (Exception ee) {
+ // ignored
}
}
int avail = 0;
while ((avail = stdout.available()) > 0) {
- int len = stdout.read(buffer, 0, (avail > 8191 ? 8192 : avail));
+ int len = stdout.read(buffer, 0, (avail > BUFFER_SIZE - 1 ? BUFFER_SIZE : avail));
strStdout.append(new String(buffer, 0, len));
}
while ((avail = stderr.available()) > 0) {
- int len = stderr.read(buffer, 0, (avail > 8191 ? 8192 : avail));
+ int len = stderr.read(buffer, 0, (avail > BUFFER_SIZE - 1 ? BUFFER_SIZE : avail));
strStderr.append(new String(buffer, 0, len));
}
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/FileUtil.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/FileUtil.java?view=diff&rev=554675&r1=554674&r2=554675
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/FileUtil.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/FileUtil.java Mon Jul 9 08:06:49 2007
@@ -39,10 +39,9 @@
* Utility class used to deal with file related operations, like copy, full reading, symlink, ...
*/
public class FileUtil {
- // tried some other values with empty files... seems to be the best one (512 * 1024 is very bad)
- // 8 * 1024 is also the size used by ant in its FileUtils... maybe they've done more study about
- // it ;-)
- private static final int BUFFER_SIZE = 8 * 1024;
+ // according to tests by users, 64kB seems to be a good value for the buffer used during copy
+ // further improvements could be obtained using NIO API
+ private static final int BUFFER_SIZE = 64 * 1024;
private static final byte[] EMPTY_BUFFER = new byte[0];
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java?view=diff&rev=554675&r1=554674&r2=554675
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java Mon Jul 9 08:06:49 2007
@@ -36,7 +36,7 @@
*/
public class BasicURLHandler extends AbstractURLHandler {
- private static final int BUFFER_SIZE = 4096;
+ private static final int BUFFER_SIZE = 64 * 1024;
private static class HttpStatus {
static final int SC_OK = 200;