本文整理匯總了Java中org.apache.hadoop.hbase.HRegionInfo.convert方法的典型用法代碼示例。如果您正苦於以下問題:Java HRegionInfo.convert方法的具體用法?Java HRegionInfo.convert怎麽用?Java HRegionInfo.convert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.hbase.HRegionInfo
的用法示例。
在下文中一共展示了HRegionInfo.convert方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: verifyRegionInfo
import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
/**
* Verify that the regionInfo is valid
* @param region the region to check
* @param manifest snapshot manifest to inspect
*/
private void verifyRegionInfo(final HRegionInfo region,
final SnapshotRegionManifest manifest) throws IOException {
HRegionInfo manifestRegionInfo = HRegionInfo.convert(manifest.getRegionInfo());
if (!region.equals(manifestRegionInfo)) {
String msg = "Manifest region info " + manifestRegionInfo +
"doesn't match expected region:" + region;
throw new CorruptedSnapshotException(msg, snapshot);
}
}
示例2: readFields
import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
@Override
public void readFields(DataInput in) throws IOException {
int len = in.readInt();
byte[] buf = new byte[len];
in.readFully(buf);
TableSnapshotRegionSplit split = TableSnapshotRegionSplit.PARSER.parseFrom(buf);
this.htd = HTableDescriptor.convert(split.getTable());
this.regionInfo = HRegionInfo.convert(split.getRegion());
List<String> locationsList = split.getLocationsList();
this.locations = locationsList.toArray(new String[locationsList.size()]);
this.scan = Bytes.toString(Bytes.readByteArray(in));
this.restoreDir = Bytes.toString(Bytes.readByteArray(in));
}
示例3: visitRegionStoreFiles
import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
/**
* Iterate over the snapshot store files in the specified region
*
* @param manifest snapshot manifest to inspect
* @param visitor callback object to get the store files
* @throws IOException if an error occurred while scanning the directory
*/
static void visitRegionStoreFiles(final SnapshotRegionManifest manifest,
final StoreFileVisitor visitor) throws IOException {
HRegionInfo regionInfo = HRegionInfo.convert(manifest.getRegionInfo());
for (SnapshotRegionManifest.FamilyFiles familyFiles: manifest.getFamilyFilesList()) {
String familyName = familyFiles.getFamilyName().toStringUtf8();
for (SnapshotRegionManifest.StoreFile storeFile: familyFiles.getStoreFilesList()) {
visitor.storeFile(regionInfo, familyName, storeFile);
}
}
}
示例4: updateFavoredNodes
import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
@Override
public UpdateFavoredNodesResponse updateFavoredNodes(RpcController controller,
UpdateFavoredNodesRequest request) throws ServiceException {
List<UpdateFavoredNodesRequest.RegionUpdateInfo> openInfoList = request.getUpdateInfoList();
UpdateFavoredNodesResponse.Builder respBuilder = UpdateFavoredNodesResponse.newBuilder();
for (UpdateFavoredNodesRequest.RegionUpdateInfo regionUpdateInfo : openInfoList) {
HRegionInfo hri = HRegionInfo.convert(regionUpdateInfo.getRegion());
regionServer.updateRegionFavoredNodesMapping(hri.getEncodedName(),
regionUpdateInfo.getFavoredNodesList());
}
respBuilder.setResponse(openInfoList.size());
return respBuilder.build();
}
示例5: testConvert
import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
@Test
public void testConvert() {
TableName tableName = TableName.valueOf("ns1:table1");
byte[] startKey = Bytes.toBytes("startKey");
byte[] endKey = Bytes.toBytes("endKey");
boolean split = false;
long regionId = System.currentTimeMillis();
int replicaId = 42;
HRegionInfo hri = new HRegionInfo(tableName, startKey, endKey, split,
regionId, replicaId);
// convert two times, compare
HRegionInfo convertedHri = HRegionInfo.convert(HRegionInfo.convert(hri));
assertEquals(hri, convertedHri);
// test convert RegionInfo without replicaId
RegionInfo info = RegionInfo.newBuilder()
.setTableName(HBaseProtos.TableName.newBuilder()
.setQualifier(ByteString.copyFrom(tableName.getQualifier()))
.setNamespace(ByteString.copyFrom(tableName.getNamespace()))
.build())
.setStartKey(ByteString.copyFrom(startKey))
.setEndKey(ByteString.copyFrom(endKey))
.setSplit(split)
.setRegionId(regionId)
.build();
convertedHri = HRegionInfo.convert(info);
HRegionInfo expectedHri = new HRegionInfo(tableName, startKey, endKey, split,
regionId, 0); // expecting default replicaId
assertEquals(expectedHri, convertedHri);
}
示例6: getRegionInfo
import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
/**
* A helper to retrieve region info given a region name
* using admin protocol.
*
* @param admin
* @param regionName
* @return the retrieved region info
* @throws IOException
*/
public static HRegionInfo getRegionInfo(final RpcController controller,
final AdminService.BlockingInterface admin, final byte[] regionName) throws IOException {
try {
GetRegionInfoRequest request =
RequestConverter.buildGetRegionInfoRequest(regionName);
GetRegionInfoResponse response =
admin.getRegionInfo(controller, request);
return HRegionInfo.convert(response.getRegionInfo());
} catch (ServiceException se) {
throw getRemoteException(se);
}
}
示例7: warmupRegion
import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
/**
* Wamrmup a region on this server.
*
* This method should only be called by Master. It synchrnously opens the region and
* closes the region bringing the most important pages in cache.
* <p>
*
* @param controller the RPC controller
* @param request the request
* @throws ServiceException
*/
@Override
public WarmupRegionResponse warmupRegion(final RpcController controller,
final WarmupRegionRequest request) throws ServiceException {
RegionInfo regionInfo = request.getRegionInfo();
final HRegionInfo region = HRegionInfo.convert(regionInfo);
HTableDescriptor htd;
WarmupRegionResponse response = WarmupRegionResponse.getDefaultInstance();
try {
checkOpen();
String encodedName = region.getEncodedName();
byte[] encodedNameBytes = region.getEncodedNameAsBytes();
final Region onlineRegion = regionServer.getFromOnlineRegions(encodedName);
if (onlineRegion != null) {
LOG.info("Region already online. Skipping warming up " + region);
return response;
}
if (LOG.isDebugEnabled()) {
LOG.debug("Warming up Region " + region.getRegionNameAsString());
}
htd = regionServer.tableDescriptors.get(region.getTable());
if (regionServer.getRegionsInTransitionInRS().containsKey(encodedNameBytes)) {
LOG.info("Region is in transition. Skipping warmup " + region);
return response;
}
HRegion.warmupHRegion(region, htd, regionServer.getWAL(region),
regionServer.getConfiguration(), regionServer, null);
} catch (IOException ie) {
LOG.error("Failed warming up region " + region.getRegionNameAsString(), ie);
throw new ServiceException(ie);
}
return response;
}
示例8: convert
import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
/**
* Convert a protobuf HBaseProtos.RegionState to a RegionState
*
* @return the RegionState
*/
public static RegionState convert(ClusterStatusProtos.RegionState proto) {
return new RegionState(HRegionInfo.convert(proto.getRegionInfo()),
State.convert(proto.getState()), proto.getStamp(), null);
}