Java 类org.apache.hadoop.hbase.protobuf.generated.AdminProtos.GetRegionInfoRequest 实例源码

项目:ditb    文件:RSRpcServices.java   
@Override
@QosPriority(priority=HConstants.ADMIN_QOS)
public GetRegionInfoResponse getRegionInfo(final RpcController controller,
    final GetRegionInfoRequest request) throws ServiceException {
  try {
    checkOpen();
    requestCount.increment();
    Region region = getRegion(request.getRegion());
    HRegionInfo info = region.getRegionInfo();
    GetRegionInfoResponse.Builder builder = GetRegionInfoResponse.newBuilder();
    builder.setRegionInfo(HRegionInfo.convert(info));
    if (request.hasCompactionState() && request.getCompactionState()) {
      builder.setCompactionState(region.getCompactionState());
    }
    builder.setIsRecovering(region.isRecovering());
    return builder.build();
  } catch (IOException ie) {
    throw new ServiceException(ie);
  }
}
项目:ditb    文件:TestMetaTableLocator.java   
/**
 * Test get of meta region fails properly if nothing to connect to.
 * @throws IOException
 * @throws InterruptedException
 * @throws KeeperException
 * @throws ServiceException
 */
@Test
public void testVerifyMetaRegionLocationFails()
throws IOException, InterruptedException, KeeperException, ServiceException {
  ClusterConnection connection = Mockito.mock(ClusterConnection.class);
  ServiceException connectException =
    new ServiceException(new ConnectException("Connection refused"));
  final AdminProtos.AdminService.BlockingInterface implementation =
    Mockito.mock(AdminProtos.AdminService.BlockingInterface.class);
  Mockito.when(implementation.getRegionInfo((RpcController)Mockito.any(),
    (GetRegionInfoRequest)Mockito.any())).thenThrow(connectException);
  Mockito.when(connection.getAdmin(Mockito.any(ServerName.class))).
    thenReturn(implementation);
      RpcControllerFactory controllerFactory = Mockito.mock(RpcControllerFactory.class);
      Mockito.when(controllerFactory.newController()).thenReturn(
        Mockito.mock(PayloadCarryingRpcController.class));
      Mockito.when(connection.getRpcControllerFactory()).thenReturn(controllerFactory);

  ServerName sn = ServerName.valueOf("example.com", 1234, System.currentTimeMillis());
  MetaTableLocator.setMetaLocation(this.watcher,
          sn,
          RegionState.State.OPENING);
  assertFalse(new MetaTableLocator().verifyMetaRegionLocation(connection, watcher, 100));
  MetaTableLocator.setMetaLocation(this.watcher, sn, RegionState.State.OPEN);
  assertFalse(new MetaTableLocator().verifyMetaRegionLocation(connection, watcher, 100));
}
项目:ditb    文件:HBaseAdmin.java   
/**
 * {@inheritDoc}
 */
@Override
public CompactionState getCompactionStateForRegion(final byte[] regionName)
throws IOException {
  try {
    Pair<HRegionInfo, ServerName> regionServerPair = getRegion(regionName);
    if (regionServerPair == null) {
      throw new IllegalArgumentException("Invalid region: " + Bytes.toStringBinary(regionName));
    }
    if (regionServerPair.getSecond() == null) {
      throw new NoServerForRegionException(Bytes.toStringBinary(regionName));
    }
    ServerName sn = regionServerPair.getSecond();
    AdminService.BlockingInterface admin = this.connection.getAdmin(sn);
    GetRegionInfoRequest request = RequestConverter.buildGetRegionInfoRequest(
      regionServerPair.getFirst().getRegionName(), true);
    PayloadCarryingRpcController controller = rpcControllerFactory.newController();
    // TODO: this does not do retries, it should. Set priority and timeout in controller
    GetRegionInfoResponse response = admin.getRegionInfo(controller, request);
    return response.getCompactionState();
  } catch (ServiceException se) {
    throw ProtobufUtil.getRemoteException(se);
  }
}
项目:pbase    文件:RSRpcServices.java   
@Override
@QosPriority(priority = HConstants.ADMIN_QOS)
public GetRegionInfoResponse getRegionInfo(final RpcController controller,
                                           final GetRegionInfoRequest request) throws ServiceException {
    try {
        checkOpen();
        requestCount.increment();
        HRegion region = getRegion(request.getRegion());
        HRegionInfo info = region.getRegionInfo();
        GetRegionInfoResponse.Builder builder = GetRegionInfoResponse.newBuilder();
        builder.setRegionInfo(HRegionInfo.convert(info));
        if (request.hasCompactionState() && request.getCompactionState()) {
            builder.setCompactionState(region.getCompactionState());
        }
        builder.setIsRecovering(region.isRecovering());
        return builder.build();
    } catch (IOException ie) {
        throw new ServiceException(ie);
    }
}
项目:pbase    文件:TestMetaTableLocator.java   
/**
 * Test get of meta region fails properly if nothing to connect to.
 * @throws IOException
 * @throws InterruptedException
 * @throws KeeperException
 * @throws ServiceException
 */
