本文整理匯總了Java中org.apache.hadoop.hbase.HRegionInfo.parseRegionName方法的典型用法代碼示例。如果您正苦於以下問題:Java HRegionInfo.parseRegionName方法的具體用法?Java HRegionInfo.parseRegionName怎麽用?Java HRegionInfo.parseRegionName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.hbase.HRegionInfo
的用法示例。
在下文中一共展示了HRegionInfo.parseRegionName方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testParseName
import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
@Test
public void testParseName() throws IOException {
TableName tableName = TableName.valueOf("testParseName");
byte[] startKey = Bytes.toBytes("startKey");
long regionId = System.currentTimeMillis();
int replicaId = 42;
// test without replicaId
byte[] regionName = HRegionInfo.createRegionName(tableName, startKey, regionId, false);
byte[][] fields = HRegionInfo.parseRegionName(regionName);
assertArrayEquals(Bytes.toString(fields[0]),tableName.getName(), fields[0]);
assertArrayEquals(Bytes.toString(fields[1]),startKey, fields[1]);
assertArrayEquals(Bytes.toString(fields[2]), Bytes.toBytes(Long.toString(regionId)),fields[2]);
assertEquals(3, fields.length);
// test with replicaId
regionName = HRegionInfo.createRegionName(tableName, startKey, regionId,
replicaId, false);
fields = HRegionInfo.parseRegionName(regionName);
assertArrayEquals(Bytes.toString(fields[0]),tableName.getName(), fields[0]);
assertArrayEquals(Bytes.toString(fields[1]),startKey, fields[1]);
assertArrayEquals(Bytes.toString(fields[2]), Bytes.toBytes(Long.toString(regionId)),fields[2]);
assertArrayEquals(Bytes.toString(fields[3]), Bytes.toBytes(
String.format(HRegionInfo.REPLICA_ID_FORMAT, replicaId)), fields[3]);
}
示例2: isEncodedRegionName
import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
private boolean isEncodedRegionName(byte[] regionName) throws IOException {
try {
HRegionInfo.parseRegionName(regionName);
return false;
} catch (IOException e) {
if (StringUtils.stringifyException(e)
.contains(HRegionInfo.INVALID_REGION_NAME_FORMAT_MESSAGE)) {
return true;
}
throw e;
}
}
示例3: parseOptions
import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
public boolean parseOptions(String args[]) throws ParseException,
IOException {
if (args.length == 0) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("HFile", options, true);
return false;
}
CommandLineParser parser = new PosixParser();
CommandLine cmd = parser.parse(options, args);
verbose = cmd.hasOption("v");
printValue = cmd.hasOption("p");
printKey = cmd.hasOption("e") || printValue;
shouldPrintMeta = cmd.hasOption("m");
printBlockIndex = cmd.hasOption("b");
printBlockHeaders = cmd.hasOption("h");
printStats = cmd.hasOption("s");
checkRow = cmd.hasOption("k");
checkFamily = cmd.hasOption("a");
if (cmd.hasOption("f")) {
files.add(new Path(cmd.getOptionValue("f")));
}
if (cmd.hasOption("w")) {
String key = cmd.getOptionValue("w");
if (key != null && key.length() != 0) {
row = Bytes.toBytesBinary(key);
isSeekToRow = true;
} else {
System.err.println("Invalid row is specified.");
System.exit(-1);
}
}
if (cmd.hasOption("r")) {
String regionName = cmd.getOptionValue("r");
byte[] rn = Bytes.toBytes(regionName);
byte[][] hri = HRegionInfo.parseRegionName(rn);
Path rootDir = FSUtils.getRootDir(getConf());
Path tableDir = FSUtils.getTableDir(rootDir, TableName.valueOf(hri[0]));
String enc = HRegionInfo.encodeRegionName(rn);
Path regionDir = new Path(tableDir, enc);
if (verbose)
System.out.println("region dir -> " + regionDir);
List<Path> regionFiles = HFile.getStoreFiles(FileSystem.get(getConf()),
regionDir);
if (verbose)
System.out.println("Number of region files found -> "
+ regionFiles.size());
if (verbose) {
int i = 1;
for (Path p : regionFiles) {
if (verbose)
System.out.println("Found file[" + i++ + "] -> " + p);
}
}
files.addAll(regionFiles);
}
return true;
}