JCIFS Samba文件获取缓慢

时间:2019-06-27 06:34:07

标签: java sockets samba nas jcifs

我正在使用JCIFS库从NAS位置获取文件。我的代码如下:

NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(domain, userName, password);

SmbFile sFile = new SmbFile(fileRecordId, auth);

jcifs.Config.setProperty("jcifs.smb.client.responseTimeout", "1200000");
jcifs.Config.setProperty("jcifs.smb.client.soTimeout", "1200000");
jcifs.Config.setProperty("jcifs.resolveOrder", "DNS");
jcifs.Config.setProperty("jcifs.util.loglevel", "3");
jcifs.Config.setProperty("jcifs.smb.client.dfs.disabled", "false");

LOG.debug("SmbFileInputStream");

BufferedInputStream inputStream = new BufferedInputStream(new SmbFileInputStream(sFile));
byte[] bytes = IOUtils.toByteArray(inputStream);

LOG.debug("fetched");

inputStream.close();

但是,对于1 MB的文件,从NAS提取将花费近1分钟,对于15 MB的文件,则需要花费15分钟左右。

我在JCIFS: file retrieval is too slow to be usable中尝试过解决方案

此外,在日志级别3中,我遇到了一堆以下异常:

jcifs.smb.SmbAuthException: Logon failure: unknown user name or bad password.
    at jcifs.smb.SmbTransport.checkStatus(SmbTransport.java:546)
    at jcifs.smb.SmbTransport.send(SmbTransport.java:663)
    at jcifs.smb.SmbSession.sessionSetup(SmbSession.java:390)
    at jcifs.smb.SmbSession.send(SmbSession.java:218)
    at jcifs.smb.SmbTree.treeConnect(SmbTree.java:176)
    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 java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
    at java.io.FilterInputStream.read(FilterInputStream.java:107)
    at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2146)
    at org.apache.commons.io.IOUtils.copy(IOUtils.java:2102)
    at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2123)
    at org.apache.commons.io.IOUtils.copy(IOUtils.java:2078)
    at org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:721)
    at cmm_tests.Samba.getArchive(Samba.java:83)
    at cmm_tests.Samba.main(Samba.java:37)

但是文件正在下载。

为什么要花费这么长时间从NAS位置获取文件?

0 个答案:

没有答案