@Test
public void testVerifyMetaRegionLocationFails()
throws IOException, InterruptedException, KeeperException, ServiceException {
  ClusterConnection connection = Mockito.mock(ClusterConnection.class);
  ServiceException connectException =
    new ServiceException(new ConnectException("Connection refused"));
  final AdminProtos.AdminService.BlockingInterface implementation =
    Mockito.mock(AdminProtos.AdminService.BlockingInterface.class);
  Mockito.when(implementation.getRegionInfo((RpcController)Mockito.any(),
    (GetRegionInfoRequest)Mockito.any())).thenThrow(connectException);
  Mockito.when(connection.getAdmin(Mockito.any(ServerName.class))).
    thenReturn(implementation);

  ServerName sn = ServerName.valueOf("example.com", 1234, System.currentTimeMillis());
  MetaTableLocator.setMetaLocation(this.watcher,
          sn,
          RegionState.State.OPENING);
  assertFalse(new MetaTableLocator().verifyMetaRegionLocation(connection, watcher, 100));
  MetaTableLocator.setMetaLocation(this.watcher, sn, RegionState.State.OPEN);
  assertFalse(new MetaTableLocator().verifyMetaRegionLocation(connection, watcher, 100));
}
项目:pbase    文件:HBaseAdmin.java   
/**
 * {@inheritDoc}
 */
@Override
public CompactionState getCompactionStateForRegion(final byte[] regionName)
throws IOException {
  try {
    Pair<HRegionInfo, ServerName> regionServerPair = getRegion(regionName);
    if (regionServerPair == null) {
      throw new IllegalArgumentException("Invalid region: " + Bytes.toStringBinary(regionName));
    }
    if (regionServerPair.getSecond() == null) {
      throw new NoServerForRegionException(Bytes.toStringBinary(regionName));
    }
    ServerName sn = regionServerPair.getSecond();
    AdminService.BlockingInterface admin = this.connection.getAdmin(sn);
    GetRegionInfoRequest request = RequestConverter.buildGetRegionInfoRequest(
      regionServerPair.getFirst().getRegionName(), true);
    GetRegionInfoResponse response = admin.getRegionInfo(null, request);
    return response.getCompactionState();
  } catch (ServiceException se) {
    throw ProtobufUtil.getRemoteException(se);
  }
}
项目:HIndex    文件:HRegionServer.java   
@Override
@QosPriority(priority=HConstants.HIGH_QOS)
public GetRegionInfoResponse getRegionInfo(final RpcController controller,
    final GetRegionInfoRequest request) throws ServiceException {
  try {
    checkOpen();
    requestCount.increment();
    HRegion region = getRegion(request.getRegion());
    HRegionInfo info = region.getRegionInfo();
    GetRegionInfoResponse.Builder builder = GetRegionInfoResponse.newBuilder();
    builder.setRegionInfo(HRegionInfo.convert(info));
    if (request.hasCompactionState() && request.getCompactionState()) {
      builder.setCompactionState(region.getCompactionState());
    }
    builder.setIsRecovering(region.isRecovering());
    return builder.build();
  } catch (IOException ie) {
    throw new ServiceException(ie);
  }
}
项目:HIndex    文件:TestCatalogTracker.java   
/**
 * Test get of meta region fails properly if nothing to connect to.
 * @throws IOException
 * @throws InterruptedException
 * @throws KeeperException
 * @throws ServiceException
 */
