use of org.apache.geode.internal.VersionedObjectInput in project geode by apache.
the class GMSLocator method recoverFromFile.
/* package */
boolean recoverFromFile(File file) throws InternalGemFireException {
if (!file.exists()) {
logger.info("recovery file not found: " + file.getAbsolutePath());
return false;
}
logger.info("Peer locator recovering from " + file.getAbsolutePath());
try (ObjectInput ois = new ObjectInputStream(new FileInputStream(file))) {
if (ois.readInt() != LOCATOR_FILE_STAMP) {
return false;
}
ObjectInput ois2 = ois;
int version = ois2.readInt();
if (version != Version.CURRENT_ORDINAL) {
Version geodeVersion = Version.fromOrdinalNoThrow((short) version, false);
logger.info("Peer locator found that persistent view was written with {}", geodeVersion);
ois2 = new VersionedObjectInput(ois2, geodeVersion);
}
Object o = DataSerializer.readObject(ois2);
this.view = (NetView) o;
logger.info("Peer locator initial membership is " + view);
return true;
} catch (Exception e) {
String msg = LOCATOR_UNABLE_TO_RECOVER_VIEW.toLocalizedString(file.toString());
logger.warn(msg, e);
if (!file.delete() && file.exists()) {
logger.warn("Peer locator was unable to recover from or delete " + file);
this.viewFile = null;
}
throw new InternalGemFireException(msg, e);
}
}
Aggregations