@InterfaceAudience.Private public class HStore extends Object implements Store, HeapSize, StoreConfigInformation, PropagatingConfigurationObserver
There's no reason to consider append-logging at this level; all logging and locking is handled at the HRegion level. Store just provides services to manage sets of StoreFiles. One of the most important of those services is compaction services where files are aggregated once they pass a configurable threshold.
Locking and transactions are handled at a higher level. This API should not be called directly but by an HRegion manager.
Modifier and Type | Class and Description |
---|---|
private class |
HStore.StoreFlusherImpl |
NO_PRIORITY, PRIORITY_USER
Modifier | Constructor and Description |
---|---|
protected |
HStore(HRegion region,
ColumnFamilyDescriptor family,
org.apache.hadoop.conf.Configuration confParam,
boolean warmup)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
add(Cell cell,
MemStoreSizing memstoreSizing)
Adds a value to the memstore
|
void |
add(Iterable<Cell> cells,
MemStoreSizing memstoreSizing)
Adds the specified value to the memstore
|
void |
addChangedReaderObserver(ChangedReadersObserver o) |
private void |
addToCompactingFiles(Collection<HStoreFile> filesToAdd)
Adds the files to compacting files.
|
boolean |
areWritesEnabled() |
void |
assertBulkLoadHFileOk(org.apache.hadoop.fs.Path srcPath)
This throws a WrongRegionException if the HFile does not fit in this region, or an
InvalidHFileException if the HFile is not valid.
|
org.apache.hadoop.fs.Path |
bulkLoadHFile(byte[] family,
String srcPathStr,
org.apache.hadoop.fs.Path dstPath) |
private void |
bulkLoadHFile(HStoreFile sf) |
void |
bulkLoadHFile(StoreFileInfo fileInfo) |
void |
cancelRequestedCompaction(CompactionContext compaction) |
boolean |
canSplit()
Returns whether this store is splittable, i.e., no reference file in this store.
|
private static void |
clearAndClose(List<KeyValueScanner> scanners) |
private void |
clearCompactedfiles(List<HStoreFile> filesToRemove) |
org.apache.hbase.thirdparty.com.google.common.collect.ImmutableCollection<HStoreFile> |
close()
Close all the readers We don't need to worry about subsequent requests because the Region holds
a write lock that will prevent any more reads or writes.
|
void |
closeAndArchiveCompactedFiles()
Closes and archives the compacted files under this store
|
private HStoreFile |
commitFile(org.apache.hadoop.fs.Path path,
long logCacheFlushId,
MonitoredTask status) |
List<HStoreFile> |
compact(CompactionContext compaction,
ThroughputController throughputController,
User user)
Compact the StoreFiles.
|
void |
compactRecentForTestingAssumingDefaultPolicy(int N)
This method tries to compact N recent files for testing.
|
protected void |
completeCompaction(Collection<HStoreFile> compactedFiles)
Update counts.
|
protected void |
createCacheConf(ColumnFamilyDescriptor family)
Creates the cache config.
|
private HFileContext |
createFileContext(Compression.Algorithm compression,
boolean includeMVCCReadpoint,
boolean includesTag,
Encryption.Context cryptoContext) |
StoreFlushContext |
createFlushContext(long cacheFlushId,
FlushLifeCycleTracker tracker) |
protected KeyValueScanner |
createScanner(Scan scan,
ScanInfo scanInfo,
NavigableSet<byte[]> targetCols,
long readPt) |
protected StoreEngine<?,?,?,?> |
createStoreEngine(HStore store,
org.apache.hadoop.conf.Configuration conf,
CellComparator kvComparator)
Creates the store engine configured for the given Store.
|
protected HStoreFile |
createStoreFileAndReader(org.apache.hadoop.fs.Path p) |
private HStoreFile |
createStoreFileAndReader(StoreFileInfo info) |
StoreFileWriter |
createWriterInTmp(long maxKeyCount,
Compression.Algorithm compression,
boolean isCompaction,
boolean includeMVCCReadpoint,
boolean includesTag,
boolean shouldDropBehind) |
StoreFileWriter |
createWriterInTmp(long maxKeyCount,
Compression.Algorithm compression,
boolean isCompaction,
boolean includeMVCCReadpoint,
boolean includesTag,
boolean shouldDropBehind,
long totalCompactedFilesSize) |
void |
deleteChangedReaderObserver(ChangedReadersObserver o) |
void |
deregisterChildren(ConfigurationManager manager)
Needs to be called to deregister the children from the manager.
|
static long |
determineTTLFromFamily(ColumnFamilyDescriptor family) |
protected List<HStoreFile> |
doCompaction(CompactionRequestImpl cr,
Collection<HStoreFile> filesToCompact,
User user,
long compactionStartTime,
List<org.apache.hadoop.fs.Path> newFiles) |
private void |
finishCompactionRequest(CompactionRequestImpl cr) |
protected List<org.apache.hadoop.fs.Path> |
flushCache(long logCacheFlushId,
MemStoreSnapshot snapshot,
MonitoredTask status,
ThroughputController throughputController,
FlushLifeCycleTracker tracker)
Write out current snapshot.
|
OptionalDouble |
getAvgStoreFileAge() |
long |
getBlockingFileCount()
The number of files required before flushes for this store will be blocked.
|
static int |
getBytesPerChecksum(org.apache.hadoop.conf.Configuration conf)
Returns the configured bytesPerChecksum value.
|
CacheConfig |
getCacheConfig()
Used for tests.
|
static ChecksumType |
getChecksumType(org.apache.hadoop.conf.Configuration conf)
Returns the configured checksum algorithm.
|
static int |
getCloseCheckInterval() |
ColumnFamilyDescriptor |
getColumnFamilyDescriptor() |
String |
getColumnFamilyName() |
long |
getCompactedCellsCount() |
long |
getCompactedCellsSize() |
Collection<HStoreFile> |
getCompactedFiles() |
int |
getCompactedFilesCount() |
long |
getCompactionCheckMultiplier() |
double |
getCompactionPressure()
This value can represent the degree of emergency of compaction for this store.
|
CompactionProgress |
getCompactionProgress()
getter for CompactionProgress object
|
int |
getCompactPriority() |
CellComparator |
getComparator() |
RegionCoprocessorHost |
getCoprocessorHost() |
int |
getCurrentParallelPutCount() |
HFileDataBlockEncoder |
getDataBlockEncoder() |
org.apache.hadoop.fs.FileSystem |
getFileSystem() |
MemStoreSize |
getFlushableSize() |
long |
getFlushedCellsCount() |
long |
getFlushedCellsSize() |
long |
getFlushedOutputFileSize() |
long |
getHFilesSize() |
HRegion |
getHRegion() |
long |
getLastCompactSize() |
long |
getMajorCompactedCellsCount() |
long |
getMajorCompactedCellsSize() |
int |
getMaxCompactedStoreFileRefCount() |
OptionalLong |
getMaxMemStoreTS() |
OptionalLong |
getMaxSequenceId() |
OptionalLong |
getMaxStoreFileAge() |
private MemStore |
getMemstore() |
long |
getMemStoreFlushSize() |
long |
getMemstoreOnlyRowReadsCount() |
MemStoreSize |
getMemStoreSize() |
OptionalLong |
getMinStoreFileAge() |
long |
getMixedRowReadsCount() |
long |
getNumHFiles() |
long |
getNumReferenceFiles() |
protected OffPeakHours |
getOffPeakHours() |
HRegionFileSystem |
getRegionFileSystem() |
RegionInfo |
getRegionInfo() |
ScanInfo |
getScanInfo() |
KeyValueScanner |
getScanner(Scan scan,
NavigableSet<byte[]> targetCols,
long readPt)
Return a scanner for both the memstore and the HStore files.
|
List<KeyValueScanner> |
getScanners(boolean cacheBlocks,
boolean isGet,
boolean usePread,
boolean isCompaction,
ScanQueryMatcher matcher,
byte[] startRow,
byte[] stopRow,
long readPt)
Get all scanners with no filtering based on TTL (that happens further down the line).
|
List<KeyValueScanner> |
getScanners(boolean cacheBlocks,
boolean usePread,
boolean isCompaction,
ScanQueryMatcher matcher,
byte[] startRow,
boolean includeStartRow,
byte[] stopRow,
boolean includeStopRow,
long readPt)
Get all scanners with no filtering based on TTL (that happens further down the line).
|
List<KeyValueScanner> |
getScanners(List<HStoreFile> files,
boolean cacheBlocks,
boolean isGet,
boolean usePread,
boolean isCompaction,
ScanQueryMatcher matcher,
byte[] startRow,
byte[] stopRow,
long readPt,
boolean includeMemstoreScanner)
Create scanners on the given files and if needed on the memstore with no filtering based on TTL
(that happens further down the line).
|
List<KeyValueScanner> |
getScanners(List<HStoreFile> files,
boolean cacheBlocks,
boolean usePread,
boolean isCompaction,
ScanQueryMatcher matcher,
byte[] startRow,
boolean includeStartRow,
byte[] stopRow,
boolean includeStopRow,
long readPt,
boolean includeMemstoreScanner)
Create scanners on the given files and if needed on the memstore with no filtering based on TTL
(that happens further down the line).
|
long |
getSize() |
long |
getSmallestReadPoint() |
MemStoreSize |
getSnapshotSize() |
Optional<byte[]> |
getSplitPoint()
Determines if Store should be split.
|
StoreEngine<?,?,?,?> |
getStoreEngine()
Returns the StoreEngine that is backing this concrete implementation of Store.
|
private LongStream |
getStoreFileAgeStream() |
private long |
getStorefileFieldSize(HStoreFile file,
ToLongFunction<StoreFileReader> f) |
Collection<HStoreFile> |
getStorefiles() |
int |
getStorefilesCount() |
private long |
getStorefilesFieldSize(ToLongFunction<StoreFileReader> f) |
(package private) long |
getStoreFileSize(HStoreFile file)
Computes the length of a store file without succumbing to any errors along the way.
|
long |
getStorefilesRootLevelIndexSize() |
long |
getStorefilesSize() |
private long |
getStorefilesSize(Collection<HStoreFile> files,
Predicate<HStoreFile> predicate) |
long |
getStoreFileTtl() |
static org.apache.hadoop.fs.Path |
getStoreHomedir(org.apache.hadoop.fs.Path tabledir,
RegionInfo hri,
byte[] family)
Deprecated.
Since 05/05/2013, HBase-7808, hbase-1.0.0
|
static org.apache.hadoop.fs.Path |
getStoreHomedir(org.apache.hadoop.fs.Path tabledir,
String encodedName,
byte[] family)
Deprecated.
Since 05/05/2013, HBase-7808, hbase-1.0.0
|
int |
getStoreRefCount() |
long |
getStoreSizeUncompressed() |
TableName |
getTableName() |
private long |
getTotalSize(Collection<HStoreFile> sfs) |
long |
getTotalStaticBloomSize()
Returns the total byte size of all Bloom filter bit arrays.
|
long |
getTotalStaticIndexSize()
Returns the total size of all index blocks in the data block indexes, including the root level,
intermediate levels, and the leaf level for multi-level indexes, or just the root level for
single-level indexes.
|
private long |
getTotalUncompressedBytes(List<HStoreFile> files) |
boolean |
hasReferences() |
boolean |
hasTooManyStoreFiles() |
long |
heapSize() |
boolean |
isPrimaryReplicaStore() |
boolean |
isSloppyMemStore() |
private List<HStoreFile> |
loadStoreFiles(boolean warmup)
Creates an unsorted list of StoreFile loaded in parallel
from the given directory.
|
private void |
logCompactionEndMessage(CompactionRequestImpl cr,
List<HStoreFile> sfs,
long now,
long compactionStartTime)
Log a very elaborate compaction completion message.
|
private List<HStoreFile> |
moveCompactedFilesIntoPlace(CompactionRequestImpl cr,
List<org.apache.hadoop.fs.Path> newFiles,
User user) |
(package private) HStoreFile |
moveFileIntoPlace(org.apache.hadoop.fs.Path newFile) |
boolean |
needsCompaction()
See if there's too much store files in this store
|
private void |
notifyChangedReadersObservers(List<HStoreFile> sfs)
Notify all observers that set of Readers has changed.
|
void |
onConfigurationChange(org.apache.hadoop.conf.Configuration conf)
This method would be called by the
ConfigurationManager
object when the Configuration object is reloaded from disk. |
private List<HStoreFile> |
openStoreFiles(Collection<StoreFileInfo> files,
boolean warmup) |
void |
postSnapshotOperation()
Perform tasks needed after the completion of snapshot operation.
|
Pair<org.apache.hadoop.fs.Path,org.apache.hadoop.fs.Path> |
preBulkLoadHFile(String srcPathStr,
long seqNum)
This method should only be called from Region.
|
Long |
preFlushSeqIDEstimation() |
void |
preSnapshotOperation()
Sets the store up for a region level snapshot operation.
|
List<KeyValueScanner> |
recreateScanners(List<KeyValueScanner> currentFileScanners,
boolean cacheBlocks,
boolean usePread,
boolean isCompaction,
ScanQueryMatcher matcher,
byte[] startRow,
boolean includeStartRow,
byte[] stopRow,
boolean includeStopRow,
long readPt,
boolean includeMemstoreScanner)
Recreates the scanners on the current list of active store file scanners
|
void |
refreshStoreFiles()
Checks the underlying store files, and opens the files that have not been opened, and removes
the store file readers for store files no longer available.
|
void |
refreshStoreFiles(Collection<String> newFiles)
Replaces the store files that the store has with the given files.
|
private void |
refreshStoreFilesInternal(Collection<StoreFileInfo> newFiles)
Checks the underlying store files, and opens the files that have not
been opened, and removes the store file readers for store files no longer
available.
|
void |
registerChildren(ConfigurationManager manager)
Needs to be called to register the children to the manager.
|
private void |
removeCompactedfiles(Collection<HStoreFile> compactedfiles,
boolean evictOnClose)
Archives and removes the compacted files
|
private void |
removeUnneededFiles() |
(package private) void |
replaceStoreFiles(Collection<HStoreFile> compactedFiles,
Collection<HStoreFile> result) |
void |
replayCompactionMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.CompactionDescriptor compaction,
boolean pickCompactionFiles,
boolean removeFiles)
Call to complete a compaction.
|
(package private) void |
reportArchivedFilesForQuota(List<? extends StoreFile> archivedFiles,
List<Long> fileSizes) |
Optional<CompactionContext> |
requestCompaction() |
Optional<CompactionContext> |
requestCompaction(int priority,
CompactionLifeCycleTracker tracker,
User user) |
(package private) void |
setDataBlockEncoderInTest(HFileDataBlockEncoder blockEncoder)
Should be used only in tests.
|
(package private) void |
setScanInfo(ScanInfo scanInfo)
Set scan info, used by test
|
boolean |
shouldPerformMajorCompaction()
Tests whether we should run a major compaction.
|
(package private) void |
snapshot()
Snapshot this stores memstore.
|
void |
startReplayingFromWAL()
This message intends to inform the MemStore that next coming updates
are going to be part of the replaying edits from WAL
|
void |
stopReplayingFromWAL()
This message intends to inform the MemStore that the replaying edits from WAL
are done
|
boolean |
throttleCompaction(long compactionSize) |
long |
timeOfOldestEdit()
When was the last edit done in the memstore
|
String |
toString() |
void |
triggerMajorCompaction() |
HStoreFile |
tryCommitRecoveredHFile(org.apache.hadoop.fs.Path path) |
(package private) void |
updateMetricsStore(boolean memstoreRead) |
(package private) void |
updateSpaceQuotaAfterFileReplacement(RegionSizeStore sizeStore,
RegionInfo regionInfo,
Collection<HStoreFile> oldFiles,
Collection<HStoreFile> newFiles)
Updates the space quota usage for this region, removing the size for files compacted away
and adding in the size for new files.
|
private boolean |
updateStorefiles(List<HStoreFile> sfs,
long snapshotId)
Change storeFiles adding into place the Reader produced by this new flush.
|
void |
upsert(Iterable<Cell> cells,
long readpoint,
MemStoreSizing memstoreSizing)
Adds or replaces the specified KeyValues.
|
private void |
validateStoreFile(org.apache.hadoop.fs.Path path)
Validates a store file by opening and closing it.
|
(package private) int |
versionsToReturn(int wantedVersions) |
private void |
writeCompactionWalRecord(Collection<HStoreFile> filesCompacted,
Collection<HStoreFile> newFiles)
Writes the compaction WAL record.
|
public static final String MEMSTORE_CLASS_NAME
public static final String COMPACTCHECKER_INTERVAL_MULTIPLIER_KEY
public static final String BLOCKING_STOREFILES_KEY
public static final String BLOCK_STORAGE_POLICY_KEY
public static final String DEFAULT_BLOCK_STORAGE_POLICY
public static final int DEFAULT_COMPACTCHECKER_INTERVAL_MULTIPLIER
public static final int DEFAULT_BLOCKING_STOREFILE_COUNT
private static final int SPLIT_REGION_COMPACTION_PRIORITY
private static final org.slf4j.Logger LOG
private final ColumnFamilyDescriptor family
private final HRegionFileSystem fs
protected org.apache.hadoop.conf.Configuration conf
protected CacheConfig cacheConf
private long lastCompactSize
volatile boolean forceMajor
static int closeCheckInterval
private AtomicLong storeSize
private AtomicLong totalUncompressedBytes
private LongAdder memstoreOnlyRowReadsCount
private LongAdder mixedRowReadsCount
private boolean cacheOnWriteLogged
final ReentrantReadWriteLock lock
final ReentrantLock archiveLock
private final boolean verifyBulkLoads
private final AtomicInteger currentParallelPutCount
private final int parallelPutCountPrintThreshold
private final List<HStoreFile> filesCompacting
private final Set<ChangedReadersObserver> changedReaderObservers
protected final int blocksize
private HFileDataBlockEncoder dataBlockEncoder
protected ChecksumType checksumType
protected int bytesPerChecksum
protected final CellComparator comparator
final StoreEngine<?,?,?,?> storeEngine
private static final AtomicBoolean offPeakCompactionTracker
private volatile OffPeakHours offPeakHours
private static final int DEFAULT_FLUSH_RETRIES_NUMBER
private int flushRetriesNumber
private int pauseTime
private long blockingFileCount
private int compactionCheckMultiplier
protected Encryption.Context cryptoContext
private AtomicLong flushedCellsCount
private AtomicLong compactedCellsCount
private AtomicLong majorCompactedCellsCount
private AtomicLong flushedCellsSize
private AtomicLong flushedOutputFileSize
private AtomicLong compactedCellsSize
private AtomicLong majorCompactedCellsSize
public static final long FIXED_OVERHEAD
public static final long DEEP_OVERHEAD
protected HStore(HRegion region, ColumnFamilyDescriptor family, org.apache.hadoop.conf.Configuration confParam, boolean warmup) throws IOException
family
- HColumnDescriptor for this columnconfParam
- configuration object failed. Can be null.IOException
private MemStore getMemstore()
protected void createCacheConf(ColumnFamilyDescriptor family)
family
- The current column family.protected StoreEngine<?,?,?,?> createStoreEngine(HStore store, org.apache.hadoop.conf.Configuration conf, CellComparator kvComparator) throws IOException
store
- The store. An unfortunate dependency needed due to it
being passed to coprocessors via the compactor.conf
- Store configuration.kvComparator
- KVComparator for storeFileManager.IOException
public static long determineTTLFromFamily(ColumnFamilyDescriptor family)
public String getColumnFamilyName()
getColumnFamilyName
in interface Store
getColumnFamilyName
in interface StoreConfigInformation
public TableName getTableName()
getTableName
in interface Store
public org.apache.hadoop.fs.FileSystem getFileSystem()
getFileSystem
in interface Store
public HRegionFileSystem getRegionFileSystem()
public long getStoreFileTtl()
getStoreFileTtl
in interface StoreConfigInformation
public long getMemStoreFlushSize()
getMemStoreFlushSize
in interface StoreConfigInformation
public MemStoreSize getFlushableSize()
getFlushableSize
in interface Store
Store.getMemStoreSize()
unless we are carrying snapshots and then it will be the size of
outstanding snapshots.public MemStoreSize getSnapshotSize()
getSnapshotSize
in interface Store
public long getCompactionCheckMultiplier()
getCompactionCheckMultiplier
in interface StoreConfigInformation
public long getBlockingFileCount()
StoreConfigInformation
getBlockingFileCount
in interface StoreConfigInformation
public static int getBytesPerChecksum(org.apache.hadoop.conf.Configuration conf)
conf
- The configurationpublic static ChecksumType getChecksumType(org.apache.hadoop.conf.Configuration conf)
conf
- The configurationpublic static int getCloseCheckInterval()
public ColumnFamilyDescriptor getColumnFamilyDescriptor()
getColumnFamilyDescriptor
in interface Store
public OptionalLong getMaxSequenceId()
getMaxSequenceId
in interface Store
public OptionalLong getMaxMemStoreTS()
getMaxMemStoreTS
in interface Store
@Deprecated public static org.apache.hadoop.fs.Path getStoreHomedir(org.apache.hadoop.fs.Path tabledir, RegionInfo hri, byte[] family)
tabledir
- Path
to where the table is being storedhri
- RegionInfo
for the region.family
- ColumnFamilyDescriptor
describing the column family@Deprecated public static org.apache.hadoop.fs.Path getStoreHomedir(org.apache.hadoop.fs.Path tabledir, String encodedName, byte[] family)
tabledir
- Path
to where the table is being storedencodedName
- Encoded region name.family
- ColumnFamilyDescriptor
describing the column familypublic HFileDataBlockEncoder getDataBlockEncoder()
void setDataBlockEncoderInTest(HFileDataBlockEncoder blockEncoder)
blockEncoder
- the block delta encoder to useprivate List<HStoreFile> loadStoreFiles(boolean warmup) throws IOException
IOException
private List<HStoreFile> openStoreFiles(Collection<StoreFileInfo> files, boolean warmup) throws IOException
IOException
public void refreshStoreFiles() throws IOException
Store
refreshStoreFiles
in interface Store
IOException
public void refreshStoreFiles(Collection<String> newFiles) throws IOException
IOException
private void refreshStoreFilesInternal(Collection<StoreFileInfo> newFiles) throws IOException
IOException
protected HStoreFile createStoreFileAndReader(org.apache.hadoop.fs.Path p) throws IOException
IOException
private HStoreFile createStoreFileAndReader(StoreFileInfo info) throws IOException
IOException
public void startReplayingFromWAL()
public void stopReplayingFromWAL()
public void add(Cell cell, MemStoreSizing memstoreSizing)
public void add(Iterable<Cell> cells, MemStoreSizing memstoreSizing)
public long timeOfOldestEdit()
Store
timeOfOldestEdit
in interface Store
public Collection<HStoreFile> getStorefiles()
getStorefiles
in interface Store
public Collection<HStoreFile> getCompactedFiles()
getCompactedFiles
in interface Store
public void assertBulkLoadHFileOk(org.apache.hadoop.fs.Path srcPath) throws IOException
IOException
public Pair<org.apache.hadoop.fs.Path,org.apache.hadoop.fs.Path> preBulkLoadHFile(String srcPathStr, long seqNum) throws IOException
seqNum
- sequence Id associated with the HFileIOException
public org.apache.hadoop.fs.Path bulkLoadHFile(byte[] family, String srcPathStr, org.apache.hadoop.fs.Path dstPath) throws IOException
IOException
public void bulkLoadHFile(StoreFileInfo fileInfo) throws IOException
IOException
private void bulkLoadHFile(HStoreFile sf) throws IOException
IOException
public org.apache.hbase.thirdparty.com.google.common.collect.ImmutableCollection<HStoreFile> close() throws IOException
StoreFiles
that were previously being used.IOException
- on failurevoid snapshot()
flushCache(long, MemStoreSnapshot, MonitoredTask, ThroughputController,
FlushLifeCycleTracker)
so it has some work to do.protected List<org.apache.hadoop.fs.Path> flushCache(long logCacheFlushId, MemStoreSnapshot snapshot, MonitoredTask status, ThroughputController throughputController, FlushLifeCycleTracker tracker) throws IOException
snapshot()
has been called previously.logCacheFlushId
- flush sequence numberIOException
- if exception occurs during processpublic HStoreFile tryCommitRecoveredHFile(org.apache.hadoop.fs.Path path) throws IOException
IOException
private HStoreFile commitFile(org.apache.hadoop.fs.Path path, long logCacheFlushId, MonitoredTask status) throws IOException
path
- The pathname of the tmp file into which the store was flushedIOException
public StoreFileWriter createWriterInTmp(long maxKeyCount, Compression.Algorithm compression, boolean isCompaction, boolean includeMVCCReadpoint, boolean includesTag, boolean shouldDropBehind) throws IOException
IOException
public StoreFileWriter createWriterInTmp(long maxKeyCount, Compression.Algorithm compression, boolean isCompaction, boolean includeMVCCReadpoint, boolean includesTag, boolean shouldDropBehind, long totalCompactedFilesSize) throws IOException
compression
- Compression algorithm to useisCompaction
- whether we are creating a new file in a compactionincludeMVCCReadpoint
- - whether to include MVCC or notincludesTag
- - includesTag or notIOException
private HFileContext createFileContext(Compression.Algorithm compression, boolean includeMVCCReadpoint, boolean includesTag, Encryption.Context cryptoContext)
private long getTotalSize(Collection<HStoreFile> sfs)
private boolean updateStorefiles(List<HStoreFile> sfs, long snapshotId) throws IOException
sfs
- Store filesIOException
private void notifyChangedReadersObservers(List<HStoreFile> sfs) throws IOException
IOException
public List<KeyValueScanner> getScanners(boolean cacheBlocks, boolean isGet, boolean usePread, boolean isCompaction, ScanQueryMatcher matcher, byte[] startRow, byte[] stopRow, long readPt) throws IOException
cacheBlocks
- cache the blocks or notusePread
- true to use pread, false if notisCompaction
- true if the scanner is created for compactionmatcher
- the scan query matcherstartRow
- the start rowstopRow
- the stop rowreadPt
- the read point of the current scanIOException
public List<KeyValueScanner> getScanners(boolean cacheBlocks, boolean usePread, boolean isCompaction, ScanQueryMatcher matcher, byte[] startRow, boolean includeStartRow, byte[] stopRow, boolean includeStopRow, long readPt) throws IOException
cacheBlocks
- cache the blocks or notusePread
- true to use pread, false if notisCompaction
- true if the scanner is created for compactionmatcher
- the scan query matcherstartRow
- the start rowincludeStartRow
- true to include start row, false if notstopRow
- the stop rowincludeStopRow
- true to include stop row, false if notreadPt
- the read point of the current scanIOException
private static void clearAndClose(List<KeyValueScanner> scanners)
public List<KeyValueScanner> getScanners(List<HStoreFile> files, boolean cacheBlocks, boolean isGet, boolean usePread, boolean isCompaction, ScanQueryMatcher matcher, byte[] startRow, byte[] stopRow, long readPt, boolean includeMemstoreScanner) throws IOException
files
- the list of files on which the scanners has to be createdcacheBlocks
- cache the blocks or notusePread
- true to use pread, false if notisCompaction
- true if the scanner is created for compactionmatcher
- the scan query matcherstartRow
- the start rowstopRow
- the stop rowreadPt
- the read point of the current scanincludeMemstoreScanner
- true if memstore has to be includedIOException
public List<KeyValueScanner> getScanners(List<HStoreFile> files, boolean cacheBlocks, boolean usePread, boolean isCompaction, ScanQueryMatcher matcher, byte[] startRow, boolean includeStartRow, byte[] stopRow, boolean includeStopRow, long readPt, boolean includeMemstoreScanner) throws IOException
files
- the list of files on which the scanners has to be createdcacheBlocks
- ache the blocks or notusePread
- true to use pread, false if notisCompaction
- true if the scanner is created for compactionmatcher
- the scan query matcherstartRow
- the start rowincludeStartRow
- true to include start row, false if notstopRow
- the stop rowincludeStopRow
- true to include stop row, false if notreadPt
- the read point of the current scanincludeMemstoreScanner
- true if memstore has to be includedIOException
public void addChangedReaderObserver(ChangedReadersObserver o)
o
- Observer who wants to know about changes in set of Readerspublic void deleteChangedReaderObserver(ChangedReadersObserver o)
o
- Observer no longer interested in changes in set of Readers.public List<HStoreFile> compact(CompactionContext compaction, ThroughputController throughputController, User user) throws IOException
During this time, the Store can work as usual, getting values from StoreFiles and writing new StoreFiles from the memstore. Existing StoreFiles are not destroyed until the new compacted StoreFile is completely written-out to disk.
The compactLock prevents multiple simultaneous compactions. The structureLock prevents us from interfering with other write operations.
We don't want to hold the structureLock for the whole time, as a compact() can be lengthy and we want to allow cache-flushes during this period.
Compaction event should be idempotent, since there is no IO Fencing for the region directory in hdfs. A region server might still try to complete the compaction after it lost the region. That is why the following events are carefully ordered for a compaction: 1. Compaction writes new files under region/.tmp directory (compaction output) 2. Compaction atomically moves the temporary file under region directory 3. Compaction appends a WAL edit containing the compaction input and output files. Forces sync on WAL. 4. Compaction deletes the input files from the region directory. Failure conditions are handled like this: - If RS fails before 2, compaction wont complete. Even if RS lives on and finishes the compaction later, it will only write the new data file to the region directory. Since we already have this data, this will be idempotent but we will have a redundant copy of the data. - If RS fails between 2 and 3, the region will have a redundant copy of the data. The RS that failed won't be able to finish sync() for WAL because of lease recovery in WAL. - If RS fails after 3, the region region server who opens the region will pick up the the compaction marker from the WAL and replay it by removing the compaction input files. Failed RS can also attempt to delete those files, but the operation will be idempotent See HBASE-2231 for details.
compaction
- compaction details obtained from requestCompaction()IOException
protected List<HStoreFile> doCompaction(CompactionRequestImpl cr, Collection<HStoreFile> filesToCompact, User user, long compactionStartTime, List<org.apache.hadoop.fs.Path> newFiles) throws IOException
IOException
private List<HStoreFile> moveCompactedFilesIntoPlace(CompactionRequestImpl cr, List<org.apache.hadoop.fs.Path> newFiles, User user) throws IOException
IOException
HStoreFile moveFileIntoPlace(org.apache.hadoop.fs.Path newFile) throws IOException
IOException
private void writeCompactionWalRecord(Collection<HStoreFile> filesCompacted, Collection<HStoreFile> newFiles) throws IOException
filesCompacted
- Files compacted (input).newFiles
- Files from compaction.IOException
void replaceStoreFiles(Collection<HStoreFile> compactedFiles, Collection<HStoreFile> result) throws IOException
IOException
void updateSpaceQuotaAfterFileReplacement(RegionSizeStore sizeStore, RegionInfo regionInfo, Collection<HStoreFile> oldFiles, Collection<HStoreFile> newFiles)
sizeStore
- The object tracking changes in region size for space quotas.regionInfo
- The identifier for the region whose size is being updated.oldFiles
- Files removed from this store's region.newFiles
- Files added to this store's region.private void logCompactionEndMessage(CompactionRequestImpl cr, List<HStoreFile> sfs, long now, long compactionStartTime)
cr
- Request.sfs
- Resulting files.compactionStartTime
- Start time.public void replayCompactionMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.CompactionDescriptor compaction, boolean pickCompactionFiles, boolean removeFiles) throws IOException
IOException
public void compactRecentForTestingAssumingDefaultPolicy(int N) throws IOException
N
- Number of files.IOException
public boolean hasReferences()
hasReferences
in interface Store
true
if the store has any underlying reference files to older HFilespublic CompactionProgress getCompactionProgress()
public boolean shouldPerformMajorCompaction() throws IOException
Store
shouldPerformMajorCompaction
in interface Store
IOException
public Optional<CompactionContext> requestCompaction() throws IOException
IOException
public Optional<CompactionContext> requestCompaction(int priority, CompactionLifeCycleTracker tracker, User user) throws IOException
IOException
private void addToCompactingFiles(Collection<HStoreFile> filesToAdd)
private void removeUnneededFiles() throws IOException
IOException
public void cancelRequestedCompaction(CompactionContext compaction)
private void finishCompactionRequest(CompactionRequestImpl cr)
private void validateStoreFile(org.apache.hadoop.fs.Path path) throws IOException
path
- the path to the store fileIOException
protected void completeCompaction(Collection<HStoreFile> compactedFiles) throws IOException
compactedFiles
- list of files that were compactedIOException
int versionsToReturn(int wantedVersions)
public boolean canSplit()
Store
public Optional<byte[]> getSplitPoint()
public long getLastCompactSize()
getLastCompactSize
in interface Store
public long getSize()
public void triggerMajorCompaction()
public KeyValueScanner getScanner(Scan scan, NavigableSet<byte[]> targetCols, long readPt) throws IOException
scan
- Scan to apply when scanning the storestargetCols
- columns to scanIOException
- on failureprotected KeyValueScanner createScanner(Scan scan, ScanInfo scanInfo, NavigableSet<byte[]> targetCols, long readPt) throws IOException
IOException
public List<KeyValueScanner> recreateScanners(List<KeyValueScanner> currentFileScanners, boolean cacheBlocks, boolean usePread, boolean isCompaction, ScanQueryMatcher matcher, byte[] startRow, boolean includeStartRow, byte[] stopRow, boolean includeStopRow, long readPt, boolean includeMemstoreScanner) throws IOException
currentFileScanners
- the current set of active store file scannerscacheBlocks
- cache the blocks or notusePread
- use pread or notisCompaction
- is the scanner for compactionmatcher
- the scan query matcherstartRow
- the scan's start rowincludeStartRow
- should the scan include the start rowstopRow
- the scan's stop rowincludeStopRow
- should the scan include the stop rowreadPt
- the read point of the current scaneincludeMemstoreScanner
- whether the current scanner should include memstorescannerIOException
public int getStorefilesCount()
getStorefilesCount
in interface Store
public int getCompactedFilesCount()
getCompactedFilesCount
in interface Store
private LongStream getStoreFileAgeStream()
public OptionalLong getMaxStoreFileAge()
getMaxStoreFileAge
in interface Store
public OptionalLong getMinStoreFileAge()
getMinStoreFileAge
in interface Store
public OptionalDouble getAvgStoreFileAge()
getAvgStoreFileAge
in interface Store
public long getNumReferenceFiles()
getNumReferenceFiles
in interface Store
public long getNumHFiles()
getNumHFiles
in interface Store
public long getStoreSizeUncompressed()
getStoreSizeUncompressed
in interface Store
public long getStorefilesSize()
getStorefilesSize
in interface Store
public long getHFilesSize()
getHFilesSize
in interface Store
private long getTotalUncompressedBytes(List<HStoreFile> files)
private long getStorefilesSize(Collection<HStoreFile> files, Predicate<HStoreFile> predicate)
private long getStorefileFieldSize(HStoreFile file, ToLongFunction<StoreFileReader> f)
private long getStorefilesFieldSize(ToLongFunction<StoreFileReader> f)
public long getStorefilesRootLevelIndexSize()
getStorefilesRootLevelIndexSize
in interface Store
public long getTotalStaticIndexSize()
Store
getTotalStaticIndexSize
in interface Store
public long getTotalStaticBloomSize()
Store
getTotalStaticBloomSize
in interface Store
public MemStoreSize getMemStoreSize()
getMemStoreSize
in interface Store
public int getCompactPriority()
getCompactPriority
in interface Store
public boolean throttleCompaction(long compactionSize)
public HRegion getHRegion()
public RegionCoprocessorHost getCoprocessorHost()
public RegionInfo getRegionInfo()
getRegionInfo
in interface Store
getRegionInfo
in interface StoreConfigInformation
public boolean areWritesEnabled()
areWritesEnabled
in interface Store
public long getSmallestReadPoint()
getSmallestReadPoint
in interface Store
public void upsert(Iterable<Cell> cells, long readpoint, MemStoreSizing memstoreSizing) throws IOException
For each KeyValue specified, if a cell with the same row, family, and qualifier exists in MemStore, it will be replaced. Otherwise, it will just be inserted to MemStore.
This operation is atomic on each KeyValue (row/family/qualifier) but not necessarily atomic across all of them.
readpoint
- readpoint below which we can safely remove duplicate KVsIOException
public StoreFlushContext createFlushContext(long cacheFlushId, FlushLifeCycleTracker tracker)
public boolean needsCompaction()
Store
needsCompaction
in interface Store
true
if number of store files is greater than the number defined in
minFilesToCompactpublic CacheConfig getCacheConfig()
public long heapSize()
public CellComparator getComparator()
getComparator
in interface Store
public ScanInfo getScanInfo()
void setScanInfo(ScanInfo scanInfo)
scanInfo
- new scan info to use for testpublic boolean hasTooManyStoreFiles()
hasTooManyStoreFiles
in interface Store
public long getFlushedCellsCount()
getFlushedCellsCount
in interface Store
public long getFlushedCellsSize()
getFlushedCellsSize
in interface Store
public long getFlushedOutputFileSize()
getFlushedOutputFileSize
in interface Store
public long getCompactedCellsCount()
getCompactedCellsCount
in interface Store
public long getCompactedCellsSize()
getCompactedCellsSize
in interface Store
public long getMajorCompactedCellsCount()
getMajorCompactedCellsCount
in interface Store
public long getMajorCompactedCellsSize()
getMajorCompactedCellsSize
in interface Store
public StoreEngine<?,?,?,?> getStoreEngine()
StoreEngine
object used internally inside this HStore object.protected OffPeakHours getOffPeakHours()
public void onConfigurationChange(org.apache.hadoop.conf.Configuration conf)
ConfigurationManager
object when the Configuration
object is reloaded from disk.onConfigurationChange
in interface ConfigurationObserver
public void registerChildren(ConfigurationManager manager)
registerChildren
in interface PropagatingConfigurationObserver
manager
- : to register topublic void deregisterChildren(ConfigurationManager manager)
deregisterChildren
in interface PropagatingConfigurationObserver
manager
- : to deregister frompublic double getCompactionPressure()
Store
And for striped stores, we should calculate this value by the files in each stripe separately and return the maximum value.
It is similar to Store.getCompactPriority()
except that it is more suitable to use in a
linear formula.
getCompactionPressure
in interface Store
public boolean isPrimaryReplicaStore()
isPrimaryReplicaStore
in interface Store
public void preSnapshotOperation()
postSnapshotOperation()
public void postSnapshotOperation()
preSnapshotOperation()
public void closeAndArchiveCompactedFiles() throws IOException
IOException
private void removeCompactedfiles(Collection<HStoreFile> compactedfiles, boolean evictOnClose) throws IOException
compactedfiles
- The compacted files in this store that are not active in readsevictOnClose
- true if blocks should be evicted from the cache when an HFile reader is
closed, false if notIOException
long getStoreFileSize(HStoreFile file)
0
instead of the actual size.file
- The file to compute the size of.file
.public Long preFlushSeqIDEstimation()
public boolean isSloppyMemStore()
isSloppyMemStore
in interface Store
private void clearCompactedfiles(List<HStoreFile> filesToRemove) throws IOException
IOException
public int getCurrentParallelPutCount()
getCurrentParallelPutCount
in interface Store
public int getStoreRefCount()
public int getMaxCompactedStoreFileRefCount()
void reportArchivedFilesForQuota(List<? extends StoreFile> archivedFiles, List<Long> fileSizes)
public long getMemstoreOnlyRowReadsCount()
getMemstoreOnlyRowReadsCount
in interface Store
public long getMixedRowReadsCount()
getMixedRowReadsCount
in interface Store
void updateMetricsStore(boolean memstoreRead)
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.