@Test
public void testVerifyMetaRegionLocationFails()
throws IOException, InterruptedException, KeeperException, ServiceException {
  HConnection connection = Mockito.mock(HConnection.class);
  ServiceException connectException =
    new ServiceException(new ConnectException("Connection refused"));
  final AdminProtos.AdminService.BlockingInterface implementation =
    Mockito.mock(AdminProtos.AdminService.BlockingInterface.class);
  Mockito.when(implementation.getRegionInfo((RpcController)Mockito.any(),
    (GetRegionInfoRequest)Mockito.any())).thenThrow(connectException);
  Mockito.when(connection.getAdmin(Mockito.any(ServerName.class), Mockito.anyBoolean())).
    thenReturn(implementation);
  final CatalogTracker ct = constructAndStartCatalogTracker(connection);

  MetaRegionTracker.setMetaLocation(this.watcher,
      ServerName.valueOf("example.com", 1234, System.currentTimeMillis()));
  Assert.assertFalse(ct.verifyMetaRegionLocation(100));
}
项目:PyroDB    文件:RSRpcServices.java   
@Override
@QosPriority(priority=HConstants.HIGH_QOS)
public GetRegionInfoResponse getRegionInfo(final RpcController controller,
    final GetRegionInfoRequest request) throws ServiceException {
  try {
    checkOpen();
    requestCount.increment();
    HRegion region = getRegion(request.getRegion());
    HRegionInfo info = region.getRegionInfo();
    GetRegionInfoResponse.Builder builder = GetRegionInfoResponse.newBuilder();
    builder.setRegionInfo(HRegionInfo.convert(info));
    if (request.hasCompactionState() && request.getCompactionState()) {
      builder.setCompactionState(region.getCompactionState());
    }
    builder.setIsRecovering(region.isRecovering());
    return builder.build();
  } catch (IOException ie) {
    throw new ServiceException(ie);
  }
}
项目:PyroDB    文件:TestCatalogTracker.java   
/**
 * Test get of meta region fails properly if nothing to connect to.
 * @throws IOException
 * @throws InterruptedException
 * @throws KeeperException
 * @throws ServiceException
 */
@Test
public void testVerifyMetaRegionLocationFails()
throws IOException, InterruptedException, KeeperException, ServiceException {
  HConnection connection = Mockito.mock(HConnection.class);
  ServiceException connectException =
    new ServiceException(new ConnectException("Connection refused"));
  final AdminProtos.AdminService.BlockingInterface implementation =
    Mockito.mock(AdminProtos.AdminService.BlockingInterface.class);
  Mockito.when(implementation.getRegionInfo((RpcController)Mockito.any(),
    (GetRegionInfoRequest)Mockito.any())).thenThrow(connectException);
  Mockito.when(connection.getAdmin(Mockito.any(ServerName.class), Mockito.anyBoolean())).
    thenReturn(implementation);
  final CatalogTracker ct = constructAndStartCatalogTracker(connection);

  MetaRegionTracker.setMetaLocation(this.watcher,
      ServerName.valueOf("example.com", 1234, System.currentTimeMillis()));
  Assert.assertFalse(ct.verifyMetaRegionLocation(100));
}
项目:c5    文件:HRegionServer.java   
@Override
@QosPriority(priority=HConstants.HIGH_QOS)
public GetRegionInfoResponse getRegionInfo(final RpcController controller,
    final GetRegionInfoRequest request) throws ServiceException {
  try {
    checkOpen();
    requestCount.increment();
    HRegion region = getRegion(request.getRegion());
    HRegionInfo info = region.getRegionInfo();
    GetRegionInfoResponse.Builder builder = GetRegionInfoResponse.newBuilder();
    builder.setRegionInfo(HRegionInfo.convert(info));
    if (request.hasCompactionState() && request.getCompactionState()) {
      builder.setCompactionState(region.getCompactionState());
    }
    builder.setIsRecovering(region.isRecovering());
    return builder.build();
  } catch (IOException ie) {
    throw new ServiceException(ie);
  }
}
项目:c5    文件:TestCatalogTracker.java   
/**
 * Test get of meta region fails properly if nothing to connect to.
 * @throws IOException
 * @throws InterruptedException
 * @throws KeeperException
 * @throws ServiceException
 */
