Search in sources :

Example 1 with SegmentVersion

use of org.apache.jackrabbit.oak.segment.SegmentVersion in project jackrabbit-oak by apache.

the class SegmentTarUtils method checkFileStoreVersionOrFail.

private static File checkFileStoreVersionOrFail(String path, boolean force) throws IOException, InvalidFileStoreVersionException {
    File directory = new File(path);
    if (!directory.exists()) {
        return directory;
    }
    ReadOnlyFileStore store = openReadOnlyFileStore(directory, false);
    try {
        SegmentVersion segmentVersion = getSegmentVersion(store);
        if (segmentVersion != LATEST_VERSION) {
            if (force) {
                System.out.printf("Segment version mismatch. Found %s, expected %s. Forcing execution.\n", segmentVersion, LATEST_VERSION);
            } else {
                throw new RuntimeException(String.format("Segment version mismatch. Found %s, expected %s. Aborting.", segmentVersion, LATEST_VERSION));
            }
        }
    } finally {
        store.close();
    }
    return directory;
}
Also used : ReadOnlyFileStore(org.apache.jackrabbit.oak.segment.file.ReadOnlyFileStore) File(java.io.File) SegmentVersion(org.apache.jackrabbit.oak.segment.SegmentVersion)

Aggregations

File (java.io.File)1 SegmentVersion (org.apache.jackrabbit.oak.segment.SegmentVersion)1 ReadOnlyFileStore (org.apache.jackrabbit.oak.segment.file.ReadOnlyFileStore)1