• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in renameTo() method

 
gim priy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,

*I am using renameTo(..) in my code to move a file when a particular task is being took place.

*Sometimes when I run the above task , task is failed to process and give the following error stack.

TaskProcessFailureException : .... attempt to move :

/usr/../../input/../xxx.dat -> /usr/../../Data/../xxx.data FAILED at ...

*This crashing is INTERMITTENT , not regulary.

*but the nice thing is, even though job is failed, data file(xxx.data) is compleately moved to the Data folder .

*We can re-run the job successfully after it is failed , by moving the data file back to the input directly and runs it again.

*I am so confused abt the behaviour of this renameTo(..) method, Can u guys pls aware me are there any issues , file size limitation , jdk verion limititaion, when we use the renameTo(..) method..


Thx and best Regards.
gimhan
 
Joe Ess
Bartender
Posts: 9361
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Gim.
If you search this forum you will find several posts about problems with renameTo. I think the most common problem is trying to rename a file which is open for writing.
 
Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
renameTo() method only works if you write to the same hd volume. If you try to rename a file to a diffrent volume this wont work. renameTo is fast but not to recommend if you don't know if you want to rename a file and move it.
 
gim priy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by P.W Mathias Nilsson:
renameTo() method only works if you write to the same hd volume. If you try to rename a file to a diffrent volume this wont work. renameTo is fast but not to recommend if you don't know if you want to rename a file and move it.


Added comments :

* Input and ouput directories remain on the same disk although it is NFS mounted , Is it affected for the above intermittancy ?

* code snippet

if (!srcFile.renameTo(dstFile))
{
logMsg = Log.logError(CATALOG_ID, 12, new Serializable[] {
new Long(jobInstanceId),
new Integer(taskOrder),
inputFileName,
outputFileName});
if (DEBUG) { System.out.println (logMsg); }
throw new TaskProcessFailureException(logMsg);
}


thx and regards,
gim
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!