@Test
public void testVerifyMetaRegionLocationFails()
throws IOException, InterruptedException, KeeperException, ServiceException {
  HConnection connection = Mockito.mock(HConnection.class);
  ServiceException connectException =
    new ServiceException(new ConnectException("Connection refused"));
  final AdminProtos.AdminService.BlockingInterface implementation =
    Mockito.mock(AdminProtos.AdminService.BlockingInterface.class);
  Mockito.when(implementation.getRegionInfo((RpcController)Mockito.any(),
    (GetRegionInfoRequest)Mockito.any())).thenThrow(connectException);
  Mockito.when(connection.getAdmin(Mockito.any(ServerName.class), Mockito.anyBoolean())).
    thenReturn(implementation);
  final CatalogTracker ct = constructAndStartCatalogTracker(connection);

  MetaRegionTracker.setMetaLocation(this.watcher,
      ServerName.valueOf("example.com", 1234, System.currentTimeMillis()));
  Assert.assertFalse(ct.verifyMetaRegionLocation(100));
}
项目:DominoHBase    文件:HRegionServer.java   
@Override
@QosPriority(priority=HConstants.HIGH_QOS)
public GetRegionInfoResponse getRegionInfo(final RpcController controller,
    final GetRegionInfoRequest request) throws ServiceException {
  try {
    checkOpen();
    requestCount.increment();
    HRegion region = getRegion(request.getRegion());
    HRegionInfo info = region.getRegionInfo();
    GetRegionInfoResponse.Builder builder = GetRegionInfoResponse.newBuilder();
    builder.setRegionInfo(HRegionInfo.convert(info));
    if (request.hasCompactionState() && request.getCompactionState()) {
      builder.setCompactionState(
        CompactionRequest.getCompactionState(info.getRegionId()));
    }
    return builder.build();
  } catch (IOException ie) {
    throw new ServiceException(ie);
  }
}
项目:DominoHBase    文件:TestCatalogTracker.java   
/**
 * Test get of root region fails properly if nothing to connect to.
 * @throws IOException
 * @throws InterruptedException
 * @throws KeeperException
 * @throws ServiceException
 */
@Test
public void testVerifyRootRegionLocationFails()
throws IOException, InterruptedException, KeeperException, ServiceException {
  HConnection connection = Mockito.mock(HConnection.class);
  ServiceException connectException =
    new ServiceException(new ConnectException("Connection refused"));
  final AdminProtocol implementation =
    Mockito.mock(AdminProtocol.class);
  Mockito.when(implementation.getRegionInfo((RpcController)Mockito.any(),
    (GetRegionInfoRequest)Mockito.any())).thenThrow(connectException);
  Mockito.when(connection.getAdmin(Mockito.anyString(),
    Mockito.anyInt(), Mockito.anyBoolean())).
    thenReturn(implementation);
  final CatalogTracker ct = constructAndStartCatalogTracker(connection);
  try {
    RootRegionTracker.setRootLocation(this.watcher,
      new ServerName("example.com", 1234, System.currentTimeMillis()));
    Assert.assertFalse(ct.verifyRootRegionLocation(100));
  } finally {
    // Clean out root location or later tests will be confused... they presume
    // start fresh in zk.
    RootRegionTracker.deleteRootLocation(this.watcher);
  }
}
项目:ditb    文件:MockRegionServer.java   
@Override
public GetRegionInfoResponse getRegionInfo(RpcController controller,
    GetRegionInfoRequest request) throws ServiceException {
  GetRegionInfoResponse.Builder builder = GetRegionInfoResponse.newBuilder();
  builder.setRegionInfo(HRegionInfo.convert(HRegionInfo.FIRST_META_REGIONINFO));
  return builder.build();
}
项目:ditb    文件:RequestConverter.java   
/**
 * Create a protocol buffer GetRegionInfoRequest for a given region name
 *
 * @param regionName the name of the region to get info
 * @param includeCompactionState indicate if the compaction state is requested
 * @return a protocol buffer GetRegionInfoRequest
 */
