Package org.apache.hadoop.hbase.quotas
Class QuotaUtil
java.lang.Object
org.apache.hadoop.hbase.quotas.QuotaTableUtil
org.apache.hadoop.hbase.quotas.QuotaUtil
Helper class to interact with the quota table
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.apache.hadoop.hbase.quotas.QuotaTableUtil
QuotaTableUtil.NamespaceQuotasVisitor, QuotaTableUtil.QuotasVisitor, QuotaTableUtil.TableQuotasVisitor, QuotaTableUtil.UserQuotasVisitor -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final longprivate static final org.slf4j.Loggerstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprivate static final booleanstatic final TableDescriptorTable descriptor for Quota internal tablestatic final Stringstatic final StringFields inherited from class org.apache.hadoop.hbase.quotas.QuotaTableUtil
QUOTA_FAMILY_INFO, QUOTA_FAMILY_USAGE, QUOTA_NAMESPACE_ROW_KEY_PREFIX, QUOTA_POLICY_COLUMN, QUOTA_QUALIFIER_POLICY, QUOTA_QUALIFIER_SETTINGS, QUOTA_QUALIFIER_SETTINGS_PREFIX, QUOTA_REGION_SERVER_ROW_KEY, QUOTA_REGION_SERVER_ROW_KEY_PREFIX, QUOTA_SNAPSHOT_SIZE_QUALIFIER, QUOTA_TABLE_NAME, QUOTA_TABLE_ROW_KEY_PREFIX, QUOTA_USER_ROW_KEY_PREFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddNamespaceQuota(Connection connection, String namespace, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas data) private static voidaddQuotas(Connection connection, byte[] rowKey, byte[] qualifier, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas data) private static voidaddQuotas(Connection connection, byte[] rowKey, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas data) static voidaddRegionServerQuota(Connection connection, String regionServer, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas data) static voidaddTableQuota(Connection connection, TableName table, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas data) static voidaddUserQuota(Connection connection, String user, String namespace, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas data) static voidaddUserQuota(Connection connection, String user, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas data) static voidaddUserQuota(Connection connection, String user, TableName table, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas data) private static Optional<org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.TimedQuota>buildDefaultTimedQuota(org.apache.hadoop.conf.Configuration conf, String key) protected static UserQuotaStatebuildDefaultUserQuotaState(org.apache.hadoop.conf.Configuration conf) static longcalculateCellsSize(List<Cell> cells) static longcalculateMutationSize(Mutation mutation) static longcalculateResultSize(List<Result> results) static longcalculateResultSize(Result result) private static voidcheckRSQuotaToEnableExceedThrottle(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas quotas) static voiddeleteNamespaceQuota(Connection connection, String namespace) private static voiddeleteQuotas(Connection connection, byte[] rowKey) private static voiddeleteQuotas(Connection connection, byte[] rowKey, byte[] qualifier) static voiddeleteRegionServerQuota(Connection connection, String regionServer) static voiddeleteTableQuota(Connection connection, TableName table) static voiddeleteUserQuota(Connection connection, String user) static voiddeleteUserQuota(Connection connection, String user, String namespace) static voiddeleteUserQuota(Connection connection, String user, TableName table) static voiddisableTableIfNotDisabled(Connection conn, TableName tableName) Method to disable a table, if not already disabled.private static voiddoDelete(Connection connection, Delete delete) private static voiddoPut(Connection connection, Put put) static voidenableTableIfNotEnabled(Connection conn, TableName tableName) Method to enable a table, if not already enabled.static <K> Map<K,QuotaState> fetchGlobalQuotas(org.apache.hadoop.conf.Configuration conf, String type, Scan scan, Connection connection, QuotaUtil.KeyFromRow<K> kfr) static Map<String,QuotaState> fetchNamespaceQuotas(org.apache.hadoop.conf.Configuration conf, Connection connection, double factor) static Map<String,QuotaState> fetchRegionServerQuotas(org.apache.hadoop.conf.Configuration conf, Connection connection) static Map<TableName,QuotaState> fetchTableQuotas(org.apache.hadoop.conf.Configuration conf, Connection connection, Map<TableName, Double> tableMachineFactors) static Map<String,UserQuotaState> fetchUserQuotas(org.apache.hadoop.conf.Configuration conf, Connection connection, Map<TableName, Double> tableMachineQuotaFactors, double factor) static OperationQuota.OperationTypegetQuotaOperationType(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.Action action, boolean hasCondition) static OperationQuota.OperationTypegetQuotaOperationType(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateRequest mutateRequest) private static OperationQuota.OperationTypegetQuotaOperationType(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto mutationProto, boolean hasCondition) protected static booleanisExceedThrottleQuotaEnabled(Connection connection) static booleanisQuotaEnabled(org.apache.hadoop.conf.Configuration conf) Returns true if the support for quota is enabledprotected static voidswitchExceedThrottleQuota(Connection connection, boolean exceedThrottleQuotaEnabled) private static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.QuotasupdateClusterQuotaToMachineQuota(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas quotas, double factor) Convert cluster scope quota to machine scope quotaprivate static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.TimedQuotaupdateTimedQuota(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.TimedQuota timedQuota, double factor) Methods inherited from class org.apache.hadoop.hbase.quotas.QuotaTableUtil
createDeletesForExistingNamespaceSnapshotSizes, createDeletesForExistingNamespaceSnapshotSizes, createDeletesForExistingSnapshotsFromScan, createDeletesForExistingTableSnapshotSizes, createDeletesForExistingTableSnapshotSizes, createGetNamespaceSnapshotSize, createPutForNamespaceSnapshotSize, createPutForSnapshotSize, createPutForSpaceSnapshot, createScanForNamespaceSnapshotSizes, createScanForNamespaceSnapshotSizes, createScanForSpaceSnapshotSizes, createScanForSpaceSnapshotSizes, deleteTableUsageSnapshotsForNamespace, doGet, doGet, extractQuotaSnapshot, extractSnapshotNameFromSizeCell, extractSnapshotSize, getCurrentSnapshotFromQuotaTable, getExceedThrottleQuotaRowKey, getNamespaceFromRowKey, getNamespaceQuota, getNamespaceRowKey, getNamespaceRowKeyRegex, getNamespaceSnapshots, getNamespaceSnapshotSize, getObservedSnapshotSizes, getProtoViolationPolicy, getRegionServerFromRowKey, getRegionServerQuota, getRegionServerRowKey, getSettingsQualifierForUserNamespace, getSettingsQualifierForUserTable, getSettingsQualifierRegexForUserNamespace, getSettingsQualifierRegexForUserTable, getSnapshots, getSnapshotSizeQualifier, getTableFromRowKey, getTableQuota, getTableRowKey, getTableRowKeyRegex, getTableSnapshots, getUserFromRowKey, getUserQuota, getUserQuota, getUserQuota, getUserRowKey, getUserRowKeyRegex, getViolationPolicy, isEmptyQuota, isNamespaceRowKey, isRegionServerRowKey, isTableRowKey, isUserRowKey, makeFilter, makeGetForSnapshotSize, makeQuotaSnapshotGetForTable, makeQuotaSnapshotScan, makeQuotaSnapshotScanForTable, makeScan, parseNamespaceResult, parseNamespaceResult, parseResult, parseResultToCollection, parseSnapshotSize, parseTableResult, parseTableResult, parseUserResult, parseUserResult, quotasFromData, quotasFromData, quotasToData
-
Field Details
-
LOG
-
QUOTA_CONF_KEY
- See Also:
-
QUOTA_ENABLED_DEFAULT
- See Also:
-
READ_CAPACITY_UNIT_CONF_KEY
- See Also:
-
DEFAULT_READ_CAPACITY_UNIT
- See Also:
-
WRITE_CAPACITY_UNIT_CONF_KEY
- See Also:
-
DEFAULT_WRITE_CAPACITY_UNIT
- See Also:
-
QUOTA_DEFAULT_USER_MACHINE_READ_NUM
- See Also:
-
QUOTA_DEFAULT_USER_MACHINE_READ_SIZE
- See Also:
-
QUOTA_DEFAULT_USER_MACHINE_REQUEST_NUM
- See Also:
-
QUOTA_DEFAULT_USER_MACHINE_REQUEST_SIZE
- See Also:
-
QUOTA_DEFAULT_USER_MACHINE_WRITE_NUM
- See Also:
-
QUOTA_DEFAULT_USER_MACHINE_WRITE_SIZE
- See Also:
-
QUOTA_DEFAULT_USER_MACHINE_ATOMIC_READ_SIZE
- See Also:
-
QUOTA_DEFAULT_USER_MACHINE_ATOMIC_REQUEST_NUM
- See Also:
-
QUOTA_DEFAULT_USER_MACHINE_ATOMIC_WRITE_SIZE
- See Also:
-
QUOTA_DEFAULT_USER_MACHINE_REQUEST_HANDLER_USAGE_MS
- See Also:
-
QUOTA_TABLE_DESC
Table descriptor for Quota internal table
-
-
Constructor Details
-
QuotaUtil
public QuotaUtil()
-
-
Method Details
-
isQuotaEnabled
Returns true if the support for quota is enabled -
addTableQuota
public static void addTableQuota(Connection connection, TableName table, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas data) throws IOException - Throws:
IOException
-
deleteTableQuota
- Throws:
IOException
-
addNamespaceQuota
public static void addNamespaceQuota(Connection connection, String namespace, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas data) throws IOException - Throws:
IOException
-
deleteNamespaceQuota
- Throws:
IOException
-
addUserQuota
public static void addUserQuota(Connection connection, String user, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas data) throws IOException - Throws:
IOException
-
addUserQuota
public static void addUserQuota(Connection connection, String user, TableName table, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas data) throws IOException - Throws:
IOException
-
addUserQuota
public static void addUserQuota(Connection connection, String user, String namespace, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas data) throws IOException - Throws:
IOException
-
deleteUserQuota
- Throws:
IOException
-
deleteUserQuota
public static void deleteUserQuota(Connection connection, String user, TableName table) throws IOException - Throws:
IOException
-
deleteUserQuota
public static void deleteUserQuota(Connection connection, String user, String namespace) throws IOException - Throws:
IOException
-
addRegionServerQuota
public static void addRegionServerQuota(Connection connection, String regionServer, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas data) throws IOException - Throws:
IOException
-
deleteRegionServerQuota
public static void deleteRegionServerQuota(Connection connection, String regionServer) throws IOException - Throws:
IOException
-
getQuotaOperationType
public static OperationQuota.OperationType getQuotaOperationType(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.Action action, boolean hasCondition) -
getQuotaOperationType
public static OperationQuota.OperationType getQuotaOperationType(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateRequest mutateRequest) -
getQuotaOperationType
private static OperationQuota.OperationType getQuotaOperationType(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto mutationProto, boolean hasCondition) -
switchExceedThrottleQuota
protected static void switchExceedThrottleQuota(Connection connection, boolean exceedThrottleQuotaEnabled) throws IOException - Throws:
IOException
-
checkRSQuotaToEnableExceedThrottle
private static void checkRSQuotaToEnableExceedThrottle(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas quotas) throws IOException - Throws:
IOException
-
isExceedThrottleQuotaEnabled
- Throws:
IOException
-
addQuotas
private static void addQuotas(Connection connection, byte[] rowKey, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas data) throws IOException - Throws:
IOException
-
addQuotas
private static void addQuotas(Connection connection, byte[] rowKey, byte[] qualifier, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas data) throws IOException - Throws:
IOException
-
deleteQuotas
- Throws:
IOException
-
deleteQuotas
private static void deleteQuotas(Connection connection, byte[] rowKey, byte[] qualifier) throws IOException - Throws:
IOException
-
fetchUserQuotas
public static Map<String,UserQuotaState> fetchUserQuotas(org.apache.hadoop.conf.Configuration conf, Connection connection, Map<TableName, Double> tableMachineQuotaFactors, double factor) throws IOException- Throws:
IOException
-
buildDefaultUserQuotaState
protected static UserQuotaState buildDefaultUserQuotaState(org.apache.hadoop.conf.Configuration conf) -
buildDefaultTimedQuota
private static Optional<org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.TimedQuota> buildDefaultTimedQuota(org.apache.hadoop.conf.Configuration conf, String key) -
fetchTableQuotas
public static Map<TableName,QuotaState> fetchTableQuotas(org.apache.hadoop.conf.Configuration conf, Connection connection, Map<TableName, Double> tableMachineFactors) throws IOException- Throws:
IOException
-
fetchNamespaceQuotas
public static Map<String,QuotaState> fetchNamespaceQuotas(org.apache.hadoop.conf.Configuration conf, Connection connection, double factor) throws IOException - Throws:
IOException
-
fetchRegionServerQuotas
public static Map<String,QuotaState> fetchRegionServerQuotas(org.apache.hadoop.conf.Configuration conf, Connection connection) throws IOException - Throws:
IOException
-
fetchGlobalQuotas
public static <K> Map<K,QuotaState> fetchGlobalQuotas(org.apache.hadoop.conf.Configuration conf, String type, Scan scan, Connection connection, QuotaUtil.KeyFromRow<K> kfr) throws IOException - Throws:
IOException
-
updateClusterQuotaToMachineQuota
private static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas updateClusterQuotaToMachineQuota(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas quotas, double factor) Convert cluster scope quota to machine scope quota- Parameters:
quotas- the original quotafactor- factor used to divide cluster limiter to machine limiter- Returns:
- the converted quota whose quota limiters all in machine scope
-
updateTimedQuota
private static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.TimedQuota updateTimedQuota(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.TimedQuota timedQuota, double factor) -
doPut
- Throws:
IOException
-
doDelete
- Throws:
IOException
-
calculateMutationSize
-
calculateResultSize
-
calculateResultSize
-
calculateCellsSize
-
enableTableIfNotEnabled
Method to enable a table, if not already enabled. This method suppressesTableNotDisabledExceptionandTableNotFoundException, if thrown while enabling the table.- Parameters:
conn- connection to re-usetableName- name of the table to be enabled- Throws:
IOException
-
disableTableIfNotDisabled
public static void disableTableIfNotDisabled(Connection conn, TableName tableName) throws IOException Method to disable a table, if not already disabled. This method suppressesTableNotEnabledException, if thrown while disabling the table.- Parameters:
conn- connection to re-usetableName- table name which has moved into space quota violation- Throws:
IOException
-