• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ScanResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse的典型用法代码示例。如果您正苦于以下问题:Java ScanResponse类的具体用法?Java ScanResponse怎么用?Java ScanResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ScanResponse类属于org.apache.hadoop.hbase.protobuf.generated.ClientProtos包,在下文中一共展示了ScanResponse类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: scan

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse; //导入依赖的package包/类
@Override
public ScanResponse scan(final RpcController controller, final ScanRequest request)
    throws ServiceException {
  if (request.hasScannerId()) {
    ScanResponse scanResponse = super.scan(controller, request);
    if (this.tableScannerId == request.getScannerId() && 
        (sleepAlways || (!slept && seqNoToSleepOn == request.getNextCallSeq()))) {
      try {
        LOG.info("SLEEPING " + (rpcTimeout + 500));
        Thread.sleep(rpcTimeout + 500);
      } catch (InterruptedException e) {
      }
      slept = true;
      tryNumber++;
      if (tryNumber > 2 * CLIENT_RETRIES_NUMBER) {
        sleepAlways = false;
      }
    }
    return scanResponse;
  } else {
    ScanResponse scanRes = super.scan(controller, request);
    String regionName = Bytes.toString(request.getRegion().getValue().toByteArray());
    if (!regionName.contains(TableName.META_TABLE_NAME.getNameAsString())) {
      tableScannerId = scanRes.getScannerId();
    }
    return scanRes;
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:29,代码来源:TestClientScannerRPCTimeout.java


示例2: getScanMetrics

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse; //导入依赖的package包/类
public static Map<String, Long> getScanMetrics(ScanResponse response) {
  Map<String, Long> metricMap = new HashMap<String, Long>();
  if (response == null || !response.hasScanMetrics() || response.getScanMetrics() == null) {
    return metricMap;
  }
  
  ScanMetrics metrics = response.getScanMetrics();
  int numberOfMetrics = metrics.getMetricsCount();
  for (int i = 0; i < numberOfMetrics; i++) {
    NameInt64Pair metricPair = metrics.getMetrics(i);
    if (metricPair != null) {
      String name = metricPair.getName();
      Long value = metricPair.getValue();
      if (name != null && value != null) {
        metricMap.put(name, value);
      }
    }
  }

  return metricMap;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:22,代码来源:ResponseConverter.java


示例3: openScanner

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse; //导入依赖的package包/类
protected long openScanner() throws IOException {
  incRPCcallsMetrics();
  ScanRequest request =
    RequestConverter.buildScanRequest(
      getLocation().getRegionInfo().getRegionName(),
      this.scan, 0, false);
  try {
    ScanResponse response = getStub().scan(null, request);
    long id = response.getScannerId();
    if (logScannerActivity) {
      LOG.info("Open scanner=" + id + " for scan=" + scan.toString()
        + " on region " + getLocation().toString());
    }
    return id;
  } catch (ServiceException se) {
    throw ProtobufUtil.getRemoteException(se);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:ScannerCallable.java


示例4: ScanOpenNextThenExceptionThenRecoverConnection

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse; //导入依赖的package包/类
ScanOpenNextThenExceptionThenRecoverConnection(Configuration conf,
    boolean managed, ExecutorService pool) throws IOException {
  super(conf, managed);
  // Mock up my stub so open scanner returns a scanner id and then on next, we throw
  // exceptions for three times and then after that, we return no more to scan.
  this.stub = Mockito.mock(ClientService.BlockingInterface.class);
  long sid = 12345L;
  try {
    Mockito.when(stub.scan((RpcController)Mockito.any(),
        (ClientProtos.ScanRequest)Mockito.any())).
      thenReturn(ClientProtos.ScanResponse.newBuilder().setScannerId(sid).build()).
      thenThrow(new ServiceException(new RegionServerStoppedException("From Mockito"))).
      thenReturn(ClientProtos.ScanResponse.newBuilder().setScannerId(sid).
          setMoreResults(false).build());
  } catch (ServiceException e) {
    throw new IOException(e);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:TestClientNoCluster.java


示例5: RegionServerStoppedOnScannerOpenConnection

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse; //导入依赖的package包/类
RegionServerStoppedOnScannerOpenConnection(Configuration conf, boolean managed,
    ExecutorService pool, User user) throws IOException {
  super(conf, managed);
  // Mock up my stub so open scanner returns a scanner id and then on next, we throw
  // exceptions for three times and then after that, we return no more to scan.
  this.stub = Mockito.mock(ClientService.BlockingInterface.class);
  long sid = 12345L;
  try {
    Mockito.when(stub.scan((RpcController)Mockito.any(),
        (ClientProtos.ScanRequest)Mockito.any())).
      thenReturn(ClientProtos.ScanResponse.newBuilder().setScannerId(sid).build()).
      thenThrow(new ServiceException(new RegionServerStoppedException("From Mockito"))).
      thenReturn(ClientProtos.ScanResponse.newBuilder().setScannerId(sid).
          setMoreResults(false).build());
  } catch (ServiceException e) {
    throw new IOException(e);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:TestClientNoCluster.java


示例6: call

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse; //导入依赖的package包/类
@Override
public Result[] call(int timeout) throws IOException {
  if (this.closed) return null;
  if (Thread.interrupted()) {
    throw new InterruptedIOException();
  }
  ScanRequest request = RequestConverter.buildScanRequest(getLocation()
      .getRegionInfo().getRegionName(), getScan(), getCaching(), true);
  ScanResponse response = null;
  PayloadCarryingRpcController controller = controllerFactory.newController();
  try {
    controller.setPriority(getTableName());
    controller.setCallTimeout(timeout);
    response = getStub().scan(controller, request);
    return ResponseConverter.getResults(controller.cellScanner(),
        response);
  } catch (ServiceException se) {
    throw ProtobufUtil.getRemoteException(se);
  }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:21,代码来源:ClientSmallScanner.java


示例7: getSmallScanCallable

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse; //导入依赖的package包/类
static RegionServerCallable<Result[]> getSmallScanCallable(
    final Scan sc, HConnection connection, TableName table, byte[] localStartKey,
    final int cacheNum, final RpcControllerFactory rpcControllerFactory) throws IOException { 
  sc.setStartRow(localStartKey);
  RegionServerCallable<Result[]> callable = new RegionServerCallable<Result[]>(
      connection, table, sc.getStartRow()) {
    public Result[] call() throws IOException {
      ScanRequest request = RequestConverter.buildScanRequest(getLocation()
        .getRegionInfo().getRegionName(), sc, cacheNum, true);
      ScanResponse response = null;
      PayloadCarryingRpcController controller = rpcControllerFactory.newController();
      try {
        controller.setPriority(getTableName());
        response = getStub().scan(controller, request);
        return ResponseConverter.getResults(controller.cellScanner(),
            response);
      } catch (ServiceException se) {
        throw ProtobufUtil.getRemoteException(se);
      }
    }
  };
  return callable;
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:24,代码来源:ClientSmallScanner.java


示例8: getSmallScanCallable

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse; //导入依赖的package包/类
static RegionServerCallable<Result[]> getSmallScanCallable(
    final Scan sc, HConnection connection, TableName table,
    byte[] localStartKey, final int cacheNum, final RpcControllerFactory rpcControllerFactory) {
  sc.setStartRow(localStartKey);
  RegionServerCallable<Result[]> callable = new RegionServerCallable<Result[]>(
      connection, table, sc.getStartRow()) {
    public Result[] call(int callTimeout) throws IOException {
      ScanRequest request = RequestConverter.buildScanRequest(getLocation()
          .getRegionInfo().getRegionName(), sc, cacheNum, true);
      PayloadCarryingRpcController controller = rpcControllerFactory.newController();
      controller.setPriority(getTableName());
      controller.setCallTimeout(callTimeout);
      try {
        ScanResponse response = getStub().scan(controller, request);
        return ResponseConverter.getResults(controller.cellScanner(), response);
      } catch (ServiceException se) {
        throw ProtobufUtil.getRemoteException(se);
      }
    }
  };
  return callable;
}
 
开发者ID:shenli-uiuc,项目名称:PyroDB,代码行数:23,代码来源:ClientSmallScanner.java


示例9: getSmallScanCallable

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse; //导入依赖的package包/类
private RegionServerCallable<Result[]> getSmallScanCallable(
    byte[] localStartKey, final int cacheNum) {
  this.scan.setStartRow(localStartKey);
  RegionServerCallable<Result[]> callable = new RegionServerCallable<Result[]>(
      getConnection(), getTable(), scan.getStartRow()) {
    public Result[] call() throws IOException {
      ScanRequest request = RequestConverter.buildScanRequest(getLocation()
          .getRegionInfo().getRegionName(), scan, cacheNum, true);
      ScanResponse response = null;
      PayloadCarryingRpcController controller = new PayloadCarryingRpcController();
      try {
        controller.setPriority(getTableName());
        response = getStub().scan(controller, request);
        return ResponseConverter.getResults(controller.cellScanner(),
            response);
      } catch (ServiceException se) {
        throw ProtobufUtil.getRemoteException(se);
      }
    }
  };
  return callable;
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:23,代码来源:ClientSmallScanner.java


示例10: openScanner

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse; //导入依赖的package包/类
protected long openScanner() throws IOException {
  incRPCcallsMetrics();
  ScanRequest request =
    RequestConverter.buildScanRequest(
      this.location.getRegionInfo().getRegionName(),
      this.scan, 0, false);
  try {
    ScanResponse response = server.scan(null, request);
    long id = response.getScannerId();
    if (logScannerActivity) {
      LOG.info("Open scanner=" + id + " for scan=" + scan.toString()
        + " on region " + this.location.toString() + " ip:"
        + this.location.getHostnamePort());
    }
    return id;
  } catch (ServiceException se) {
    throw ProtobufUtil.getRemoteException(se);
  }
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:20,代码来源:ScannerCallable.java


示例11: scan

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse; //导入依赖的package包/类
@Override
public ScanResponse scan(RpcController controller, ScanRequest request)
    throws ServiceException {
  ScanResponse.Builder builder = ScanResponse.newBuilder();
  try {
    if (request.hasScan()) {
      byte[] regionName = request.getRegion().getValue().toByteArray();
      builder.setScannerId(openScanner(regionName, null));
      builder.setMoreResults(true);
    }
    else {
      long scannerId = request.getScannerId();
      Result result = next(scannerId);
      if (result != null) {
        builder.addCellsPerResult(result.size());
        List<CellScannable> results = new ArrayList<CellScannable>(1);
        results.add(result);
        ((PayloadCarryingRpcController) controller).setCellScanner(CellUtil
            .createCellScanner(results));
        builder.setMoreResults(true);
      }
      else {
        builder.setMoreResults(false);
        close(scannerId);
      }
    }
  } catch (IOException ie) {
    throw new ServiceException(ie);
  }
  return builder.build();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:32,代码来源:MockRegionServer.java


示例12: scan

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse; //导入依赖的package包/类
@Override
public ScanResponse scan(RpcController controller, ScanRequest request) 
    throws ServiceException {
  ScanRequest.Builder builder = ScanRequest.newBuilder(request);
  builder.setClientHandlesHeartbeats(heartbeatsEnabled);
  return super.scan(controller, builder.build());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:8,代码来源:TestScannerHeartbeatMessages.java


示例13: updateServerSideMetrics

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse; //导入依赖的package包/类
/**
 * Use the scan metrics returned by the server to add to the identically named counters in the
 * client side metrics. If a counter does not exist with the same name as the server side metric,
 * the attempt to increase the counter will fail.
 * @param response
 */
private void updateServerSideMetrics(ScanResponse response) {
  if (this.scanMetrics == null || response == null || !response.hasScanMetrics()) return;

  Map<String, Long> serverMetrics = ResponseConverter.getScanMetrics(response);
  for (Entry<String, Long> entry : serverMetrics.entrySet()) {
    this.scanMetrics.addToCounter(entry.getKey(), entry.getValue());
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:ScannerCallable.java


示例14: call

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse; //导入依赖的package包/类
@Override
public Result[] call(int timeout) throws IOException {
  if (this.closed) return null;
  if (Thread.interrupted()) {
    throw new InterruptedIOException();
  }
  ScanRequest request = RequestConverter.buildScanRequest(getLocation()
      .getRegionInfo().getRegionName(), getScan(), getCaching(), true);
  ScanResponse response = null;
  controller = controllerFactory.newController();
  try {
    controller.setPriority(getTableName());
    controller.setCallTimeout(timeout);
    response = getStub().scan(controller, request);
    Result[] results = ResponseConverter.getResults(controller.cellScanner(),
        response);
    if (response.hasMoreResultsInRegion()) {
      setHasMoreResultsContext(true);
      setServerHasMoreResults(response.getMoreResultsInRegion());
    } else {
      setHasMoreResultsContext(false);
    }
    // We need to update result metrics since we are overriding call()
    updateResultsMetrics(results);
    return results;
  } catch (ServiceException se) {
    throw ProtobufUtil.getRemoteException(se);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:30,代码来源:ClientSmallScanner.java


示例15: scan

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse; //导入依赖的package包/类
@Override
public ScanResponse scan(RpcController controller,
    ScanRequest request) throws ServiceException {
  // Presume it is a scan of meta for now. Not all scans provide a region spec expecting
  // the server to keep reference by scannerid.  TODO.
  return doMetaScanResponse(meta, sequenceids, request);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:8,代码来源:TestClientNoCluster.java


示例16: doMetaScanResponse

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse; //导入依赖的package包/类
static ScanResponse doMetaScanResponse(final SortedMap<byte [], Pair<HRegionInfo, ServerName>> meta,
    final AtomicLong sequenceids, final ScanRequest request) {
  ScanResponse.Builder builder = ScanResponse.newBuilder();
  int max = request.getNumberOfRows();
  int count = 0;
  Map<byte [], Pair<HRegionInfo, ServerName>> tail =
    request.hasScan()? meta.tailMap(request.getScan().getStartRow().toByteArray()): meta;
    ClientProtos.Result.Builder resultBuilder = ClientProtos.Result.newBuilder();
  for (Map.Entry<byte [], Pair<HRegionInfo, ServerName>> e: tail.entrySet()) {
    // Can be 0 on open of a scanner -- i.e. rpc to setup scannerid only.
    if (max <= 0) break;
    if (++count > max) break;
    HRegionInfo hri = e.getValue().getFirst();
    ByteString row = ByteStringer.wrap(hri.getRegionName());
    resultBuilder.clear();
    resultBuilder.addCell(getRegionInfo(row, hri));
    resultBuilder.addCell(getServer(row, e.getValue().getSecond()));
    resultBuilder.addCell(getStartCode(row));
    builder.addResults(resultBuilder.build());
    // Set more to false if we are on the last region in table.
    if (hri.getEndKey().length <= 0) builder.setMoreResults(false);
    else builder.setMoreResults(true);
  }
  // If no scannerid, set one.
  builder.setScannerId(request.hasScannerId()?
    request.getScannerId(): sequenceids.incrementAndGet());
  return builder.build();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:29,代码来源:TestClientNoCluster.java


示例17: doMetaScanResponse

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse; //导入依赖的package包/类
static ScanResponse doMetaScanResponse(final SortedMap<byte [], Pair<HRegionInfo, ServerName>> meta,
    final AtomicLong sequenceids, final ScanRequest request) {
  ScanResponse.Builder builder = ScanResponse.newBuilder();
  int max = request.getNumberOfRows();
  int count = 0;
  Map<byte [], Pair<HRegionInfo, ServerName>> tail =
    request.hasScan()? meta.tailMap(request.getScan().getStartRow().toByteArray()): meta;
    ClientProtos.Result.Builder resultBuilder = ClientProtos.Result.newBuilder();
  for (Map.Entry<byte [], Pair<HRegionInfo, ServerName>> e: tail.entrySet()) {
    // Can be 0 on open of a scanner -- i.e. rpc to setup scannerid only.
    if (max <= 0) break;
    if (++count > max) break;
    HRegionInfo hri = e.getValue().getFirst();
    ByteString row = HBaseZeroCopyByteString.wrap(hri.getRegionName());
    resultBuilder.clear();
    resultBuilder.addCell(getRegionInfo(row, hri));
    resultBuilder.addCell(getServer(row, e.getValue().getSecond()));
    resultBuilder.addCell(getStartCode(row));
    builder.addResults(resultBuilder.build());
    // Set more to false if we are on the last region in table.
    if (hri.getEndKey().length <= 0) builder.setMoreResults(false);
    else builder.setMoreResults(true);
  }
  // If no scannerid, set one.
  builder.setScannerId(request.hasScannerId()?
    request.getScannerId(): sequenceids.incrementAndGet());
  return builder.build();
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:29,代码来源:TestClientNoCluster.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IntToExprCast类代码示例发布时间:2022-05-23
下一篇:
Java ArtifactStoreBuilder类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap