本文整理汇总了Java中org.apache.hadoop.hbase.io.HFileLink.buildFromHFileLinkPattern方法的典型用法代码示例。如果您正苦于以下问题:Java HFileLink.buildFromHFileLinkPattern方法的具体用法?Java HFileLink.buildFromHFileLinkPattern怎么用?Java HFileLink.buildFromHFileLinkPattern使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.io.HFileLink
的用法示例。
在下文中一共展示了HFileLink.buildFromHFileLinkPattern方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testHFileLink
import org.apache.hadoop.hbase.io.HFileLink; //导入方法依赖的package包/类
@Test
public void testHFileLink() throws Exception {
// pass a link, and verify that correct paths are returned.
Path rootDir = FSUtils.getRootDir(TEST_UTIL.getConfiguration());
Path aFileLink = new Path(rootDir, "table/2086db948c48/cf/table=21212abcdc33-0906db948c48");
Path preNamespaceTablePath = new Path(rootDir, "table/21212abcdc33/cf/0906db948c48");
Path preNamespaceArchivePath =
new Path(rootDir, ".archive/table/21212abcdc33/cf/0906db948c48");
Path preNamespaceTempPath = new Path(rootDir, ".tmp/table/21212abcdc33/cf/0906db948c48");
boolean preNSTablePathExists = false;
boolean preNSArchivePathExists = false;
boolean preNSTempPathExists = false;
assertTrue(HFileLink.isHFileLink(aFileLink));
HFileLink hFileLink =
HFileLink.buildFromHFileLinkPattern(TEST_UTIL.getConfiguration(), aFileLink);
assertTrue(hFileLink.getArchivePath().toString().startsWith(rootDir.toString()));
HFileV1Detector t = new HFileV1Detector();
t.setConf(TEST_UTIL.getConfiguration());
FileLink fileLink = t.getFileLinkWithPreNSPath(aFileLink);
//assert it has 6 paths (2 NS, 2 Pre NS, and 2 .tmp) to look.
assertTrue(fileLink.getLocations().length == 6);
for (Path p : fileLink.getLocations()) {
if (p.equals(preNamespaceArchivePath)) preNSArchivePathExists = true;
if (p.equals(preNamespaceTablePath)) preNSTablePathExists = true;
if (p.equals(preNamespaceTempPath)) preNSTempPathExists = true;
}
assertTrue(preNSArchivePathExists & preNSTablePathExists & preNSTempPathExists);
}
示例2: testMobFilePath
import org.apache.hadoop.hbase.io.HFileLink; //导入方法依赖的package包/类
@Test
public void testMobFilePath() throws IOException {
final TableName tableName = TableName.valueOf(name.getMethodName());
Configuration conf = HBaseConfiguration.create();
FileSystem fs = FileSystem.get(conf);
Path rootDir = FSUtils.getRootDir(conf);
Path tableDir = FSUtils.getTableDir(rootDir, tableName);
Path archiveDir = FSUtils.getTableDir(HFileArchiveUtil.getArchivePath(conf), tableName);
String fileName = "mobFile";
String encodedRegionName = MobUtils.getMobRegionInfo(tableName).getEncodedName();
String columnFamily = "columnFamily";
Path regionDir = new Path(tableDir, encodedRegionName);
Path archivedRegionDir = new Path(archiveDir, encodedRegionName);
Path expectedMobFilePath = new Path(MobUtils.getMobFamilyPath(conf, tableName, columnFamily),
fileName).makeQualified(fs.getUri(), fs.getWorkingDirectory());
Path expectedOriginPath = new Path(new Path(regionDir, columnFamily), fileName).makeQualified(
fs.getUri(), fs.getWorkingDirectory());
Path expectedArchivePath = new Path(new Path(archivedRegionDir, columnFamily), fileName)
.makeQualified(fs.getUri(), fs.getWorkingDirectory());
String hfileLinkName = tableName.getNameAsString() + "=" + encodedRegionName + "-" + fileName;
Path hfileLinkPath = new Path(columnFamily, hfileLinkName);
HFileLink hfileLink = HFileLink.buildFromHFileLinkPattern(conf, hfileLinkPath);
Assert.assertEquals(expectedMobFilePath, hfileLink.getMobPath());
Assert.assertEquals(expectedOriginPath, hfileLink.getOriginPath());
Assert.assertEquals(expectedArchivePath, hfileLink.getArchivePath());
}
示例3: getFileLink
import org.apache.hadoop.hbase.io.HFileLink; //导入方法依赖的package包/类
private FileLink getFileLink(Path path, Configuration conf) throws IOException{
String regionName = HFileLink.getReferencedRegionName(path.getName());
TableName tableName = HFileLink.getReferencedTableName(path.getName());
if(MobUtils.getMobRegionInfo(tableName).getEncodedName().equals(regionName)) {
return HFileLink.buildFromHFileLinkPattern(MobUtils.getQualifiedMobRootDir(conf),
HFileArchiveUtil.getArchivePath(conf), path);
}
return HFileLink.buildFromHFileLinkPattern(inputRoot, inputArchive, path);
}
示例4: offlineHLinkFileRepair
import org.apache.hadoop.hbase.io.HFileLink; //导入方法依赖的package包/类
/**
* Scan all the store file names to find any lingering HFileLink files,
* which refer to some none-exiting files. If "fix" option is enabled,
* any lingering HFileLink file will be sidelined if found.
*/
private void offlineHLinkFileRepair() throws IOException, InterruptedException {
Configuration conf = getConf();
Path hbaseRoot = FSUtils.getRootDir(conf);
FileSystem fs = hbaseRoot.getFileSystem(conf);
LOG.info("Computing mapping of all link files");
Map<String, Path> allFiles = FSUtils
.getTableStoreFilePathMap(fs, hbaseRoot, new FSUtils.HFileLinkFilter(), executor, errors);
errors.print("");
LOG.info("Validating mapping using HDFS state");
for (Path path : allFiles.values()) {
// building HFileLink object to gather locations
HFileLink actualLink = HFileLink.buildFromHFileLinkPattern(conf, path);
if (actualLink.exists(fs)) continue; // good, expected
// Found a lingering HFileLink
errors.reportError(ERROR_CODE.LINGERING_HFILELINK, "Found lingering HFileLink " + path);
if (!shouldFixHFileLinks()) continue;
// Now, trying to fix it since requested
setShouldRerun();
// An HFileLink path should be like
// ${hbase.rootdir}/data/namespace/table_name/region_id/family_name/linkedtable=linkedregionname-linkedhfilename
// sidelineing will happen in the ${hbase.rootdir}/${sidelinedir} directory with the same folder structure.
boolean success = sidelineFile(fs, hbaseRoot, path);
if (!success) {
LOG.error("Failed to sideline HFileLink file " + path);
}
// An HFileLink backreference path should be like
// ${hbase.rootdir}/archive/data/namespace/table_name/region_id/family_name/.links-linkedhfilename
// sidelineing will happen in the ${hbase.rootdir}/${sidelinedir} directory with the same folder structure.
Path backRefPath = FileLink.getBackReferencesDir(HFileArchiveUtil
.getStoreArchivePath(conf, HFileLink.getReferencedTableName(path.getName().toString()),
HFileLink.getReferencedRegionName(path.getName().toString()),
path.getParent().getName()),
HFileLink.getReferencedHFileName(path.getName().toString()));
success = sidelineFile(fs, hbaseRoot, backRefPath);
if (!success) {
LOG.error("Failed to sideline HFileLink backreference file " + path);
}
}
}
示例5: getFileLinkWithPreNSPath
import org.apache.hadoop.hbase.io.HFileLink; //导入方法依赖的package包/类
/**
* Creates a FileLink which adds pre-namespace paths in its list of available paths. This is used
* when reading a snapshot file in a pre-namespace file layout, for example, while upgrading.
* @param storeFilePath
* @return a FileLink which could read from pre-namespace paths.
* @throws IOException
*/
public FileLink getFileLinkWithPreNSPath(Path storeFilePath) throws IOException {
HFileLink link = HFileLink.buildFromHFileLinkPattern(getConf(), storeFilePath);
List<Path> pathsToProcess = getPreNSPathsForHFileLink(link);
pathsToProcess.addAll(Arrays.asList(link.getLocations()));
return new FileLink(pathsToProcess);
}