@InterfaceAudience.Private @InterfaceStability.Evolving public class QuotaTableUtil extends Object
ROW-KEY | FAM/QUAL | DATA | DESC |
---|---|---|---|
n.<namespace> | q:s | <global-quotas> | |
n.<namespace> | u:p | <namespace-quota policy> | |
n.<namespace> | u:s | <SpaceQuotaSnapshot> | The size of all snapshots against tables in the namespace |
t.<table> | q:s | <global-quotas> | |
t.<table> | u:p | <table-quota policy> | |
t.<table> | u:ss.<snapshot name> | <SpaceQuotaSnapshot> | The size of a snapshot against a table |
u.<user> | q:s | <global-quotas> | |
u.<user> | q:s.<table> | <table-quotas> | |
u.<user> | q:s.<ns> | <namespace-quotas> |
Modifier and Type | Class and Description |
---|---|
static interface |
QuotaTableUtil.NamespaceQuotasVisitor |
static interface |
QuotaTableUtil.QuotasVisitor |
private static interface |
QuotaTableUtil.RegionServerQuotasVisitor |
static interface |
QuotaTableUtil.TableQuotasVisitor |
static interface |
QuotaTableUtil.UserQuotasVisitor |
Modifier and Type | Field and Description |
---|---|
private static org.slf4j.Logger |
LOG |
private static byte[] |
QUOTA_EXCEED_THROTTLE_QUOTA_ROW_KEY |
protected static byte[] |
QUOTA_FAMILY_INFO |
protected static byte[] |
QUOTA_FAMILY_USAGE |
protected static byte[] |
QUOTA_NAMESPACE_ROW_KEY_PREFIX |
protected static String |
QUOTA_POLICY_COLUMN |
protected static byte[] |
QUOTA_QUALIFIER_POLICY |
protected static byte[] |
QUOTA_QUALIFIER_SETTINGS |
protected static byte[] |
QUOTA_QUALIFIER_SETTINGS_PREFIX |
static String |
QUOTA_REGION_SERVER_ROW_KEY |
protected static byte[] |
QUOTA_REGION_SERVER_ROW_KEY_PREFIX |
protected static byte[] |
QUOTA_SNAPSHOT_SIZE_QUALIFIER |
static TableName |
QUOTA_TABLE_NAME
System table for quotas
|
protected static byte[] |
QUOTA_TABLE_ROW_KEY_PREFIX |
protected static byte[] |
QUOTA_USER_ROW_KEY_PREFIX |
Constructor and Description |
---|
QuotaTableUtil() |
Modifier and Type | Method and Description |
---|---|
(package private) static List<Delete> |
createDeletesForExistingNamespaceSnapshotSizes(Connection connection)
Returns a list of
Delete to remove all namespace snapshot entries from quota table. |
(package private) static List<Delete> |
createDeletesForExistingNamespaceSnapshotSizes(Set<String> snapshotEntriesToRemove)
Returns a list of
Delete to remove given namespace snapshot entries to removefrom quota
table |
(package private) static List<Delete> |
createDeletesForExistingSnapshotsFromScan(Connection connection,
Scan scan)
Returns a list of
Delete to remove all entries returned by the passed scanner. |
(package private) static List<Delete> |
createDeletesForExistingTableSnapshotSizes(Connection connection)
Returns a list of
Delete to remove all table snapshot entries from quota table. |
(package private) static List<Delete> |
createDeletesForExistingTableSnapshotSizes(org.apache.hbase.thirdparty.com.google.common.collect.Multimap<TableName,String> snapshotEntriesToRemove)
Returns a list of
Delete to remove given table snapshot entries to remove from quota
table |
(package private) static Get |
createGetNamespaceSnapshotSize(String namespace)
Creates a
Get to fetch the namespace's total snapshot size. |
(package private) static Put |
createPutForNamespaceSnapshotSize(String namespace,
long size)
Creates a
Put for the namespace's total snapshot size. |
(package private) static Put |
createPutForSnapshotSize(TableName tableName,
String snapshot,
long size)
|
(package private) static Put |
createPutForSpaceSnapshot(TableName tableName,
SpaceQuotaSnapshot snapshot)
|
(package private) static Scan |
createScanForNamespaceSnapshotSizes()
Returns a scanner for all existing namespace snapshot entries.
|
(package private) static Scan |
createScanForNamespaceSnapshotSizes(String namespace)
Returns a scanner for all namespace snapshot entries of the given namespace
|
(package private) static Scan |
createScanForSpaceSnapshotSizes() |
(package private) static Scan |
createScanForSpaceSnapshotSizes(TableName table) |
(package private) static void |
deleteTableUsageSnapshotsForNamespace(Connection connection,
String namespace)
Remove table usage snapshots (u:p columns) for the namespace passed
|
protected static Result |
doGet(Connection connection,
Get get) |
protected static Result[] |
doGet(Connection connection,
List<Get> gets) |
static void |
extractQuotaSnapshot(Result result,
Map<TableName,SpaceQuotaSnapshot> snapshots)
Extracts the
SpaceViolationPolicy and TableName from the provided
Result and adds them to the given Map . |
protected static String |
extractSnapshotNameFromSizeCell(Cell c) |
protected static long |
extractSnapshotSize(byte[] data,
int offset,
int length) |
static SpaceQuotaSnapshot |
getCurrentSnapshotFromQuotaTable(Connection conn,
TableName tableName)
Returns the current space quota snapshot of the given
tableName from
QuotaTableUtil.QUOTA_TABLE_NAME or null if the no quota information is available for
that tableName. |
protected static byte[] |
getExceedThrottleQuotaRowKey() |
protected static String |
getNamespaceFromRowKey(byte[] key) |
static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas |
getNamespaceQuota(Connection connection,
String namespace) |
protected static byte[] |
getNamespaceRowKey(String namespace) |
protected static String |
getNamespaceRowKeyRegex(String namespace) |
static Set<String> |
getNamespaceSnapshots(Connection conn)
Returns a set of the names of all namespaces containing snapshot entries.
|
(package private) static long |
getNamespaceSnapshotSize(Connection conn,
String namespace)
Fetches the computed size of all snapshots against tables in a namespace for space quotas.
|
static Map<String,Long> |
getObservedSnapshotSizes(Connection conn)
Fetches any persisted HBase snapshot sizes stored in the quota table.
|
protected static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota |
getProtoViolationPolicy(SpaceViolationPolicy policy) |
private static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas |
getQuotas(Connection connection,
byte[] rowKey) |
private static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas |
getQuotas(Connection connection,
byte[] rowKey,
byte[] qualifier) |
protected static String |
getRegionServerFromRowKey(byte[] key) |
static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas |
getRegionServerQuota(Connection connection,
String regionServer) |
protected static byte[] |
getRegionServerRowKey(String regionServer) |
private static String |
getRegionServerRowKeyRegex(String regionServer) |
private static String |
getRowKeyRegEx(byte[] prefix,
String regex) |
protected static byte[] |
getSettingsQualifierForUserNamespace(String namespace) |
protected static byte[] |
getSettingsQualifierForUserTable(TableName tableName) |
protected static String |
getSettingsQualifierRegexForUserNamespace(String namespace) |
protected static String |
getSettingsQualifierRegexForUserTable(String table) |
static Map<TableName,SpaceQuotaSnapshot> |
getSnapshots(Connection conn)
Fetches all
SpaceQuotaSnapshot objects from the hbase:quota table. |
protected static byte[] |
getSnapshotSizeQualifier(String snapshotName) |
protected static TableName |
getTableFromRowKey(byte[] key) |
static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas |
getTableQuota(Connection connection,
TableName table) |
protected static byte[] |
getTableRowKey(TableName table) |
protected static String |
getTableRowKeyRegex(String table) |
static org.apache.hbase.thirdparty.com.google.common.collect.Multimap<TableName,String> |
getTableSnapshots(Connection conn)
Returns a multimap for all existing table snapshot entries.
|
protected static String |
getUserFromRowKey(byte[] key) |
static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas |
getUserQuota(Connection connection,
String user) |
static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas |
getUserQuota(Connection connection,
String user,
String namespace) |
static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas |
getUserQuota(Connection connection,
String user,
TableName table) |
protected static byte[] |
getUserRowKey(String user) |
protected static String |
getUserRowKeyRegex(String user) |
protected static SpaceViolationPolicy |
getViolationPolicy(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota proto) |
static boolean |
isEmptyQuota(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas quotas) |
private static boolean |
isExceedThrottleQuotaRowKey(byte[] key) |
protected static boolean |
isNamespaceRowKey(byte[] key) |
protected static boolean |
isRegionServerRowKey(byte[] key) |
protected static boolean |
isTableRowKey(byte[] key) |
protected static boolean |
isUserRowKey(byte[] key) |
static Filter |
makeFilter(QuotaFilter filter)
converts quotafilter to serializeable filterlists.
|
static Get |
makeGetForNamespaceQuotas(String namespace) |
static Get |
makeGetForRegionServerQuotas(String regionServer) |
(package private) static Get |
makeGetForSnapshotSize(TableName tn,
String snapshot)
Creates a
Get for the HBase snapshot's size against the given table. |
static Get |
makeGetForTableQuotas(TableName table) |
static Get |
makeGetForUserQuotas(String user,
Iterable<TableName> tables,
Iterable<String> namespaces) |
static Get |
makeQuotaSnapshotGetForTable(TableName tn)
Creates a
Get which returns only SpaceQuotaSnapshot from the quota table for a
specific table. |
static Scan |
makeQuotaSnapshotScan()
Creates a
Scan which returns only quota snapshots from the quota table. |
static Scan |
makeQuotaSnapshotScanForTable(TableName tn)
Creates a
Scan which returns only SpaceQuotaSnapshot from the quota table for a
specific table. |
static Scan |
makeScan(QuotaFilter filter) |
static void |
parseNamespaceResult(Result result,
QuotaTableUtil.NamespaceQuotasVisitor visitor) |
protected static void |
parseNamespaceResult(String namespace,
Result result,
QuotaTableUtil.NamespaceQuotasVisitor visitor) |
private static void |
parseRegionServerResult(Result result,
QuotaTableUtil.RegionServerQuotasVisitor visitor) |
private static void |
parseRegionServerResult(String regionServer,
Result result,
QuotaTableUtil.RegionServerQuotasVisitor visitor) |
static void |
parseResult(Result result,
QuotaTableUtil.QuotasVisitor visitor) |
static void |
parseResultToCollection(Result result,
Collection<QuotaSettings> quotaSettings) |
(package private) static long |
parseSnapshotSize(Cell c)
Parses the snapshot size from the given Cell's value.
|
static void |
parseTableResult(Result result,
QuotaTableUtil.TableQuotasVisitor visitor) |
protected static void |
parseTableResult(TableName table,
Result result,
QuotaTableUtil.TableQuotasVisitor visitor) |
static void |
parseUserResult(Result result,
QuotaTableUtil.UserQuotasVisitor visitor) |
protected static void |
parseUserResult(String userName,
Result result,
QuotaTableUtil.UserQuotasVisitor visitor) |
protected static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas |
quotasFromData(byte[] data) |
protected static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas |
quotasFromData(byte[] data,
int offset,
int length) |
protected static byte[] |
quotasToData(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas data) |
private static final org.slf4j.Logger LOG
public static final TableName QUOTA_TABLE_NAME
protected static final byte[] QUOTA_FAMILY_INFO
protected static final byte[] QUOTA_FAMILY_USAGE
protected static final byte[] QUOTA_QUALIFIER_SETTINGS
protected static final byte[] QUOTA_QUALIFIER_SETTINGS_PREFIX
protected static final byte[] QUOTA_QUALIFIER_POLICY
protected static final byte[] QUOTA_SNAPSHOT_SIZE_QUALIFIER
protected static final String QUOTA_POLICY_COLUMN
protected static final byte[] QUOTA_USER_ROW_KEY_PREFIX
protected static final byte[] QUOTA_TABLE_ROW_KEY_PREFIX
protected static final byte[] QUOTA_NAMESPACE_ROW_KEY_PREFIX
protected static final byte[] QUOTA_REGION_SERVER_ROW_KEY_PREFIX
private static final byte[] QUOTA_EXCEED_THROTTLE_QUOTA_ROW_KEY
public static final String QUOTA_REGION_SERVER_ROW_KEY
public QuotaTableUtil()
public static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas getTableQuota(Connection connection, TableName table) throws IOException
IOException
public static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas getNamespaceQuota(Connection connection, String namespace) throws IOException
IOException
public static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas getUserQuota(Connection connection, String user) throws IOException
IOException
public static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas getUserQuota(Connection connection, String user, TableName table) throws IOException
IOException
public static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas getUserQuota(Connection connection, String user, String namespace) throws IOException
IOException
private static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas getQuotas(Connection connection, byte[] rowKey) throws IOException
IOException
public static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas getRegionServerQuota(Connection connection, String regionServer) throws IOException
IOException
private static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas getQuotas(Connection connection, byte[] rowKey, byte[] qualifier) throws IOException
IOException
public static Get makeGetForTableQuotas(TableName table)
public static Get makeGetForNamespaceQuotas(String namespace)
public static Get makeGetForRegionServerQuotas(String regionServer)
public static Get makeGetForUserQuotas(String user, Iterable<TableName> tables, Iterable<String> namespaces)
public static Scan makeScan(QuotaFilter filter)
public static Filter makeFilter(QuotaFilter filter)
public static Scan makeQuotaSnapshotScan()
Scan
which returns only quota snapshots from the quota table.public static Map<TableName,SpaceQuotaSnapshot> getSnapshots(Connection conn) throws IOException
SpaceQuotaSnapshot
objects from the hbase:quota
table.conn
- The HBase connectionIOException
public static Scan makeQuotaSnapshotScanForTable(TableName tn)
Scan
which returns only SpaceQuotaSnapshot
from the quota table for a
specific table.tn
- Optionally, a table name to limit the scan's rowkey space. Can be null.public static Get makeQuotaSnapshotGetForTable(TableName tn)
Get
which returns only SpaceQuotaSnapshot
from the quota table for a
specific table.tn
- table name to get from. Can't be null.public static void extractQuotaSnapshot(Result result, Map<TableName,SpaceQuotaSnapshot> snapshots)
SpaceViolationPolicy
and TableName
from the provided
Result
and adds them to the given Map
. If the result does not contain the
expected information or the serialized policy in the value is invalid, this method will throw
an IllegalArgumentException
.result
- A row from the quota table.snapshots
- A map of snapshots to add the result of this method into.public static void parseResult(Result result, QuotaTableUtil.QuotasVisitor visitor) throws IOException
IOException
public static void parseResultToCollection(Result result, Collection<QuotaSettings> quotaSettings) throws IOException
IOException
public static void parseNamespaceResult(Result result, QuotaTableUtil.NamespaceQuotasVisitor visitor) throws IOException
IOException
protected static void parseNamespaceResult(String namespace, Result result, QuotaTableUtil.NamespaceQuotasVisitor visitor) throws IOException
IOException
private static void parseRegionServerResult(Result result, QuotaTableUtil.RegionServerQuotasVisitor visitor) throws IOException
IOException
private static void parseRegionServerResult(String regionServer, Result result, QuotaTableUtil.RegionServerQuotasVisitor visitor) throws IOException
IOException
public static void parseTableResult(Result result, QuotaTableUtil.TableQuotasVisitor visitor) throws IOException
IOException
protected static void parseTableResult(TableName table, Result result, QuotaTableUtil.TableQuotasVisitor visitor) throws IOException
IOException
public static void parseUserResult(Result result, QuotaTableUtil.UserQuotasVisitor visitor) throws IOException
IOException
protected static void parseUserResult(String userName, Result result, QuotaTableUtil.UserQuotasVisitor visitor) throws IOException
IOException
static Put createPutForSpaceSnapshot(TableName tableName, SpaceQuotaSnapshot snapshot)
static Get makeGetForSnapshotSize(TableName tn, String snapshot)
Get
for the HBase snapshot's size against the given table.static Put createPutForSnapshotSize(TableName tableName, String snapshot, long size)
static Put createPutForNamespaceSnapshotSize(String namespace, long size)
Put
for the namespace's total snapshot size.static List<Delete> createDeletesForExistingTableSnapshotSizes(org.apache.hbase.thirdparty.com.google.common.collect.Multimap<TableName,String> snapshotEntriesToRemove)
Delete
to remove given table snapshot entries to remove from quota
tablesnapshotEntriesToRemove
- the entries to removestatic List<Delete> createDeletesForExistingTableSnapshotSizes(Connection connection) throws IOException
Delete
to remove all table snapshot entries from quota table.connection
- connection to re-useIOException
static List<Delete> createDeletesForExistingNamespaceSnapshotSizes(Set<String> snapshotEntriesToRemove)
Delete
to remove given namespace snapshot entries to removefrom quota
tablesnapshotEntriesToRemove
- the entries to removestatic List<Delete> createDeletesForExistingNamespaceSnapshotSizes(Connection connection) throws IOException
Delete
to remove all namespace snapshot entries from quota table.connection
- connection to re-useIOException
static List<Delete> createDeletesForExistingSnapshotsFromScan(Connection connection, Scan scan) throws IOException
Delete
to remove all entries returned by the passed scanner.connection
- connection to re-usescan
- the scanner to use to generate the list of deletesIOException
static void deleteTableUsageSnapshotsForNamespace(Connection connection, String namespace) throws IOException
connection
- connection to re-usenamespace
- the namespace to fetch the list of table usage snapshotsIOException
static long getNamespaceSnapshotSize(Connection conn, String namespace) throws IOException
IOException
static Get createGetNamespaceSnapshotSize(String namespace)
Get
to fetch the namespace's total snapshot size.static long parseSnapshotSize(Cell c) throws org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException
org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException
static Scan createScanForNamespaceSnapshotSizes()
static Scan createScanForNamespaceSnapshotSizes(String namespace)
namespace
- name of the namespace whose snapshot entries are to be scannedstatic Scan createScanForSpaceSnapshotSizes()
static Scan createScanForSpaceSnapshotSizes(TableName table)
public static Map<String,Long> getObservedSnapshotSizes(Connection conn) throws IOException
IOException
public static org.apache.hbase.thirdparty.com.google.common.collect.Multimap<TableName,String> getTableSnapshots(Connection conn) throws IOException
conn
- connection to re-useIOException
public static Set<String> getNamespaceSnapshots(Connection conn) throws IOException
conn
- connection to re-useIOException
public static SpaceQuotaSnapshot getCurrentSnapshotFromQuotaTable(Connection conn, TableName tableName) throws IOException
tableName
from
QuotaTableUtil.QUOTA_TABLE_NAME
or null if the no quota information is available for
that tableName.conn
- connection to re-usetableName
- name of the table whose current snapshot is to be retreivedIOException
protected static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas quotasFromData(byte[] data) throws IOException
IOException
protected static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas quotasFromData(byte[] data, int offset, int length) throws IOException
IOException
protected static byte[] quotasToData(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas data) throws IOException
IOException
public static boolean isEmptyQuota(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas quotas)
protected static Result doGet(Connection connection, Get get) throws IOException
IOException
protected static Result[] doGet(Connection connection, List<Get> gets) throws IOException
IOException
protected static byte[] getUserRowKey(String user)
protected static byte[] getTableRowKey(TableName table)
protected static byte[] getNamespaceRowKey(String namespace)
protected static byte[] getRegionServerRowKey(String regionServer)
protected static byte[] getSettingsQualifierForUserTable(TableName tableName)
protected static byte[] getSettingsQualifierForUserNamespace(String namespace)
protected static String getUserRowKeyRegex(String user)
protected static String getTableRowKeyRegex(String table)
protected static String getNamespaceRowKeyRegex(String namespace)
private static String getRegionServerRowKeyRegex(String regionServer)
protected static byte[] getExceedThrottleQuotaRowKey()
private static String getRowKeyRegEx(byte[] prefix, String regex)
protected static String getSettingsQualifierRegexForUserTable(String table)
protected static String getSettingsQualifierRegexForUserNamespace(String namespace)
protected static boolean isNamespaceRowKey(byte[] key)
protected static String getNamespaceFromRowKey(byte[] key)
protected static boolean isRegionServerRowKey(byte[] key)
private static boolean isExceedThrottleQuotaRowKey(byte[] key)
protected static String getRegionServerFromRowKey(byte[] key)
protected static boolean isTableRowKey(byte[] key)
protected static TableName getTableFromRowKey(byte[] key)
protected static boolean isUserRowKey(byte[] key)
protected static String getUserFromRowKey(byte[] key)
protected static org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota getProtoViolationPolicy(SpaceViolationPolicy policy)
protected static SpaceViolationPolicy getViolationPolicy(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota proto)
protected static byte[] getSnapshotSizeQualifier(String snapshotName)
protected static String extractSnapshotNameFromSizeCell(Cell c)
protected static long extractSnapshotSize(byte[] data, int offset, int length) throws org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException
org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.