Java Code Examples for org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil#toTableName()
The following examples show how to use
org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil#toTableName() .
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: BackupManifest.java From hbase with Apache License 2.0 | 6 votes |
private static HashMap<TableName, HashMap<String, Long>> loadIncrementalTimestampMap( BackupProtos.BackupImage proto) { List<BackupProtos.TableServerTimestamp> list = proto.getTstMapList(); HashMap<TableName, HashMap<String, Long>> incrTimeRanges = new HashMap<>(); if (list == null || list.size() == 0) { return incrTimeRanges; } for (BackupProtos.TableServerTimestamp tst : list) { TableName tn = ProtobufUtil.toTableName(tst.getTableName()); HashMap<String, Long> map = incrTimeRanges.get(tn); if (map == null) { map = new HashMap<>(); incrTimeRanges.put(tn, map); } List<BackupProtos.ServerTimestamp> listSt = tst.getServerTimestampList(); for (BackupProtos.ServerTimestamp stm : listSt) { ServerName sn = ProtobufUtil.toServerName(stm.getServerName()); map.put(sn.getHostname() + ":" + sn.getPort(), stm.getTimestamp()); } } return incrTimeRanges; }
Example 2
Source File: AccessControlUtil.java From hbase with Apache License 2.0 | 6 votes |
/** * Converts a TablePermission proto to a client TablePermission object. * @param proto the protobuf TablePermission * @return the converted TablePermission */ public static TablePermission toTablePermission(AccessControlProtos.TablePermission proto) { Permission.Action[] actions = toPermissionActions(proto.getActionList()); TableName table = null; byte[] qualifier = null; byte[] family = null; if (!proto.hasTableName()) { throw new IllegalStateException("TableName cannot be empty"); } table = ProtobufUtil.toTableName(proto.getTableName()); if (proto.hasFamily()) { family = proto.getFamily().toByteArray(); } if (proto.hasQualifier()) { qualifier = proto.getQualifier().toByteArray(); } return new TablePermission(table, family, qualifier, actions); }
Example 3
Source File: TruncateTableProcedure.java From hbase with Apache License 2.0 | 6 votes |
@Override protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException { super.deserializeStateData(serializer); MasterProcedureProtos.TruncateTableStateData state = serializer.deserialize(MasterProcedureProtos.TruncateTableStateData.class); setUser(MasterProcedureUtil.toUserInfo(state.getUserInfo())); if (state.hasTableSchema()) { tableDescriptor = ProtobufUtil.toTableDescriptor(state.getTableSchema()); tableName = tableDescriptor.getTableName(); } else { tableName = ProtobufUtil.toTableName(state.getTableName()); } preserveSplits = state.getPreserveSplits(); if (state.getRegionInfoCount() == 0) { regions = null; } else { regions = new ArrayList<>(state.getRegionInfoCount()); for (HBaseProtos.RegionInfo hri: state.getRegionInfoList()) { regions.add(ProtobufUtil.toRegionInfo(hri)); } } }
Example 4
Source File: MasterRpcServices.java From hbase with Apache License 2.0 | 6 votes |
/** * Update state of the table in meta only. This is required by hbck in some situations to cleanup * stuck assign/ unassign regions procedures for the table. * * @return previous state of the table */ @Override public GetTableStateResponse setTableStateInMeta(RpcController controller, SetTableStateInMetaRequest request) throws ServiceException { TableName tn = ProtobufUtil.toTableName(request.getTableName()); try { TableState prevState = this.master.getTableStateManager().getTableState(tn); TableState newState = TableState.convert(tn, request.getTableState()); LOG.info("{} set table={} state from {} to {}", master.getClientIdAuditPrefix(), tn, prevState.getState(), newState.getState()); this.master.getTableStateManager().setTableState(tn, newState.getState()); return GetTableStateResponse.newBuilder().setTableState(prevState.convert()).build(); } catch (Exception e) { throw new ServiceException(e); } }
Example 5
Source File: DeleteTableProcedure.java From hbase with Apache License 2.0 | 6 votes |
@Override protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException { super.deserializeStateData(serializer); MasterProcedureProtos.DeleteTableStateData state = serializer.deserialize(MasterProcedureProtos.DeleteTableStateData.class); setUser(MasterProcedureUtil.toUserInfo(state.getUserInfo())); tableName = ProtobufUtil.toTableName(state.getTableName()); if (state.getRegionInfoCount() == 0) { regions = null; } else { regions = new ArrayList<>(state.getRegionInfoCount()); for (HBaseProtos.RegionInfo hri: state.getRegionInfoList()) { regions.add(ProtobufUtil.toRegionInfo(hri)); } } }
Example 6
Source File: LockProcedure.java From hbase with Apache License 2.0 | 6 votes |
@Override protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException { final LockProcedureData state = serializer.deserialize(LockProcedureData.class); type = LockType.valueOf(state.getLockType().name()); description = state.getDescription(); if (state.getRegionInfoCount() > 0) { regionInfos = new RegionInfo[state.getRegionInfoCount()]; for (int i = 0; i < state.getRegionInfoCount(); ++i) { regionInfos[i] = ProtobufUtil.toRegionInfo(state.getRegionInfo(i)); } } else if (state.hasNamespace()) { namespace = state.getNamespace(); } else if (state.hasTableName()) { tableName = ProtobufUtil.toTableName(state.getTableName()); } recoveredMasterLock = state.getIsMasterLock(); this.lock = setupLock(); }
Example 7
Source File: MasterRpcServices.java From hbase with Apache License 2.0 | 6 votes |
/** * Get the number of regions of the table that have been updated by the alter. * * @return Pair indicating the number of regions updated Pair.getFirst is the * regions that are yet to be updated Pair.getSecond is the total number * of regions of the table * @throws ServiceException */ @Override public GetSchemaAlterStatusResponse getSchemaAlterStatus( RpcController controller, GetSchemaAlterStatusRequest req) throws ServiceException { // TODO: currently, we query using the table name on the client side. this // may overlap with other table operations or the table operation may // have completed before querying this API. We need to refactor to a // transaction system in the future to avoid these ambiguities. TableName tableName = ProtobufUtil.toTableName(req.getTableName()); try { master.checkInitialized(); Pair<Integer,Integer> pair = master.getAssignmentManager().getReopenStatus(tableName); GetSchemaAlterStatusResponse.Builder ret = GetSchemaAlterStatusResponse.newBuilder(); ret.setYetToUpdateRegions(pair.getFirst()); ret.setTotalRegions(pair.getSecond()); return ret.build(); } catch (IOException ioe) { throw new ServiceException(ioe); } }
Example 8
Source File: BackupTableInfo.java From hbase with Apache License 2.0 | 5 votes |
public static BackupTableInfo convert(BackupProtos.BackupTableInfo proto) { BackupTableInfo bs = new BackupTableInfo(); bs.table = ProtobufUtil.toTableName(proto.getTableName()); if (proto.hasSnapshotName()) { bs.snapshotName = proto.getSnapshotName(); } return bs; }
Example 9
Source File: RSRpcServices.java From hbase with Apache License 2.0 | 5 votes |
@Override @QosPriority(priority=HConstants.ADMIN_QOS) public GetRegionLoadResponse getRegionLoad(RpcController controller, GetRegionLoadRequest request) throws ServiceException { List<HRegion> regions; if (request.hasTableName()) { TableName tableName = ProtobufUtil.toTableName(request.getTableName()); regions = regionServer.getRegions(tableName); } else { regions = regionServer.getRegions(); } List<RegionLoad> rLoads = new ArrayList<>(regions.size()); RegionLoad.Builder regionLoadBuilder = ClusterStatusProtos.RegionLoad.newBuilder(); RegionSpecifier.Builder regionSpecifier = RegionSpecifier.newBuilder(); try { for (HRegion region : regions) { rLoads.add(regionServer.createRegionLoad(region, regionLoadBuilder, regionSpecifier)); } } catch (IOException e) { throw new ServiceException(e); } GetRegionLoadResponse.Builder builder = GetRegionLoadResponse.newBuilder(); builder.addAllRegionLoads(rLoads); return builder.build(); }
Example 10
Source File: RSGroupAdminServiceImpl.java From hbase with Apache License 2.0 | 5 votes |
@Override public void getRSGroupInfoOfTable(RpcController controller, GetRSGroupInfoOfTableRequest request, RpcCallback<GetRSGroupInfoOfTableResponse> done) { GetRSGroupInfoOfTableResponse.Builder builder = GetRSGroupInfoOfTableResponse.newBuilder(); TableName tableName = ProtobufUtil.toTableName(request.getTableName()); LOG.info( master.getClientIdAuditPrefix() + " initiates rsgroup info retrieval, table=" + tableName); try { if (master.getMasterCoprocessorHost() != null) { master.getMasterCoprocessorHost().preGetRSGroupInfoOfTable(tableName); } Optional<RSGroupInfo> optGroup = RSGroupUtil.getRSGroupInfo(master, rsGroupInfoManager, tableName); if (optGroup.isPresent()) { builder.setRSGroupInfo(ProtobufUtil.toProtoGroupInfo(fillTables(optGroup.get()))); } else { if (master.getTableStateManager().isTablePresent(tableName)) { RSGroupInfo rsGroupInfo = rsGroupInfoManager.getRSGroup(RSGroupInfo.DEFAULT_GROUP); builder.setRSGroupInfo(ProtobufUtil.toProtoGroupInfo(fillTables(rsGroupInfo))); } } if (master.getMasterCoprocessorHost() != null) { master.getMasterCoprocessorHost().postGetRSGroupInfoOfTable(tableName); } } catch (IOException e) { CoprocessorRpcUtils.setControllerException(controller, e); } done.run(builder.build()); }
Example 11
Source File: MasterRpcServices.java From hbase with Apache License 2.0 | 5 votes |
@Override public GetRSGroupInfoOfTableResponse getRSGroupInfoOfTable(RpcController controller, GetRSGroupInfoOfTableRequest request) throws ServiceException { TableName tableName = ProtobufUtil.toTableName(request.getTableName()); LOG.info( master.getClientIdAuditPrefix() + " initiates rsgroup info retrieval, table=" + tableName); try { if (master.getMasterCoprocessorHost() != null) { master.getMasterCoprocessorHost().preGetRSGroupInfoOfTable(tableName); } GetRSGroupInfoOfTableResponse resp; TableDescriptor td = master.getTableDescriptors().get(tableName); if (td == null) { resp = GetRSGroupInfoOfTableResponse.getDefaultInstance(); } else { RSGroupInfo rsGroupInfo = RSGroupUtil.getRSGroupInfo(master, master.getRSGroupInfoManager(), tableName) .orElse(master.getRSGroupInfoManager().getRSGroup(RSGroupInfo.DEFAULT_GROUP)); resp = GetRSGroupInfoOfTableResponse.newBuilder() .setRSGroupInfo(ProtobufUtil.toProtoGroupInfo(rsGroupInfo)).build(); } if (master.getMasterCoprocessorHost() != null) { master.getMasterCoprocessorHost().postGetRSGroupInfoOfTable(tableName); } return resp; } catch (IOException e) { throw new ServiceException(e); } }
Example 12
Source File: MasterRpcServices.java From hbase with Apache License 2.0 | 5 votes |
@Override public GetTableStateResponse getTableState(RpcController controller, GetTableStateRequest request) throws ServiceException { try { master.checkServiceStarted(); TableName tableName = ProtobufUtil.toTableName(request.getTableName()); TableState ts = master.getTableStateManager().getTableState(tableName); GetTableStateResponse.Builder builder = GetTableStateResponse.newBuilder(); builder.setTableState(ts.convert()); return builder.build(); } catch (IOException e) { throw new ServiceException(e); } }
Example 13
Source File: EnableTableProcedure.java From hbase with Apache License 2.0 | 5 votes |
@Override protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException { super.deserializeStateData(serializer); MasterProcedureProtos.EnableTableStateData enableTableMsg = serializer.deserialize(MasterProcedureProtos.EnableTableStateData.class); setUser(MasterProcedureUtil.toUserInfo(enableTableMsg.getUserInfo())); tableName = ProtobufUtil.toTableName(enableTableMsg.getTableName()); }
Example 14
Source File: ReopenTableRegionsProcedure.java From hbase with Apache License 2.0 | 5 votes |
@Override protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException { super.deserializeStateData(serializer); ReopenTableRegionsStateData data = serializer.deserialize(ReopenTableRegionsStateData.class); tableName = ProtobufUtil.toTableName(data.getTableName()); regions = data.getRegionList().stream().map(ProtobufUtil::toRegionLocation) .collect(Collectors.toList()); }
Example 15
Source File: DisableTableProcedure.java From hbase with Apache License 2.0 | 5 votes |
@Override protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException { super.deserializeStateData(serializer); MasterProcedureProtos.DisableTableStateData disableTableMsg = serializer.deserialize(MasterProcedureProtos.DisableTableStateData.class); setUser(MasterProcedureUtil.toUserInfo(disableTableMsg.getUserInfo())); tableName = ProtobufUtil.toTableName(disableTableMsg.getTableName()); skipTableStateCheck = disableTableMsg.getSkipTableStateCheck(); }
Example 16
Source File: MasterRpcServices.java From hbase with Apache License 2.0 | 4 votes |
@Override public GetUserPermissionsResponse getUserPermissions(RpcController controller, GetUserPermissionsRequest request) throws ServiceException { try { master.checkInitialized(); if (master.cpHost != null && hasAccessControlServiceCoprocessor(master.cpHost)) { final String userName = request.hasUserName() ? request.getUserName().toStringUtf8() : null; String namespace = request.hasNamespaceName() ? request.getNamespaceName().toStringUtf8() : null; TableName table = request.hasTableName() ? ProtobufUtil.toTableName(request.getTableName()) : null; byte[] cf = request.hasColumnFamily() ? request.getColumnFamily().toByteArray() : null; byte[] cq = request.hasColumnQualifier() ? request.getColumnQualifier().toByteArray() : null; Type permissionType = request.hasType() ? request.getType() : null; master.getMasterCoprocessorHost().preGetUserPermissions(userName, namespace, table, cf, cq); List<UserPermission> perms = null; if (permissionType == Type.Table) { boolean filter = (cf != null || userName != null) ? true : false; perms = PermissionStorage.getUserTablePermissions(master.getConfiguration(), table, cf, cq, userName, filter); } else if (permissionType == Type.Namespace) { perms = PermissionStorage.getUserNamespacePermissions(master.getConfiguration(), namespace, userName, userName != null ? true : false); } else { perms = PermissionStorage.getUserPermissions(master.getConfiguration(), null, null, null, userName, userName != null ? true : false); // Skip super users when filter user is specified if (userName == null) { // Adding superusers explicitly to the result set as PermissionStorage do not store // them. Also using acl as table name to be inline with the results of global admin and // will help in avoiding any leakage of information about being superusers. for (String user : Superusers.getSuperUsers()) { perms.add(new UserPermission(user, Permission.newBuilder().withActions(Action.values()).build())); } } } master.getMasterCoprocessorHost().postGetUserPermissions(userName, namespace, table, cf, cq); AccessControlProtos.GetUserPermissionsResponse response = ShadedAccessControlUtil.buildGetUserPermissionsResponse(perms); return response; } else { throw new DoNotRetryIOException( new UnsupportedOperationException(AccessController.class.getName() + " is not loaded")); } } catch (IOException ioe) { throw new ServiceException(ioe); } }
Example 17
Source File: MasterAnnotationReadingPriorityFunction.java From hbase with Apache License 2.0 | 4 votes |
@Override public int getPriority(RPCProtos.RequestHeader header, Message param, User user) { // Yes this is copy pasted from the base class but it keeps from having to look in the // annotatedQos table twice something that could get costly since this is called for // every single RPC request. int priorityByAnnotation = getAnnotatedPriority(header); if (priorityByAnnotation >= 0) { // no one can have higher priority than meta transition. if (priorityByAnnotation >= META_TRANSITION_QOS) { return META_TRANSITION_QOS - 1; } else { return priorityByAnnotation; } } // If meta is moving then all the other of reports of state transitions will be // un able to edit meta. Those blocked reports should not keep the report that opens meta from // running. Hence all reports of meta transition should always be in a different thread. // This keeps from deadlocking the cluster. if (param instanceof RegionServerStatusProtos.ReportRegionStateTransitionRequest) { // Regions are moving. Lets see which ones. RegionServerStatusProtos.ReportRegionStateTransitionRequest tRequest = (RegionServerStatusProtos.ReportRegionStateTransitionRequest) param; for (RegionServerStatusProtos.RegionStateTransition rst : tRequest.getTransitionList()) { if (rst.getRegionInfoList() != null) { for (HBaseProtos.RegionInfo info : rst.getRegionInfoList()) { TableName tn = ProtobufUtil.toTableName(info.getTableName()); if (TableName.META_TABLE_NAME.equals(tn)) { return META_TRANSITION_QOS; } } } } return HConstants.HIGH_QOS; } // also use HIGH_QOS for region server report if (param instanceof RegionServerStatusProtos.RegionServerReportRequest) { return HConstants.HIGH_QOS; } // Handle the rest of the different reasons to change priority. return getBasePriority(header, param); }
Example 18
Source File: MasterQuotaManager.java From hbase with Apache License 2.0 | 4 votes |
public SetQuotaResponse setQuota(final SetQuotaRequest req) throws IOException, InterruptedException { checkQuotaSupport(); if (req.hasUserName()) { userLocks.lock(req.getUserName()); try { if (req.hasTableName()) { setUserQuota(req.getUserName(), ProtobufUtil.toTableName(req.getTableName()), req); } else if (req.hasNamespace()) { setUserQuota(req.getUserName(), req.getNamespace(), req); } else { setUserQuota(req.getUserName(), req); } } finally { userLocks.unlock(req.getUserName()); } } else if (req.hasTableName()) { TableName table = ProtobufUtil.toTableName(req.getTableName()); tableLocks.lock(table); try { setTableQuota(table, req); } finally { tableLocks.unlock(table); } } else if (req.hasNamespace()) { namespaceLocks.lock(req.getNamespace()); try { setNamespaceQuota(req.getNamespace(), req); } finally { namespaceLocks.unlock(req.getNamespace()); } } else if (req.hasRegionServer()) { regionServerLocks.lock(req.getRegionServer()); try { setRegionServerQuota(req.getRegionServer(), req); } finally { regionServerLocks.unlock(req.getRegionServer()); } } else { throw new DoNotRetryIOException(new UnsupportedOperationException( "a user, a table, a namespace or region server must be specified")); } return SetQuotaResponse.newBuilder().build(); }
Example 19
Source File: AccessController.java From hbase with Apache License 2.0 | 4 votes |
/** * @deprecated since 2.2.0 and will be removed in 4.0.0. Use * {@link Admin#getUserPermissions(GetUserPermissionsRequest)} instead. * @see Admin#getUserPermissions(GetUserPermissionsRequest) * @see <a href="https://issues.apache.org/jira/browse/HBASE-21911">HBASE-21911</a> */ @Deprecated @Override public void getUserPermissions(RpcController controller, AccessControlProtos.GetUserPermissionsRequest request, RpcCallback<AccessControlProtos.GetUserPermissionsResponse> done) { AccessControlProtos.GetUserPermissionsResponse response = null; try { // only allowed to be called on _acl_ region if (aclRegion) { if (!initialized) { throw new CoprocessorException("AccessController not yet initialized"); } User caller = RpcServer.getRequestUser().orElse(null); final String userName = request.hasUserName() ? request.getUserName().toStringUtf8() : null; final String namespace = request.hasNamespaceName() ? request.getNamespaceName().toStringUtf8() : null; final TableName table = request.hasTableName() ? ProtobufUtil.toTableName(request.getTableName()) : null; final byte[] cf = request.hasColumnFamily() ? request.getColumnFamily().toByteArray() : null; final byte[] cq = request.hasColumnQualifier() ? request.getColumnQualifier().toByteArray() : null; preGetUserPermissions(caller, userName, namespace, table, cf, cq); GetUserPermissionsRequest getUserPermissionsRequest = null; if (request.getType() == AccessControlProtos.Permission.Type.Table) { getUserPermissionsRequest = GetUserPermissionsRequest.newBuilder(table).withFamily(cf) .withQualifier(cq).withUserName(userName).build(); } else if (request.getType() == AccessControlProtos.Permission.Type.Namespace) { getUserPermissionsRequest = GetUserPermissionsRequest.newBuilder(namespace).withUserName(userName).build(); } else { getUserPermissionsRequest = GetUserPermissionsRequest.newBuilder().withUserName(userName).build(); } List<UserPermission> perms = regionEnv.getConnection().getAdmin().getUserPermissions(getUserPermissionsRequest); response = AccessControlUtil.buildGetUserPermissionsResponse(perms); } else { throw new CoprocessorException(AccessController.class, "This method " + "can only execute at " + PermissionStorage.ACL_TABLE_NAME + " table."); } } catch (IOException ioe) { // pass exception back up CoprocessorRpcUtils.setControllerException(controller, ioe); } done.run(response); }
Example 20
Source File: QuotaSettings.java From hbase with Apache License 2.0 | 4 votes |
/** * Converts the protocol buffer request into a QuotaSetting POJO. Arbitrarily * enforces that the request only contain one "limit", despite the message * allowing multiple. The public API does not allow such use of the message. * * @param request The protocol buffer request. * @return A {@link QuotaSettings} POJO. */ @InterfaceAudience.Private public static QuotaSettings buildFromProto(SetQuotaRequest request) { String username = null; if (request.hasUserName()) { username = request.getUserName(); } TableName tableName = null; if (request.hasTableName()) { tableName = ProtobufUtil.toTableName(request.getTableName()); } String namespace = null; if (request.hasNamespace()) { namespace = request.getNamespace(); } String regionServer = null; if (request.hasRegionServer()) { regionServer = request.getRegionServer(); } if (request.hasBypassGlobals()) { // Make sure we don't have either of the two below limits also included if (request.hasSpaceLimit() || request.hasThrottle()) { throw new IllegalStateException( "SetQuotaRequest has multiple limits: " + TextFormat.shortDebugString(request)); } return new QuotaGlobalsSettingsBypass( username, tableName, namespace, regionServer, request.getBypassGlobals()); } else if (request.hasSpaceLimit()) { // Make sure we don't have the below limit as well if (request.hasThrottle()) { throw new IllegalStateException( "SetQuotaRequests has multiple limits: " + TextFormat.shortDebugString(request)); } // Sanity check on the pb received. if (!request.getSpaceLimit().hasQuota()) { throw new IllegalArgumentException( "SpaceLimitRequest is missing the expected SpaceQuota."); } return QuotaSettingsFactory.fromSpace( tableName, namespace, request.getSpaceLimit().getQuota()); } else if (request.hasThrottle()) { return new ThrottleSettings(username, tableName, namespace, regionServer, request.getThrottle()); } else { throw new IllegalStateException("Unhandled SetRequestRequest state"); } }