/** * Get the directory to archive a store directory * @param conf {@link Configuration} to read for the archive directory name. * @param region parent region information under which the store currently lives * @param tabledir directory for the table under which the store currently lives * @param family name of the family in the store * @return {@link Path} to the directory to archive the given store or <tt>null</tt> if it should * not be archived */ public static Path getStoreArchivePath(Configuration conf, RegionInfo region, Path tabledir, byte[] family) throws IOException { return getStoreArchivePath(conf, region, family); }
/** * Get the full path to the archive directory on the configured * {@link org.apache.hadoop.hbase.master.MasterFileSystem} * @param conf to look for archive directory name and root directory. Cannot be null. Notes for * testing: requires a FileSystem root directory to be specified. * @return the full {@link Path} to the archive directory, as defined by the configuration * @throws IOException if an unexpected error occurs */ public static Path getArchivePath(Configuration conf) throws IOException { return getArchivePath(FSUtils.getRootDir(conf)); }
@Test public void testRegionArchiveDir() { Path regionDir = new Path("region"); assertNotNull(HFileArchiveUtil.getRegionArchiveDir(rootDir, TableName.valueOf(name.getMethodName()), regionDir)); }
HRegionInfo hriLink = new HRegionInfo(tableLinkName); Path archiveDir = HFileArchiveUtil.getArchivePath(conf); Path archiveStoreDir = HFileArchiveUtil.getStoreArchivePath(conf, tableName, hri.getEncodedName(), familyName); Path archiveLinkStoreDir = HFileArchiveUtil.getStoreArchivePath(conf, tableLinkName, hriLink.getEncodedName(), familyName);
/** * Get the archive directory for a given region under the specified table * @param rootDir {@link Path} to the root directory where hbase files are stored (for building * the archive path) * @param tableName name of the table to archive. Cannot be null. * @return {@link Path} to the directory to archive the given region, or <tt>null</tt> if it * should not be archived */ public static Path getRegionArchiveDir(Path rootDir, TableName tableName, String encodedRegionName) { // get the archive directory for a table Path archiveDir = getTableArchivePath(rootDir, tableName); return HRegion.getRegionDir(archiveDir, encodedRegionName); }
HRegionInfo hriLink = new HRegionInfo(tableLinkName); Path archiveDir = HFileArchiveUtil.getArchivePath(conf); Path archiveStoreDir = HFileArchiveUtil.getStoreArchivePath(conf, tableName, hri.getEncodedName(), familyName); Path archiveLinkStoreDir = HFileArchiveUtil.getStoreArchivePath(conf, tableLinkName, hriLink.getEncodedName(), familyName);
/** * Get the archive directory for a given region under the specified table * @param tableName the table name. Cannot be null. * @param regiondir the path to the region directory. Cannot be null. * @return {@link Path} to the directory to archive the given region, or <tt>null</tt> if it * should not be archived */ public static Path getRegionArchiveDir(Path rootDir, TableName tableName, Path regiondir) { // get the archive directory for a table Path archiveDir = getTableArchivePath(rootDir, tableName); // then add on the region path under the archive String encodedRegionName = regiondir.getName(); return HRegion.getRegionDir(archiveDir, encodedRegionName); }
Path familyArchivePath; try { familyArchivePath = HFileArchiveUtil.getStoreArchivePath(conf, tn, regionName, family); } catch (IOException e) { LOG.warn("Could not compute path for the archive directory for the region", e);
/** * Get the path to the table archive directory based on the configured archive directory. * <p> * Assumed that the table should already be archived. * @param conf {@link Configuration} to read the archive directory property. Can be null * @param tableName Name of the table to be archived. Cannot be null. * @return {@link Path} to the archive directory for the table */ public static Path getTableArchivePath(final Configuration conf, final TableName tableName) throws IOException { return FSUtils.getTableDir(getArchivePath(conf), tableName); }
/** * Get the directory to archive a store directory * @param conf {@link Configuration} to read for the archive directory name * @param tableName table name under which the store currently lives * @param regionName region encoded name under which the store currently lives * @param familyName name of the family in the store * @return {@link Path} to the directory to archive the given store or * <tt>null</tt> if it should not be archived */ public static Path getStoreArchivePath(final Configuration conf, final TableName tableName, final String regionName, final String familyName) throws IOException { Path tableArchiveDir = getTableArchivePath(conf, tableName); return HStore.getStoreHomedir(tableArchiveDir, regionName, Bytes.toBytes(familyName)); }
Path regionArchiveDir = HFileArchiveUtil.getRegionArchiveDir(rootdir, FSUtils.getTableName(tableDir), regionDir.getName());
/** * Archive the store file * @param fs the filesystem where the store files live * @param regionInfo region hosting the store files * @param conf {@link Configuration} to examine to determine the archive directory * @param tableDir {@link Path} to where the table is being stored (for building the archive path) * @param family the family hosting the store files * @param storeFile file to be archived * @throws IOException if the files could not be correctly disposed. */ public static void archiveStoreFile(Configuration conf, FileSystem fs, RegionInfo regionInfo, Path tableDir, byte[] family, Path storeFile) throws IOException { Path storeArchiveDir = HFileArchiveUtil.getStoreArchivePath(conf, regionInfo, tableDir, family); // make sure we don't archive if we can't and that the archive dir exists if (!fs.mkdirs(storeArchiveDir)) { throw new IOException("Could not make archive directory (" + storeArchiveDir + ") for store:" + Bytes.toString(family) + ", deleting compacted files instead."); } // do the actual archive long start = EnvironmentEdgeManager.currentTime(); File file = new FileablePath(fs, storeFile); if (!resolveAndArchiveFile(storeArchiveDir, file, Long.toString(start))) { throw new IOException("Failed to archive/delete the file for region:" + regionInfo.getRegionNameAsString() + ", family:" + Bytes.toString(family) + " into " + storeArchiveDir + ". Something is probably awry on the filesystem."); } }
/** * Get the path to the table archive directory based on the configured archive directory. * <p> * Get the path to the table's archive directory. * <p> * Generally of the form: /hbase/.archive/[tablename] * @param rootdir {@link Path} to the root directory where hbase files are stored (for building * the archive path) * @param tableName Name of the table to be archived. Cannot be null. * @return {@link Path} to the archive directory for the table */ public static Path getTableArchivePath(final Path rootdir, final TableName tableName) { return FSUtils.getTableDir(getArchivePath(rootdir), tableName); }
/** * Gets the directory to archive a store directory. * @param conf {@link Configuration} to read for the archive directory name. * @param region parent region information under which the store currently lives * @param family name of the family in the store * @return {@link Path} to the directory to archive the given store or <tt>null</tt> if it should * not be archived */ public static Path getStoreArchivePath(Configuration conf, RegionInfo region, byte[] family) throws IOException { Path rootDir = FSUtils.getRootDir(conf); Path tableArchiveDir = getTableArchivePath(rootDir, region.getTable()); return HStore.getStoreHomedir(tableArchiveDir, region, family); }
/** * Helper method to get the archive directory for the specified region * @param conf {@link Configuration} to check for the name of the archive directory * @param region region that is being archived * @return {@link Path} to the archive directory for the given region */ public static Path getRegionArchiveDir(Configuration conf, HRegion region) throws IOException { return HFileArchiveUtil.getRegionArchiveDir( FSUtils.getRootDir(conf), region.getTableDescriptor().getTableName(), region.getRegionInfo().getEncodedName()); }
files = mapForSrc[srcIdx].get(fam.getBytes()); Path archiveDir = HFileArchiveUtil.getStoreArchivePath(conf, srcTable, regionName, fam); String tblName = srcTable.getQualifierAsString(); Path tgtFam = new Path(new Path(tgtTable, regionName), fam);
/** * @param conf {@link Configuration} from which to extract specific archive locations * @param hFileLinkPattern The path ending with a HFileLink pattern. (table=region-hfile) * @throws IOException on unexpected error. */ public static final HFileLink buildFromHFileLinkPattern(Configuration conf, Path hFileLinkPattern) throws IOException { return buildFromHFileLinkPattern(FSUtils.getRootDir(conf), HFileArchiveUtil.getArchivePath(conf), hFileLinkPattern); }
@Test public void testGetTableArchivePath() { assertNotNull(HFileArchiveUtil.getTableArchivePath(rootDir, TableName.valueOf(name.getMethodName()))); }
Path regionArchiveDir = HFileArchiveUtil.getRegionArchiveDir(rootdir, tableDir, regionDir);
Path archiveStoreDir = HFileArchiveUtil.getStoreArchivePath(conf, linkedTable, linkedRegion, familyName); Path backRefPath = null;