public static GetRegionInfoRequest
    buildGetRegionInfoRequest(final byte[] regionName,
      final boolean includeCompactionState) {
  GetRegionInfoRequest.Builder builder = GetRegionInfoRequest.newBuilder();
  RegionSpecifier region = buildRegionSpecifier(
    RegionSpecifierType.REGION_NAME, regionName);
  builder.setRegion(region);
  if (includeCompactionState) {
    builder.setCompactionState(includeCompactionState);
  }
  return builder.build();
}
项目:ditb    文件:ProtobufUtil.java   
/**
 * A helper to retrieve region info given a region name
 * using admin protocol.
 *
 * @param admin
 * @param regionName
 * @return the retrieved region info
 * @throws IOException
 */
public static HRegionInfo getRegionInfo(final RpcController controller,
    final AdminService.BlockingInterface admin, final byte[] regionName) throws IOException {
  try {
    GetRegionInfoRequest request =
      RequestConverter.buildGetRegionInfoRequest(regionName);
    GetRegionInfoResponse response =
      admin.getRegionInfo(controller, request);
    return HRegionInfo.convert(response.getRegionInfo());
  } catch (ServiceException se) {
    throw getRemoteException(se);
  }
}
项目:pbase    文件:MockRegionServer.java   
@Override
public GetRegionInfoResponse getRegionInfo(RpcController controller,
    GetRegionInfoRequest request) throws ServiceException {
  GetRegionInfoResponse.Builder builder = GetRegionInfoResponse.newBuilder();
  builder.setRegionInfo(HRegionInfo.convert(HRegionInfo.FIRST_META_REGIONINFO));
  return builder.build();
}
项目:pbase    文件:RequestConverter.java   
/**
 * Create a protocol buffer GetRegionInfoRequest for a given region name
 *
 * @param regionName the name of the region to get info
 * @param includeCompactionState indicate if the compaction state is requested
 * @return a protocol buffer GetRegionInfoRequest
 */
public static GetRegionInfoRequest
    buildGetRegionInfoRequest(final byte[] regionName,
      final boolean includeCompactionState) {
  GetRegionInfoRequest.Builder builder = GetRegionInfoRequest.newBuilder();
  RegionSpecifier region = buildRegionSpecifier(
    RegionSpecifierType.REGION_NAME, regionName);
  builder.setRegion(region);
  if (includeCompactionState) {
    builder.setCompactionState(includeCompactionState);
  }
  return builder.build();
}
项目:pbase    文件:ProtobufUtil.java   
/**
 * A helper to retrieve region info given a region name
 * using admin protocol.
 *
 * @param admin
 * @param regionName
 * @return the retrieved region info
 * @throws IOException
 */
public static HRegionInfo getRegionInfo(final AdminService.BlockingInterface admin,
    final byte[] regionName) throws IOException {
  try {
    GetRegionInfoRequest request =
      RequestConverter.buildGetRegionInfoRequest(regionName);
    GetRegionInfoResponse response =
      admin.getRegionInfo(null, request);
    return HRegionInfo.convert(response.getRegionInfo());
  } catch (ServiceException se) {
    throw getRemoteException(se);
  }
}
项目:HIndex    文件:MockRegionServer.java   
@Override
public GetRegionInfoResponse getRegionInfo(RpcController controller,
    GetRegionInfoRequest request) throws ServiceException {
  GetRegionInfoResponse.Builder builder = GetRegionInfoResponse.newBuilder();
  builder.setRegionInfo(HRegionInfo.convert(HRegionInfo.FIRST_META_REGIONINFO));
  return builder.build();
}
项目:HIndex    文件:RequestConverter.java   
/**
 * Create a protocol buffer GetRegionInfoRequest for a given region name
 *
 * @param regionName the name of the region to get info
 * @param includeCompactionState indicate if the compaction state is requested
 * @return a protocol buffer GetRegionInfoRequest
 */
