Index: hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshot.java =================================================================== --- hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshot.java (revision 1468297) +++ hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshot.java (working copy) @@ -39,6 +39,7 @@ 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 @@ 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 @@ */ 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, Index: hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSnapshotDescriptionUtils.java =================================================================== --- hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSnapshotDescriptionUtils.java (revision 1468297) +++ hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSnapshotDescriptionUtils.java (working copy) @@ -29,6 +29,7 @@ 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 @@ */ @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 Index: hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (revision 1468297) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (working copy) @@ -2537,7 +2537,7 @@ ListSnapshotRequest request) throws ServiceException { try { ListSnapshotResponse.Builder builder = ListSnapshotResponse.newBuilder(); - List snapshots = snapshotManager.getCompletedSnapshots(); + List snapshots = snapshotManager.getCompletedSnapshots(null); // convert to protobuf for (SnapshotDescription snapshot : snapshots) { Index: hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java (revision 1468297) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java (working copy) @@ -146,6 +146,7 @@ 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 @@ 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,26 +176,27 @@ 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(); } /** * Gets the list of all completed snapshots. + * @param snapshotDir snapshot directory * @return list of SnapshotDescriptions * @throws IOException File system exception */ - public List getCompletedSnapshots() throws IOException { + public List getCompletedSnapshots(Path snapshotDir) throws IOException { List snapshotDescs = new ArrayList(); // 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 +878,15 @@ 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(), ".snapshot"); + FileSystem fs = mfs.getFileSystem(); + List 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 +923,6 @@ 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)); Index: hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotFromAdmin.java =================================================================== --- hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotFromAdmin.java (revision 1468297) +++ hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotFromAdmin.java (working copy) @@ -123,7 +123,7 @@ 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 @@ LOG.debug("Correctly failed to start snapshot:" + e.getMessage()); } } -} \ No newline at end of file +} Index: hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java =================================================================== --- hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java (revision 1468297) +++ hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java (working copy) @@ -787,7 +787,7 @@ * 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"; /** Temporary directory used for table creation and deletion */ public static final String HBASE_TEMP_DIRECTORY = ".tmp"; @@ -796,7 +796,8 @@ public static final List 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, + ".snapshot"})); /** Directories that are not HBase user table directories */ public static final List HBASE_NON_USER_TABLE_DIRS =