// disable recovery if this is a restart
shouldRecover = false;
// write the jobtracker.info file
try {
FSDataOutputStream out = FileSystem.create(fs, restartFile,
filePerm);
out.writeInt(0);
out.close();
} catch (IOException ioe) {
LOG.warn("Writing to file " + restartFile + " failed!");
LOG.warn("FileSystem is not ready yet!");
fs.delete(restartFile, false);
throw ioe;
}
return;
}
FSDataInputStream in = fs.open(restartFile);
try {
// read the old count
restartCount = in.readInt();
++restartCount; // increment the restart count
} catch (IOException ioe) {
LOG.warn("System directory is garbled. Failed to read file "
+ restartFile);
LOG.warn("Jobtracker recovery is not possible with garbled"
+ " system directory! Please delete the system directory and"
+ " restart the jobtracker. Note that deleting the system"
+ " directory will result in loss of all the running jobs.");
throw new RuntimeException(ioe);
} finally {
if (in != null) {
in.close();
}
}
// Write back the new restart count and rename the old info file
//TODO This is similar to jobhistory recovery, maybe this common code
// can be factored out.
// write to the tmp file
FSDataOutputStream out = FileSystem.create(fs, tmpRestartFile, filePerm);
out.writeInt(restartCount);
out.close();
// delete the main file
fs.delete(restartFile, false);
// rename the .rec to main file