当前位置: 首页>>代码示例>>Java>>正文


Java HTable.getRegionLocations方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.client.HTable.getRegionLocations方法的典型用法代码示例。如果您正苦于以下问题:Java HTable.getRegionLocations方法的具体用法?Java HTable.getRegionLocations怎么用?Java HTable.getRegionLocations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.client.HTable的用法示例。


在下文中一共展示了HTable.getRegionLocations方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createTable

import org.apache.hadoop.hbase.client.HTable; //导入方法依赖的package包/类
/**
 * Create a table with specified table name and region number.
 * @param tablename
 * @param regionNum
 * @return
 * @throws IOException
 */
private static void createTable(TableName tableName, int regionNum)
    throws IOException {
  int expectedRegions = regionNum;
  byte[][] splitKeys = new byte[expectedRegions - 1][];
  for (int i = 1; i < expectedRegions; i++) {
    byte splitKey = (byte) i;
    splitKeys[i - 1] = new byte[] { splitKey, splitKey, splitKey };
  }

  HTableDescriptor desc = new HTableDescriptor(tableName);
  desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY));
  admin.createTable(desc, splitKeys);

  HTable ht = (HTable) CONNECTION.getTable(tableName);
  @SuppressWarnings("deprecation")
  Map<HRegionInfo, ServerName> regions = ht.getRegionLocations();
  assertEquals("Tried to create " + expectedRegions + " regions "
      + "but only found " + regions.size(), expectedRegions, regions.size());
  ht.close();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:28,代码来源:TestRegionPlacement.java

示例2: verifyBounds

import org.apache.hadoop.hbase.client.HTable; //导入方法依赖的package包/类
private void verifyBounds(List<byte[]> expectedBounds, TableName tableName)
        throws Exception {
    // Get region boundaries from the cluster and verify their endpoints
    final Configuration conf = UTIL.getConfiguration();
    final int numRegions = expectedBounds.size()-1;
    final HTable hTable = new HTable(conf, tableName);
    final Map<HRegionInfo, ServerName> regionInfoMap = hTable.getRegionLocations();
    assertEquals(numRegions, regionInfoMap.size());
    for (Map.Entry<HRegionInfo, ServerName> entry: regionInfoMap.entrySet()) {
        final HRegionInfo regionInfo = entry.getKey();
        byte[] regionStart = regionInfo.getStartKey();
        byte[] regionEnd = regionInfo.getEndKey();

        // This region's start key should be one of the region boundaries
        int startBoundaryIndex = indexOfBytes(expectedBounds, regionStart);
        assertNotSame(-1, startBoundaryIndex);

        // This region's end key should be the region boundary that comes
        // after the starting boundary.
        byte[] expectedRegionEnd = expectedBounds.get(
                startBoundaryIndex+1);
        assertEquals(0, Bytes.compareTo(regionEnd, expectedRegionEnd));
    }
    hTable.close();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:26,代码来源:TestRegionSplitter.java

示例3: init

import org.apache.hadoop.hbase.client.HTable; //导入方法依赖的package包/类
private void init() {
  logger.debug("Getting region locations");
  try {
    HTable table = new HTable(storagePluginConfig.getHBaseConf(), hbaseScanSpec.getTableName());
    this.hTableDesc = table.getTableDescriptor();
    NavigableMap<HRegionInfo, ServerName> regionsMap = table.getRegionLocations();
    statsCalculator = new TableStatsCalculator(table, hbaseScanSpec, storagePlugin.getContext().getConfig(), storagePluginConfig);

    boolean foundStartRegion = false;
    regionsToScan = new TreeMap<HRegionInfo, ServerName>();
    for (Entry<HRegionInfo, ServerName> mapEntry : regionsMap.entrySet()) {
      HRegionInfo regionInfo = mapEntry.getKey();
      if (!foundStartRegion && hbaseScanSpec.getStartRow() != null && hbaseScanSpec.getStartRow().length != 0 && !regionInfo.containsRow(hbaseScanSpec.getStartRow())) {
        continue;
      }
      foundStartRegion = true;
      regionsToScan.put(regionInfo, mapEntry.getValue());
      scanSizeInBytes += statsCalculator.getRegionSizeInBytes(regionInfo.getRegionName());
      if (hbaseScanSpec.getStopRow() != null && hbaseScanSpec.getStopRow().length != 0 && regionInfo.containsRow(hbaseScanSpec.getStopRow())) {
        break;
      }
    }

    table.close();
  } catch (IOException e) {
    throw new DrillRuntimeException("Error getting region info for table: " + hbaseScanSpec.getTableName(), e);
  }
  verifyColumns();
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:30,代码来源:HBaseGroupScan.java

示例4: assertAllOnLine

import org.apache.hadoop.hbase.client.HTable; //导入方法依赖的package包/类
private void assertAllOnLine(final HTable t) throws IOException {
  NavigableMap<HRegionInfo, ServerName> regions = t.getRegionLocations();
  for (Map.Entry<HRegionInfo, ServerName> e: regions.entrySet()) {
    byte [] startkey = e.getKey().getStartKey();
    Scan s = new Scan(startkey);
    ResultScanner scanner = t.getScanner(s);
    Result r = scanner.next();
    org.junit.Assert.assertTrue(r != null && r.size() > 0);
    scanner.close();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:12,代码来源:TestLoadAndSwitchEncodeOnDisk.java


注:本文中的org.apache.hadoop.hbase.client.HTable.getRegionLocations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。