Package org.apache.hadoop.hbase.quotas
Class FileArchiverNotifierImpl
java.lang.Object
org.apache.hadoop.hbase.quotas.FileArchiverNotifierImpl
- All Implemented Interfaces:
FileArchiverNotifier
Tracks file archiving and updates the hbase quota table.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn Exception thrown when SnapshotSize updates to hbase:quota fail to be written.(package private) static classA struct encapsulating the name of a snapshot and its "size" on the filesystem.(package private) static classA reference to a collection of files in the archive directory for a single region. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.apache.hadoop.conf.Configurationprivate final Connectionprivate final org.apache.hadoop.fs.FileSystemprivate longprivate static final org.slf4j.Loggerprivate final ReentrantReadWriteLock.ReadLockprivate final TableNameprivate final ReentrantReadWriteLock.WriteLock -
Constructor Summary
ConstructorsConstructorDescriptionFileArchiverNotifierImpl(Connection conn, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, TableName tn) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddArchivedFiles(Set<Map.Entry<String, Long>> fileSizes) Records a file and its size in bytes being moved to the archive directory.(package private) voidbucketFilesToSnapshot(String snapshotName, Map<String, Long> filesToUpdate, Map<String, Long> snapshotSizeChanges) For the given snapshot, find all files which thissnapshotNamereferences.longcomputeAndStoreSnapshotSizes(Collection<String> currentSnapshots) Computes the size of a table and all of its snapshots, recording new "full" sizes for each.(package private) List<FileArchiverNotifierImpl.SnapshotWithSize>computeSnapshotSizes(List<String> snapshots) Computes the size of each snapshot against the table referenced bythis.(package private) longReturns a strictly-increasing measure of time extracted bySystem.nanoTime().(package private) static ObjectgetLockForNamespace(String namespace) (package private) longgetPreviousNamespaceSnapshotSize(Table quotaTable, String namespace) Fetches the current size of all snapshots in the givennamespace.(package private) longgetSizeOfStoreFile(TableName tn, String regionName, String family, String storeFile) Computes the size of the store file given its name, region and family name in the archive directory.(package private) longgetSizeOfStoreFile(TableName tn, FileArchiverNotifierImpl.StoreFileReference storeFileName) Computes the size of the store files for a single region.(package private) longgetSizeOfStoreFiles(TableName tn, Set<FileArchiverNotifierImpl.StoreFileReference> storeFileNames) Computes the size of each store file instoreFileNames(package private) longExtracts the size component from a serializedSpaceQuotaSnapshotprotobuf.(package private) Set<FileArchiverNotifierImpl.StoreFileReference>getStoreFilesFromSnapshot(SnapshotManifest manifest, Predicate<String> filter) Extracts the names of the store files referenced by this snapshot which satisfy the given predicate (the predicate returnstrue).(package private) voidgroupArchivedFiledBySnapshotAndRecordSize(List<String> snapshots, Set<Map.Entry<String, Long>> fileSizes) For each file in the map, this updates the first snapshot (lexicographic snapshot name) that references this file.(package private) voidpersistSnapshotSizeChanges(Map<String, Long> snapshotSizeChanges) Reads the current size for each snapshot to update, generates a new update based on that value, and then writes the new update.(package private) voidpersistSnapshotSizes(Table table, List<FileArchiverNotifierImpl.SnapshotWithSize> snapshotSizes) Writes the snapshot sizes to the providedtable.toString()
-
Field Details
-
LOG
-
conn
-
conf
-
fs
-
tn
-
readLock
-
writeLock
-
lastFullCompute
-
currentSnapshots
-
NAMESPACE_LOCKS
-
-
Constructor Details
-
FileArchiverNotifierImpl
public FileArchiverNotifierImpl(Connection conn, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, TableName tn)
-
-
Method Details
-
getLockForNamespace
-
getLastFullCompute
long getLastFullCompute()Returns a strictly-increasing measure of time extracted bySystem.nanoTime(). -
addArchivedFiles
Description copied from interface:FileArchiverNotifierRecords a file and its size in bytes being moved to the archive directory.- Specified by:
addArchivedFilesin interfaceFileArchiverNotifier- Parameters:
fileSizes- A collection of file name to size in bytes- Throws:
IOException- If there was an IO-related error persisting the file size(s)
-
groupArchivedFiledBySnapshotAndRecordSize
void groupArchivedFiledBySnapshotAndRecordSize(List<String> snapshots, Set<Map.Entry<String, Long>> fileSizes) throws IOExceptionFor each file in the map, this updates the first snapshot (lexicographic snapshot name) that references this file. The result of this computation is serialized to the quota table.- Parameters:
snapshots- A collection of HBase snapshots to group the files intofileSizes- A map of file names to their sizes- Throws:
IOException
-
bucketFilesToSnapshot
void bucketFilesToSnapshot(String snapshotName, Map<String, Long> filesToUpdate, Map<String, throws IOExceptionLong> snapshotSizeChanges) For the given snapshot, find all files which thissnapshotNamereferences. After a file is found to be referenced by the snapshot, it is removed fromfilesToUpdateandsnapshotSizeChangesis updated in concert.- Parameters:
snapshotName- The snapshot to checkfilesToUpdate- A mapping of archived files to their sizesnapshotSizeChanges- A mapping of snapshots and their change in size- Throws:
IOException
-
persistSnapshotSizeChanges
Reads the current size for each snapshot to update, generates a new update based on that value, and then writes the new update.- Parameters:
snapshotSizeChanges- A map of snapshot name to size change- Throws:
IOException
-
getPreviousNamespaceSnapshotSize
Fetches the current size of all snapshots in the givennamespace.- Parameters:
quotaTable- The HBase quota tablenamespace- Namespace to fetch the sum of snapshot sizes for- Returns:
- The size of all snapshot sizes for the namespace in bytes.
- Throws:
IOException
-
getSnapshotSizeFromResult
long getSnapshotSizeFromResult(Result r) throws org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException Extracts the size component from a serializedSpaceQuotaSnapshotprotobuf.- Parameters:
r- A Result containing one cell with a SpaceQuotaSnapshot protobuf- Returns:
- The size in bytes of the snapshot.
- Throws:
org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException
-
computeAndStoreSnapshotSizes
Description copied from interface:FileArchiverNotifierComputes the size of a table and all of its snapshots, recording new "full" sizes for each.- Specified by:
computeAndStoreSnapshotSizesin interfaceFileArchiverNotifier- Parameters:
currentSnapshots- the current list of snapshots against this table- Returns:
- The total size of all snapshots against this table.
- Throws:
IOException- If there was an IO-related error computing or persisting the sizes.
-
toString
-
computeSnapshotSizes
List<FileArchiverNotifierImpl.SnapshotWithSize> computeSnapshotSizes(List<String> snapshots) throws IOException Computes the size of each snapshot against the table referenced bythis.- Parameters:
snapshots- A sorted list of snapshots againsttn.- Returns:
- A list of the size for each snapshot against
tn. - Throws:
IOException
-
getSizeOfStoreFiles
long getSizeOfStoreFiles(TableName tn, Set<FileArchiverNotifierImpl.StoreFileReference> storeFileNames) Computes the size of each store file instoreFileNames -
getSizeOfStoreFile
Computes the size of the store files for a single region. -
getSizeOfStoreFile
Computes the size of the store file given its name, region and family name in the archive directory. -
getStoreFilesFromSnapshot
Set<FileArchiverNotifierImpl.StoreFileReference> getStoreFilesFromSnapshot(SnapshotManifest manifest, Predicate<String> filter) Extracts the names of the store files referenced by this snapshot which satisfy the given predicate (the predicate returnstrue). -
persistSnapshotSizes
void persistSnapshotSizes(Table table, List<FileArchiverNotifierImpl.SnapshotWithSize> snapshotSizes) throws IOException Writes the snapshot sizes to the providedtable.- Throws:
IOException
-