Package org.apache.hadoop.hbase.quotas
Class QuotaObserverChore
java.lang.Object
org.apache.hadoop.hbase.ScheduledChore
org.apache.hadoop.hbase.quotas.QuotaObserverChore
- All Implemented Interfaces:
Runnable
Reads the currently received Region filesystem-space use reports and acts on those which violate
a defined quota.
-
Nested Class Summary
Modifier and TypeClassDescription(package private) static class
A container which encapsulates the tables that have either a table quota or are contained in a namespace which have a namespace quota. -
Field Summary
Modifier and TypeFieldDescriptionprivate final org.apache.hadoop.conf.Configuration
private final Connection
private static final org.slf4j.Logger
private final MetricsMaster
private final Map<String,
SpaceQuotaSnapshot> private QuotaSnapshotStore<String>
(package private) static final long
(package private) static final String
(package private) static final int
(package private) static final String
(package private) static final double
(package private) static final String
(package private) static final String
(package private) static final String
private final MasterQuotaManager
private final Map<String,
SpaceQuotaSnapshot> private final Map<TableName,
SpaceQuotaSnapshot> (package private) static final long
(package private) static final String
private final long
private final SpaceQuotaSnapshotNotifier
private final Map<TableName,
SpaceQuotaSnapshot> private QuotaSnapshotStore<TableName>
-
Constructor Summary
ConstructorDescriptionQuotaObserverChore
(Connection conn, org.apache.hadoop.conf.Configuration conf, SpaceQuotaSnapshotNotifier snapshotNotifier, MasterQuotaManager quotaManager, Stoppable stopper, MetricsMaster metrics) QuotaObserverChore
(HMaster master, MetricsMaster metrics) -
Method Summary
Modifier and TypeMethodDescription(package private) void
_chore()
protected void
chore()
The task to execute on each scheduled execution of the Chore(package private) QuotaObserverChore.TablesWithQuotas
Computes the set of all tables that have quotas defined.(package private) static long
getInitialDelay
(org.apache.hadoop.conf.Configuration conf) Extracts the initial delay for the chore from the configuration.(package private) SpaceQuotaSnapshot
getNamespaceQuotaSnapshot
(String namespace) Fetches theSpaceQuotaSnapshot
for the given namespace from this chore.Returns an unmodifiable view over the currentSpaceQuotaSnapshot
objects for each HBase namespace with a quota defined.(package private) QuotaSnapshotStore<String>
(package private) static int
getPeriod
(org.apache.hadoop.conf.Configuration conf) Extracts the period for the chore from the configuration.(package private) static Double
getRegionReportPercent
(org.apache.hadoop.conf.Configuration conf) Extracts the percent of Regions for a table to have been reported to enable quota violation state change.(package private) SpaceQuotaSnapshot
getTableQuotaSnapshot
(TableName table) Fetches theSpaceQuotaSnapshot
for the given table.Returns an unmodifiable view over the currentSpaceQuotaSnapshot
objects for each HBase table with a quota defined.(package private) QuotaSnapshotStore<TableName>
(package private) static TimeUnit
getTimeUnit
(org.apache.hadoop.conf.Configuration conf) Extracts the time unit for the chore period and initial delay from the configuration.(package private) void
initializeSnapshotStores
(Map<RegionInfo, Long> regionSizes) private boolean
isDisableSpaceViolationPolicy
(SpaceViolationPolicy currPolicy, SpaceViolationPolicy targetPolicy) Method to check whether we are dealing with DISABLESpaceViolationPolicy
.(package private) void
processNamespacesWithQuotas
(Set<String> namespacesWithQuotas, org.apache.hbase.thirdparty.com.google.common.collect.Multimap<String, TableName> tablesByNamespace) Processes each namespace which has a quota defined and moves all of the tables contained in that namespace into or out of violation of the quota.(package private) void
processTablesWithQuotas
(Set<TableName> tablesWithTableQuotas) Processes eachTableName
which has a quota defined and moves it in or out of violation based on the space use.(package private) void
Removes region reports over a certain age.(package private) void
setNamespaceQuotaSnapshot
(String namespace, SpaceQuotaSnapshot snapshot) Stores the givensnapshot
for the givennamespace
in this chore.(package private) void
setTableQuotaSnapshot
(TableName table, SpaceQuotaSnapshot snapshot) Stores the quota state for the given table.(package private) void
updateNamespaceQuota
(String namespace, SpaceQuotaSnapshot currentSnapshot, SpaceQuotaSnapshot targetSnapshot, org.apache.hbase.thirdparty.com.google.common.collect.Multimap<String, TableName> tablesByNamespace) Updates the hbase:quota table with the target quota policy for thisnamespace
if necessary.(package private) void
updateTableQuota
(TableName table, SpaceQuotaSnapshot currentSnapshot, SpaceQuotaSnapshot targetSnapshot) Updates the hbase:quota table with the new quota policy for thistable
if necessary.Methods inherited from class org.apache.hadoop.hbase.ScheduledChore
cancel, cancel, choreForTesting, cleanup, getInitialDelay, getName, getPeriod, getStopper, getTimeUnit, initialChore, isInitialChoreComplete, isScheduled, run, shutdown, shutdown, toString, triggerNow
-
Field Details
-
LOG
-
QUOTA_OBSERVER_CHORE_PERIOD_KEY
- See Also:
-
QUOTA_OBSERVER_CHORE_PERIOD_DEFAULT
- See Also:
-
QUOTA_OBSERVER_CHORE_DELAY_KEY
- See Also:
-
QUOTA_OBSERVER_CHORE_DELAY_DEFAULT
- See Also:
-
QUOTA_OBSERVER_CHORE_TIMEUNIT_KEY
- See Also:
-
QUOTA_OBSERVER_CHORE_TIMEUNIT_DEFAULT
-
QUOTA_OBSERVER_CHORE_REPORT_PERCENT_KEY
- See Also:
-
QUOTA_OBSERVER_CHORE_REPORT_PERCENT_DEFAULT
- See Also:
-
REGION_REPORT_RETENTION_DURATION_KEY
- See Also:
-
REGION_REPORT_RETENTION_DURATION_DEFAULT
- See Also:
-
conn
-
conf
-
quotaManager
-
metrics
-
snapshotNotifier
-
tableQuotaSnapshots
-
readOnlyTableQuotaSnapshots
-
namespaceQuotaSnapshots
-
readOnlyNamespaceSnapshots
-
regionReportLifetimeMillis
-
tableSnapshotStore
-
namespaceSnapshotStore
-
-
Constructor Details
-
QuotaObserverChore
-
QuotaObserverChore
QuotaObserverChore(Connection conn, org.apache.hadoop.conf.Configuration conf, SpaceQuotaSnapshotNotifier snapshotNotifier, MasterQuotaManager quotaManager, Stoppable stopper, MetricsMaster metrics)
-
-
Method Details
-
chore
Description copied from class:ScheduledChore
The task to execute on each scheduled execution of the Chore- Specified by:
chore
in classScheduledChore
-
_chore
- Throws:
IOException
-
initializeSnapshotStores
-
processTablesWithQuotas
Processes eachTableName
which has a quota defined and moves it in or out of violation based on the space use.- Parameters:
tablesWithTableQuotas
- The HBase tables which have quotas defined- Throws:
IOException
-
processNamespacesWithQuotas
void processNamespacesWithQuotas(Set<String> namespacesWithQuotas, org.apache.hbase.thirdparty.com.google.common.collect.Multimap<String, TableName> tablesByNamespace) throws IOExceptionProcesses each namespace which has a quota defined and moves all of the tables contained in that namespace into or out of violation of the quota. Tables which are already in violation of a quota at the table level which also have a reside in a namespace with a violated quota will not have the namespace quota enacted. The table quota takes priority over the namespace quota.- Parameters:
namespacesWithQuotas
- The set of namespaces that have quotas definedtablesByNamespace
- A mapping of namespaces and the tables contained in those namespaces- Throws:
IOException
-
updateTableQuota
void updateTableQuota(TableName table, SpaceQuotaSnapshot currentSnapshot, SpaceQuotaSnapshot targetSnapshot) throws IOException Updates the hbase:quota table with the new quota policy for thistable
if necessary.- Parameters:
table
- The table being checkedcurrentSnapshot
- The state of the quota on this table from the previous invocation.targetSnapshot
- The state the quota should be in for this table.- Throws:
IOException
-
isDisableSpaceViolationPolicy
private boolean isDisableSpaceViolationPolicy(SpaceViolationPolicy currPolicy, SpaceViolationPolicy targetPolicy) Method to check whether we are dealing with DISABLESpaceViolationPolicy
. In such a case, currPolicy or/and targetPolicy will be having DISABLE policy.- Parameters:
currPolicy
- currently set space violation policytargetPolicy
- new space violation policy- Returns:
- true if is DISABLE space violation policy; otherwise false
-
updateNamespaceQuota
void updateNamespaceQuota(String namespace, SpaceQuotaSnapshot currentSnapshot, SpaceQuotaSnapshot targetSnapshot, org.apache.hbase.thirdparty.com.google.common.collect.Multimap<String, TableName> tablesByNamespace) throws IOExceptionUpdates the hbase:quota table with the target quota policy for thisnamespace
if necessary.- Parameters:
namespace
- The namespace being checkedcurrentSnapshot
- The state of the quota on this namespace from the previous invocationtargetSnapshot
- The state the quota should be in for this namespacetablesByNamespace
- A mapping of tables in namespaces.- Throws:
IOException
-
pruneOldRegionReports
void pruneOldRegionReports()Removes region reports over a certain age. -
fetchAllTablesWithQuotasDefined
Computes the set of all tables that have quotas defined. This includes tables with quotas explicitly set on them, in addition to tables that exist namespaces which have a quota defined.- Throws:
IOException
-
getTableSnapshotStore
-
getNamespaceSnapshotStore
-
getTableQuotaSnapshots
Returns an unmodifiable view over the currentSpaceQuotaSnapshot
objects for each HBase table with a quota defined. -
getNamespaceQuotaSnapshots
Returns an unmodifiable view over the currentSpaceQuotaSnapshot
objects for each HBase namespace with a quota defined. -
getTableQuotaSnapshot
Fetches theSpaceQuotaSnapshot
for the given table. -
setTableQuotaSnapshot
Stores the quota state for the given table. -
getNamespaceQuotaSnapshot
Fetches theSpaceQuotaSnapshot
for the given namespace from this chore. -
setNamespaceQuotaSnapshot
Stores the givensnapshot
for the givennamespace
in this chore. -
getPeriod
Extracts the period for the chore from the configuration.- Parameters:
conf
- The configuration object.- Returns:
- The configured chore period or the default value in the given timeunit.
- See Also:
-
getInitialDelay
Extracts the initial delay for the chore from the configuration.- Parameters:
conf
- The configuration object.- Returns:
- The configured chore initial delay or the default value in the given timeunit.
- See Also:
-
getTimeUnit
Extracts the time unit for the chore period and initial delay from the configuration. The configuration value forQUOTA_OBSERVER_CHORE_TIMEUNIT_KEY
must correspond to aTimeUnit
value.- Parameters:
conf
- The configuration object.- Returns:
- The configured time unit for the chore period and initial delay or the default value.
-
getRegionReportPercent
Extracts the percent of Regions for a table to have been reported to enable quota violation state change.- Parameters:
conf
- The configuration object.- Returns:
- The percent of regions reported to use.
-