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
Nested ClassesModifier and TypeClassDescription(package private) static classA container which encapsulates the tables that have either a table quota or are contained in a namespace which have a namespace quota. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.apache.hadoop.conf.Configurationprivate final Connectionprivate static final org.slf4j.Loggerprivate final MetricsMasterprivate 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 Stringprivate final MasterQuotaManagerprivate final Map<String,SpaceQuotaSnapshot> private final Map<TableName,SpaceQuotaSnapshot> (package private) static final long(package private) static final Stringprivate final longprivate final SpaceQuotaSnapshotNotifierprivate final Map<TableName,SpaceQuotaSnapshot> private QuotaSnapshotStore<TableName> -
Constructor Summary
ConstructorsConstructorDescriptionQuotaObserverChore(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 voidchore()The task to execute on each scheduled execution of the Chore(package private) QuotaObserverChore.TablesWithQuotasComputes the set of all tables that have quotas defined.(package private) static longgetInitialDelay(org.apache.hadoop.conf.Configuration conf) Extracts the initial delay for the chore from the configuration.(package private) SpaceQuotaSnapshotgetNamespaceQuotaSnapshot(String namespace) Fetches theSpaceQuotaSnapshotfor the given namespace from this chore.Returns an unmodifiable view over the currentSpaceQuotaSnapshotobjects for each HBase namespace with a quota defined.(package private) QuotaSnapshotStore<String>(package private) static intgetPeriod(org.apache.hadoop.conf.Configuration conf) Extracts the period for the chore from the configuration.(package private) static DoublegetRegionReportPercent(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) SpaceQuotaSnapshotgetTableQuotaSnapshot(TableName table) Fetches theSpaceQuotaSnapshotfor the given table.Returns an unmodifiable view over the currentSpaceQuotaSnapshotobjects for each HBase table with a quota defined.(package private) QuotaSnapshotStore<TableName>(package private) static TimeUnitgetTimeUnit(org.apache.hadoop.conf.Configuration conf) Extracts the time unit for the chore period and initial delay from the configuration.(package private) voidinitializeSnapshotStores(Map<RegionInfo, Long> regionSizes) private booleanisDisableSpaceViolationPolicy(SpaceViolationPolicy currPolicy, SpaceViolationPolicy targetPolicy) Method to check whether we are dealing with DISABLESpaceViolationPolicy.(package private) voidprocessNamespacesWithQuotas(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) voidprocessTablesWithQuotas(Set<TableName> tablesWithTableQuotas) Processes eachTableNamewhich has a quota defined and moves it in or out of violation based on the space use.(package private) voidRemoves region reports over a certain age.(package private) voidsetNamespaceQuotaSnapshot(String namespace, SpaceQuotaSnapshot snapshot) Stores the givensnapshotfor the givennamespacein this chore.(package private) voidsetTableQuotaSnapshot(TableName table, SpaceQuotaSnapshot snapshot) Stores the quota state for the given table.(package private) voidupdateNamespaceQuota(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 thisnamespaceif necessary.(package private) voidupdateTableQuota(TableName table, SpaceQuotaSnapshot currentSnapshot, SpaceQuotaSnapshot targetSnapshot) Updates the hbase:quota table with the new quota policy for thistableif 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:ScheduledChoreThe task to execute on each scheduled execution of the Chore- Specified by:
chorein classScheduledChore
-
_chore
- Throws:
IOException
-
initializeSnapshotStores
-
processTablesWithQuotas
Processes eachTableNamewhich 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 thistableif 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 thisnamespaceif 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 currentSpaceQuotaSnapshotobjects for each HBase table with a quota defined. -
getNamespaceQuotaSnapshots
Returns an unmodifiable view over the currentSpaceQuotaSnapshotobjects for each HBase namespace with a quota defined. -
getTableQuotaSnapshot
Fetches theSpaceQuotaSnapshotfor the given table. -
setTableQuotaSnapshot
Stores the quota state for the given table. -
getNamespaceQuotaSnapshot
Fetches theSpaceQuotaSnapshotfor the given namespace from this chore. -
setNamespaceQuotaSnapshot
Stores the givensnapshotfor the givennamespacein 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_KEYmust correspond to aTimeUnitvalue.- 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.
-