You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by im...@apache.org on 2005/11/02 20:59:16 UTC
svn commit: r330337 - in /jakarta/commons/proper/vfs/trunk: ./
src/java/org/apache/commons/vfs/provider/sftp/
src/test/org/apache/commons/vfs/
Author: imario
Date: Wed Nov 2 11:59:06 2005
New Revision: 330337
URL: http://svn.apache.org/viewcvs?rev=330337&view=rev
Log:
sftp enh: using listChildrenResolved for performance
sftp enh: activated RandomRead
Modified:
jakarta/commons/proper/vfs/trunk/RELEASE_NOTES.txt
jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java
jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileProvider.java
jakarta/commons/proper/vfs/trunk/src/test/org/apache/commons/vfs/RunTest.java
Modified: jakarta/commons/proper/vfs/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/RELEASE_NOTES.txt?rev=330337&r1=330336&r2=330337&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/RELEASE_NOTES.txt (original)
+++ jakarta/commons/proper/vfs/trunk/RELEASE_NOTES.txt Wed Nov 2 11:59:06 2005
@@ -3,6 +3,8 @@
sftp:
new configuration parameter SftpFileSystemConfigBuilder.timeout
upgrade to jsch-0.1.23
+using listChildrenResolved for performance
+activated RandomRead
ftp:
better error message if it isnt possible to aquire a input or output stream
Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java?rev=330337&r1=330336&r2=330337&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java Wed Nov 2 11:59:06 2005
@@ -275,11 +275,11 @@
continue;
}
- SftpFileObject fo = (SftpFileObject) getFileSystem().resolveFile(
- getFileSystem().getFileSystemManager().resolveName(
- getName(),
- UriParser.encode(name),
- NameScope.CHILD));
+ SftpFileObject fo = (SftpFileObject) getFileSystem()
+ .resolveFile(
+ getFileSystem().getFileSystemManager().resolveName(
+ getName(), UriParser.encode(name),
+ NameScope.CHILD));
fo.setStat(stat.getAttrs());
children.add(fo);
@@ -323,21 +323,29 @@
*/
InputStream getInputStream(long filePointer) throws IOException
{
- throw new UnsupportedOperationException(
- "Implemented. Yes. But have to wait for jsch release :-)");
- /*
- * final ChannelSftp channel = fileSystem.getChannel(); try { // return
- * channel.get(getName().getPath()); // hmmm - using the in memory
- * method is soooo much faster ...
- * // TODO - Don't read the entire file into memory. Use the //
- * stream-based methods on ChannelSftp once they work properly final
- * ByteArrayOutputStream outstr = new ByteArrayOutputStream(); try {
- * channel.get(getName().getPathDecoded(), outstr, null,
- * ChannelSftp.RESUME, filePointer); } catch (SftpException e) { throw
- * new FileSystemException(e); } outstr.close(); return new
- * ByteArrayInputStream(outstr.toByteArray());
- * } finally { fileSystem.putChannel(channel); }
- */
+ final ChannelSftp channel = fileSystem.getChannel();
+ try
+ {
+ // hmmm - using the in memory method is soooo much faster ...
+ // TODO - Don't read the entire file into memory. Use the
+ // stream-based methods on ChannelSftp once they work properly final
+ ByteArrayOutputStream outstr = new ByteArrayOutputStream();
+ try
+ {
+ channel.get(getName().getPathDecoded(), outstr, null,
+ ChannelSftp.RESUME, filePointer);
+ }
+ catch (SftpException e)
+ {
+ throw new FileSystemException(e);
+ }
+ outstr.close();
+ return new ByteArrayInputStream(outstr.toByteArray());
+ }
+ finally
+ {
+ fileSystem.putChannel(channel);
+ }
}
/**
Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileProvider.java?rev=330337&r1=330336&r2=330337&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileProvider.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileProvider.java Wed Nov 2 11:59:06 2005
@@ -49,8 +49,8 @@
Capability.URI,
Capability.WRITE_CONTENT,
Capability.GET_LAST_MODIFIED,
- Capability.SET_LAST_MODIFIED_FILE
-// Capability.RANDOM_ACCESS_READ
+ Capability.SET_LAST_MODIFIED_FILE,
+ Capability.RANDOM_ACCESS_READ
}));
public final static String ATTR_USER_INFO = "UI";
Modified: jakarta/commons/proper/vfs/trunk/src/test/org/apache/commons/vfs/RunTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/test/org/apache/commons/vfs/RunTest.java?rev=330337&r1=330336&r2=330337&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/test/org/apache/commons/vfs/RunTest.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/test/org/apache/commons/vfs/RunTest.java Wed Nov 2 11:59:06 2005
@@ -8,6 +8,7 @@
import org.apache.commons.vfs.provider.jar.test.NestedJarTestCase;
import org.apache.commons.vfs.provider.sftp.test.SftpProviderTestCase;
import org.apache.commons.vfs.provider.smb.test.SmbProviderTestCase;
+import org.apache.commons.vfs.provider.smb.test.FileNameTestCase;
import org.apache.commons.vfs.provider.tar.test.NestedTarTestCase;
import org.apache.commons.vfs.provider.tar.test.NestedTbz2TestCase;
import org.apache.commons.vfs.provider.tar.test.NestedTgzTestCase;
@@ -30,83 +31,91 @@
public class RunTest
{
- public static void main(String[] args) throws Exception
- {
- Properties props = System.getProperties();
- props.setProperty("test.data.src", "src/test-data");
- props.setProperty("test.basedir", "target/test-data");
- props.setProperty("test.policy", "src/test-data/test.policy");
- props.setProperty("test.secure", "false");
- props.setProperty("test.smb.uri", "smb://HOME\\vfsusr:vfs%2f%25\\te:st@10.0.1.54/vfsusr/vfstest");
- props.setProperty("test.ftp.uri", "ftp://vfsusr:vfs%2f%25\\te:st@10.0.1.54/vfstest");
- props.setProperty("test.http.uri", "http://10.0.1.54/vfstest");
- props.setProperty("test.webdav.uri", "webdav://vfsusr:vfs%2f%25\\te:st@10.0.1.54/vfstest");
- props.setProperty("test.sftp.uri", "sftp://vfsusr:vfs%2f%25\\te:st@10.0.1.54/vfstest");
-
- Test tests[] = new Test[]
- {
- new GenericFileNameTestCase(),
-
- UrlProviderHttpTestCase.suite(),
-
- LocalProviderTestCase.suite(),
- VirtualProviderTestCase.suite(),
- TemporaryProviderTestCase.suite(),
- UrlProviderTestCase.suite(),
- ResourceProviderTestCase.suite(),
-
- FtpProviderTestCase.suite(),
- HttpProviderTestCase.suite(),
-
- WebdavProviderTestCase.suite(),
- SmbProviderTestCase.suite(),
- SftpProviderTestCase.suite(),
-
- JarProviderTestCase.suite(),
- NestedJarTestCase.suite(),
- ZipProviderTestCase.suite(),
- NestedZipTestCase.suite(),
- TarProviderTestCase.suite(),
- TgzProviderTestCase.suite(),
- Tbz2ProviderTestCase.suite(),
- NestedTarTestCase.suite(),
- NestedTgzTestCase.suite(),
- NestedTbz2TestCase.suite(),
- };
-
- TestResult result = new TestResult()
- {
- public void startTest(Test test)
- {
- System.out.println("start " + test);
- System.out.flush();
- }
-
- public void endTest(Test test)
- {
- // System.err.println("end " + test);
- }
-
- public synchronized void addError(Test test, Throwable throwable)
- {
- throwable.printStackTrace();
- }
-
- public synchronized void addFailure(Test test, AssertionFailedError assertionFailedError)
- {
- assertionFailedError.printStackTrace();
- }
- };
-
- for (int i = 0; i < tests.length; i++)
- {
- System.out.println("start test#" + i);
- System.out.flush();
-
- Test test = tests[i];
- test.run(result);
-
-// break;
- }
- }
+ public static void main(String[] args) throws Exception
+ {
+ Properties props = System.getProperties();
+ props.setProperty("test.data.src", "src/test-data");
+ props.setProperty("test.basedir", "target/test-data");
+ props.setProperty("test.policy", "src/test-data/test.policy");
+ props.setProperty("test.secure", "false");
+ props.setProperty("test.smb.uri",
+ "smb://HOME\\vfsusr:vfs%2f%25\\te:st@10.0.1.54/vfsusr/vfstest");
+ props.setProperty("test.ftp.uri",
+ "ftp://vfsusr:vfs%2f%25\\te:st@10.0.1.54/vfstest");
+ props.setProperty("test.http.uri", "http://10.0.1.54/vfstest");
+ props.setProperty("test.webdav.uri",
+ "webdav://vfsusr:vfs%2f%25\\te:st@10.0.1.54/vfstest");
+ props.setProperty("test.sftp.uri",
+ "sftp://vfsusr:vfs%2f%25\\te:st@10.0.1.54/vfstest");
+
+ Test tests[] = new Test[]
+ {
+ // SmbProviderTestCase.suite(),
+
+ // LocalProviderTestCase.suite(),
+ // FtpProviderTestCase.suite(),
+
+ // UrlProviderHttpTestCase.suite(),
+
+ // VirtualProviderTestCase.suite(),
+ // TemporaryProviderTestCase.suite(),
+ // UrlProviderTestCase.suite(),
+ // ResourceProviderTestCase.suite(),
+
+ // HttpProviderTestCase.suite(),
+
+ // WebdavProviderTestCase.suite(),
+
+ SftpProviderTestCase.suite(),
+
+ // JarProviderTestCase.suite(),
+ // NestedJarTestCase.suite(),
+ // ZipProviderTestCase.suite(),
+ // NestedZipTestCase.suite(),
+ // TarProviderTestCase.suite(),
+ // TgzProviderTestCase.suite(),
+ // Tbz2ProviderTestCase.suite(),
+ // NestedTarTestCase.suite(),
+ // NestedTgzTestCase.suite(),
+ // NestedTbz2TestCase.suite(),
+ };
+
+ TestResult result = new TestResult()
+ {
+ public void startTest(Test test)
+ {
+ System.out.println("start " + test);
+ System.out.flush();
+ }
+
+ public void endTest(Test test)
+ {
+ // System.err.println("end " + test);
+ }
+
+ public synchronized void addError(Test test, Throwable throwable)
+ {
+ // throw new RuntimeException(throwable.getMessage());
+ throwable.printStackTrace();
+ }
+
+ public synchronized void addFailure(Test test,
+ AssertionFailedError assertionFailedError)
+ {
+ // throw new RuntimeException(assertionFailedError.getMessage());
+ assertionFailedError.printStackTrace();
+ }
+ };
+
+ for (int i = 0; i < tests.length; i++)
+ {
+ System.out.println("start test#" + i);
+ System.out.flush();
+
+ Test test = tests[i];
+ test.run(result);
+
+ // break;
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org