public static GetRegionInfoRequest
    buildGetRegionInfoRequest(final byte[] regionName,
      final boolean includeCompactionState) {
  GetRegionInfoRequest.Builder builder = GetRegionInfoRequest.newBuilder();
  RegionSpecifier region = buildRegionSpecifier(
    RegionSpecifierType.REGION_NAME, regionName);
  builder.setRegion(region);
  if (includeCompactionState) {
    builder.setCompactionState(includeCompactionState);
  }
  return builder.build();
}
项目:HIndex    文件:ProtobufUtil.java   
/**
 * A helper to retrieve region info given a region name
 * using admin protocol.
 *
 * @param admin
 * @param regionName
 * @return the retrieved region info
 * @throws IOException
 */
public static HRegionInfo getRegionInfo(final AdminService.BlockingInterface admin,
    final byte[] regionName) throws IOException {
  try {
    GetRegionInfoRequest request =
      RequestConverter.buildGetRegionInfoRequest(regionName);
    GetRegionInfoResponse response =
      admin.getRegionInfo(null, request);
    return HRegionInfo.convert(response.getRegionInfo());
  } catch (ServiceException se) {
    throw getRemoteException(se);
  }
}
项目:PyroDB    文件:MockRegionServer.java   
@Override
public GetRegionInfoResponse getRegionInfo(RpcController controller,
    GetRegionInfoRequest request) throws ServiceException {
  GetRegionInfoResponse.Builder builder = GetRegionInfoResponse.newBuilder();
  builder.setRegionInfo(HRegionInfo.convert(HRegionInfo.FIRST_META_REGIONINFO));
  return builder.build();
}
项目:PyroDB    文件:RequestConverter.java   
/**
 * Create a protocol buffer GetRegionInfoRequest for a given region name
 *
 * @param regionName the name of the region to get info
 * @param includeCompactionState indicate if the compaction state is requested
 * @return a protocol buffer GetRegionInfoRequest
 */
public static GetRegionInfoRequest
    buildGetRegionInfoRequest(final byte[] regionName,
      final boolean includeCompactionState) {
  GetRegionInfoRequest.Builder builder = GetRegionInfoRequest.newBuilder();
  RegionSpecifier region = buildRegionSpecifier(
    RegionSpecifierType.REGION_NAME, regionName);
  builder.setRegion(region);
  if (includeCompactionState) {
    builder.setCompactionState(includeCompactionState);
  }
  return builder.build();
}
项目:PyroDB    文件:ProtobufUtil.java   
/**
 * A helper to retrieve region info given a region name
 * using admin protocol.
 *
 * @param admin
 * @param regionName
 * @return the retrieved region info
 * @throws IOException
 */
public static HRegionInfo getRegionInfo(final AdminService.BlockingInterface admin,
    final byte[] regionName) throws IOException {
  try {
    GetRegionInfoRequest request =
      RequestConverter.buildGetRegionInfoRequest(regionName);
    GetRegionInfoResponse response =
      admin.getRegionInfo(null, request);
    return HRegionInfo.convert(response.getRegionInfo());
  } catch (ServiceException se) {
    throw getRemoteException(se);
  }
}
项目:c5    文件:MockRegionServer.java   
@Override
public GetRegionInfoResponse getRegionInfo(RpcController controller,
    GetRegionInfoRequest request) throws ServiceException {
  GetRegionInfoResponse.Builder builder = GetRegionInfoResponse.newBuilder();
  builder.setRegionInfo(HRegionInfo.convert(HRegionInfo.FIRST_META_REGIONINFO));
  return builder.build();
}
项目:c5    文件:RequestConverter.java   
/**
 * Create a protocol buffer GetRegionInfoRequest for a given region name
 *
 * @param regionName the name of the region to get info
 * @param includeCompactionState indicate if the compaction state is requested
 * @return a protocol buffer GetRegionInfoRequest
 */
