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


Java HRegionInfo.getRegionId方法代碼示例

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


在下文中一共展示了HRegionInfo.getRegionId方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: compare

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
@Override
public int compare(HRegionInfo l, HRegionInfo r) {
  long diff = r.getRegionId() - l.getRegionId();
  if (diff < 0) return -1;
  if (diff > 0) return 1;
  return 0;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:8,代碼來源:RegionInfoComparator.java

示例3: cloneRegionInfo

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
public static HRegionInfo cloneRegionInfo(TableName tableName, HRegionInfo snapshotRegionInfo) {
  HRegionInfo regionInfo = new HRegionInfo(tableName,
                    snapshotRegionInfo.getStartKey(), snapshotRegionInfo.getEndKey(),
                    snapshotRegionInfo.isSplit(), snapshotRegionInfo.getRegionId());
  regionInfo.setOffline(snapshotRegionInfo.isOffline());
  return regionInfo;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:8,代碼來源:RestoreSnapshotHelper.java

示例4: getDaughterRegionIdTimestamp

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
/**
 * Calculate daughter regionid to use.
 * @param hri Parent {@link HRegionInfo}
 * @return Daughter region id (timestamp) to use.
 */
private static long getDaughterRegionIdTimestamp(final HRegionInfo hri) {
  long rid = EnvironmentEdgeManager.currentTime();
  // Regionid is timestamp.  Can't be less than that of parent else will insert
  // at wrong location in hbase:meta (See HBASE-710).
  if (rid < hri.getRegionId()) {
    LOG.warn("Clock skew; parent regions id is " + hri.getRegionId() +
      " but current time here is " + rid);
    rid = hri.getRegionId() + 1;
  }
  return rid;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:17,代碼來源:SplitTransactionImpl.java

示例5: getMergedRegionInfo

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
/**
 * Get merged region info through the specified two regions
 * @param a merging region A
 * @param b merging region B
 * @return the merged region info
 */
public static HRegionInfo getMergedRegionInfo(final HRegionInfo a,
    final HRegionInfo b) {
  long rid = EnvironmentEdgeManager.currentTime();
  // Regionid is timestamp. Merged region's id can't be less than that of
  // merging regions else will insert at wrong location in hbase:meta
  if (rid < a.getRegionId() || rid < b.getRegionId()) {
    LOG.warn("Clock skew; merging regions id are " + a.getRegionId()
        + " and " + b.getRegionId() + ", but current time here is " + rid);
    rid = Math.max(a.getRegionId(), b.getRegionId()) + 1;
  }

  byte[] startKey = null;
  byte[] endKey = null;
  // Choose the smaller as start key
  if (a.compareTo(b) <= 0) {
    startKey = a.getStartKey();
  } else {
    startKey = b.getStartKey();
  }
  // Choose the bigger as end key
  if (Bytes.equals(a.getEndKey(), HConstants.EMPTY_BYTE_ARRAY)
      || (!Bytes.equals(b.getEndKey(), HConstants.EMPTY_BYTE_ARRAY)
          && Bytes.compareTo(a.getEndKey(), b.getEndKey()) > 0)) {
    endKey = a.getEndKey();
  } else {
    endKey = b.getEndKey();
  }

  // Merged region is sorted between two merging regions in META
  HRegionInfo mergedRegionInfo = new HRegionInfo(a.getTable(), startKey,
      endKey, false, rid);
  return mergedRegionInfo;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:40,代碼來源:RegionMergeTransactionImpl.java

示例6: compareRegionInfosWithoutReplicaId

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
private static int compareRegionInfosWithoutReplicaId(HRegionInfo regionInfoA,
    HRegionInfo regionInfoB) {
  int result = regionInfoA.getTable().compareTo(regionInfoB.getTable());
  if (result != 0) {
    return result;
  }

  // Compare start keys.
  result = Bytes.compareTo(regionInfoA.getStartKey(), regionInfoB.getStartKey());
  if (result != 0) {
    return result;
  }

  // Compare end keys.
  result = Bytes.compareTo(regionInfoA.getEndKey(), regionInfoB.getEndKey());

  if (result != 0) {
    if (regionInfoA.getStartKey().length != 0
            && regionInfoA.getEndKey().length == 0) {
        return 1; // this is last region
    }
    if (regionInfoB.getStartKey().length != 0
            && regionInfoB.getEndKey().length == 0) {
        return -1; // o is the last region
    }
    return result;
  }

  // regionId is usually milli timestamp -- this defines older stamps
  // to be "smaller" than newer stamps in sort order.
  if (regionInfoA.getRegionId() > regionInfoB.getRegionId()) {
    return 1;
  } else if (regionInfoA.getRegionId() < regionInfoB.getRegionId()) {
    return -1;
  }
  return 0;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:38,代碼來源:RegionReplicaUtil.java


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