use of org.neo4j.kernel.impl.storemigration.StoreUpgrader.UnexpectedUpgradingStoreFormatException in project neo4j by neo4j.
the class UpgradableDatabase method checkUpgradeable.
/**
* Assumed to only be called if {@link #hasCurrentVersion(File)} returns {@code false}.
*
* @param storeDirectory the store to check for upgradability is in.
* @return the {@link RecordFormats} the current store (which is upgradable) is currently in.
* @throws UpgradeMissingStoreFilesException if store cannot be upgraded due to some store files are missing.
* @throws UpgradingStoreVersionNotFoundException if store cannot be upgraded due to store
* version cannot be determined.
* @throws UnexpectedUpgradingStoreVersionException if store cannot be upgraded due to an unexpected store
* version found.
* @throws UnexpectedUpgradingStoreFormatException if store cannot be upgraded due to an unexpected store
* format found.
* @throws DatabaseNotCleanlyShutDownException if store cannot be upgraded due to not being cleanly shut down.
*/
public RecordFormats checkUpgradeable(File storeDirectory) {
Result result = storeVersionCheck.hasVersion(new File(storeDirectory, MetaDataStore.DEFAULT_NAME), format.storeVersion());
if (result.outcome.isSuccessful()) {
// Although this method should not have been called in this case.
return format;
}
RecordFormats fromFormat;
try {
fromFormat = RecordFormatSelector.selectForVersion(result.actualVersion);
// of the config setting to change since downgrades aren't possible but the store can still be opened.
if (FormatFamily.isLowerFamilyFormat(format, fromFormat)) {
throw new StoreUpgrader.UnexpectedUpgradingStoreFormatException();
}
if (FormatFamily.isSameFamily(fromFormat, format) && (fromFormat.generation() > format.generation())) {
// Tried to downgrade, that isn't supported
result = new Result(Outcome.attemptedStoreDowngrade, fromFormat.storeVersion(), new File(storeDirectory, MetaDataStore.DEFAULT_NAME).getAbsolutePath());
} else {
result = fromFormat.hasCapability(Capability.VERSION_TRAILERS) ? checkCleanShutDownByVersionTrailer(storeDirectory, fromFormat) : checkCleanShutDownByCheckPoint(storeDirectory);
if (result.outcome.isSuccessful()) {
return fromFormat;
}
}
} catch (IllegalArgumentException e) {
result = new Result(Outcome.unexpectedStoreVersion, result.actualVersion, result.storeFilename);
}
switch(result.outcome) {
case missingStoreFile:
throw new StoreUpgrader.UpgradeMissingStoreFilesException(getPathToStoreFile(storeDirectory, result));
case storeVersionNotFound:
throw new StoreUpgrader.UpgradingStoreVersionNotFoundException(getPathToStoreFile(storeDirectory, result));
case attemptedStoreDowngrade:
throw new StoreUpgrader.AttemptedDowngradeException();
case unexpectedStoreVersion:
throw new StoreUpgrader.UnexpectedUpgradingStoreVersionException(result.actualVersion, format.storeVersion());
case storeNotCleanlyShutDown:
throw new StoreUpgrader.DatabaseNotCleanlyShutDownException();
default:
throw new IllegalArgumentException("Unexpected outcome: " + result.outcome.name());
}
}
Aggregations