@Override @QosPriority(priority=HConstants.ADMIN_QOS) public GetOnlineRegionResponse getOnlineRegion(final RpcController controller, final GetOnlineRegionRequest request) throws ServiceException { try { checkOpen(); requestCount.increment(); Map<String, Region> onlineRegions = regionServer.onlineRegions; List<HRegionInfo> list = new ArrayList<HRegionInfo>(onlineRegions.size()); for (Region region: onlineRegions.values()) { list.add(region.getRegionInfo()); } Collections.sort(list); return ResponseConverter.buildGetOnlineRegionResponse(list); } catch (IOException ie) { throw new ServiceException(ie); } }
@Override @QosPriority(priority = HConstants.ADMIN_QOS) public GetOnlineRegionResponse getOnlineRegion(final RpcController controller, final GetOnlineRegionRequest request) throws ServiceException { try { checkOpen(); requestCount.increment(); Map<String, HRegion> onlineRegions = regionServer.onlineRegions; List<HRegionInfo> list = new ArrayList<HRegionInfo>(onlineRegions.size()); for (HRegion region : onlineRegions.values()) { list.add(region.getRegionInfo()); } Collections.sort(list); return ResponseConverter.buildGetOnlineRegionResponse(list); } catch (IOException ie) { throw new ServiceException(ie); } }
@Override @QosPriority(priority=HConstants.HIGH_QOS) public GetOnlineRegionResponse getOnlineRegion(final RpcController controller, final GetOnlineRegionRequest request) throws ServiceException { try { checkOpen(); requestCount.increment(); List<HRegionInfo> list = new ArrayList<HRegionInfo>(onlineRegions.size()); for (HRegion region: this.onlineRegions.values()) { list.add(region.getRegionInfo()); } Collections.sort(list); return ResponseConverter.buildGetOnlineRegionResponse(list); } catch (IOException ie) { throw new ServiceException(ie); } }
@Override @QosPriority(priority=HConstants.HIGH_QOS) public GetOnlineRegionResponse getOnlineRegion(final RpcController controller, final GetOnlineRegionRequest request) throws ServiceException { try { checkOpen(); requestCount.increment(); Map<String, HRegion> onlineRegions = regionServer.onlineRegions; List<HRegionInfo> list = new ArrayList<HRegionInfo>(onlineRegions.size()); for (HRegion region: onlineRegions.values()) { list.add(region.getRegionInfo()); } Collections.sort(list); return ResponseConverter.buildGetOnlineRegionResponse(list); } catch (IOException ie) { throw new ServiceException(ie); } }
/** * A utility to build a GetOnlineRegionResponse. * * @param regions * @return the response */ public static GetOnlineRegionResponse buildGetOnlineRegionResponse( final List<HRegionInfo> regions) { GetOnlineRegionResponse.Builder builder = GetOnlineRegionResponse.newBuilder(); for (HRegionInfo region: regions) { builder.addRegionInfo(HRegionInfo.convert(region)); } return builder.build(); }
/** * A helper to get the all the online regions on a region * server using admin protocol. * @return a list of online region info */ public static List<HRegionInfo> getOnlineRegions(final RpcController controller, final AdminService.BlockingInterface admin) throws IOException { GetOnlineRegionRequest request = RequestConverter.buildGetOnlineRegionRequest(); GetOnlineRegionResponse response = null; try { response = admin.getOnlineRegion(controller, request); } catch (ServiceException se) { throw getRemoteException(se); } return getRegionInfos(response); }
/** * Get the list of region info from a GetOnlineRegionResponse * * @param proto the GetOnlineRegionResponse * @return the list of region info or null if <code>proto</code> is null */ static List<HRegionInfo> getRegionInfos(final GetOnlineRegionResponse proto) { if (proto == null) return null; List<HRegionInfo> regionInfos = new ArrayList<HRegionInfo>(); for (RegionInfo regionInfo: proto.getRegionInfoList()) { regionInfos.add(HRegionInfo.convert(regionInfo)); } return regionInfos; }
/** * A helper to get the all the online regions on a region * server using admin protocol. * * @param admin * @return a list of online region info * @throws IOException */ public static List<HRegionInfo> getOnlineRegions(final AdminService.BlockingInterface admin) throws IOException { GetOnlineRegionRequest request = RequestConverter.buildGetOnlineRegionRequest(); GetOnlineRegionResponse response = null; try { response = admin.getOnlineRegion(null, request); } catch (ServiceException se) { throw getRemoteException(se); } return getRegionInfos(response); }
/** * A helper to get the all the online regions on a region * server using admin protocol. * * @param admin * @return a list of online region info * @throws IOException */ public static List<HRegionInfo> getOnlineRegions(final AdminProtocol admin) throws IOException { GetOnlineRegionRequest request = RequestConverter.buildGetOnlineRegionRequest(); GetOnlineRegionResponse response = null; try { response = admin.getOnlineRegion(null, request); } catch (ServiceException se) { throw getRemoteException(se); } return getRegionInfos(response); }
@Override public GetOnlineRegionResponse getOnlineRegion(RpcController controller, GetOnlineRegionRequest request) throws ServiceException { // TODO Auto-generated method stub return null; }
/** * Get the list of region info from a GetOnlineRegionResponse * * @param proto the GetOnlineRegionResponse * @return the list of region info */ public static List<HRegionInfo> getRegionInfos(final GetOnlineRegionResponse proto) { if (proto == null || proto.getRegionInfoCount() == 0) return null; return ProtobufUtil.getRegionInfos(proto); }