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 SummaryNested 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 SummaryFieldsModifier 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 SummaryConstructorsConstructorDescriptionQuotaObserverChore(Connection conn, org.apache.hadoop.conf.Configuration conf, SpaceQuotaSnapshotNotifier snapshotNotifier, MasterQuotaManager quotaManager, Stoppable stopper, MetricsMaster metrics) QuotaObserverChore(HMaster master, MetricsMaster metrics) 
- 
Method SummaryModifier 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.ScheduledChorecancel, 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
- 
QuotaObserverChoreQuotaObserverChore(Connection conn, org.apache.hadoop.conf.Configuration conf, SpaceQuotaSnapshotNotifier snapshotNotifier, MasterQuotaManager quotaManager, Stoppable stopper, MetricsMaster metrics) 
 
- 
- 
Method Details- 
choreDescription copied from class:ScheduledChoreThe task to execute on each scheduled execution of the Chore- Specified by:
- chorein class- ScheduledChore
 
- 
_chore- Throws:
- IOException
 
- 
initializeSnapshotStores
- 
processTablesWithQuotasProcesses 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
 
- 
processNamespacesWithQuotasvoid 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 defined
- tablesByNamespace- A mapping of namespaces and the tables contained in those namespaces
- Throws:
- IOException
 
- 
updateTableQuotavoid 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 checked
- currentSnapshot- 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
 
- 
isDisableSpaceViolationPolicyprivate 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 policy
- targetPolicy- new space violation policy
- Returns:
- true if is DISABLE space violation policy; otherwise false
 
- 
updateNamespaceQuotavoid 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 checked
- currentSnapshot- The state of the quota on this namespace from the previous invocation
- targetSnapshot- The state the quota should be in for this namespace
- tablesByNamespace- A mapping of tables in namespaces.
- Throws:
- IOException
 
- 
pruneOldRegionReportsvoid pruneOldRegionReports()Removes region reports over a certain age.
- 
fetchAllTablesWithQuotasDefinedComputes 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
- 
getTableQuotaSnapshotsReturns an unmodifiable view over the currentSpaceQuotaSnapshotobjects for each HBase table with a quota defined.
- 
getNamespaceQuotaSnapshotsReturns an unmodifiable view over the currentSpaceQuotaSnapshotobjects for each HBase namespace with a quota defined.
- 
getTableQuotaSnapshotFetches theSpaceQuotaSnapshotfor the given table.
- 
setTableQuotaSnapshotStores the quota state for the given table.
- 
getNamespaceQuotaSnapshotFetches theSpaceQuotaSnapshotfor the given namespace from this chore.
- 
setNamespaceQuotaSnapshotStores the givensnapshotfor the givennamespacein this chore.
- 
getPeriodExtracts 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:
 
- 
getInitialDelayExtracts 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:
 
- 
getTimeUnitExtracts 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.
 
- 
getRegionReportPercentExtracts 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.
 
 
-