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


Java ClientProtos类代码示例

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


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

示例1: testVerifyMetaRegionLocationWithException

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos; //导入依赖的package包/类
private void testVerifyMetaRegionLocationWithException(Exception ex)
throws IOException, InterruptedException, KeeperException, ServiceException {
  // Mock an ClientProtocol.
  final ClientProtos.ClientService.BlockingInterface implementation =
    Mockito.mock(ClientProtos.ClientService.BlockingInterface.class);

  ClusterConnection connection = mockConnection(null, implementation);

  // If a 'get' is called on mocked interface, throw connection refused.
  Mockito.when(implementation.get((RpcController) Mockito.any(), (GetRequest) Mockito.any())).
    thenThrow(new ServiceException(ex));

  long timeout = UTIL.getConfiguration().
          getLong("hbase.catalog.verification.timeout", 1000);
  MetaTableLocator.setMetaLocation(this.watcher, SN, RegionState.State.OPENING);
  assertFalse(new MetaTableLocator().verifyMetaRegionLocation(
    connection, watcher, timeout));

  MetaTableLocator.setMetaLocation(this.watcher, SN, RegionState.State.OPEN);
  assertFalse(new MetaTableLocator().verifyMetaRegionLocation(
          connection, watcher, timeout));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:TestMetaTableLocator.java

示例2: buildMultiResponse

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos; //导入依赖的package包/类
private MultiResponse buildMultiResponse(MultiRequest req) {
  MultiResponse.Builder builder = MultiResponse.newBuilder();
  RegionActionResult.Builder regionActionResultBuilder =
      RegionActionResult.newBuilder();
  ResultOrException.Builder roeBuilder = ResultOrException.newBuilder();
  for (RegionAction regionAction: req.getRegionActionList()) {
    regionActionResultBuilder.clear();
    for (ClientProtos.Action action: regionAction.getActionList()) {
      roeBuilder.clear();
      roeBuilder.setResult(ClientProtos.Result.getDefaultInstance());
      roeBuilder.setIndex(action.getIndex());
      regionActionResultBuilder.addResultOrException(roeBuilder.build());
    }
    builder.addRegionActionResult(regionActionResultBuilder.build());
  }
  return builder.build();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:TestCatalogJanitor.java

示例3: getMockedConnection

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private HConnection getMockedConnection(final Configuration conf)
throws IOException, ServiceException {
  HConnection c = Mockito.mock(HConnection.class);
  Mockito.when(c.getConfiguration()).thenReturn(conf);
  Mockito.doNothing().when(c).close();
  // Make it so we return a particular location when asked.
  final HRegionLocation loc = new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO,
      ServerName.valueOf("example.org", 1234, 0));
  Mockito.when(c.getRegionLocation((TableName) Mockito.any(),
      (byte[]) Mockito.any(), Mockito.anyBoolean())).
    thenReturn(loc);
  Mockito.when(c.locateRegion((TableName) Mockito.any(), (byte[]) Mockito.any())).
    thenReturn(loc);
  ClientProtos.ClientService.BlockingInterface hri =
    Mockito.mock(ClientProtos.ClientService.BlockingInterface.class);
  Mockito.when(hri.bulkLoadHFile((RpcController)Mockito.any(), (BulkLoadHFileRequest)Mockito.any())).
    thenThrow(new ServiceException(new IOException("injecting bulk load error")));
  Mockito.when(c.getClient(Mockito.any(ServerName.class))).
    thenReturn(hri);
  return c;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:TestLoadIncrementalHFilesSplitRecovery.java

示例4: buildGetRowOrBeforeRequest

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos; //导入依赖的package包/类
/**
 * Create a new protocol buffer GetRequest to get a row, all columns in a family.
 * If there is no such row, return the closest row before it.
 *
 * @param regionName the name of the region to get
 * @param row the row to get
 * @param family the column family to get
 * should return the immediate row before
 * @return a protocol buffer GetReuqest
 */
public static GetRequest buildGetRowOrBeforeRequest(
    final byte[] regionName, final byte[] row, final byte[] family) {
  GetRequest.Builder builder = GetRequest.newBuilder();
  RegionSpecifier region = buildRegionSpecifier(
    RegionSpecifierType.REGION_NAME, regionName);
  builder.setRegion(region);

  Column.Builder columnBuilder = Column.newBuilder();
  columnBuilder.setFamily(ByteStringer.wrap(family));
  ClientProtos.Get.Builder getBuilder =
    ClientProtos.Get.newBuilder();
  getBuilder.setRow(ByteStringer.wrap(row));
  getBuilder.addColumn(columnBuilder.build());
  getBuilder.setClosestRowBefore(true);
  builder.setGet(getBuilder.build());
  return builder.build();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:28,代码来源:RequestConverter.java

示例5: buildRegionAction

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos; //导入依赖的package包/类
/**
 * Create a protocol buffer MultiRequest for row mutations.
 * Does not propagate Action absolute position.  Does not set atomic action on the created
 * RegionAtomic.  Caller should do that if wanted.
 * @param regionName
 * @param rowMutations
 * @return a data-laden RegionMutation.Builder
 * @throws IOException
 */
public static RegionAction.Builder buildRegionAction(final byte [] regionName,
    final RowMutations rowMutations)
throws IOException {
  RegionAction.Builder builder =
    getRegionActionBuilderWithRegion(RegionAction.newBuilder(), regionName);
  ClientProtos.Action.Builder actionBuilder = ClientProtos.Action.newBuilder();
  MutationProto.Builder mutationBuilder = MutationProto.newBuilder();
  for (Mutation mutation: rowMutations.getMutations()) {
    MutationType mutateType = null;
    if (mutation instanceof Put) {
      mutateType = MutationType.PUT;
    } else if (mutation instanceof Delete) {
      mutateType = MutationType.DELETE;
    } else {
      throw new DoNotRetryIOException("RowMutations supports only put and delete, not " +
        mutation.getClass().getName());
    }
    mutationBuilder.clear();
    MutationProto mp = ProtobufUtil.toMutation(mutateType, mutation, mutationBuilder);
    actionBuilder.clear();
    actionBuilder.setMutation(mp);
    builder.addAction(actionBuilder.build());
  }
  return builder;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:35,代码来源:RequestConverter.java

示例6: buildNoDataRegionAction

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos; //导入依赖的package包/类
/**
 * Create a protocol buffer MultiRequest for row mutations that does not hold data.  Data/Cells
 * are carried outside of protobuf.  Return references to the Cells in <code>cells</code> param.
  * Does not propagate Action absolute position.  Does not set atomic action on the created
 * RegionAtomic.  Caller should do that if wanted.
 * @param regionName
 * @param rowMutations
 * @param cells Return in here a list of Cells as CellIterable.
 * @return a region mutation minus data
 * @throws IOException
 */
public static RegionAction.Builder buildNoDataRegionAction(final byte[] regionName,
    final RowMutations rowMutations, final List<CellScannable> cells,
    final RegionAction.Builder regionActionBuilder,
    final ClientProtos.Action.Builder actionBuilder,
    final MutationProto.Builder mutationBuilder)
throws IOException {
  for (Mutation mutation: rowMutations.getMutations()) {
    MutationType type = null;
    if (mutation instanceof Put) {
      type = MutationType.PUT;
    } else if (mutation instanceof Delete) {
      type = MutationType.DELETE;
    } else {
      throw new DoNotRetryIOException("RowMutations supports only put and delete, not " +
        mutation.getClass().getName());
    }
    mutationBuilder.clear();
    MutationProto mp = ProtobufUtil.toMutationNoData(type, mutation, mutationBuilder);
    cells.add(mutation);
    actionBuilder.clear();
    regionActionBuilder.addAction(actionBuilder.setMutation(mp).build());
  }
  return regionActionBuilder;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:36,代码来源:RequestConverter.java

示例7: toDurability

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos; //导入依赖的package包/类
/**
 * Convert a protobuf Durability into a client Durability
 */
public static Durability toDurability(
    final ClientProtos.MutationProto.Durability proto) {
  switch(proto) {
  case USE_DEFAULT:
    return Durability.USE_DEFAULT;
  case SKIP_WAL:
    return Durability.SKIP_WAL;
  case ASYNC_WAL:
    return Durability.ASYNC_WAL;
  case SYNC_WAL:
    return Durability.SYNC_WAL;
  case FSYNC_WAL:
    return Durability.FSYNC_WAL;
  default:
    return Durability.USE_DEFAULT;
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:ProtobufUtil.java

示例8: toResult

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos; //导入依赖的package包/类
/**
 * Convert a client Result to a protocol buffer Result
 *
 * @param result the client Result to convert
 * @return the converted protocol buffer Result
 */
public static ClientProtos.Result toResult(final Result result) {
  if (result.getExists() != null) {
    return toResult(result.getExists(), result.isStale());
  }

  Cell[] cells = result.rawCells();
  if (cells == null || cells.length == 0) {
    return result.isStale() ? EMPTY_RESULT_PB_STALE : EMPTY_RESULT_PB;
  }

  ClientProtos.Result.Builder builder = ClientProtos.Result.newBuilder();
  for (Cell c : cells) {
    builder.addCell(toCell(c));
  }

  builder.setStale(result.isStale());
  builder.setPartial(result.isPartial());

  return builder.build();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:27,代码来源:ProtobufUtil.java

示例9: call

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos; //导入依赖的package包/类
@Override
public Result call(int callTimeout) throws Exception {
  if (controller.isCanceled()) return null;

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

  byte[] reg = location.getRegionInfo().getRegionName();

  ClientProtos.GetRequest request =
      RequestConverter.buildGetRequest(reg, get);
  controller.setCallTimeout(callTimeout);

  try {
    ClientProtos.GetResponse response = getStub().get(controller, request);
    if (response == null) {
      return null;
    }
    return ProtobufUtil.toResult(response.getResult());
  } catch (ServiceException se) {
    throw ProtobufUtil.getRemoteException(se);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:25,代码来源:RpcRetryingCallerWithReadReplicas.java

示例10: updateStats

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos; //导入依赖的package包/类
/**
 * Update the stats for the specified region if the result is an instance of {@link
 * ResultStatsUtil}
 *
 * @param r object that contains the result and possibly the statistics about the region
 * @param serverStats stats tracker to update from the result
 * @param server server from which the result was obtained
 * @param regionName full region name for the stats.
 * @return the underlying {@link Result} if the passed result is an {@link
 * ResultStatsUtil} or just returns the result;
 */
public static <T> T updateStats(T r, ServerStatisticTracker serverStats,
    ServerName server, byte[] regionName) {
  if (!(r instanceof Result)) {
    return r;
  }
  Result result = (Result) r;
  // early exit if there are no stats to collect
  ClientProtos.RegionLoadStats stats = result.getStats();
  if(stats == null){
    return r;
  }

  if (regionName != null) {
    serverStats.updateRegionStats(server, regionName, stats);
  }

  return r;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:30,代码来源:ResultStatsUtil.java

示例11: getRowOrBefore

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos; //导入依赖的package包/类
/**
* {@inheritDoc}
* @deprecated Use reversed scan instead.
*/
@Override
@Deprecated
public Result getRowOrBefore(final byte[] row, final byte[] family)
    throws IOException {
  RegionServerCallable<Result> callable = new RegionServerCallable<Result>(this.connection,
      tableName, row) {
    @Override
   public Result call(int callTimeout) throws IOException {
      PayloadCarryingRpcController controller = rpcControllerFactory.newController();
      controller.setPriority(tableName);
      controller.setCallTimeout(callTimeout);
      ClientProtos.GetRequest request = RequestConverter.buildGetRowOrBeforeRequest(
          getLocation().getRegionInfo().getRegionName(), row, family);
      try {
        ClientProtos.GetResponse response = getStub().get(controller, request);
        if (!response.hasResult()) return null;
        return ProtobufUtil.toResult(response.getResult());
      } catch (ServiceException se) {
        throw ProtobufUtil.getRemoteException(se);
      }
    }
  };
  return rpcCallerFactory.<Result>newCaller().callWithRetries(callable, this.operationTimeout);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:29,代码来源:HTable.java

示例12: testAttributesSerialization

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos; //导入依赖的package包/类
@Test
public void testAttributesSerialization() throws IOException {
  Scan scan = new Scan();
  scan.setAttribute("attribute1", Bytes.toBytes("value1"));
  scan.setAttribute("attribute2", Bytes.toBytes("value2"));
  scan.setAttribute("attribute3", Bytes.toBytes("value3"));

  ClientProtos.Scan scanProto = ProtobufUtil.toScan(scan);

  Scan scan2 = ProtobufUtil.toScan(scanProto);

  Assert.assertNull(scan2.getAttribute("absent"));
  Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), scan2.getAttribute("attribute1")));
  Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), scan2.getAttribute("attribute2")));
  Assert.assertTrue(Arrays.equals(Bytes.toBytes("value3"), scan2.getAttribute("attribute3")));
  Assert.assertEquals(3, scan2.getAttributesMap().size());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:TestScan.java

示例13: ScanOpenNextThenExceptionThenRecoverConnection

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

示例14: RegionServerStoppedOnScannerOpenConnection

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

示例15: doMultiResponse

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos; //导入依赖的package包/类
static MultiResponse doMultiResponse(final SortedMap<byte [], Pair<HRegionInfo, ServerName>> meta,
    final AtomicLong sequenceids, final MultiRequest request) {
  // Make a response to match the request.  Act like there were no failures.
  ClientProtos.MultiResponse.Builder builder = ClientProtos.MultiResponse.newBuilder();
  // Per Region.
  RegionActionResult.Builder regionActionResultBuilder =
      RegionActionResult.newBuilder();
  ResultOrException.Builder roeBuilder = ResultOrException.newBuilder();
  for (RegionAction regionAction: request.getRegionActionList()) {
    regionActionResultBuilder.clear();
    // Per Action in a Region.
    for (ClientProtos.Action action: regionAction.getActionList()) {
      roeBuilder.clear();
      // Return empty Result and proper index as result.
      roeBuilder.setResult(ClientProtos.Result.getDefaultInstance());
      roeBuilder.setIndex(action.getIndex());
      regionActionResultBuilder.addResultOrException(roeBuilder.build());
    }
    builder.addRegionActionResult(regionActionResultBuilder.build());
  }
  return builder.build();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:TestClientNoCluster.java


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