public static GetRegionInfoRequest
    buildGetRegionInfoRequest(final byte[] regionName,
      final boolean includeCompactionState) {
  GetRegionInfoRequest.Builder builder = GetRegionInfoRequest.newBuilder();
  RegionSpecifier region = buildRegionSpecifier(
    RegionSpecifierType.REGION_NAME, regionName);
  builder.setRegion(region);
  if (includeCompactionState) {
    builder.setCompactionState(includeCompactionState);
  }
  return builder.build();
}
项目:c5    文件:ProtobufUtil.java   
/**
 * A helper to retrieve region info given a region name
 * using admin protocol.
 *
 * @param admin
 * @param regionName
 * @return the retrieved region info
 * @throws IOException
 */
public static HRegionInfo getRegionInfo(final AdminService.BlockingInterface admin,
    final byte[] regionName) throws IOException {
  try {
    GetRegionInfoRequest request =
      RequestConverter.buildGetRegionInfoRequest(regionName);
    GetRegionInfoResponse response =
      admin.getRegionInfo(null, request);
    return HRegionInfo.convert(response.getRegionInfo());
  } catch (ServiceException se) {
    throw getRemoteException(se);
  }
}
项目:DominoHBase    文件:RequestConverter.java   
/**
 * Create a protocol buffer GetRegionInfoRequest for a given region name
 *
 * @param regionName the name of the region to get info
 * @param includeCompactionState indicate if the compaction state is requested
 * @return a protocol buffer GetRegionInfoRequest
 */
public static GetRegionInfoRequest
    buildGetRegionInfoRequest(final byte[] regionName,
      final boolean includeCompactionState) {
  GetRegionInfoRequest.Builder builder = GetRegionInfoRequest.newBuilder();
  RegionSpecifier region = buildRegionSpecifier(
    RegionSpecifierType.REGION_NAME, regionName);
  builder.setRegion(region);
  if (includeCompactionState) {
    builder.setCompactionState(includeCompactionState);
  }
  return builder.build();
}
项目:DominoHBase    文件:ProtobufUtil.java   
/**
 * A helper to retrieve region info given a region name
 * using admin protocol.
 *
 * @param admin
 * @param regionName
 * @return the retrieved region info
 * @throws IOException
 */
public static HRegionInfo getRegionInfo(final AdminProtocol admin,
    final byte[] regionName) throws IOException {
  try {
    GetRegionInfoRequest request =
      RequestConverter.buildGetRegionInfoRequest(regionName);
    GetRegionInfoResponse response =
      admin.getRegionInfo(null, request);
    return HRegionInfo.convert(response.getRegionInfo());
  } catch (ServiceException se) {
    throw getRemoteException(se);
  }
}
项目:DominoHBase    文件:MockRegionServer.java   
@Override
public GetRegionInfoResponse getRegionInfo(RpcController controller,
    GetRegionInfoRequest request) throws ServiceException {
  GetRegionInfoResponse.Builder builder = GetRegionInfoResponse.newBuilder();
  builder.setRegionInfo(HRegionInfo.convert(HRegionInfo.ROOT_REGIONINFO));
  return builder.build();
}
项目:DominoHBase    文件:TestCatalogTracker.java   
/**
 * Test waiting on meta w/ no timeout specified.
 * @throws Exception
 */
