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


Java ScanRequest类代码示例

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


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

示例1: getDeadline

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest; //导入依赖的package包/类
/**
 * Based on the request content, returns the deadline of the request.
 *
 * @param header
 * @param param
 * @return Deadline of this request. 0 now, otherwise msec of 'delay'
 */
@Override
public long getDeadline(RequestHeader header, Message param) {
  if (param instanceof ScanRequest) {
    ScanRequest request = (ScanRequest)param;
    if (!request.hasScannerId()) {
      return 0;
    }

    // get the 'virtual time' of the scanner, and applies sqrt() to get a
    // nice curve for the delay. More a scanner is used the less priority it gets.
    // The weight is used to have more control on the delay.
    long vtime = rpcServices.getScannerVirtualTime(request.getScannerId());
    return Math.round(Math.sqrt(vtime * scanVirtualTimeWeight));
  }
  return 0;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:24,代码来源:AnnotationReadingPriorityFunction.java

示例2: scan

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest; //导入依赖的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

示例3: close

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest; //导入依赖的package包/类
private void close() {
  if (this.scannerId == -1L) {
    return;
  }
  try {
    incRPCcallsMetrics();
    ScanRequest request =
        RequestConverter.buildScanRequest(this.scannerId, 0, true, this.scanMetrics != null);
    try {
      getStub().scan(null, request);
    } catch (ServiceException se) {
      throw ProtobufUtil.getRemoteException(se);
    }
  } catch (IOException e) {
    LOG.warn("Ignore, probably already closed", e);
  }
  this.scannerId = -1L;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:ScannerCallable.java

示例4: openScanner

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest; //导入依赖的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

示例5: ScanOpenNextThenExceptionThenRecoverConnection

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest; //导入依赖的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

示例6: RegionServerStoppedOnScannerOpenConnection

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest; //导入依赖的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

示例7: getDeadline

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest; //导入依赖的package包/类
/**
 * Based on the request content, returns the deadline of the request.
 *
 * @param header
 * @param param
 * @return Deadline of this request. 0 now, otherwise msec of 'delay'
 */
@Override
public long getDeadline(RequestHeader header, Message param) {
  String methodName = header.getMethodName();
  if (methodName.equalsIgnoreCase("scan")) {
    ScanRequest request = (ScanRequest)param;
    if (!request.hasScannerId()) {
      return 0;
    }

    // get the 'virtual time' of the scanner, and applies sqrt() to get a
    // nice curve for the delay. More a scanner is used the less priority it gets.
    // The weight is used to have more control on the delay.
    long vtime = rpcServices.getScannerVirtualTime(request.getScannerId());
    return Math.round(Math.sqrt(vtime * scanVirtualTimeWeight));
  }
  return 0;
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:25,代码来源:AnnotationReadingPriorityFunction.java

示例8: test

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest; //导入依赖的package包/类
/**
 * attempt to locate the region and perform a get and scan
 * @return True if successful, False otherwise.
 */
private boolean test(HConnection con, TableName tableName, byte[] row,
    HRegionServer server) {
  // not using HTable to avoid timeouts and retries
  try {
    byte[] regionName = con.relocateRegion(tableName, row).getRegionInfo()
        .getRegionName();
    // get and scan should now succeed without exception
    ClientProtos.GetRequest request =
        RequestConverter.buildGetRequest(regionName, new Get(row));
    server.getRSRpcServices().get(null, request);
    ScanRequest scanRequest = RequestConverter.buildScanRequest(
      regionName, new Scan(row), 1, true);
    try {
      server.getRSRpcServices().scan(
        new PayloadCarryingRpcController(), scanRequest);
    } catch (ServiceException se) {
      throw ProtobufUtil.getRemoteException(se);
    }
  } catch (IOException x) {
    return false;
  } catch (ServiceException e) {
    return false;
  }
  return true;
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:30,代码来源:TestEndToEndSplitTransaction.java

示例9: close

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest; //导入依赖的package包/类
private void close() {
  if (this.scannerId == -1L) {
    return;
  }
  try {
    incRPCcallsMetrics();
    ScanRequest request =
      RequestConverter.buildScanRequest(this.scannerId, 0, true);
    try {
      getStub().scan(null, request);
    } catch (ServiceException se) {
      throw ProtobufUtil.getRemoteException(se);
    }
  } catch (IOException e) {
    LOG.warn("Ignore, probably already closed", e);
  }
  this.scannerId = -1L;
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:19,代码来源:ScannerCallable.java

示例10: call

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest; //导入依赖的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

示例11: test

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest; //导入依赖的package包/类
/**
 * attempt to locate the region and perform a get and scan
 * @return True if successful, False otherwise.
 */
private boolean test(HConnection con, TableName tableName, byte[] row,
    HRegionServer server) {
  // not using HTable to avoid timeouts and retries
  try {
    byte[] regionName = con.relocateRegion(tableName, row).getRegionInfo()
        .getRegionName();
    // get and scan should now succeed without exception
    ProtobufUtil.get(server, regionName, new Get(row));
    ScanRequest scanRequest = RequestConverter.buildScanRequest(
      regionName, new Scan(row), 1, true);
    try {
      server.scan(new PayloadCarryingRpcController(), scanRequest);
    } catch (ServiceException se) {
      throw ProtobufUtil.getRemoteException(se);
    }
  } catch (IOException x) {
    return false;
  }
  return true;
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:25,代码来源:TestEndToEndSplitTransaction.java

示例12: getSmallScanCallable

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest; //导入依赖的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

示例13: getSmallScanCallable

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest; //导入依赖的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

示例14: getSmallScanCallable

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest; //导入依赖的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

示例15: close

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest; //导入依赖的package包/类
private void close() {
  if (this.scannerId == -1L) {
    return;
  }
  try {
    incRPCcallsMetrics();
    ScanRequest request =
      RequestConverter.buildScanRequest(this.scannerId, 0, true);
    try {
      server.scan(null, request);
    } catch (ServiceException se) {
      throw ProtobufUtil.getRemoteException(se);
    }
  } catch (IOException e) {
    LOG.warn("Ignore, probably already closed", e);
  }
  this.scannerId = -1L;
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:19,代码来源:ScannerCallable.java


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