HBASE-8352 Rename '.snapshot' directory (Ted Yu)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1468669 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7eb77dad7b
commit
cfded304c1
|
@ -123,7 +123,7 @@ public class TestSnapshotFromAdmin {
|
|||
HBaseAdmin admin = new HBaseAdmin(mockConnection);
|
||||
SnapshotDescription.Builder builder = SnapshotDescription.newBuilder();
|
||||
// check that invalid snapshot names fail
|
||||
failSnapshotStart(admin, builder.setName(".snapshot").build());
|
||||
failSnapshotStart(admin, builder.setName(HConstants.SNAPSHOT_DIR_NAME).build());
|
||||
failSnapshotStart(admin, builder.setName("-snapshot").build());
|
||||
failSnapshotStart(admin, builder.setName("snapshot fails").build());
|
||||
failSnapshotStart(admin, builder.setName("snap$hot").build());
|
||||
|
@ -157,4 +157,4 @@ public class TestSnapshotFromAdmin {
|
|||
LOG.debug("Correctly failed to start snapshot:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -787,8 +787,11 @@ public final class HConstants {
|
|||
* remaining snapshot constants; this is here to keep HConstants dependencies at a minimum and
|
||||
* uni-directional.
|
||||
*/
|
||||
public static final String SNAPSHOT_DIR_NAME = ".snapshot";
|
||||
public static final String SNAPSHOT_DIR_NAME = ".hbase-snapshot";
|
||||
|
||||
/* Name of old snapshot directory. See HBASE-8352 for details on why it needs to be renamed */
|
||||
public static final String OLD_SNAPSHOT_DIR_NAME = ".snapshot";
|
||||
|
||||
/** Temporary directory used for table creation and deletion */
|
||||
public static final String HBASE_TEMP_DIRECTORY = ".tmp";
|
||||
|
||||
|
@ -796,7 +799,8 @@ public final class HConstants {
|
|||
public static final List<String> HBASE_NON_TABLE_DIRS =
|
||||
Collections.unmodifiableList(Arrays.asList(new String[] { HREGION_LOGDIR_NAME,
|
||||
HREGION_OLDLOGDIR_NAME, CORRUPT_DIR_NAME, SPLIT_LOGDIR_NAME,
|
||||
HBCK_SIDELINEDIR_NAME, HFILE_ARCHIVE_DIRECTORY, SNAPSHOT_DIR_NAME, HBASE_TEMP_DIRECTORY }));
|
||||
HBCK_SIDELINEDIR_NAME, HFILE_ARCHIVE_DIRECTORY, SNAPSHOT_DIR_NAME, HBASE_TEMP_DIRECTORY,
|
||||
OLD_SNAPSHOT_DIR_NAME }));
|
||||
|
||||
/** Directories that are not HBase user table directories */
|
||||
public static final List<String> HBASE_NON_USER_TABLE_DIRS =
|
||||
|
|
|
@ -146,6 +146,7 @@ public class SnapshotManager implements Stoppable {
|
|||
this.master = master;
|
||||
this.metricsMaster = metricsMaster;
|
||||
|
||||
this.rootDir = master.getMasterFileSystem().getRootDir();
|
||||
checkSnapshotSupport(master.getConfiguration(), master.getMasterFileSystem());
|
||||
|
||||
// get the configuration for the coordinator
|
||||
|
@ -159,7 +160,6 @@ public class SnapshotManager implements Stoppable {
|
|||
ProcedureCoordinatorRpcs comms = new ZKProcedureCoordinatorRpcs(
|
||||
master.getZooKeeper(), SnapshotManager.ONLINE_SNAPSHOT_CONTROLLER_DESCRIPTION, name);
|
||||
this.coordinator = new ProcedureCoordinator(comms, tpool);
|
||||
this.rootDir = master.getMasterFileSystem().getRootDir();
|
||||
this.executorService = master.getExecutorService();
|
||||
resetTempDir();
|
||||
}
|
||||
|
@ -176,12 +176,12 @@ public class SnapshotManager implements Stoppable {
|
|||
this.master = master;
|
||||
this.metricsMaster = metricsMaster;
|
||||
|
||||
this.rootDir = master.getMasterFileSystem().getRootDir();
|
||||
checkSnapshotSupport(master.getConfiguration(), master.getMasterFileSystem());
|
||||
|
||||
this.wakeFrequency = master.getConfiguration().getInt(SNAPSHOT_WAKE_MILLIS_KEY,
|
||||
SNAPSHOT_WAKE_MILLIS_DEFAULT);
|
||||
this.coordinator = coordinator;
|
||||
this.rootDir = master.getMasterFileSystem().getRootDir();
|
||||
this.executorService = pool;
|
||||
resetTempDir();
|
||||
}
|
||||
|
@ -192,10 +192,20 @@ public class SnapshotManager implements Stoppable {
|
|||
* @throws IOException File system exception
|
||||
*/
|
||||
public List<SnapshotDescription> getCompletedSnapshots() throws IOException {
|
||||
return getCompletedSnapshots(SnapshotDescriptionUtils.getSnapshotsDir(rootDir));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of all completed snapshots.
|
||||
* @param snapshotDir snapshot directory
|
||||
* @return list of SnapshotDescriptions
|
||||
* @throws IOException File system exception
|
||||
*/
|
||||
private List<SnapshotDescription> getCompletedSnapshots(Path snapshotDir) throws IOException {
|
||||
List<SnapshotDescription> snapshotDescs = new ArrayList<SnapshotDescription>();
|
||||
// first create the snapshot root path and check to see if it exists
|
||||
Path snapshotDir = SnapshotDescriptionUtils.getSnapshotsDir(rootDir);
|
||||
FileSystem fs = master.getMasterFileSystem().getFileSystem();
|
||||
if (snapshotDir == null) snapshotDir = SnapshotDescriptionUtils.getSnapshotsDir(rootDir);
|
||||
|
||||
// if there are no snapshots, return an empty list
|
||||
if (!fs.exists(snapshotDir)) {
|
||||
|
@ -877,6 +887,15 @@ public class SnapshotManager implements Stoppable {
|
|||
cleaners = conf.getStrings(HConstants.HBASE_MASTER_LOGCLEANER_PLUGINS);
|
||||
if (cleaners != null) Collections.addAll(logCleaners, cleaners);
|
||||
|
||||
// check if an older version of snapshot directory was present
|
||||
Path oldSnapshotDir = new Path(mfs.getRootDir(), HConstants.OLD_SNAPSHOT_DIR_NAME);
|
||||
FileSystem fs = mfs.getFileSystem();
|
||||
List<SnapshotDescription> ss = getCompletedSnapshots(new Path(rootDir, oldSnapshotDir));
|
||||
if (ss != null && !ss.isEmpty()) {
|
||||
LOG.error("Snapshots from an earlier release were found under: " + oldSnapshotDir);
|
||||
LOG.error("Please rename the directory as " + HConstants.SNAPSHOT_DIR_NAME);
|
||||
}
|
||||
|
||||
// If the user has enabled the snapshot, we force the cleaners to be present
|
||||
// otherwise we still need to check if cleaners are enabled or not and verify
|
||||
// that there're no snapshot in the .snapshot folder.
|
||||
|
@ -913,7 +932,6 @@ public class SnapshotManager implements Stoppable {
|
|||
if (!snapshotEnabled) {
|
||||
LOG.info("Snapshot feature is not enabled, missing log and hfile cleaners.");
|
||||
Path snapshotDir = SnapshotDescriptionUtils.getSnapshotsDir(mfs.getRootDir());
|
||||
FileSystem fs = mfs.getFileSystem();
|
||||
if (fs.exists(snapshotDir)) {
|
||||
FileStatus[] snapshots = FSUtils.listStatus(fs, snapshotDir,
|
||||
new SnapshotDescriptionUtils.CompletedSnaphotDirectoriesFilter(fs));
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.apache.hadoop.fs.FileStatus;
|
|||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||
import org.apache.hadoop.hbase.HConstants;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.KeyValue;
|
||||
|
@ -205,12 +206,12 @@ public class TestExportSnapshot {
|
|||
for (FileStatus fileStatus: rootFiles) {
|
||||
String name = fileStatus.getPath().getName();
|
||||
assertTrue(fileStatus.isDir());
|
||||
assertTrue(name.equals(".snapshot") || name.equals(".archive"));
|
||||
assertTrue(name.equals(HConstants.SNAPSHOT_DIR_NAME) || name.equals(".archive"));
|
||||
}
|
||||
|
||||
// compare the snapshot metadata and verify the hfiles
|
||||
final FileSystem hdfs = FileSystem.get(hdfsUri, TEST_UTIL.getConfiguration());
|
||||
final Path snapshotDir = new Path(".snapshot", Bytes.toString(snapshotName));
|
||||
final Path snapshotDir = new Path(HConstants.SNAPSHOT_DIR_NAME, Bytes.toString(snapshotName));
|
||||
verifySnapshot(hdfs, new Path(TEST_UTIL.getDefaultRootDirPath(), snapshotDir),
|
||||
fs, new Path(copyDir, snapshotDir));
|
||||
verifyArchive(fs, copyDir, Bytes.toString(snapshotName));
|
||||
|
@ -233,7 +234,8 @@ public class TestExportSnapshot {
|
|||
*/
|
||||
private void verifyArchive(final FileSystem fs, final Path rootDir, final String snapshotName)
|
||||
throws IOException {
|
||||
final Path exportedSnapshot = new Path(rootDir, new Path(".snapshot", snapshotName));
|
||||
final Path exportedSnapshot = new Path(rootDir,
|
||||
new Path(HConstants.SNAPSHOT_DIR_NAME, snapshotName));
|
||||
final Path exportedArchive = new Path(rootDir, ".archive");
|
||||
LOG.debug(listFiles(fs, exportedArchive, exportedArchive));
|
||||
SnapshotReferenceUtil.visitReferencedFiles(fs, exportedSnapshot,
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.apache.hadoop.conf.Configuration;
|
|||
import org.apache.hadoop.fs.FileSystem;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||
import org.apache.hadoop.hbase.HConstants;
|
||||
import org.apache.hadoop.hbase.MediumTests;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription.Type;
|
||||
|
@ -88,7 +89,7 @@ public class TestSnapshotDescriptionUtils {
|
|||
*/
|
||||
@Test
|
||||
public void testCompleteSnapshotWithNoSnapshotDirectoryFailure() throws Exception {
|
||||
Path snapshotDir = new Path(root, ".snapshot");
|
||||
Path snapshotDir = new Path(root, HConstants.SNAPSHOT_DIR_NAME);
|
||||
Path tmpDir = new Path(snapshotDir, ".tmp");
|
||||
Path workingDir = new Path(tmpDir, "not_a_snapshot");
|
||||
assertFalse("Already have working snapshot dir: " + workingDir
|
||||
|
@ -101,4 +102,4 @@ public class TestSnapshotDescriptionUtils {
|
|||
LOG.info("Correctly failed to move non-existant directory: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue