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

项目: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    文件: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    文件: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);
  }
}
项目: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);
  }
}
项目: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);
  }
}
项目: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);
  }
}
项目: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    文件: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    文件: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    文件: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    文件: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    文件: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    文件: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);
  }
}