You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by fr...@apache.org on 2017/07/27 09:29:38 UTC

svn commit: r1803153 - in /jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file: AbstractFileStore.java FileStore.java

Author: frm
Date: Thu Jul 27 09:29:37 2017
New Revision: 1803153

URL: http://svn.apache.org/viewvc?rev=1803153&view=rev
Log:
OAK-6458 - Increment the manifest version number

Modified:
    jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/AbstractFileStore.java
    jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java

Modified: jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/AbstractFileStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/AbstractFileStore.java?rev=1803153&r1=1803152&r2=1803153&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/AbstractFileStore.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/AbstractFileStore.java Thu Jul 27 09:29:37 2017
@@ -76,11 +76,24 @@ public abstract class AbstractFileStore
     private static final int INVALID_STORE_VERSION = 0;
 
     /**
-     * The store version is an always incrementing number, strictly greater than
-     * zero, that is changed every time there is a backwards incompatible
-     * modification to the format of the segment store.
+     * The minimum supported store version. It is possible for an implementation
+     * to support in a transparent and backwards-compatible way older versions
+     * of a repository. In this case, the minimum supported store version
+     * identifies the store format that can still be processed by the
+     * implementation. The minimum store version has to be greater than zero and
+     * less than or equal to the maximum store version.
      */
-    static final int CURRENT_STORE_VERSION = 1;
+    static final int MIN_STORE_VERSION = 1;
+
+    /**
+     * The maximum supported store version. It is possible for an implementation
+     * to support in a transparent and forwards-compatible way newer version of
+     * a repository. In this case, the maximum supported store version
+     * identifies the store format that can still be processed by the
+     * implementation. The maximum supported store version has to be greater
+     * than zero and greater than or equal to the minimum store version.
+     */
+    static final int MAX_STORE_VERSION = 2;
 
     protected static boolean notEmptyDirectory(File path) {
         Collection<File> entries = FileUtils.listFiles(path, new String[] {"tar"}, false);
@@ -165,11 +178,11 @@ public abstract class AbstractFileStore
             throw new IllegalStateException("Invalid store version");
         }
 
-        if (storeVersion < CURRENT_STORE_VERSION) {
+         if (storeVersion < MIN_STORE_VERSION) {
             throw new InvalidFileStoreVersionException("Using a too recent version of oak-segment-tar");
-        }
+         }
 
-        if (storeVersion > CURRENT_STORE_VERSION) {
+         if (storeVersion > MAX_STORE_VERSION) {
             throw new InvalidFileStoreVersionException("Using a too old version of oak-segment tar");
         }
 

Modified: jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java?rev=1803153&r1=1803152&r2=1803153&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java Thu Jul 27 09:29:37 2017
@@ -258,7 +258,12 @@ public class FileStore extends AbstractF
     }
 
     private void saveManifest(Manifest manifest) throws IOException {
-        manifest.setStoreVersion(CURRENT_STORE_VERSION);
+        // Always update the store version to the maximum supported store
+        // version. In doing so, we prevent older implementations from tampering
+        // with the store's data, which from this moment on could be written in
+        // a format that an older implementation might not be able to
+        // understand.
+        manifest.setStoreVersion(MAX_STORE_VERSION);
         manifest.save(getManifestFile());
     }