[jcifs] Slow File Copy from Windows to Linux using JCIFS 1.3.17
Lim, Ludwig Isaac (Legacy System Archeaologist)
hou-fu.lin at hp.com
Tue Apr 1 05:49:15 MDT 2014
Hi:
I'm using JCIFS to programmatically copy batch of files from Windows to Linux using JCIFS. After upgrading from v 1.2.9 to 1.3.17, the performance turned very slow. A copy of 1.3 MB file using JCIFS v 1.2.9 takes 2.4 seconds but for v 1.3.17 it takes 10.9 seconds (with the same code).
Adding -Djcifs.util.loglevel=3 to program invocation gave me the following:
jcifs.smb.SmbException: Failed to connect: americas/<ip>
jcifs.util.transport.TransportException
java.net.NoRouteToHostException: No route to host
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at jcifs.smb.SmbTransport.ssn139(SmbTransport.java:196)
at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:249)
at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:325)
at jcifs.util.transport.Transport.run(Transport.java:241)
at java.lang.Thread.run(Thread.java:724)
at jcifs.util.transport.Transport.run(Transport.java:258)
at java.lang.Thread.run(Thread.java:724)
at jcifs.smb.SmbTransport.connect(SmbTransport.java:309)
at jcifs.smb.SmbTree.treeConnect(SmbTree.java:156)
at jcifs.smb.SmbTree.send(SmbTree.java:74)
at jcifs.smb.SmbTransport.getDfsReferrals(SmbTransport.java:703)
at jcifs.smb.Dfs.getTrustedDomains(Dfs.java:66)
at jcifs.smb.Dfs.resolve(Dfs.java:167)
at jcifs.smb.SmbFile.resolveDfs(SmbFile.java:671)
at jcifs.smb.SmbFile.send(SmbFile.java:773)
at jcifs.smb.SmbFileInputStream.readDirect(SmbFileInputStream.java:181)
at jcifs.smb.SmbFileInputStream.read(SmbFileInputStream.java:142)
at jcifs.smb.SmbFileInputStream.read(SmbFileInputStream.java:132)
at Test.main(Test.java:53)
My code is basically like this (with some parts removed):
class Test
{
public static void main(String args[])
{
final int BUFF_SIZE = 8 * 1024 ;
jcifs.Config.setProperty("jcifs.resolveOrder", "DNS");
jcifs.Config.setProperty ("jcifs.util.loglevel","3");
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("americas", "...", "...");
SmbFile rmifile;
try {
rmifile = new SmbFile("..",auth) ;
} catch (Exception e) {
System.out.println("Error : " + e.getMessage());
return;
}
File localfile = null;
InputStream bis = null;
OutputStream bos = null;
String localpath = "/home/accos/jcifs";
String filename = rmifile.getName();
localfile = new File(localpath + File.separator + filename);
byte[] buffer = new byte [BUFF_SIZE];
int bytesRead;
try {
bis = new SmbFileInputStream(rmifile);
bos = new FileOutputStream(localfile);
while ( (bytesRead = bis.read(buffer))>0 ) {
System.out.print("ok\n");
bos.write(buffer,0,bytesRead);
}
} catch ( Exception e) {
System.out.println("Unable to copy file from samba to local file : " + e.getMessage());
}
finally {
try {
bos.close();
bis.close();
} catch (IOException e) {
}
}
}
}
The file was copied as I was able to see bunch of "OK"s
Thanks in advance.
--Ludwig Lim-
P.S. Seems that the code below doesn't work
jcifs.Config.setProperty ("jcifs.util.loglevel","3");
I have to do something like java -D jcifs.util.loglevel=3 Test to display the logs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.samba.org/pipermail/jcifs/attachments/20140401/55a51a73/attachment-0001.html>
More information about the jCIFS
mailing list