@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); } }
@Test public void testWithRegions() throws IOException, ServiceException { HTableDescriptor htd = new HTableDescriptor(TableName.valueOf("mytable")); List<HRegionInfo> regions = Lists.newArrayList( new HRegionInfo(htd.getTableName(), Bytes.toBytes("a"), Bytes.toBytes("d")), new HRegionInfo(htd.getTableName(), Bytes.toBytes("d"), Bytes.toBytes("z")) ); Mockito.doReturn(ResponseConverter.buildGetOnlineRegionResponse( regions)).when(rpcServices).getOnlineRegion((RpcController)Mockito.any(), (GetOnlineRegionRequest)Mockito.any()); new RSStatusTmpl().render(new StringWriter(), rs); }
/** * 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); }
/** * 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); }
@Test public void testWithRegions() throws IOException, ServiceException { HTableDescriptor htd = new HTableDescriptor(TableName.valueOf("mytable")); List<HRegionInfo> regions = Lists.newArrayList( new HRegionInfo(htd.getTableName(), Bytes.toBytes("a"), Bytes.toBytes("d")), new HRegionInfo(htd.getTableName(), Bytes.toBytes("d"), Bytes.toBytes("z")) ); Mockito.doReturn(ResponseConverter.buildGetOnlineRegionResponse( regions)).when(rs).getOnlineRegion((RpcController)Mockito.any(), (GetOnlineRegionRequest)Mockito.any()); new RSStatusTmpl().render(new StringWriter(), rs); }
/** * 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); }
@Test public void testWithRegions() throws IOException, ServiceException { HTableDescriptor htd = new HTableDescriptor("mytable"); List<HRegionInfo> regions = Lists.newArrayList( new HRegionInfo(htd.getName(), Bytes.toBytes("a"), Bytes.toBytes("d")), new HRegionInfo(htd.getName(), Bytes.toBytes("d"), Bytes.toBytes("z")) ); Mockito.doReturn(ResponseConverter.buildGetOnlineRegionResponse( regions)).when(rs).getOnlineRegion((RpcController)Mockito.any(), (GetOnlineRegionRequest)Mockito.any()); new RSStatusTmpl().render(new StringWriter(), rs); }
@Test public void testQosFunctionWithoutKnownArgument() throws IOException { //The request is not using any of the //known argument classes (it uses one random request class) //(known argument classes are listed in //HRegionServer.QosFunction.knownArgumentClasses) RpcRequestBody.Builder rpcRequestBuilder = RpcRequestBody.newBuilder(); rpcRequestBuilder.setMethodName("foo"); rpcRequestBuilder.setRequestClassName(GetOnlineRegionRequest.class.getCanonicalName()); RpcRequestBody rpcRequest = rpcRequestBuilder.build(); QosFunction qosFunc = regionServer.getQosFunction(); assertTrue (qosFunc.apply(rpcRequest) == HConstants.NORMAL_QOS); }
@Override public GetOnlineRegionResponse getOnlineRegion(RpcController controller, GetOnlineRegionRequest request) throws ServiceException { // TODO Auto-generated method stub return null; }
/** * Create a protocol buffer GetOnlineRegionRequest * * @return a protocol buffer GetOnlineRegionRequest */ public static GetOnlineRegionRequest buildGetOnlineRegionRequest() { return GetOnlineRegionRequest.newBuilder().build(); }