I have a piece of code which writes a file in Java to a shared Samba folder on a virtual server, but I have a performance issue/question.
The first thing my code does, is checking if the Samba folder exists. If it does, it instantiates the file it is going to write. Then more irrelevant stuff happens.
If I check my log file, there are always 6 seconds between Instantiated destination samba directory...
and Checking if the file already exists...
. This means that the if(!destination.exists)
takes 6 seconds, which looks awefully long, since the if(smbOutputFile.exists))
doesn't even take 1 second. (In my testcase, both of them do exist).
What could be any of the factors of this performance issue? And is there a way to speed this up?
SmbFile destinationShare = new SmbFile(sambaDestinationPath, destinationAuthentication);
logger.info("Instantiated destination samba directory : " + destinationShare);
if (!destinationShare.exists()) { //destinationShare = a directory
destinationShare.mkdir();
logger.debug("Shared directory created");
}
smbOutputFile = new SmbFile(sambaDestinationPath + filename, destinationAuthentication);
logger.debug("Checking if the file already exists and rename it to '.old'");
if (smbOutputFile.exists()) { //smbOutputFile = a file
//Do something
}
Thanks!