if (fs.exists(snapshotDir)) { FileStatus[] snapshots = FSUtils.listStatus(fs, snapshotDir, new SnapshotDescriptionUtils.CompletedSnaphotDirectoriesFilter(fs)); if (snapshots != null) { LOG.error("Snapshots are present, but cleaners are not enabled.");
if (fs.exists(snapshotDir)) { FileStatus[] snapshots = FSUtils.listStatus(fs, snapshotDir, new SnapshotDescriptionUtils.CompletedSnaphotDirectoriesFilter(fs)); if (snapshots != null) { LOG.error("Snapshots are present, but cleaners are not enabled.");
if (fs.exists(snapshotDir)) { FileStatus[] snapshots = FSUtils.listStatus(fs, snapshotDir, new SnapshotDescriptionUtils.CompletedSnaphotDirectoriesFilter(fs)); if (snapshots != null) { LOG.error("Snapshots are present, but cleaners are not enabled.");
new SnapshotDescriptionUtils.CompletedSnaphotDirectoriesFilter(fs)); MasterCoprocessorHost cpHost = master.getMasterCoprocessorHost();
public void migrateSnapshots() throws IOException { //migrate snapshot dir Path oldSnapshotDir = new Path(rootDir, HConstants.OLD_SNAPSHOT_DIR_NAME); Path newSnapshotDir = new Path(rootDir, HConstants.SNAPSHOT_DIR_NAME); if (fs.exists(oldSnapshotDir)) { boolean foundOldSnapshotDir = false; // Logic to verify old snapshot dir culled from SnapshotManager // ignore all the snapshots in progress FileStatus[] snapshots = fs.listStatus(oldSnapshotDir, new SnapshotDescriptionUtils.CompletedSnaphotDirectoriesFilter(fs)); // loop through all the completed snapshots for (FileStatus snapshot : snapshots) { Path info = new Path(snapshot.getPath(), SnapshotDescriptionUtils.SNAPSHOTINFO_FILE); // if the snapshot is bad if (fs.exists(info)) { foundOldSnapshotDir = true; break; } } if(foundOldSnapshotDir) { LOG.info("Migrating snapshot dir"); if (!fs.rename(oldSnapshotDir, newSnapshotDir)) { throw new IOException("Failed to move old snapshot dir "+ oldSnapshotDir+" to new "+newSnapshotDir); } } } }
/** * Migrates all snapshots, user tables and system tables that require migration. * First migrates snapshots. * Then migrates each user table in order, * then attempts ROOT (should be gone) * Migrates hbase:meta last to indicate migration is complete. */ private static void migrateFsTableDescriptors(FileSystem fs, Path rootDir) throws IOException { // First migrate snapshots - will migrate any snapshot dir that contains a table info file Path snapshotsDir = SnapshotDescriptionUtils.getSnapshotsDir(rootDir); if (fs.exists(snapshotsDir)) { LOG.info("Migrating snapshots"); FileStatus[] snapshots = fs.listStatus(snapshotsDir, new SnapshotDescriptionUtils.CompletedSnaphotDirectoriesFilter(fs)); for (FileStatus snapshot : snapshots) { migrateTable(fs, snapshot.getPath()); } } LOG.info("Migrating user tables"); List<Path> userTableDirs = FSUtils.getTableDirs(fs, rootDir); for (Path userTableDir : userTableDirs) { migrateTable(fs, userTableDir); } LOG.info("Migrating system tables"); // migrate meta last because that's what we check to see if migration is complete migrateTableIfExists(fs, rootDir, TableName.META_TABLE_NAME); }
/** * Returns the list of available snapshots in the specified location * @param conf the {@link Configuration} to use * @return the list of snapshots */ public static List<SnapshotDescription> getSnapshotList(final Configuration conf) throws IOException { Path rootDir = FSUtils.getRootDir(conf); FileSystem fs = FileSystem.get(rootDir.toUri(), conf); Path snapshotDir = SnapshotDescriptionUtils.getSnapshotsDir(rootDir); FileStatus[] snapshots = fs.listStatus(snapshotDir, new SnapshotDescriptionUtils.CompletedSnaphotDirectoriesFilter(fs)); List<SnapshotDescription> snapshotLists = new ArrayList<SnapshotDescription>(snapshots.length); for (FileStatus snapshotDirStat: snapshots) { snapshotLists.add(SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDirStat.getPath())); } return snapshotLists; }
new SnapshotDescriptionUtils.CompletedSnaphotDirectoriesFilter(fs)); MasterCoprocessorHost cpHost = master.getMasterCoprocessorHost(); withCpCall = withCpCall && cpHost != null;
/** * Returns value represent path for: * ""/$USER/SBACKUP_ROOT/backup_id/namespace/table/.hbase-snapshot/ * snapshot_1396650097621_namespace_table" * this path contains .snapshotinfo, .tabledesc (0.96 and 0.98) this path contains .snapshotinfo, * .data.manifest (trunk) * @param tableName table name * @return path to table info * @throws IOException exception */ Path getTableInfoPath(TableName tableName) throws IOException { Path tableSnapShotPath = getTableSnapshotPath(backupRootPath, tableName, backupId); Path tableInfoPath = null; // can't build the path directly as the timestamp values are different FileStatus[] snapshots = fs.listStatus(tableSnapShotPath, new SnapshotDescriptionUtils.CompletedSnaphotDirectoriesFilter(fs)); for (FileStatus snapshot : snapshots) { tableInfoPath = snapshot.getPath(); // SnapshotManifest.DATA_MANIFEST_NAME = "data.manifest"; if (tableInfoPath.getName().endsWith("data.manifest")) { break; } } return tableInfoPath; }
/** * Returns the list of available snapshots in the specified location * @param conf the {@link Configuration} to use * @return the list of snapshots */ public static List<SnapshotDescription> getSnapshotList(final Configuration conf) throws IOException { Path rootDir = FSUtils.getRootDir(conf); FileSystem fs = FileSystem.get(rootDir.toUri(), conf); Path snapshotDir = SnapshotDescriptionUtils.getSnapshotsDir(rootDir); FileStatus[] snapshots = fs.listStatus(snapshotDir, new SnapshotDescriptionUtils.CompletedSnaphotDirectoriesFilter(fs)); List<SnapshotDescription> snapshotLists = new ArrayList<>(snapshots.length); for (FileStatus snapshotDirStat: snapshots) { SnapshotProtos.SnapshotDescription snapshotDesc = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDirStat.getPath()); snapshotLists.add(ProtobufUtil.createSnapshotDesc(snapshotDesc)); } return snapshotLists; }