Copy large size file takes longer time

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Copy large size file takes longer time

vittal

Hi All,
I would like to have advice on multiple issues, code snippet java code.

void test(){
SmbFile sFile = null;
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(activeUserDomain, activeUserID, activePwd);
sFile = new SmbFile("smb:"+absoluteFilePath.replaceAll("\\\\", "/"), auth);

File inFile = new File(tempZipDir,zipFileName);
inFile.createNewFile();
DataOutputStream outZ = new DataOutputStream(new FileOutputStream(inFile));
InputStream inZ = sFile.getInputStream();
copyStreams(inZ,outZ);
}

private static final void copyStreams ( InputStream in, OutputStream out ) throws IOException
    { 
     byte [  ]  buffer = new byte[1024];
     int len;
 
 
     while (  ( len = in.read(buffer)) >= 0 )  {
       out.write( buffer, 0, len ) ;
     }
 
     in.close() ;
     out.close() ;
    } 

1. Above snippet of code setup locally, worked for sometime, once I got connection time error, since than always  throws  below exception, similar behavior in my secondary machine as well, please advice, what might causing?

java.net.ConnectException: Connection timed out: connect
 at java.net.DualStackPlainSocketImpl.connect0(Native Method)
 at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
 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.PlainSocketImpl.connect(PlainSocketImpl.java:172)
 at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
 at java.net.Socket.connect(Socket.java:579)
 at java.net.Socket.connect(Socket.java:528)
 at java.net.Socket.<init>(Socket.java:425)
 at java.net.Socket.<init>(Socket.java:208)
 at jcifs.smb.SmbTransport.ssn139(SmbTransport.java:226)
 at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:288)
 at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:353)
 at jcifs.util.transport.Transport.run(Transport.java:240)
 at java.lang.Thread.run(Thread.java:745

2. I am very new to smb implementation, I am trying to trouble shoot performance issue on existing implementation, same code have been working for years i.e. to copy zip file(3KB to 800MB) from samba server to appserver but since recent time copy function takes long time for a give file, please advice what might cause?


--

Regards
---------------------------------------
Vittal
Reply | Threaded
Open this post in threaded view
|

Re: Copy large size file takes longer time

vittal
If we map source drive (\\xxx.xx.xx.xx\abcd95\D\NJ$) from target machine (aaaaaa.bbb.ccc), using window copy option transfer is quick 160MB takes 3 sec. Whereas this functionality we are doing from code implemented using JAVA API with SAMBA protocol (jcifs-1.3.17.jar) takes longer time. This implementation been working fine 8+ years, no change in implementation, since recently performance degraded, transfer take 40+ minutes, sometime transfer fails. Is it some would have changed on samba server/configuration?, please advise.

On Mon, Nov 2, 2015 at 9:10 PM, vittal <[hidden email]> wrote:

Hi All,
I would like to have advice on multiple issues, code snippet java code.

void test(){
SmbFile sFile = null;
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(activeUserDomain, activeUserID, activePwd);
sFile = new SmbFile("smb:"+absoluteFilePath.replaceAll("\\\\", "/"), auth);

File inFile = new File(tempZipDir,zipFileName);
inFile.createNewFile();
DataOutputStream outZ = new DataOutputStream(new FileOutputStream(inFile));
InputStream inZ = sFile.getInputStream();
copyStreams(inZ,outZ);
}

private static final void copyStreams ( InputStream in, OutputStream out ) throws IOException
    { 
     byte [  ]  buffer = new byte[1024];
     int len;
 
 
     while (  ( len = in.read(buffer)) >= 0 )  {
       out.write( buffer, 0, len ) ;
     }
 
     in.close() ;
     out.close() ;
    } 

1. Above snippet of code setup locally, worked for sometime, once I got connection time error, since than always  throws  below exception, similar behavior in my secondary machine as well, please advice, what might causing?

java.net.ConnectException: Connection timed out: connect
 at java.net.DualStackPlainSocketImpl.connect0(Native Method)
 at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
 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.PlainSocketImpl.connect(PlainSocketImpl.java:172)
 at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
 at java.net.Socket.connect(Socket.java:579)
 at java.net.Socket.connect(Socket.java:528)
 at java.net.Socket.<init>(Socket.java:425)
 at java.net.Socket.<init>(Socket.java:208)
 at jcifs.smb.SmbTransport.ssn139(SmbTransport.java:226)
 at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:288)
 at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:353)
 at jcifs.util.transport.Transport.run(Transport.java:240)
 at java.lang.Thread.run(Thread.java:745

2. I am very new to smb implementation, I am trying to trouble shoot performance issue on existing implementation, same code have been working for years i.e. to copy zip file(3KB to 800MB) from samba server to appserver but since recent time copy function takes long time for a give file, please advice what might cause?


--

Regards
---------------------------------------
Vittal



--
Regards
---------------------------------------
M.Vittal Reddy
Reply | Threaded
Open this post in threaded view
|

Re: Copy large size file takes longer time

Richard Heap-3
In reply to this post by vittal
As nothing has changed, this is unlikely to be a jcifs issue. It's much more likely to be a DNS or dfs issue. Try disabling dfs in jcifs.
--
Sent from my Android phone with mail.com Mail. Please excuse my brevity.

vittal <[hidden email]> wrote:
If we map source drive (\\xxx.xx.xx.xx\abcd95\D\NJ$) from target machine (aaaaaa.bbb.ccc), using window copy option transfer is quick 160MB takes 3 sec. Whereas this functionality we are doing from code implemented using JAVA API with SAMBA protocol (jcifs-1.3.17.jar) takes longer time. This implementation been working fine 8+ years, no change in implementation, since recently performance degraded, transfer take 40+ minutes, sometime transfer fails. Is it some would have changed on samba server/configuration?, please advise.

On Mon, Nov 2, 2015 at 9:10 PM, vittal <[hidden email]> wrote:

Hi All,
I would like to have advice on multiple issues, code snippet java code.

void test(){
SmbFile sFile = null;
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(activeUserDomain, activeUserID, activePwd);
sFile = new SmbFile("smb:"+absoluteFilePath.replaceAll("\\\\", "/"), auth);

File inFile = new File(tempZipDir,zipFileName);
inFile.createNewFile();
DataOutputStream outZ = new DataOutputStream(new FileOutputStream(inFile));
InputStream inZ = sFile.getInputStream();
copyStreams(inZ,outZ);
}

private static final void copyStreams ( InputStream in, OutputStream out ) throws IOException
    { 
     byte [  ]  buffer = new byte[1024];
     int len;
 
 
     while (  ( len = in.read(buffer)) >= 0 )  {
       out.write( buffer, 0, len ) ;
     }
 
     in.close() ;
     out.close() ;
    } 

1. Above snippet of code setup locally, worked for sometime, once I got connection time error, since than always  throws  below exception, similar behavior in my secondary machine as well, please advice, what might causing?

java.net.ConnectException: Connection timed out: connect
 at java.net.DualStackPlainSocketImpl.connect0(Native Method)
 at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
 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.PlainSocketImpl.connect(PlainSocketImpl.java:172)
 at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
 at java.net.Socket.connect(Socket.java:579)
 at java.net.Socket.connect(Socket.java:528)
 at java.net.Socket.<init>(Socket.java:425)
 at java.net.Socket.<init>(Socket.java:208)
 at jcifs.smb.SmbTransport.ssn139(SmbTransport.java:226)
 at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:288)
 at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:353)
 at jcifs.util.transport.Transport.run(Transport.java:240)
 at java.lang.Thread.run(Thread.java:745

2. I am very new to smb implementation, I am trying to trouble shoot performance issue on existing implementation, same code have been working for years i.e. to copy zip file(3KB to 800MB) from samba server to appserver but since recent time copy function takes long time for a give file, please advice what might cause?


--

Regards
---------------------------------------
Vittal



--
Regards
---------------------------------------
M.Vittal Reddy