@InterfaceAudience.Private @InterfaceStability.Evolving public class QuotaTableUtil extends Object
ROW-KEY | FAM/QUAL | DATA |
---|---|---|
n.<namespace> | q:s | <global-quotas> |
n.<namespace> | u:p | <namespace-quota policy> |
n.<namespace> | u:s | <SpaceQuotaSnapshot> |
t.<table> | q:s | <global-quotas> |
t.<table> | u:p | <table-quota policy> |
t.<table> | u:ss.<snapshot name> | <SpaceQuotaSnapshot> |
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 |
static interface |
QuotaTableUtil.TableQuotasVisitor |
static interface |
QuotaTableUtil.UserQuotasVisitor |
Modifier and Type | Field and Description |
---|---|
private static org.slf4j.Logger |
LOG |
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 |
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 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 |
createScanForSpaceSnapshotSizes() |
(package private) static Scan |
createScanForSpaceSnapshotSizes(TableName table) |
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 |
getCurrentSnapshot(Connection conn,
String namespace)
Returns the Master's view of a quota on the given
namespace or null if the
Master has no quota information on that namespace. |
static SpaceQuotaSnapshot |
getCurrentSnapshot(Connection conn,
TableName tn)
Returns the Master's view of a quota on the given
tableName or null if the
Master has no quota information on that table. |
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. |
static Map<TableName,Long> |
getMasterReportedTableSizes(Connection conn)
Fetches the table sizes on the filesystem as tracked by the HBase Master.
|
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) |
(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) |
static Map<TableName,SpaceQuotaSnapshot> |
getRegionServerQuotaSnapshots(Connection conn,
ServerName regionServer)
Fetches the observed
SpaceQuotaSnapshot s observed by a 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) |
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) |
protected static boolean |
isNamespaceRowKey(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) |
(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) |
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
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
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 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
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 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 createScanForSpaceSnapshotSizes()
static Scan createScanForSpaceSnapshotSizes(TableName table)
public static Map<String,Long> getObservedSnapshotSizes(Connection conn) throws IOException
IOException
public static Map<TableName,Long> getMasterReportedTableSizes(Connection conn) throws IOException
IOException
public static Map<TableName,SpaceQuotaSnapshot> getRegionServerQuotaSnapshots(Connection conn, ServerName regionServer) throws IOException
SpaceQuotaSnapshot
s observed by a RegionServer.IOException
public static SpaceQuotaSnapshot getCurrentSnapshot(Connection conn, TableName tn) throws IOException
tableName
or null if the
Master has no quota information on that table.IOException
public static SpaceQuotaSnapshot getCurrentSnapshot(Connection conn, String namespace) throws IOException
namespace
or null if the
Master has no quota information on that namespace.IOException
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[] 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 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 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–2019 The Apache Software Foundation. All rights reserved.