Java Code Examples for org.apache.hadoop.hbase.HRegionLocation#getRegionInfo()

The following examples show how to use org.apache.hadoop.hbase.HRegionLocation#getRegionInfo() . 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: HBaseSplitsProvider.java    From geowave with Apache License 2.0 6 votes vote down vote up
protected static void binFullRange(
    final Map<HRegionLocation, Map<HRegionInfo, List<ByteArrayRange>>> binnedRanges,
    final RegionLocator regionLocator) throws IOException {

  final List<HRegionLocation> locations = regionLocator.getAllRegionLocations();

  for (final HRegionLocation location : locations) {
    Map<HRegionInfo, List<ByteArrayRange>> regionInfoMap = binnedRanges.get(location);
    if (regionInfoMap == null) {
      regionInfoMap = new HashMap<>();
      binnedRanges.put(location, regionInfoMap);
    }

    final HRegionInfo regionInfo = location.getRegionInfo();
    List<ByteArrayRange> rangeList = regionInfoMap.get(regionInfo);
    if (rangeList == null) {
      rangeList = new ArrayList<>();
      regionInfoMap.put(regionInfo, rangeList);
    }

    final ByteArrayRange regionRange =
        new ByteArrayRange(regionInfo.getStartKey(), regionInfo.getEndKey());
    rangeList.add(regionRange);
  }
}
 
Example 2
Source File: HBaseDataFragmenter.java    From pxf with Apache License 2.0 5 votes vote down vote up
private void addFragment(HRegionLocation location,
        byte[] userData) throws IOException {
    ServerName serverInfo = location.getServerName();
    String[] hosts = new String[] {serverInfo.getHostname()};
    HRegionInfo region = location.getRegionInfo();
    byte[] fragmentMetadata = prepareFragmentMetadata(region);
    Fragment fragment = new Fragment(context.getDataSource(), hosts, fragmentMetadata, userData);
    fragments.add(fragment);
}
 
Example 3
Source File: AdapterPartition.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
private List<Partition> formatPartitions(List<HRegionLocation> tableLocations) {
    List<Partition> partitions=new ArrayList<>(tableLocations.size());
    for(HRegionLocation location : tableLocations){
        HRegionInfo regionInfo=location.getRegionInfo();
        partitions.add(new RangedClientPartition(this,regionInfo,new RLServer(location)));
    }
    return partitions;
}
 
Example 4
Source File: HBaseSplitsProvider.java    From geowave with Apache License 2.0 4 votes vote down vote up
protected static List<ByteArrayRange> binRanges(
    final List<ByteArrayRange> inputRanges,
    final Map<HRegionLocation, Map<HRegionInfo, List<ByteArrayRange>>> binnedRanges,
    final RegionLocator regionLocator) throws IOException {

  // Loop through ranges, getting RegionLocation and RegionInfo for
  // startKey, clipping range by that regionInfo's extent, and leaving
  // remainder in the List to be region'd
  final ListIterator<ByteArrayRange> i = inputRanges.listIterator();
  while (i.hasNext()) {
    final ByteArrayRange range = i.next();
    final byte[] startKey = range == null ? HConstants.EMPTY_BYTE_ARRAY : range.getStart();
    final byte[] endKey = range == null ? HConstants.EMPTY_BYTE_ARRAY : range.getEnd();

    final HRegionLocation location = regionLocator.getRegionLocation(startKey);

    Map<HRegionInfo, List<ByteArrayRange>> regionInfoMap = binnedRanges.get(location);
    if (regionInfoMap == null) {
      regionInfoMap = new HashMap<>();
      binnedRanges.put(location, regionInfoMap);
    }

    final HRegionInfo regionInfo = location.getRegionInfo();
    List<ByteArrayRange> rangeList = regionInfoMap.get(regionInfo);
    if (rangeList == null) {
      rangeList = new ArrayList<>();
      regionInfoMap.put(regionInfo, rangeList);
    }

    // Check if region contains range or if it's the last range
    if ((endKey == HConstants.EMPTY_BYTE_ARRAY) || regionInfo.containsRange(startKey, endKey)) {
      rangeList.add(range);
      i.remove();
    } else {
      final ByteArrayRange thisRange = new ByteArrayRange(startKey, endKey);
      final ByteArrayRange regionRange =
          new ByteArrayRange(regionInfo.getStartKey(), regionInfo.getEndKey());

      final ByteArrayRange overlappingRange = thisRange.intersection(regionRange);

      rangeList.add(new ByteArrayRange(overlappingRange.getStart(), overlappingRange.getEnd()));
      i.remove();

      i.add(new ByteArrayRange(regionInfo.getEndKey(), endKey));
    }
  }
  // the underlying assumption is that by the end of this any input range
  // at least has the partition key portion and is the same partition key
  // for start and end keys on the range, because thats really by
  // definition what a region or tablets is using split points
  return inputRanges;
}