org.apache.hadoop.hbase.regionserver.Region#getRegionInfo ( )源码实例Demo

下面列出了org.apache.hadoop.hbase.regionserver.Region#getRegionInfo ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hbase   文件: AccessController.java
@Override
public void preOpen(ObserverContext<RegionCoprocessorEnvironment> c)
    throws IOException {
  RegionCoprocessorEnvironment env = c.getEnvironment();
  final Region region = env.getRegion();
  if (region == null) {
    LOG.error("NULL region from RegionCoprocessorEnvironment in preOpen()");
  } else {
    RegionInfo regionInfo = region.getRegionInfo();
    if (regionInfo.getTable().isSystemTable()) {
      checkSystemOrSuperUser(getActiveUser(c));
    } else {
      requirePermission(c, "preOpen", Action.ADMIN);
    }
  }
}
 
private void separateLocalAndRemoteMutations(Table targetHTable, Region region, List<Mutation> mutations,
                                             List<Mutation> localRegionMutations, List<Mutation> remoteRegionMutations,
                                             boolean isPKChanging){
    boolean areMutationsInSameTable = areMutationsInSameTable(targetHTable, region);
    //if we're writing to the same table, but the PK can change, that means that some
    //mutations might be in our current region, and others in a different one.
    if (areMutationsInSameTable && isPKChanging) {
        RegionInfo regionInfo = region.getRegionInfo();
        for (Mutation mutation : mutations){
            if (regionInfo.containsRow(mutation.getRow())){
                localRegionMutations.add(mutation);
            } else {
                remoteRegionMutations.add(mutation);
            }
        }
    } else if (areMutationsInSameTable && !isPKChanging) {
        localRegionMutations.addAll(mutations);
    } else {
        remoteRegionMutations.addAll(mutations);
    }
}
 
源代码3 项目: hbase   文件: AccessController.java
private TableName getTableName(Region region) {
  RegionInfo regionInfo = region.getRegionInfo();
  if (regionInfo != null) {
    return regionInfo.getTable();
  }
  return null;
}
 
源代码4 项目: hbase   文件: TestFileSystemUtilizationChore.java
/**
 * Creates a region which is the parent of a split.
 *
 * @param storeSizes A list of sizes for each Store.
 * @return A mocked Region.
 */
private Region mockSplitParentRegionWithSize(Collection<Long> storeSizes) {
  final Region r = mockRegionWithSize(storeSizes);
  final RegionInfo info = r.getRegionInfo();
  when(info.isSplitParent()).thenReturn(true);
  return r;
}
 
源代码5 项目: hbase   文件: TestFileSystemUtilizationChore.java
/**
 * Creates a region who has a replicaId of <code>1</code>.
 *
 * @param storeSizes A list of sizes for each Store.
 * @return A mocked Region.
 */
private Region mockRegionReplicaWithSize(Collection<Long> storeSizes) {
  final Region r = mockRegionWithSize(storeSizes);
  final RegionInfo info = r.getRegionInfo();
  when(info.getReplicaId()).thenReturn(1);
  return r;
}
 
private RegionScanner collectStats(final RegionScanner innerScanner, StatisticsCollector stats,
        final Region region, final Scan scan, Configuration config) throws IOException {
    StatsCollectionCallable callable =
            new StatsCollectionCallable(stats, region, innerScanner, config, scan);
    byte[] asyncBytes = scan.getAttribute(BaseScannerRegionObserver.RUN_UPDATE_STATS_ASYNC_ATTRIB);
    boolean async = false;
    if (asyncBytes != null) {
        async = Bytes.toBoolean(asyncBytes);
    }
    long rowCount = 0; // in case of async, we report 0 as number of rows updated
    StatisticsCollectionRunTracker statsRunTracker =
            StatisticsCollectionRunTracker.getInstance(config);
    final boolean runUpdateStats = statsRunTracker.addUpdateStatsCommandRegion(region.getRegionInfo(),scan.getFamilyMap().keySet());
    if (runUpdateStats) {
        if (!async) {
            rowCount = callable.call();
        } else {
            statsRunTracker.runTask(callable);
        }
    } else {
        rowCount = CONCURRENT_UPDATE_STATS_ROW_COUNT;
        LOGGER.info("UPDATE STATISTICS didn't run because another UPDATE STATISTICS command was already running on the region "
                + region.getRegionInfo().getRegionNameAsString());
    }
    byte[] rowCountBytes = PLong.INSTANCE.toBytes(Long.valueOf(rowCount));
    final Cell aggKeyValue =
            PhoenixKeyValueUtil.newKeyValue(UNGROUPED_AGG_ROW_KEY, SINGLE_COLUMN_FAMILY,
                SINGLE_COLUMN, AGG_TIMESTAMP, rowCountBytes, 0, rowCountBytes.length);
    RegionScanner scanner = new BaseRegionScanner(innerScanner) {
        @Override
        public RegionInfo getRegionInfo() {
            return region.getRegionInfo();
        }

        @Override
        public boolean isFilterDone() {
            return true;
        }

        @Override
        public void close() throws IOException {
            // If we ran/scheduled StatsCollectionCallable the delegate
            // scanner is closed there. Otherwise close it here.
            if (!runUpdateStats) {
                super.close();
            }
        }

        @Override
        public boolean next(List<Cell> results) throws IOException {
            results.add(aggKeyValue);
            return false;
        }

        @Override
        public long getMaxResultSize() {
            return scan.getMaxResultSize();
        }
    };
    return scanner;
}