@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 |
---|---|
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 |
---|---|
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 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.
|
static Map<String,Long> |
getObservedSnapshotSizes(Connection conn)
Fetches any persisted HBase snapshot sizes stored in the quota table.
|
protected static QuotaProtos.SpaceQuota |
getProtoViolationPolicy(SpaceViolationPolicy policy) |
static Map<TableName,SpaceQuotaSnapshot> |
getRegionServerQuotaSnapshots(Connection conn,
ServerName regionServer)
Fetches the observed
SpaceQuotaSnapshot s observed by a RegionServer. |
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 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 QuotaProtos.Quotas |
getUserQuota(Connection connection,
String user) |
static QuotaProtos.Quotas |
getUserQuota(Connection connection,
String user,
String namespace) |
static 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(QuotaProtos.SpaceQuota proto) |
static boolean |
isEmptyQuota(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) |
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) |
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 QuotaProtos.Quotas |
quotasFromData(byte[] data) |
protected static QuotaProtos.Quotas |
quotasFromData(byte[] data,
int offset,
int length) |
protected static byte[] |
quotasToData(QuotaProtos.Quotas data) |
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 static QuotaProtos.Quotas getTableQuota(Connection connection, TableName table) throws IOException
IOException
public static QuotaProtos.Quotas getNamespaceQuota(Connection connection, String namespace) throws IOException
IOException
public static QuotaProtos.Quotas getUserQuota(Connection connection, String user) throws IOException
IOException
public static QuotaProtos.Quotas getUserQuota(Connection connection, String user, TableName table) throws IOException
IOException
public static QuotaProtos.Quotas getUserQuota(Connection connection, String user, String namespace) throws IOException
IOException
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
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 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 QuotaProtos.Quotas quotasFromData(byte[] data) throws IOException
IOException
protected static QuotaProtos.Quotas quotasFromData(byte[] data, int offset, int length) throws IOException
IOException
protected static byte[] quotasToData(QuotaProtos.Quotas data) throws IOException
IOException
public static boolean isEmptyQuota(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 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 QuotaProtos.SpaceQuota getProtoViolationPolicy(SpaceViolationPolicy policy)
protected static SpaceViolationPolicy getViolationPolicy(QuotaProtos.SpaceQuota proto)
protected static byte[] getSnapshotSizeQualifier(String snapshotName)
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 Cloudera. All rights reserved.