@Override public void editRegion(final RegionInfo regionInfo) throws IOException { snapshotManifest.addRegion(FSUtils.getTableDir(rootDir, snapshotTable), regionInfo); } });
/** * Return the table directory in HDFS */ @VisibleForTesting Path getTableDir(final TableName tableName) { return FSUtils.getTableDir(rootdir, tableName); }
/** * Returns the latest table descriptor for the given table directly from the file system * if it exists, bypassing the local cache. * Returns null if it's not found. */ public static TableDescriptor getTableDescriptorFromFs(FileSystem fs, Path hbaseRootDir, TableName tableName) throws IOException { Path tableDir = FSUtils.getTableDir(hbaseRootDir, tableName); return getTableDescriptorFromFs(fs, tableDir); }
/** * Gets the table dir of the mob files under the qualified HBase root dir. * It's {rootDir}/mobdir/data/${namespace}/${tableName} * @param rootDir The qualified path of HBase root directory. * @param tableName The name of table. * @return The table dir of the mob file. */ public static Path getMobTableDir(Path rootDir, TableName tableName) { return FSUtils.getTableDir(getMobHome(rootDir), tableName); }
private static Path getFamilyDirPath (final Path rootDir, final TableName table, final String region, final String family) { return new Path(new Path(FSUtils.getTableDir(rootDir, table), region), family); }
/** * Gets the region dir of the mob files under the specified root dir. * It's {rootDir}/mobdir/data/{namespace}/{tableName}/{regionEncodedName}. * @param rootDir The qualified path of HBase root directory. * @param tableName The current table name. * @return The region dir of the mob files. */ public static Path getMobRegionPath(Path rootDir, TableName tableName) { Path tablePath = FSUtils.getTableDir(getMobHome(rootDir), tableName); RegionInfo regionInfo = getMobRegionInfo(tableName); return new Path(tablePath, regionInfo.getEncodedName()); }
/** * Take a snapshot of the specified disabled region */ protected void snapshotDisabledRegion(final RegionInfo regionInfo) throws IOException { snapshotManifest.addRegion(FSUtils.getTableDir(rootDir, snapshotTable), regionInfo); monitor.rethrowException(); status.setStatus("Completed referencing HFiles for offline region " + regionInfo.toString() + " of table: " + snapshotTable); }
/** * @return the directory for a give {@code region}. */ public Path getRegionDir(RegionInfo region) { return FSUtils.getRegionDir(FSUtils.getTableDir(getRootDir(), region.getTable()), region); }
public MobCompactor(Configuration conf, FileSystem fs, TableName tableName, ColumnFamilyDescriptor column, ExecutorService pool) { this.conf = conf; this.fs = fs; this.tableName = tableName; this.column = column; this.pool = pool; mobTableDir = FSUtils.getTableDir(MobUtils.getMobHome(conf), tableName); mobFamilyDir = MobUtils.getMobFamilyPath(conf, tableName, column.getNameAsString()); }
/** * @return all the HFiles for a given table in the specified dir * @throws IOException on expected failure */ private final Collection<String> getHFiles(Path dir, FileSystem fs, TableName tableName) throws IOException { Path tableDir = FSUtils.getTableDir(dir, tableName); return SnapshotTestingUtils.listHFileNames(fs, tableDir); }
public void deleteTableDir(TableName table) throws IOException { Path rootDir = FSUtils.getRootDir(conf); FileSystem fs = rootDir.getFileSystem(conf); Path p = FSUtils.getTableDir(rootDir, table); HBaseFsck.debugLsr(conf, p); boolean success = fs.delete(p, true); LOG.info("Deleted " + p + " sucessfully? " + success); }
private boolean mobTableDirExist(TableName tn) throws IOException { FileSystem fs = TEST_UTIL.getTestFileSystem(); Path tableDir = FSUtils.getTableDir(MobUtils.getMobHome(TEST_UTIL.getConfiguration()), tn); return fs.exists(tableDir); }
@Test public void testGetStoreArchivePath() throws IOException { byte[] family = Bytes.toBytes("Family"); Path tabledir = FSUtils.getTableDir(rootDir, TableName.valueOf(name.getMethodName())); HRegionInfo region = new HRegionInfo(TableName.valueOf(name.getMethodName())); Configuration conf = new Configuration(); FSUtils.setRootDir(conf, new Path("root")); assertNotNull(HFileArchiveUtil.getStoreArchivePath(conf, region, tabledir, family)); } }
protected void addHFilesToRegions() throws IOException { MasterFileSystem mfs = HTU.getMiniHBaseCluster().getMaster().getMasterFileSystem(); Path tableDir = FSUtils.getTableDir(mfs.getRootDir(), TABLE_NAME); for (Region region : cluster.getRegions(TABLE_NAME)) { Path regionDir = new Path(tableDir, region.getRegionInfo().getEncodedName()); Path familyDir = new Path(regionDir, Bytes.toString(FAMILY)); HFileTestUtil .createHFile(HTU.getConfiguration(), HTU.getTestFileSystem(), new Path(familyDir, HFILE_NAME), FAMILY, QUALIFIER, Bytes.toBytes("50"), Bytes.toBytes("60"), NUM_ROWS); } } }
/** * Clean up a merged region * @param env MasterProcedureEnv */ private void cleanupMergedRegion(final MasterProcedureEnv env) throws IOException { final MasterFileSystem mfs = env.getMasterServices().getMasterFileSystem(); final Path tabledir = FSUtils.getTableDir(mfs.getRootDir(), regionsToMerge[0].getTable()); final FileSystem fs = mfs.getFileSystem(); HRegionFileSystem regionFs = HRegionFileSystem.openRegionFromFileSystem( env.getMasterConfiguration(), fs, tabledir, regionsToMerge[0], false); regionFs.cleanupMergedRegion(mergedRegion); }
private Set<String> getFamiliesFromFS(final TableName tableName) throws IOException { MasterFileSystem mfs = TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterFileSystem(); Set<String> families = new HashSet<>(); Path tableDir = FSUtils.getTableDir(mfs.getRootDir(), tableName); for (Path regionDir : FSUtils.getRegionDirs(mfs.getFileSystem(), tableDir)) { for (Path familyDir : FSUtils.getFamilyDirs(mfs.getFileSystem(), regionDir)) { families.add(familyDir.getName()); } } return families; }
@Test public void testOpeningReadOnlyRegionBasic() throws Exception { String snapshotDir = client.createSnapshot(baseDir, SNAPSHOT_NAME); RegionInfo firstRegion = TEST_UTIL.getConnection().getRegionLocator( table.getName()).getAllRegionLocations().stream().findFirst().get().getRegion(); Path tableDir = FSUtils.getTableDir(new Path(snapshotDir), TABLE_NAME); HRegion snapshottedRegion = openSnapshotRegion(firstRegion, tableDir); Assert.assertNotNull(snapshottedRegion); snapshottedRegion.close(); }
@VisibleForTesting HRegionFileSystem getFileSystem(Connection connection) throws IOException { Admin admin = connection.getAdmin(); return HRegionFileSystem.openRegionFromFileSystem(admin.getConfiguration(), FSUtils.getCurrentFileSystem(admin.getConfiguration()), FSUtils.getTableDir(FSUtils.getRootDir(admin.getConfiguration()), region.getTable()), region, true); }
private HRegionFileSystem getHRegionFS(HTable table, Configuration conf) throws IOException { FileSystem fs = TEST_UTIL.getDFSCluster().getFileSystem(); Path tableDir = FSUtils.getTableDir(TEST_UTIL.getDefaultRootDirPath(), table.getName()); List<Path> regionDirs = FSUtils.getRegionDirs(fs, tableDir); assertEquals(1, regionDirs.size()); List<Path> familyDirs = FSUtils.getFamilyDirs(fs, regionDirs.get(0)); assertEquals(2, familyDirs.size()); RegionInfo hri = table.getRegionLocator().getAllRegionLocations().get(0).getRegionInfo(); HRegionFileSystem regionFs = new HRegionFileSystem(conf, new HFileSystem(fs), tableDir, hri); return regionFs; }
private void verifyTableDescriptor(final TableName tableName, final byte[]... families) throws Exception { // Verify descriptor from master TableDescriptor htd = admin.getDescriptor(tableName).get(); verifyTableDescriptor(htd, tableName, families); // Verify descriptor from HDFS MasterFileSystem mfs = TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterFileSystem(); Path tableDir = FSUtils.getTableDir(mfs.getRootDir(), tableName); TableDescriptor td = FSTableDescriptors.getTableDescriptorFromFs(mfs.getFileSystem(), tableDir); verifyTableDescriptor(td, tableName, families); }