本文整理汇总了Java中org.apache.hadoop.hbase.regionserver.HRegion.getRegionDir方法的典型用法代码示例。如果您正苦于以下问题:Java HRegion.getRegionDir方法的具体用法?Java HRegion.getRegionDir怎么用?Java HRegion.getRegionDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.regionserver.HRegion
的用法示例。
在下文中一共展示了HRegion.getRegionDir方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRegionArchiveDir
import org.apache.hadoop.hbase.regionserver.HRegion; //导入方法依赖的package包/类
/**
* 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);
}
示例2: getHFileFromBackReference
import org.apache.hadoop.hbase.regionserver.HRegion; //导入方法依赖的package包/类
/**
* Get the full path of the HFile referenced by the back reference
*
* @param rootDir root hbase directory
* @param linkRefPath Link Back Reference path
* @return full path of the referenced hfile
*/
public static Path getHFileFromBackReference(final Path rootDir, final Path linkRefPath) {
Pair<TableName, String> p = parseBackReferenceName(linkRefPath.getName());
TableName linkTableName = p.getFirst();
String linkRegionName = p.getSecond();
String hfileName = getBackReferenceFileName(linkRefPath.getParent());
Path familyPath = linkRefPath.getParent().getParent();
Path regionPath = familyPath.getParent();
Path tablePath = regionPath.getParent();
String linkName = createHFileLinkName(FSUtils.getTableName(tablePath),
regionPath.getName(), hfileName);
Path linkTableDir = FSUtils.getTableDir(rootDir, linkTableName);
Path regionDir = HRegion.getRegionDir(linkTableDir, linkRegionName);
return new Path(new Path(regionDir, familyPath.getName()), linkName);
}
示例3: testRemovesRegionDirOnArchive
import org.apache.hadoop.hbase.regionserver.HRegion; //导入方法依赖的package包/类
@Test
public void testRemovesRegionDirOnArchive() throws Exception {
TableName TABLE_NAME =
TableName.valueOf("testRemovesRegionDirOnArchive");
UTIL.createTable(TABLE_NAME, TEST_FAM);
final Admin admin = UTIL.getHBaseAdmin();
// get the current store files for the region
List<HRegion> servingRegions = UTIL.getHBaseCluster().getRegions(TABLE_NAME);
// make sure we only have 1 region serving this table
assertEquals(1, servingRegions.size());
HRegion region = servingRegions.get(0);
// and load the table
UTIL.loadRegion(region, TEST_FAM);
// shutdown the table so we can manipulate the files
admin.disableTable(TABLE_NAME);
FileSystem fs = UTIL.getTestFileSystem();
// now attempt to depose the region
Path rootDir = region.getRegionFileSystem().getTableDir().getParent();
Path regionDir = HRegion.getRegionDir(rootDir, region.getRegionInfo());
HFileArchiver.archiveRegion(UTIL.getConfiguration(), fs, region.getRegionInfo());
// check for the existence of the archive directory and some files in it
Path archiveDir = HFileArchiveTestingUtil.getRegionArchiveDir(UTIL.getConfiguration(), region);
assertTrue(fs.exists(archiveDir));
// check to make sure the store directory was copied
// check to make sure the store directory was copied
FileStatus[] stores = fs.listStatus(archiveDir, new PathFilter() {
@Override
public boolean accept(Path p) {
if (p.getName().contains(HConstants.RECOVERED_EDITS_DIR)) {
return false;
}
return true;
}
});
assertTrue(stores.length == 1);
// make sure we archived the store files
FileStatus[] storeFiles = fs.listStatus(stores[0].getPath());
assertTrue(storeFiles.length > 0);
// then ensure the region's directory isn't present
assertFalse(fs.exists(regionDir));
UTIL.deleteTable(TABLE_NAME);
}
示例4: testBackReference
import org.apache.hadoop.hbase.regionserver.HRegion; //导入方法依赖的package包/类
@Test
public void testBackReference() {
Path rootDir = new Path("/root");
Path archiveDir = new Path(rootDir, ".archive");
String storeFileName = "121212";
String linkDir = FileLink.BACK_REFERENCES_DIRECTORY_PREFIX + storeFileName;
String encodedRegion = "FEFE";
String cf = "cf1";
TableName refTables[] = {TableName.valueOf("refTable"),
TableName.valueOf("ns", "refTable")};
for(TableName refTable : refTables) {
Path refTableDir = FSUtils.getTableDir(archiveDir, refTable);
Path refRegionDir = HRegion.getRegionDir(refTableDir, encodedRegion);
Path refDir = new Path(refRegionDir, cf);
Path refLinkDir = new Path(refDir, linkDir);
String refStoreFileName = refTable.getNameAsString().replace(
TableName.NAMESPACE_DELIM, '=') + "=" + encodedRegion + "-" + storeFileName;
TableName tableNames[] = {TableName.valueOf("tableName1"),
TableName.valueOf("ns", "tableName2")};
for( TableName tableName : tableNames) {
Path tableDir = FSUtils.getTableDir(rootDir, tableName);
Path regionDir = HRegion.getRegionDir(tableDir, encodedRegion);
Path cfDir = new Path(regionDir, cf);
//Verify back reference creation
assertEquals(encodedRegion+"."+
tableName.getNameAsString().replace(TableName.NAMESPACE_DELIM, '='),
HFileLink.createBackReferenceName(tableName.getNameAsString(),
encodedRegion));
//verify parsing back reference
Pair<TableName, String> parsedRef =
HFileLink.parseBackReferenceName(encodedRegion+"."+
tableName.getNameAsString().replace(TableName.NAMESPACE_DELIM, '='));
assertEquals(parsedRef.getFirst(), tableName);
assertEquals(parsedRef.getSecond(), encodedRegion);
//verify resolving back reference
Path storeFileDir = new Path(refLinkDir, encodedRegion+"."+
tableName.getNameAsString().replace(TableName.NAMESPACE_DELIM, '='));
Path linkPath = new Path(cfDir, refStoreFileName);
assertEquals(linkPath, HFileLink.getHFileFromBackReference(rootDir, storeFileDir));
}
}
}
示例5: metaRegionExists
import org.apache.hadoop.hbase.regionserver.HRegion; //导入方法依赖的package包/类
/**
* Checks if meta region exists
*
* @param fs file system
* @param rootdir root directory of HBase installation
* @return true if exists
* @throws IOException e
*/
@SuppressWarnings("deprecation")
public static boolean metaRegionExists(FileSystem fs, Path rootdir)
throws IOException {
Path metaRegionDir =
HRegion.getRegionDir(rootdir, HRegionInfo.FIRST_META_REGIONINFO);
return fs.exists(metaRegionDir);
}