Class CatalogJanitor
java.lang.Object
org.apache.hadoop.hbase.ScheduledChore
org.apache.hadoop.hbase.master.janitor.CatalogJanitor
- All Implemented Interfaces:
Runnable
A janitor for the catalog tables. Scans the
hbase:meta catalog table on a period.
Makes a lastReport on state of hbase:meta. Looks for unused regions to garbage collect. Scan of
hbase:meta runs if we are NOT in maintenance mode, if we are NOT shutting down, AND if the
assignmentmanager is loaded. Playing it safe, we will garbage collect no-longer needed region
references only if there are no regions-in-transition (RIT).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classCompare HRegionInfos in a way that has split parents sort BEFORE their daughters. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicBooleanstatic final intprivate final AtomicBooleanprivate CatalogJanitorReportSaved report from last hbase:meta scan to completion.private static final org.slf4j.Loggerprivate final MasterServices -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidcheckRegionReferences(MasterServices services, TableName tableName, RegionInfo region) Checks if a region still holds references to parent.protected voidchore()The task to execute on each scheduled execution of the Chore(package private) static booleancleanMergeRegion(MasterServices services, RegionInfo mergedRegion, List<RegionInfo> parents) If merged region no longer holds reference to the merge regions, archive merge region on hdfs and perform deleting references in hbase:metaprivate booleancleanParent(RegionInfo parent, Result rowContent) If daughters no longer hold reference to the parents, delete the parent.(package private) static booleancleanParent(MasterServices services, RegionInfo parent, Result rowContent) booleanReturns Returns last published Report that comes of last successful scan of hbase:meta.private static booleanprotected booleanOverride to run a task before we start looping.private static booleanprivate static booleanstatic voidFor testing against a cluster.intscan()Run janitorial scan of cataloghbase:metatable looking for garbage to collect.protected CatalogJanitorReportScan hbase:meta.booleansetEnabled(boolean enabled) private voidMethods inherited from class org.apache.hadoop.hbase.ScheduledChore
cancel, cancel, choreForTesting, cleanup, getInitialDelay, getName, getPeriod, getStopper, getTimeUnit, isInitialChoreComplete, isScheduled, run, shutdown, shutdown, toString, triggerNow
-
Field Details
-
DEFAULT_HBASE_CATALOGJANITOR_INTERVAL
- See Also:
-
LOG
-
alreadyRunning
-
enabled
-
services
-
lastReport
Saved report from last hbase:meta scan to completion. May be stale if having trouble completing scan. Check its date.
-
-
Constructor Details
-
CatalogJanitor
-
-
Method Details
-
initialChore
Description copied from class:ScheduledChoreOverride to run a task before we start looping.- Overrides:
initialChorein classScheduledChore- Returns:
- true if initial chore was successful
-
setEnabled
-
getEnabled
-
chore
Description copied from class:ScheduledChoreThe task to execute on each scheduled execution of the Chore- Specified by:
chorein classScheduledChore
-
isMetaLoaded
-
isRIT
-
scan
Run janitorial scan of cataloghbase:metatable looking for garbage to collect.- Returns:
- How many items gc'd whether for merge or split. Returns -1 if previous scan is in progress.
- Throws:
IOException
-
scanForReport
Scan hbase:meta.- Returns:
- Return generated
CatalogJanitorReport - Throws:
IOException
-
getLastReport
Returns Returns last published Report that comes of last successful scan of hbase:meta. -
cleanMergeRegion
static boolean cleanMergeRegion(MasterServices services, RegionInfo mergedRegion, List<RegionInfo> parents) throws IOException If merged region no longer holds reference to the merge regions, archive merge region on hdfs and perform deleting references in hbase:meta- Returns:
- true if we delete references in merged region on hbase:meta and archive the files on the file system
- Throws:
IOException
-
cleanParent
static boolean cleanParent(MasterServices services, RegionInfo parent, Result rowContent) throws IOException - Throws:
IOException
-
cleanParent
If daughters no longer hold reference to the parents, delete the parent.- Parameters:
parent- RegionInfo of split offlined parentrowContent- Content ofparentrow inmetaRegionName- Returns:
- True if we removed
parentfrom meta table and from the filesystem. - Throws:
IOException
-
hasNoReferences
- Parameters:
p- A pair where the first boolean says whether or not the daughter region directory exists in the filesystem and then the second boolean says whether the daughter has references to the parent.- Returns:
- True the passed
psignifies no references.
-
checkRegionReferences
private static Pair<Boolean,Boolean> checkRegionReferences(MasterServices services, TableName tableName, RegionInfo region) throws IOException Checks if a region still holds references to parent.- Parameters:
tableName- The table for the regionregion- The region to check- Returns:
- A pair where the first boolean says whether the region directory exists in the filesystem and then the second boolean says whether the region has references to a parent.
- Throws:
IOException
-
updateAssignmentManagerMetrics
-
checkLog4jProperties
-
main
For testing against a cluster. Doesn't have a MasterServices context so does not report on good vs bad servers.- Throws:
IOException
-