Java Code Examples for org.apache.hadoop.hbase.client.RegionInfo#parseFromOrNull()

The following examples show how to use org.apache.hadoop.hbase.client.RegionInfo#parseFromOrNull() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HBCKMetaTableAccessor.java    From hbase-operator-tools with Apache License 2.0 6 votes vote down vote up
public static List<RegionInfo> getMergeRegions(Cell[] cells) {
  if (cells == null) {
    return null;
  }
  List<RegionInfo> regionsToMerge = null;
  for (Cell cell : cells) {
    if (!isMergeQualifierPrefix(cell)) {
      continue;
    }
    // Ok. This cell is that of a info:merge* column.
    RegionInfo ri = RegionInfo
        .parseFromOrNull(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
    if (ri != null) {
      if (regionsToMerge == null) {
        regionsToMerge = new ArrayList<>();
      }
      regionsToMerge.add(ri);
    }
  }
  return regionsToMerge;
}
 
Example 2
Source File: MetaTableAccessor.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * @return Deserialized values of &lt;qualifier,regioninfo&gt; pairs taken from column values that
 *         match the regex 'info:merge.*' in array of <code>cells</code>.
 */
@Nullable
public static Map<String, RegionInfo> getMergeRegionsWithName(Cell[] cells) {
  if (cells == null) {
    return null;
  }
  Map<String, RegionInfo> regionsToMerge = null;
  for (Cell cell : cells) {
    if (!isMergeQualifierPrefix(cell)) {
      continue;
    }
    // Ok. This cell is that of a info:merge* column.
    RegionInfo ri = RegionInfo.parseFromOrNull(cell.getValueArray(), cell.getValueOffset(),
      cell.getValueLength());
    if (ri != null) {
      if (regionsToMerge == null) {
        regionsToMerge = new LinkedHashMap<>();
      }
      regionsToMerge.put(Bytes.toString(CellUtil.cloneQualifier(cell)), ri);
    }
  }
  return regionsToMerge;
}
 
Example 3
Source File: HBCKMetaTableAccessor.java    From hbase-operator-tools with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the RegionInfo object from the column {@link HConstants#CATALOG_FAMILY} and
 * <code>qualifier</code> of the catalog table result.
 * (Copied from MetaTableAccessor)
 * @param r a Result object from the catalog table scan
 * @param qualifier Column family qualifier
 * @return An RegionInfo instance or null.
 */
public static RegionInfo getRegionInfo(final Result r, byte [] qualifier) {
  Cell cell = r.getColumnLatestCell(CATALOG_FAMILY, qualifier);
  if (cell == null) {
    return null;
  }
  return RegionInfo.parseFromOrNull(cell.getValueArray(),
    cell.getValueOffset(), cell.getValueLength());
}
 
Example 4
Source File: TestScanner.java    From hbase with Apache License 2.0 5 votes vote down vote up
/** Compare the HRegionInfo we read from HBase to what we stored */
private void validateRegionInfo(byte [] regionBytes) throws IOException {
  RegionInfo info = RegionInfo.parseFromOrNull(regionBytes);

  assertEquals(REGION_INFO.getRegionId(), info.getRegionId());
  assertEquals(0, info.getStartKey().length);
  assertEquals(0, info.getEndKey().length);
  assertEquals(0, Bytes.compareTo(info.getRegionName(), REGION_INFO.getRegionName()));
  //assertEquals(0, info.getTableDesc().compareTo(REGION_INFO.getTableDesc()));
}
 
Example 5
Source File: CatalogFamilyFormat.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the RegionInfo object from the column {@link HConstants#CATALOG_FAMILY} and
 * <code>qualifier</code> of the catalog table result.
 * @param r a Result object from the catalog table scan
 * @param qualifier Column family qualifier
 * @return An RegionInfo instance or null.
 */
@Nullable
public static RegionInfo getRegionInfo(final Result r, byte[] qualifier) {
  Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY, qualifier);
  if (cell == null) {
    return null;
  }
  return RegionInfo.parseFromOrNull(cell.getValueArray(), cell.getValueOffset(),
    cell.getValueLength());
}