org.apache.hadoop.hbase.shaded.protobuf.ResponseConverter Java Examples
The following examples show how to use
org.apache.hadoop.hbase.shaded.protobuf.ResponseConverter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RSRpcServices.java From hbase with Apache License 2.0 | 6 votes |
@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.getOnlineRegions(); List<RegionInfo> list = new ArrayList<>(onlineRegions.size()); for (HRegion region: onlineRegions.values()) { list.add(region.getRegionInfo()); } list.sort(RegionInfo.COMPARATOR); return ResponseConverter.buildGetOnlineRegionResponse(list); } catch (IOException ie) { throw new ServiceException(ie); } }
Example #2
Source File: MasterRpcServices.java From hbase with Apache License 2.0 | 5 votes |
@Override @QosPriority(priority = HConstants.ADMIN_QOS) public GetLastFlushedSequenceIdResponse getLastFlushedSequenceId(RpcController controller, GetLastFlushedSequenceIdRequest request) throws ServiceException { try { master.checkServiceStarted(); } catch (IOException ioe) { throw new ServiceException(ioe); } byte[] encodedRegionName = request.getRegionName().toByteArray(); RegionStoreSequenceIds ids = master.getServerManager() .getLastFlushedSequenceId(encodedRegionName); return ResponseConverter.buildGetLastFlushedSequenceIdResponse(ids); }
Example #3
Source File: MasterRpcServices.java From hbase with Apache License 2.0 | 5 votes |
@Override public RunCatalogScanResponse runCatalogScan(RpcController c, RunCatalogScanRequest req) throws ServiceException { rpcPreCheck("runCatalogScan"); try { return ResponseConverter.buildRunCatalogScanResponse( this.master.catalogJanitorChore.scan()); } catch (IOException ioe) { throw new ServiceException(ioe); } }
Example #4
Source File: MasterRpcServices.java From hbase with Apache License 2.0 | 5 votes |
@Override public RunCleanerChoreResponse runCleanerChore(RpcController c, RunCleanerChoreRequest req) throws ServiceException { rpcPreCheck("runCleanerChore"); boolean result = master.getHFileCleaner().runCleaner() && master.getLogCleaner().runCleaner(); return ResponseConverter.buildRunCleanerChoreResponse(result); }
Example #5
Source File: RSRpcServices.java From hbase with Apache License 2.0 | 5 votes |
/** * Get some information of the region server. * * @param controller the RPC controller * @param request the request * @throws ServiceException */ @Override @QosPriority(priority=HConstants.ADMIN_QOS) public GetServerInfoResponse getServerInfo(final RpcController controller, final GetServerInfoRequest request) throws ServiceException { try { checkOpen(); } catch (IOException ie) { throw new ServiceException(ie); } requestCount.increment(); int infoPort = regionServer.infoServer != null ? regionServer.infoServer.getPort() : -1; return ResponseConverter.buildGetServerInfoResponse(regionServer.serverName, infoPort); }
Example #6
Source File: RSRpcServices.java From hbase with Apache License 2.0 | 5 votes |
private void failRegionAction(MultiResponse.Builder responseBuilder, RegionActionResult.Builder regionActionResultBuilder, RegionAction regionAction, CellScanner cellScanner, Throwable error) { rpcServer.getMetrics().exception(error); regionActionResultBuilder.setException(ResponseConverter.buildException(error)); responseBuilder.addRegionActionResult(regionActionResultBuilder.build()); // All Mutations in this RegionAction not executed as we can not see the Region online here // in this RS. Will be retried from Client. Skipping all the Cells in CellScanner // corresponding to these Mutations. if (cellScanner != null) { skipCellsForMutations(regionAction.getActionList(), cellScanner); } }
Example #7
Source File: TestRSStatusServlet.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testWithRegions() throws IOException, ServiceException { HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name.getMethodName())); List<RegionInfo> regions = Lists.newArrayList( RegionInfoBuilder.newBuilder(htd.getTableName()).setStartKey(Bytes.toBytes("a")) .setEndKey(Bytes.toBytes("d")).build(), RegionInfoBuilder.newBuilder(htd.getTableName()).setStartKey(Bytes.toBytes("d")) .setEndKey(Bytes.toBytes("z")).build()); Mockito.doReturn(ResponseConverter.buildGetOnlineRegionResponse(regions)).when(rpcServices) .getOnlineRegion(Mockito.any(), Mockito.any()); new RSStatusTmpl().render(new StringWriter(), rs); }
Example #8
Source File: ConnectionUtils.java From hbase with Apache License 2.0 | 5 votes |
/** * Use the scan metrics returned by the server to add to the identically named counters in the * client side metrics. If a counter does not exist with the same name as the server side metric, * the attempt to increase the counter will fail. */ static void updateServerSideMetrics(ScanMetrics scanMetrics, ScanResponse response) { if (scanMetrics == null || response == null || !response.hasScanMetrics()) { return; } ResponseConverter.getScanMetrics(response).forEach(scanMetrics::addToCounter); }
Example #9
Source File: RangerAuthorizationCoprocessor.java From ranger with Apache License 2.0 | 4 votes |
@Override public void getUserPermissions(RpcController controller, AccessControlProtos.GetUserPermissionsRequest request, RpcCallback<AccessControlProtos.GetUserPermissionsResponse> done) { AccessControlProtos.GetUserPermissionsResponse response = null; try { String operation = "userPermissions"; final RangerAccessResourceImpl resource = new RangerAccessResourceImpl(); User user = getActiveUser(null); Set<String> groups = _userUtils.getUserGroups(user); if (groups.isEmpty() && user.getUGI() != null) { String[] groupArray = user.getUGI().getGroupNames(); if (groupArray != null) { groups = Sets.newHashSet(groupArray); } } RangerAccessRequestImpl rangerAccessrequest = new RangerAccessRequestImpl(resource, null, _userUtils.getUserAsString(user), groups, null); rangerAccessrequest.setAction(operation); rangerAccessrequest.setClientIPAddress(getRemoteAddress()); rangerAccessrequest.setResourceMatchingScope(RangerAccessRequest.ResourceMatchingScope.SELF); List<UserPermission> perms = null; if (request.getType() == AccessControlProtos.Permission.Type.Table) { final TableName table = request.hasTableName() ? ProtobufUtil.toTableName(request.getTableName()) : null; requirePermission(null, operation, table.getName(), Action.ADMIN); resource.setValue(RangerHBaseResource.KEY_TABLE, table.getNameAsString()); perms = User.runAsLoginUser(new PrivilegedExceptionAction<List<UserPermission>>() { @Override public List<UserPermission> run() throws Exception { return getUserPermissions( hbasePlugin.getResourceACLs(rangerAccessrequest), table.getNameAsString(), false); } }); } else if (request.getType() == AccessControlProtos.Permission.Type.Namespace) { final String namespace = request.getNamespaceName().toStringUtf8(); requireGlobalPermission(null, "getUserPermissionForNamespace", namespace, Action.ADMIN); resource.setValue(RangerHBaseResource.KEY_TABLE, namespace + RangerHBaseResource.NAMESPACE_SEPARATOR); rangerAccessrequest.setRequestData(namespace); perms = User.runAsLoginUser(new PrivilegedExceptionAction<List<UserPermission>>() { @Override public List<UserPermission> run() throws Exception { return getUserPermissions( hbasePlugin.getResourceACLs(rangerAccessrequest), namespace, true); } }); } else { requirePermission(null, "userPermissions", Action.ADMIN); perms = User.runAsLoginUser(new PrivilegedExceptionAction<List<UserPermission>>() { @Override public List<UserPermission> run() throws Exception { return getUserPermissions( hbasePlugin.getResourceACLs(rangerAccessrequest), null, false); } }); if (_userUtils.isSuperUser(user)) { perms.add(new UserPermission(Bytes.toBytes(_userUtils.getUserAsString(user)), AccessControlLists.ACL_TABLE_NAME, null, Action.values())); } } response = AccessControlUtil.buildGetUserPermissionsResponse(perms); } catch (IOException ioe) { // pass exception back up ResponseConverter.setControllerException(controller, ioe); } done.run(response); }
Example #10
Source File: RSRpcServices.java From hbase with Apache License 2.0 | 4 votes |
private static ResultOrException getResultOrException(final ClientProtos.Result r, final int index){ return getResultOrException(ResponseConverter.buildActionResult(r), index); }
Example #11
Source File: RSRpcServices.java From hbase with Apache License 2.0 | 4 votes |
private static ResultOrException getResultOrException(final Exception e, final int index) { return getResultOrException(ResponseConverter.buildActionResult(e), index); }