diff --git a/hbase-common/src/main/resources/hbase-default.xml b/hbase-common/src/main/resources/hbase-default.xml
index dac527b..463f434 100644
--- a/hbase-common/src/main/resources/hbase-default.xml
+++ b/hbase-common/src/main/resources/hbase-default.xml
@@ -1007,6 +1007,16 @@ possible configurations would overwhelm and obscure the important.
Set to true to allow snapshots to be taken / restored / cloned.
+ hbase.snapshot.format.version
+ 1
+ The Snapshot format version to use for new snapshots.
+ 1 is the old format used by 0.94, 0.96 and 0.98 as default.
+ 2 is the new format, which should be used if all the clients that are
+ accessing snapshots via MR job are updated with the latest hbase jars.
+ By switching to version 2, the previous snapshots will still be readable.
+
+
+
hbase.snapshot.restore.take.failsafe.snapshot
true
Set to true to take a snapshot before the restore operation.
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java
index fb588d0..94bbf02 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java
@@ -160,6 +160,11 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable
private Path rootDir;
private ExecutorService executorService;
+ /**
+ * Snapshot layout version to use when writing a new snapshot.
+ */
+ private int snapshotLayoutVersion = SnapshotDescriptionUtils.SNAPSHOT_LAYOUT_LATEST_FORMAT;
+
public SnapshotManager() {}
/**
@@ -177,6 +182,9 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable
this.rootDir = master.getMasterFileSystem().getRootDir();
checkSnapshotSupport(master.getConfiguration(), master.getMasterFileSystem());
+ this.snapshotLayoutVersion = SnapshotDescriptionUtils.getDefaultSnapshotLayoutFormat(
+ master.getConfiguration());
+
this.coordinator = coordinator;
this.executorService = pool;
resetTempDir();
@@ -545,7 +553,7 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable
// if not specified, set the snapshot format
if (!snapshot.hasVersion()) {
snapshot = snapshot.toBuilder()
- .setVersion(SnapshotDescriptionUtils.SNAPSHOT_LAYOUT_VERSION)
+ .setVersion(snapshotLayoutVersion)
.build();
}
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotDescriptionUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotDescriptionUtils.java
index 203f6de..670cf67 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotDescriptionUtils.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotDescriptionUtils.java
@@ -31,6 +31,7 @@ import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
+import org.apache.hadoop.hbase.snapshot.SnapshotManifestV1;
import org.apache.hadoop.hbase.snapshot.SnapshotManifestV2;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.FSUtils;
@@ -87,11 +88,13 @@ public class SnapshotDescriptionUtils {
}
private static final Log LOG = LogFactory.getLog(SnapshotDescriptionUtils.class);
+
/**
- * Version of the fs layout for a snapshot. Future snapshots may have different file layouts,
- * which we may need to read in differently.
+ * Version of the fs layout for new snapshot.
+ * Each version of hbase should be able to read older formats.
*/
- public static final int SNAPSHOT_LAYOUT_VERSION = SnapshotManifestV2.DESCRIPTOR_VERSION;
+ public static final String SNAPSHOT_LAYOUT_CONF_KEY = "hbase.snapshot.format.version";
+ public static final int SNAPSHOT_LAYOUT_LATEST_FORMAT = SnapshotManifestV2.DESCRIPTOR_VERSION;
// snapshot directory constants
/**
@@ -114,6 +117,15 @@ public class SnapshotDescriptionUtils {
// private constructor for utility class
}
+ public static int getDefaultSnapshotLayoutFormat(final Configuration conf) {
+ int layoutFormat = conf.getInt(SNAPSHOT_LAYOUT_CONF_KEY, SNAPSHOT_LAYOUT_LATEST_FORMAT);
+ if (layoutFormat >= SnapshotManifestV2.DESCRIPTOR_VERSION) {
+ return SnapshotManifestV2.DESCRIPTOR_VERSION;
+ }
+ return SnapshotManifestV1.DESCRIPTOR_VERSION;
+ }
+
+
/**
* @param conf {@link Configuration} from which to check for the timeout
* @param type type of snapshot being taken