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
Modifier and TypeClassDescription(package private) static class
Compare HRegionInfos in a way that has split parents sort BEFORE their daughters. -
Field Summary
Modifier and TypeFieldDescriptionprivate final AtomicBoolean
static final int
private final AtomicBoolean
private CatalogJanitorReport
Saved report from last hbase:meta scan to completion.private static final org.slf4j.Logger
private final MasterServices
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static void
checkRegionReferences
(MasterServices services, TableName tableName, RegionInfo region) Checks if a region still holds references to parent.protected void
chore()
The task to execute on each scheduled execution of the Chore(package private) static boolean
cleanMergeRegion
(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 boolean
cleanParent
(RegionInfo parent, Result rowContent) If daughters no longer hold reference to the parents, delete the parent.(package private) static boolean
cleanParent
(MasterServices services, RegionInfo parent, Result rowContent) boolean
Returns Returns last published Report that comes of last successful scan of hbase:meta.private static boolean
protected boolean
Override to run a task before we start looping.private static boolean
private static boolean
static void
For testing against a cluster.int
scan()
Run janitorial scan of cataloghbase:meta
table looking for garbage to collect.protected CatalogJanitorReport
Scan hbase:meta.boolean
setEnabled
(boolean enabled) private void
Methods 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:ScheduledChore
Override to run a task before we start looping.- Overrides:
initialChore
in classScheduledChore
- Returns:
- true if initial chore was successful
-
setEnabled
-
getEnabled
-
chore
Description copied from class:ScheduledChore
The task to execute on each scheduled execution of the Chore- Specified by:
chore
in classScheduledChore
-
isMetaLoaded
-
isRIT
-
scan
Run janitorial scan of cataloghbase:meta
table 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 ofparent
row inmetaRegionName
- Returns:
- True if we removed
parent
from 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
p
signifies 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
-