}
public Vector<Recoverable> recover() throws LogException {
if (corrupt_)
throw new LogException("Instance might be corrupted");
Vector<Recoverable> ret = new Vector<Recoverable>();
try {
FileInputStream f = file_.openLastValidVersionForReading();
int count = 0;
if (LOGGER.isInfoEnabled()) {
LOGGER.logInfo("Starting read of logfile " + file_.getCurrentVersionFileName());
}
while (f.available()>0) {
// if crashed, then unproper closing might cause endless blocking!
// therefore, we check if avaible first.
count++;
SystemLogImage systemLogImage = new SystemLogImage();
systemLogImage.readData(new DataInputStream(f));
ret.addElement(systemLogImage);
if (count % 10 == 0) {
LOGGER.logInfo(".");
}
}
LOGGER.logInfo("Done read of logfile");
} catch (java.io.EOFException unexpectedEOF) {
LOGGER.logDebug("Unexpected EOF - logfile not closed properly last time?", unexpectedEOF);
// merely return what was read so far...
} catch (StreamCorruptedException unexpectedEOF) {
LOGGER.logDebug("Unexpected EOF - logfile not closed properly last time?", unexpectedEOF);
// merely return what was read so far...
} catch (ObjectStreamException unexpectedEOF) {
LOGGER.logDebug("Unexpected EOF - logfile not closed properly last time?", unexpectedEOF);
// merely return what was read so far...
} catch (FileNotFoundException firstStart) {
// the file could not be opened for reading;
// merely return the default empty vector
} catch (Exception e) {
String msg = "Error in recover";
LOGGER.logWarning(msg, e);
throw new LogException(msg, e);
}
return ret;
}