[jcifs] search files by jcifs

Michael B. Allen miallen at eskimo.com
Thu Feb 27 08:17:36 EST 2003


On Wed, 26 Feb 2003 17:30:18 +0800
HMChung at ITRI.ORG.TW wrote:

> Dear All:
> I have a problem about jcifs libary.
> I try to search files from multi-subdirectories by SmbFile.listFiles() or
> SmbFile.listFiles(wildcard) method.
> If there are many clients to search files from the file server,the reponse
> time is too longer.

This algorithm is pathalogically bad for a "find" function. If you create
an SmbFile[] list and then traverse into it's children recursively (like
you are doing) when the thread makes it back up to the top of the stack
you will have many files with stale attributes which by default will cause
the client to query the server again. That will be very slow. You have to
select an algorithm that never leaves files unprocessed for longer than
jcifs.smb.client.attrExpirationPeriod ms (default 5000 == 5 seconds). Look
at the crawler examples for ways to speed up the algorithm. You can also
test this theory by setting attrExpirationPeriod to something very large
like 1000000. That will make it fast but the resultset may be wrong if
people are actively working on files. Better choose a good BFS algorithm.

Mike

PS: Please post in an i18n characterset like UTF-8 or a western
characterset if possible (e.g. ISO-8859-1).

-- 
A  program should be written to model the concepts of the task it
performs rather than the physical world or a process because this
maximizes  the  potential  for it to be applied to tasks that are
conceptually  similar and, more important, to tasks that have not
yet been conceived. 


More information about the jcifs mailing list