[jcifs] SmbFile.copyTo - how reliable under heavy load

Michael B Allen ioplex at gmail.com
Mon Jun 6 19:11:05 MDT 2011


Hi Volker,

SmbFile.copyTo is designed to copy entire directories in an efficient
way (it can read and write data at the same time), set attributes and
timestamps and so on. But if an error occurs on one file, rather than
aborting the entire copy, it will just log the exception and move on.
So it is very possible that some file was temporarily inaccessible
such as because it was locked or the network stalled and that one file
was never successfully copied.

If you want to explicitly validate each step of a copy you will just
have to write that code yourself. Meaning open the source file with
SmbFileInputStream and the destination file with SmbFileOutputStream,
read / write in a loop, close, etc. That will give you the opportunity
to handle any errors along the way.

Also, make sure that you do not have more than one thread operating on
the same SmbFile object at the same time. SmbFile methods are not
thread-safe. If you want to operate on the same file at the same time
using multiple threads that is ok but you will have to create separate
SmbFile objects. If your threads are trying to operate on the same
object at the same time, that certainly could yield odd results.

Mike

On Thu, Jun 2, 2011 at 1:17 PM, Volker Schmelich <volker at quadnova.com> wrote:
> Hi there,
>
> We are using the latest jCIFS on Windows within two applications. Both
> applications are multithreaded and do work which includes a lot of file
> copy operations with jCIFS.
>
> So for example, app 1 has 5 worker threads which in turn copy let's say
> 50 files on average from one share to another share on the same box.
> App2 also has 5 worker threads and is doing the same, basically waiting
> for app1 to signal done, then pick up the files and copy from a share to
> another. This is a development scenario - in production both apps will
> run on different servers.
>
> Under this heavy load, some copied files do not appear in the target.
> There is no SmbException thrown. It seems like the copyTo is called,
> does not work, throws no Exception to indicate it did not work.
>
> When I wrap the copyTo call in a retry loop and check the target file
> existence, the copyTo succeeds after the first or second retry.
>
> So my question is: Is it possible, that jCIFS (or specifically the copy
> thread) dies but no SmbException is thrown? Maybe because the thread
> died?
>
> Regards,
> Volker
>



-- 
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/


More information about the jCIFS mailing list