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


Java RegionLocations.size方法代码示例

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


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

示例1: prepare

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的package包/类
/**
 * Two responsibilities
 * - if the call is already completed (by another replica) stops the retries.
 * - set the location to the right region, depending on the replica.
 */
@Override
public void prepare(final boolean reload) throws IOException {
  if (controller.isCanceled()) return;

  if (Thread.interrupted()) {
    throw new InterruptedIOException();
  }

  if (reload || location == null) {
    RegionLocations rl = getRegionLocations(false, id, cConnection, tableName, get.getRow());
    location = id < rl.size() ? rl.getRegionLocation(id) : null;
  }

  if (location == null || location.getServerName() == null) {
    // With this exception, there will be a retry. The location can be null for a replica
    //  when the table is created or after a split.
    throw new HBaseIOException("There is no location for replica id #" + id);
  }

  ServerName dest = location.getServerName();

  setStub(cConnection.getClient(dest));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:29,代码来源:RpcRetryingCallerWithReadReplicas.java

示例2: prepare

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的package包/类
/**
 * Two responsibilities
 * - if the call is already completed (by another replica) stops the retries.
 * - set the location to the right region, depending on the replica.
 */
@Override
// TODO: Very like the super class implemenation. Can we shrink this down?
public void prepare(final boolean reload) throws IOException {
  if (getRpcController().isCanceled()) return;
  if (Thread.interrupted()) {
    throw new InterruptedIOException();
  }
  if (reload || location == null) {
    RegionLocations rl = getRegionLocations(false, id, cConnection, tableName, get.getRow());
    location = id < rl.size() ? rl.getRegionLocation(id) : null;
  }

  if (location == null || location.getServerName() == null) {
    // With this exception, there will be a retry. The location can be null for a replica
    //  when the table is created or after a split.
    throw new HBaseIOException("There is no location for replica id #" + id);
  }

  setStubByServiceName(this.location.getServerName());
}
 
开发者ID:apache,项目名称:hbase,代码行数:26,代码来源:RpcRetryingCallerWithReadReplicas.java

示例3: prepare

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的package包/类
/**
 * @param reload force reload of server location
 * @throws IOException
 */
@Override
public void prepare(boolean reload) throws IOException {
  if (Thread.interrupted()) {
    throw new InterruptedIOException();
  }
  RegionLocations rl = RpcRetryingCallerWithReadReplicas.getRegionLocations(!reload,
      id, getConnection(), getTableName(), getRow());
  location = id < rl.size() ? rl.getRegionLocation(id) : null;
  if (location == null || location.getServerName() == null) {
    // With this exception, there will be a retry. The location can be null for a replica
    //  when the table is created or after a split.
    throw new HBaseIOException("There is no location for replica id #" + id);
  }
  ServerName dest = location.getServerName();
  setStub(super.getConnection().getClient(dest));
  if (!instantiated || reload) {
    checkIfRegionServerIsRemote();
    instantiated = true;
  }
  cursor = null;
  // check how often we retry.
  if (reload) {
    incRPCRetriesMetrics(scanMetrics, isRegionServerRemote);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:30,代码来源:ScannerCallable.java

示例4: prepare

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的package包/类
/**
 * @param reload force reload of server location
 * @throws IOException
 */
@Override
public void prepare(boolean reload) throws IOException {
  if (Thread.interrupted()) {
    throw new InterruptedIOException();
  }
  RegionLocations rl = RpcRetryingCallerWithReadReplicas.getRegionLocations(!reload,
      id, getConnection(), getTableName(), getRow());
  location = id < rl.size() ? rl.getRegionLocation(id) : null;
  if (location == null || location.getServerName() == null) {
    // With this exception, there will be a retry. The location can be null for a replica
    //  when the table is created or after a split.
    throw new HBaseIOException("There is no location for replica id #" + id);
  }
  ServerName dest = location.getServerName();
  setStub(super.getConnection().getClient(dest));
  if (!instantiated || reload) {
    checkIfRegionServerIsRemote();
    instantiated = true;
  }

  // check how often we retry.
  // HConnectionManager will call instantiateServer with reload==true
  // if and only if for retries.
  if (reload && this.scanMetrics != null) {
    this.scanMetrics.countOfRPCRetries.incrementAndGet();
    if (isRegionServerRemote) {
      this.scanMetrics.countOfRemoteRPCRetries.incrementAndGet();
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:35,代码来源:ScannerCallable.java

示例5: locateRegionsInRange

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的package包/类
/**
 * Get the corresponding regions for an arbitrary range of keys.
 * @param startKey Starting row in range, inclusive
 * @param endKey Ending row in range, exclusive
 * @param reload force reload of server location
 * @return A list of HRegionLocation corresponding to the regions that contain
 *         the specified range
 * @throws IOException
 */
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="NP_NULL_ON_SOME_PATH",
    justification="I thought I'd fixed it but FB still complains; see below")
private List<HRegionLocation> locateRegionsInRange(byte[] startKey,
    byte[] endKey, boolean reload) throws IOException {
  final boolean endKeyIsEndOfTable = Bytes.equals(endKey,
      HConstants.EMPTY_END_ROW);
  if ((Bytes.compareTo(startKey, endKey) > 0) && !endKeyIsEndOfTable) {
    throw new IllegalArgumentException("Invalid range: "
        + Bytes.toStringBinary(startKey) + " > "
        + Bytes.toStringBinary(endKey));
  }
  List<HRegionLocation> regionList = new ArrayList<HRegionLocation>();
  byte[] currentKey = startKey;
  do {
    RegionLocations rl = RpcRetryingCallerWithReadReplicas.getRegionLocations(reload, id,
        getConnection(), tableName, currentKey);
    HRegionLocation regionLocation = id < rl.size() ? rl.getRegionLocation(id) : null;
    if (regionLocation != null && regionLocation.getRegionInfo().containsRow(currentKey)) {
      regionList.add(regionLocation);
    } else {
      // FindBugs: NP_NULL_ON_SOME_PATH Complaining about regionLocation
      throw new DoNotRetryIOException("Does hbase:meta exist hole? Locating row "
          + Bytes.toStringBinary(currentKey) + " returns incorrect region "
          + (regionLocation != null? regionLocation.getRegionInfo(): null));
    }
    currentKey = regionLocation.getRegionInfo().getEndKey();
  } while (!Bytes.equals(currentKey, HConstants.EMPTY_END_ROW)
      && (endKeyIsEndOfTable || Bytes.compareTo(currentKey, endKey) < 0));
  return regionList;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:40,代码来源:ReversedScannerCallable.java

示例6: locateRegionsInRange

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的package包/类
/**
 * Get the corresponding regions for an arbitrary range of keys.
 * @param startKey Starting row in range, inclusive
 * @param endKey Ending row in range, exclusive
 * @param reload force reload of server location
 * @return A list of HRegionLocation corresponding to the regions that contain
 *         the specified range
 * @throws IOException
 */
private List<HRegionLocation> locateRegionsInRange(byte[] startKey,
    byte[] endKey, boolean reload) throws IOException {
  final boolean endKeyIsEndOfTable = Bytes.equals(endKey,
      HConstants.EMPTY_END_ROW);
  if ((Bytes.compareTo(startKey, endKey) > 0) && !endKeyIsEndOfTable) {
    throw new IllegalArgumentException("Invalid range: "
        + Bytes.toStringBinary(startKey) + " > "
        + Bytes.toStringBinary(endKey));
  }
  List<HRegionLocation> regionList = new ArrayList<HRegionLocation>();
  byte[] currentKey = startKey;
  do {
    RegionLocations rl = RpcRetryingCallerWithReadReplicas.getRegionLocations(reload, id,
        getConnection(), tableName, currentKey);
    HRegionLocation regionLocation = id < rl.size() ? rl.getRegionLocation(id) : null;
    if (regionLocation != null && regionLocation.getRegionInfo().containsRow(currentKey)) {
      regionList.add(regionLocation);
    } else {
      throw new DoNotRetryIOException("Does hbase:meta exist hole? Locating row "
          + Bytes.toStringBinary(currentKey) + " returns incorrect region "
          + regionLocation.getRegionInfo());
    }
    currentKey = regionLocation.getRegionInfo().getEndKey();
  } while (!Bytes.equals(currentKey, HConstants.EMPTY_END_ROW)
      && (endKeyIsEndOfTable || Bytes.compareTo(currentKey, endKey) < 0));
  return regionList;
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:37,代码来源:ReversedScannerCallable.java

示例7: locateRegionsInRange

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的package包/类
/**
 * Get the corresponding regions for an arbitrary range of keys.
 * @param startKey Starting row in range, inclusive
 * @param endKey Ending row in range, exclusive
 * @param reload force reload of server location
 * @return A list of HRegionLocation corresponding to the regions that contain
 *         the specified range
 * @throws IOException
 */
private List<HRegionLocation> locateRegionsInRange(byte[] startKey,
    byte[] endKey, boolean reload) throws IOException {
  final boolean endKeyIsEndOfTable = Bytes.equals(endKey,
      HConstants.EMPTY_END_ROW);
  if ((Bytes.compareTo(startKey, endKey) > 0) && !endKeyIsEndOfTable) {
    throw new IllegalArgumentException("Invalid range: "
        + Bytes.toStringBinary(startKey) + " > "
        + Bytes.toStringBinary(endKey));
  }
  List<HRegionLocation> regionList = new ArrayList<>();
  byte[] currentKey = startKey;
  do {
    RegionLocations rl = RpcRetryingCallerWithReadReplicas.getRegionLocations(!reload, id,
        getConnection(), getTableName(), currentKey);
    HRegionLocation regionLocation = id < rl.size() ? rl.getRegionLocation(id) : null;
    if (regionLocation != null && regionLocation.getRegionInfo().containsRow(currentKey)) {
      regionList.add(regionLocation);
    } else {
      throw new DoNotRetryIOException("Does hbase:meta exist hole? Locating row "
          + Bytes.toStringBinary(currentKey) + " returns incorrect region "
          + (regionLocation == null ? null : regionLocation.getRegionInfo()));
    }
    currentKey = regionLocation.getRegionInfo().getEndKey();
  } while (!Bytes.equals(currentKey, HConstants.EMPTY_END_ROW)
      && (endKeyIsEndOfTable || Bytes.compareTo(currentKey, endKey) < 0));
  return regionList;
}
 
开发者ID:apache,项目名称:hbase,代码行数:37,代码来源:ReversedScannerCallable.java

示例8: prepare

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的package包/类
/**
 * @param reload force reload of server location
 * @throws IOException
 */
@Override
public void prepare(boolean reload) throws IOException {
  if (Thread.interrupted()) {
    throw new InterruptedIOException();
  }
  if (!instantiated || reload) {
    if (locateStartRow == null) {
      // Just locate the region with the row
      RegionLocations rl = RpcRetryingCallerWithReadReplicas.getRegionLocations(reload, id,
          getConnection(), tableName, row);
      this.location = id < rl.size() ? rl.getRegionLocation(id) : null;
      if (this.location == null) {
        throw new IOException("Failed to find location, tableName="
            + tableName + ", row=" + Bytes.toStringBinary(row) + ", reload="
            + reload);
      }
    } else {
      // Need to locate the regions with the range, and the target location is
      // the last one which is the previous region of last region scanner
      List<HRegionLocation> locatedRegions = locateRegionsInRange(
          locateStartRow, row, reload);
      if (locatedRegions.isEmpty()) {
        throw new DoNotRetryIOException(
            "Does hbase:meta exist hole? Couldn't get regions for the range from "
                + Bytes.toStringBinary(locateStartRow) + " to "
                + Bytes.toStringBinary(row));
      }
      this.location = locatedRegions.get(locatedRegions.size() - 1);
    }
    setStub(getConnection().getClient(getLocation().getServerName()));
    checkIfRegionServerIsRemote();
    instantiated = true;
  }

  // check how often we retry.
  // HConnectionManager will call instantiateServer with reload==true
  // if and only if for retries.
  if (reload && this.scanMetrics != null) {
    this.scanMetrics.countOfRPCRetries.incrementAndGet();
    if (isRegionServerRemote) {
      this.scanMetrics.countOfRemoteRPCRetries.incrementAndGet();
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:49,代码来源:ReversedScannerCallable.java

示例9: prepare

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的package包/类
/**
 * @param reload force reload of server location
 * @throws IOException
 */
@Override
public void prepare(boolean reload) throws IOException {
  if (Thread.interrupted()) {
    throw new InterruptedIOException();
  }
  if (!instantiated || reload) {
    // we should use range locate if
    // 1. we do not want the start row
    // 2. the start row is empty which means we need to locate to the last region.
    if (scan.includeStartRow() && !isEmptyStartRow(getRow())) {
      // Just locate the region with the row
      RegionLocations rl = RpcRetryingCallerWithReadReplicas.getRegionLocations(!reload, id,
          getConnection(), getTableName(), getRow());
      this.location = id < rl.size() ? rl.getRegionLocation(id) : null;
      if (location == null || location.getServerName() == null) {
        throw new IOException("Failed to find location, tableName="
            + getTableName() + ", row=" + Bytes.toStringBinary(getRow()) + ", reload="
            + reload);
      }
    } else {
      // Need to locate the regions with the range, and the target location is
      // the last one which is the previous region of last region scanner
      byte[] locateStartRow = createCloseRowBefore(getRow());
      List<HRegionLocation> locatedRegions = locateRegionsInRange(
          locateStartRow, getRow(), reload);
      if (locatedRegions.isEmpty()) {
        throw new DoNotRetryIOException(
            "Does hbase:meta exist hole? Couldn't get regions for the range from "
                + Bytes.toStringBinary(locateStartRow) + " to "
                + Bytes.toStringBinary(getRow()));
      }
      this.location = locatedRegions.get(locatedRegions.size() - 1);
    }
    setStub(getConnection().getClient(getLocation().getServerName()));
    checkIfRegionServerIsRemote();
    instantiated = true;
  }

  // check how often we retry.
  if (reload) {
    incRPCRetriesMetrics(scanMetrics, isRegionServerRemote);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:48,代码来源:ReversedScannerCallable.java


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