@InterfaceAudience.Private public class FileArchiverNotifierImpl extends Object implements FileArchiverNotifier
Modifier and Type | Class and Description |
---|---|
static class |
FileArchiverNotifierImpl.QuotaSnapshotSizeSerializationException
An Exception thrown when SnapshotSize updates to hbase:quota fail to be written.
|
(package private) static class |
FileArchiverNotifierImpl.SnapshotWithSize
A struct encapsulating the name of a snapshot and its "size" on the filesystem.
|
(package private) static class |
FileArchiverNotifierImpl.StoreFileReference
A reference to a collection of files in the archive directory for a single region.
|
Modifier and Type | Field and Description |
---|---|
private org.apache.hadoop.conf.Configuration |
conf |
private Connection |
conn |
private List<String> |
currentSnapshots |
private org.apache.hadoop.fs.FileSystem |
fs |
private long |
lastFullCompute |
private static org.slf4j.Logger |
LOG |
private static Map<String,Object> |
NAMESPACE_LOCKS |
private ReentrantReadWriteLock.ReadLock |
readLock |
private TableName |
tn |
private ReentrantReadWriteLock.WriteLock |
writeLock |
Constructor and Description |
---|
FileArchiverNotifierImpl(Connection conn,
org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
TableName tn) |
Modifier and Type | Method and Description |
---|---|
void |
addArchivedFiles(Set<Map.Entry<String,Long>> fileSizes)
Records a file and its size in bytes being moved to the archive directory.
|
(package private) void |
bucketFilesToSnapshot(String snapshotName,
Map<String,Long> filesToUpdate,
Map<String,Long> snapshotSizeChanges)
For the given snapshot, find all files which this
snapshotName references. |
long |
computeAndStoreSnapshotSizes(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 by
this . |
(package private) long |
getLastFullCompute()
Returns a strictly-increasing measure of time extracted by
System.nanoTime() . |
(package private) static Object |
getLockForNamespace(String namespace) |
(package private) long |
getPreviousNamespaceSnapshotSize(Table quotaTable,
String namespace)
Fetches the current size of all snapshots in the given
namespace . |
(package private) long |
getSizeOfStoreFile(TableName tn,
FileArchiverNotifierImpl.StoreFileReference storeFileName)
Computes the size of the store files for a single region.
|
(package private) long |
getSizeOfStoreFile(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) long |
getSizeOfStoreFiles(TableName tn,
Set<FileArchiverNotifierImpl.StoreFileReference> storeFileNames)
Computes the size of each store file in
storeFileNames |
(package private) long |
getSnapshotSizeFromResult(Result r)
Extracts the size component from a serialized
SpaceQuotaSnapshot protobuf. |
(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 returns
true ). |
(package private) void |
groupArchivedFiledBySnapshotAndRecordSize(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) void |
persistSnapshotSizeChanges(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) void |
persistSnapshotSizes(Table table,
List<FileArchiverNotifierImpl.SnapshotWithSize> snapshotSizes)
Writes the snapshot sizes to the provided
table . |
String |
toString() |
private static final org.slf4j.Logger LOG
private final Connection conn
private final org.apache.hadoop.conf.Configuration conf
private final org.apache.hadoop.fs.FileSystem fs
private final ReentrantReadWriteLock.ReadLock readLock
private final ReentrantReadWriteLock.WriteLock writeLock
private volatile long lastFullCompute
private List<String> currentSnapshots
private static final Map<String,Object> NAMESPACE_LOCKS
public FileArchiverNotifierImpl(Connection conn, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, TableName tn)
static Object getLockForNamespace(String namespace)
long getLastFullCompute()
System.nanoTime()
.public void addArchivedFiles(Set<Map.Entry<String,Long>> fileSizes) throws IOException
FileArchiverNotifier
addArchivedFiles
in interface FileArchiverNotifier
fileSizes
- A collection of file name to size in bytesIOException
- If there was an IO-related error persisting the file size(s)void groupArchivedFiledBySnapshotAndRecordSize(List<String> snapshots, Set<Map.Entry<String,Long>> fileSizes) throws IOException
snapshots
- A collection of HBase snapshots to group the files intofileSizes
- A map of file names to their sizesIOException
void bucketFilesToSnapshot(String snapshotName, Map<String,Long> filesToUpdate, Map<String,Long> snapshotSizeChanges) throws IOException
snapshotName
references. After a file
is found to be referenced by the snapshot, it is removed from filesToUpdate
and
snapshotSizeChanges
is updated in concert.snapshotName
- The snapshot to checkfilesToUpdate
- A mapping of archived files to their sizesnapshotSizeChanges
- A mapping of snapshots and their change in sizeIOException
void persistSnapshotSizeChanges(Map<String,Long> snapshotSizeChanges) throws IOException
snapshotSizeChanges
- A map of snapshot name to size changeIOException
long getPreviousNamespaceSnapshotSize(Table quotaTable, String namespace) throws IOException
namespace
.quotaTable
- The HBase quota tablenamespace
- Namespace to fetch the sum of snapshot sizes forIOException
long getSnapshotSizeFromResult(Result r) throws org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException
SpaceQuotaSnapshot
protobuf.r
- A Result containing one cell with a SpaceQuotaSnapshot protobuforg.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException
public long computeAndStoreSnapshotSizes(Collection<String> currentSnapshots) throws IOException
FileArchiverNotifier
computeAndStoreSnapshotSizes
in interface FileArchiverNotifier
currentSnapshots
- the current list of snapshots against this tableIOException
- If there was an IO-related error computing or persisting the sizes.List<FileArchiverNotifierImpl.SnapshotWithSize> computeSnapshotSizes(List<String> snapshots) throws IOException
this
.snapshots
- A sorted list of snapshots against tn
.tn
.IOException
long getSizeOfStoreFiles(TableName tn, Set<FileArchiverNotifierImpl.StoreFileReference> storeFileNames)
storeFileNames
long getSizeOfStoreFile(TableName tn, FileArchiverNotifierImpl.StoreFileReference storeFileName)
long getSizeOfStoreFile(TableName tn, String regionName, String family, String storeFile)
Set<FileArchiverNotifierImpl.StoreFileReference> getStoreFilesFromSnapshot(SnapshotManifest manifest, Predicate<String> filter)
true
).void persistSnapshotSizes(Table table, List<FileArchiverNotifierImpl.SnapshotWithSize> snapshotSizes) throws IOException
table
.IOException
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.