@Ignore // Can't make it work reliably on all platforms; mockito gets confused
// Throwing: org.mockito.exceptions.misusing.WrongTypeOfReturnValue:
// Result cannot be returned by locateRegion()
// If you plug locateRegion, it then throws for incCounter, and if you plug
// that ... and so one.
@Test public void testNoTimeoutWaitForMeta()
throws Exception {
  // Mock an HConnection and a AdminProtocol implementation.  Have the
  // HConnection return the HRI.  Have the HRI return a few mocked up responses
  // to make our test work.
  // Mock an AdminProtocol.
  final AdminProtocol implementation = Mockito.mock(AdminProtocol.class);
  HConnection connection = mockConnection(implementation, null);
  try {
    // Now the ct is up... set into the mocks some answers that make it look
    // like things have been getting assigned. Make it so we'll return a
    // location (no matter what the Get is). Same for getHRegionInfo -- always
    // just return the meta region.
    final Result result = getMetaTableRowResult();

    // TODO: Refactor.  This method has been moved out of HConnection.
    // It works for now but has been deprecated.
    Mockito.when(connection.getRegionServerWithRetries((ServerCallable<Result>)Mockito.any())).
      thenReturn(result);
    GetRegionInfoResponse.Builder builder = GetRegionInfoResponse.newBuilder();
    builder.setRegionInfo(HRegionInfo.convert(HRegionInfo.FIRST_META_REGIONINFO));
    Mockito.when(implementation.getRegionInfo((RpcController)Mockito.any(),
      (GetRegionInfoRequest)Mockito.any())).thenReturn(builder.build());
    final CatalogTracker ct = constructAndStartCatalogTracker(connection);
    ServerName hsa = ct.getMetaLocation();
    Assert.assertNull(hsa);

    // Now test waiting on meta location getting set.
    Thread t = new WaitOnMetaThread(ct) {
      @Override
      void doWaiting() throws InterruptedException {
        this.ct.waitForMeta();
      }
    };
    startWaitAliveThenWaitItLives(t, 1000);

    // This should trigger wake up of meta wait (Its the removal of the meta
    // region unassigned node that triggers catalogtrackers that a meta has
    // been assigned).
    String node = ct.getMetaNodeTracker().getNode();
    ZKUtil.createAndFailSilent(this.watcher, node);
    MetaEditor.updateMetaLocation(ct, HRegionInfo.FIRST_META_REGIONINFO, SN);
    ZKUtil.deleteNode(this.watcher, node);
    // Go get the new meta location. waitForMeta gets and verifies meta.
    Assert.assertTrue(ct.waitForMeta(10000).equals(SN));
    // Join the thread... should exit shortly.
    t.join();
    // Now meta is available.
    Assert.assertTrue(ct.waitForMeta(10000).equals(SN));
  } finally {
    HConnectionManager.deleteConnection(UTIL.getConfiguration(), true);
  }
}
项目:ditb    文件:RequestConverter.java   
/**
 * Create a protocol buffer GetRegionInfoRequest for a given region name
 *
 * @param regionName the name of the region to get info
 * @return a protocol buffer GetRegionInfoRequest
 */
public static GetRegionInfoRequest
    buildGetRegionInfoRequest(final byte[] regionName) {
  return buildGetRegionInfoRequest(regionName, false);
}
项目:pbase    文件:RequestConverter.java   
/**
 * Create a protocol buffer GetRegionInfoRequest for a given region name
 *
 * @param regionName the name of the region to get info
 * @return a protocol buffer GetRegionInfoRequest
 */
public static GetRegionInfoRequest
    buildGetRegionInfoRequest(final byte[] regionName) {
  return buildGetRegionInfoRequest(regionName, false);
}
项目:HIndex    文件:RequestConverter.java   
/**
 * Create a protocol buffer GetRegionInfoRequest for a given region name
 *
 * @param regionName the name of the region to get info
 * @return a protocol buffer GetRegionInfoRequest
 */
public static GetRegionInfoRequest
    buildGetRegionInfoRequest(final byte[] regionName) {
  return buildGetRegionInfoRequest(regionName, false);
}
项目:PyroDB    文件:RequestConverter.java   
/**
 * Create a protocol buffer GetRegionInfoRequest for a given region name
 *
 * @param regionName the name of the region to get info
 * @return a protocol buffer GetRegionInfoRequest
 */
public static GetRegionInfoRequest
    buildGetRegionInfoRequest(final byte[] regionName) {
  return buildGetRegionInfoRequest(regionName, false);
}
项目:c5    文件:RequestConverter.java   
/**
 * Create a protocol buffer GetRegionInfoRequest for a given region name
 *
 * @param regionName the name of the region to get info
 * @return a protocol buffer GetRegionInfoRequest
 */
public static GetRegionInfoRequest
    buildGetRegionInfoRequest(final byte[] regionName) {
  return buildGetRegionInfoRequest(regionName, false);
}
项目:DominoHBase    文件:RequestConverter.java   
/**
 * Create a protocol buffer GetRegionInfoRequest for a given region name
 *
 * @param regionName the name of the region to get info
 * @return a protocol buffer GetRegionInfoRequest
 */
public static GetRegionInfoRequest
    buildGetRegionInfoRequest(final byte[] regionName) {
  return buildGetRegionInfoRequest(regionName, false);
}