當前位置: 首頁>>代碼示例>>Java>>正文


Java HRegionInfo.getServerName方法代碼示例

本文整理匯總了Java中org.apache.hadoop.hbase.HRegionInfo.getServerName方法的典型用法代碼示例。如果您正苦於以下問題:Java HRegionInfo.getServerName方法的具體用法?Java HRegionInfo.getServerName怎麽用?Java HRegionInfo.getServerName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.hbase.HRegionInfo的用法示例。


在下文中一共展示了HRegionInfo.getServerName方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getRegionInfo

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
@Override
public TRegionInfo getRegionInfo(ByteBuffer searchRow) throws IOError {
  try {
    byte[] row = getBytes(searchRow);
    Result startRowResult =
        getRowOrBefore(TableName.META_TABLE_NAME.getName(), row, HConstants.CATALOG_FAMILY);

    if (startRowResult == null) {
      throw new IOException("Cannot find row in "+ TableName.META_TABLE_NAME+", row="
                            + Bytes.toStringBinary(row));
    }

    // find region start and end keys
    HRegionInfo regionInfo = HRegionInfo.getHRegionInfo(startRowResult);
    if (regionInfo == null) {
      throw new IOException("HRegionInfo REGIONINFO was null or " +
                            " empty in Meta for row="
                            + Bytes.toStringBinary(row));
    }
    TRegionInfo region = new TRegionInfo();
    region.setStartKey(regionInfo.getStartKey());
    region.setEndKey(regionInfo.getEndKey());
    region.id = regionInfo.getRegionId();
    region.setName(regionInfo.getRegionName());
    region.version = regionInfo.getVersion();

    // find region assignment to server
    ServerName serverName = HRegionInfo.getServerName(startRowResult);
    if (serverName != null) {
      region.setServerName(Bytes.toBytes(serverName.getHostname()));
      region.port = serverName.getPort();
    }
    return region;
  } catch (IOException e) {
    LOG.warn(e.getMessage(), e);
    throw new IOError(Throwables.getStackTraceAsString(e));
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:39,代碼來源:ThriftServerRunner.java

示例2: isTableAvailable

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
@Override
public boolean isTableAvailable(final TableName tableName) throws IOException {
  final AtomicBoolean available = new AtomicBoolean(true);
  final AtomicInteger regionCount = new AtomicInteger(0);
  MetaScannerVisitor visitor = new MetaScannerVisitorBase() {
    @Override
    public boolean processRow(Result row) throws IOException {
      HRegionInfo info = MetaScanner.getHRegionInfo(row);
      if (info != null && !info.isSplitParent()) {
        if (tableName.equals(info.getTable())) {
          ServerName server = HRegionInfo.getServerName(row);
          if (server == null) {
            available.set(false);
            return false;
          }
          regionCount.incrementAndGet();
        } else if (tableName.compareTo(info.getTable()) < 0) {
          // Return if we are done with the current table
          return false;
        }
      }
      return true;
    }
  };
  MetaScanner.metaScan(this, visitor, tableName);
  return available.get() && (regionCount.get() > 0);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:28,代碼來源:ConnectionManager.java


注:本文中的org.apache.hadoop.hbase.HRegionInfo.getServerName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。