@InterfaceAudience.Private public class HRegion extends Object implements HeapSize, PropagatingConfigurationObserver, Region
An Region is defined by its table and its key extent.
Locking at the Region level serves only one purpose: preventing the region from being closed (and consequently split) while other operations are ongoing. Each row level operation obtains both a row lock and a region read lock for the duration of the operation. While a scanner is being constructed, getScanner holds a read lock. If the scanner is successfully constructed, it holds a read lock until it is closed. A close takes out a write lock and consequently will block for ongoing operations and will block new operations from starting while the close is in progress.
Modifier and Type | Class and Description |
---|---|
private static class |
HRegion.BatchOperation<T>
Class that tracks the progress of a batch operations, accumulating status codes and tracking
the index at which processing is proceeding.
|
static interface |
HRegion.BulkLoadListener
Listener class to enable callers of
bulkLoadHFile() to perform any necessary
pre/post processing of a given bulkload call
|
static interface |
HRegion.FlushResult |
static class |
HRegion.FlushResultImpl
Objects from this class are created when flushing to describe all the different states that
that method ends up in.
|
(package private) static class |
HRegion.MutationBatchOperation
Batch of mutation operations.
|
(package private) static class |
HRegion.ObservedExceptionsInBatch
A class that tracks exceptions that have been observed in one batch.
|
(package private) static class |
HRegion.PrepareFlushResult
A result object from prepare flush cache stage
|
(package private) class |
HRegion.RegionScannerImpl
RegionScannerImpl is used to combine scanners from multiple Stores (aka column families).
|
(package private) static class |
HRegion.ReplayBatchOperation
Batch of mutations for replay.
|
(package private) class |
HRegion.RowLockContext |
static class |
HRegion.RowLockImpl
Class used to represent a lock on a row.
|
(package private) static class |
HRegion.WriteState |
Region.Operation, Region.RowLock
Modifier and Type | Field and Description |
---|---|
private org.apache.hadoop.conf.Configuration |
baseConf |
private LongAdder |
blockedRequestsCount |
private long |
blockingMemStoreSize |
(package private) long |
busyWaitDuration |
(package private) LongAdder |
checkAndMutateChecksFailed |
(package private) LongAdder |
checkAndMutateChecksPassed |
(package private) AtomicBoolean |
closed |
private Object |
closeLock |
(package private) AtomicBoolean |
closing |
(package private) LongAdder |
compactionNumBytesCompacted |
(package private) LongAdder |
compactionNumFilesCompacted |
(package private) LongAdder |
compactionsFailed |
(package private) LongAdder |
compactionsFinished |
(package private) LongAdder |
compactionsQueued |
protected org.apache.hadoop.conf.Configuration |
conf |
private Optional<ConfigurationManager> |
configurationManager |
private RegionCoprocessorHost |
coprocessorHost |
private Map<String,com.google.protobuf.Service> |
coprocessorServiceHandlers |
(package private) LongAdder |
dataInMemoryWithoutWAL |
static long |
DEEP_OVERHEAD |
(package private) static long |
DEFAULT_BUSY_WAIT_DURATION |
static int |
DEFAULT_CACHE_FLUSH_INTERVAL
Default interval for the memstore flush
|
private static Durability |
DEFAULT_DURABILITY
This is the global default value for durability.
|
static long |
DEFAULT_FLUSH_PER_CHANGES |
static int |
DEFAULT_HBASE_REGIONSERVER_MINIBATCH_SIZE |
static int |
DEFAULT_MAX_CELL_SIZE |
(package private) static long |
DEFAULT_ROW_PROCESSOR_TIMEOUT |
(package private) static int |
DEFAULT_ROWLOCK_WAIT_DURATION |
private byte[] |
explicitSplitPoint |
(package private) LongAdder |
filteredReadRequestsCount |
static long |
FIXED_OVERHEAD |
private long |
flushCheckInterval |
(package private) LongAdder |
flushesQueued |
private long |
flushPerChanges |
private FlushPolicy |
flushPolicy |
private static byte[] |
FOR_UNIT_TESTS_ONLY
Row needed by below method.
|
private HRegionFileSystem |
fs |
static String |
HBASE_MAX_CELL_SIZE_KEY |
static String |
HBASE_REGIONSERVER_MINIBATCH_SIZE |
private TableDescriptor |
htableDescriptor |
private boolean |
isLoadingCfsOnDemandDefault
The default setting for whether to enable on-demand CF loading for
scan requests to this region.
|
private long |
lastFlushOpSeqId
Record the sequence id of last flush operation.
|
protected long |
lastReplayedCompactionSeqId |
protected long |
lastReplayedOpenRegionSeqId
The sequence id of the last replayed open region event from the primary region.
|
private ConcurrentMap<HStore,Long> |
lastStoreFlushTimeMap |
static String |
LOAD_CFS_ON_DEMAND_CONFIG_KEY |
(package private) ReentrantReadWriteLock |
lock |
private ConcurrentHashMap<HashedBytes,HRegion.RowLockContext> |
lockedRows |
private static org.slf4j.Logger |
LOG |
private AtomicInteger |
majorInProgress |
static long |
MAX_FLUSH_PER_CHANGES
The following MAX_FLUSH_PER_CHANGES is large enough because each KeyValue has 20+ bytes
overhead.
|
(package private) long |
maxBusyWaitDuration |
(package private) int |
maxBusyWaitMultiplier |
(package private) long |
maxCellSize |
private long |
maxFlushedSeqId
The max sequence id of flushed data on this region.
|
(package private) Map<byte[],Long> |
maxSeqIdInStores |
static String |
MEMSTORE_FLUSH_PER_CHANGES
Conf key to force a flush if there are already enough changes for one region in memstore
|
static String |
MEMSTORE_PERIODIC_FLUSH_INTERVAL
Conf key for the periodic flush interval
|
(package private) long |
memstoreFlushSize |
private MemStoreSizing |
memStoreSizing |
private MetricsRegion |
metricsRegion |
private MetricsRegionWrapperImpl |
metricsRegionWrapper |
private int |
miniBatchSize |
private AtomicInteger |
minorInProgress |
private static List<Cell> |
MOCKED_LIST
A mocked list implementation - discards all updates.
|
private MultiVersionConcurrencyControl |
mvcc |
(package private) LongAdder |
numMutationsWithoutWAL |
private long |
openSeqNum
The sequence ID that was enLongAddered when this region was opened.
|
private HRegion.PrepareFlushResult |
prepareFlushResult
Saved state from replaying prepare flush cache
|
(package private) LongAdder |
readRequestsCount |
private org.apache.hadoop.fs.Path |
regionDir |
private Durability |
regionDurability |
(package private) RegionServicesForStores |
regionServicesForStores |
private boolean |
regionStatsEnabled |
private NavigableMap<byte[],Integer> |
replicationScope |
private int |
rowLockWaitDuration |
(package private) ExecutorService |
rowProcessorExecutor |
(package private) long |
rowProcessorTimeout |
private RegionServerAccounting |
rsAccounting |
(package private) RegionServerServices |
rsServices |
private ConcurrentHashMap<RegionScanner,Long> |
scannerReadPoints |
private RegionSplitPolicy |
splitPolicy |
private boolean |
splitRequest |
protected Map<byte[],HStore> |
stores |
static int |
SYSTEM_CACHE_FLUSH_INTERVAL
Default interval for System tables memstore flush
|
private Long |
timeoutForWriteLock |
(package private) long |
timestampSlop |
private ReentrantReadWriteLock |
updatesLock |
private WAL |
wal |
private org.apache.hadoop.fs.FileSystem |
walFS |
(package private) LongAdder |
writeRequestsCount |
(package private) HRegion.WriteState |
writestate |
Constructor and Description |
---|
HRegion(HRegionFileSystem fs,
WAL wal,
org.apache.hadoop.conf.Configuration confParam,
TableDescriptor htd,
RegionServerServices rsServices)
HRegion constructor.
|
HRegion(org.apache.hadoop.fs.Path tableDir,
WAL wal,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.conf.Configuration confParam,
RegionInfo regionInfo,
TableDescriptor htd,
RegionServerServices rsServices)
Deprecated.
Use other constructors.
|
Modifier and Type | Method and Description |
---|---|
void |
addRegionToSnapshot(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription desc,
ForeignExceptionSnare exnSnare)
Complete taking the snapshot on the region.
|
Result |
append(Append append)
Perform one or more append operations on a row.
|
Result |
append(Append mutation,
long nonceGroup,
long nonce) |
private void |
applyToMemStore(HStore store,
Cell cell,
MemStoreSizing memstoreAccounting) |
private void |
applyToMemStore(HStore store,
List<Cell> cells,
boolean delta,
MemStoreSizing memstoreAccounting) |
boolean |
areWritesEnabled() |
(package private) OperationStatus[] |
batchMutate(HRegion.BatchOperation<?> batchOp)
Perform a batch of mutations.
|
OperationStatus[] |
batchMutate(Mutation[] mutations)
Perform a batch of mutations.
|
OperationStatus[] |
batchMutate(Mutation[] mutations,
boolean atomic,
long nonceGroup,
long nonce) |
OperationStatus[] |
batchMutate(Mutation[] mutations,
long nonceGroup,
long nonce) |
OperationStatus[] |
batchReplay(WALSplitter.MutationReplay[] mutations,
long replaySeqId) |
void |
blockUpdates() |
Map<byte[],List<org.apache.hadoop.fs.Path>> |
bulkLoadHFiles(Collection<Pair<byte[],String>> familyPaths,
boolean assignSeqId,
HRegion.BulkLoadListener bulkLoadListener)
Attempts to atomically load a group of hfiles.
|
Map<byte[],List<org.apache.hadoop.fs.Path>> |
bulkLoadHFiles(Collection<Pair<byte[],String>> familyPaths,
boolean assignSeqId,
HRegion.BulkLoadListener bulkLoadListener,
boolean copyFile)
Attempts to atomically load a group of hfiles.
|
boolean |
checkAndMutate(byte[] row,
byte[] family,
byte[] qualifier,
CompareOperator op,
ByteArrayComparable comparator,
TimeRange timeRange,
Mutation mutation)
Atomically checks if a row/family/qualifier value matches the expected value and if it does,
it performs the mutation.
|
boolean |
checkAndRowMutate(byte[] row,
byte[] family,
byte[] qualifier,
CompareOperator op,
ByteArrayComparable comparator,
TimeRange timeRange,
RowMutations rm)
Atomically checks if a row/family/qualifier value matches the expected values and if it does,
it performs the row mutations.
|
private void |
checkClassLoading() |
private void |
checkCompressionCodecs() |
private void |
checkEncryption() |
void |
checkFamilies(Collection<byte[]> families)
Check the collection of families for validity.
|
(package private) void |
checkFamily(byte[] family) |
private void |
checkMutationType(Mutation mutation,
byte[] row) |
private void |
checkNegativeMemStoreDataSize(long memStoreDataSize,
long delta) |
protected void |
checkReadOnly() |
protected void |
checkReadsEnabled() |
(package private) void |
checkResources() |
(package private) void |
checkRow(byte[] row,
String op)
Make sure this is a valid row for the HRegion
|
byte[] |
checkSplit()
Return the splitpoint.
|
private void |
checkTargetRegion(byte[] encodedRegionName,
String exceptionMsg,
Object payload)
Checks whether the given regionName is either equal to our region, or that
the regionName is the primary region to our corresponding range for the secondary replica.
|
void |
checkTimestamps(Map<byte[],List<Cell>> familyMap,
long now)
Check the collection of families for valid timestamps
|
(package private) void |
clearSplit() |
Map<byte[],List<HStoreFile>> |
close()
Close down this HRegion.
|
Map<byte[],List<HStoreFile>> |
close(boolean abort)
Close down this HRegion.
|
private void |
closeBulkRegionOperation()
Closes the lock.
|
void |
closeRegionOperation()
Closes the region operation lock.
|
void |
closeRegionOperation(Region.Operation operation)
Closes the region operation lock.
|
void |
compact(boolean majorCompaction)
Synchronously compact all stores in the region.
|
boolean |
compact(CompactionContext compaction,
HStore store,
ThroughputController throughputController)
Called by compaction thread and after region is opened to compact the
HStores if necessary.
|
boolean |
compact(CompactionContext compaction,
HStore store,
ThroughputController throughputController,
User user) |
(package private) void |
compactStore(byte[] family,
ThroughputController throughputController)
This is a helper function that compact the given store.
|
void |
compactStores()
This is a helper function that compact all the stores synchronously.
|
static HDFSBlocksDistribution |
computeHDFSBlocksDistribution(org.apache.hadoop.conf.Configuration conf,
TableDescriptor tableDescriptor,
RegionInfo regionInfo)
This is a helper function to compute HDFS block distribution on demand
|
static HDFSBlocksDistribution |
computeHDFSBlocksDistribution(org.apache.hadoop.conf.Configuration conf,
TableDescriptor tableDescriptor,
RegionInfo regionInfo,
org.apache.hadoop.fs.Path tablePath)
This is a helper function to compute HDFS block distribution on demand
|
static HRegion |
createHRegion(RegionInfo info,
org.apache.hadoop.fs.Path rootDir,
org.apache.hadoop.conf.Configuration conf,
TableDescriptor hTableDescriptor,
WAL wal) |
static HRegion |
createHRegion(RegionInfo info,
org.apache.hadoop.fs.Path rootDir,
org.apache.hadoop.conf.Configuration conf,
TableDescriptor hTableDescriptor,
WAL wal,
boolean initialize)
Convenience method creating new HRegions.
|
static HRegionFileSystem |
createRegionDir(org.apache.hadoop.conf.Configuration configuration,
RegionInfo ri,
org.apache.hadoop.fs.Path rootDir)
Create the region directory in the filesystem.
|
(package private) static void |
decorateRegionConfiguration(org.apache.hadoop.conf.Configuration conf)
This method modifies the region's configuration in order to inject replication-related
features
|
void |
decrementCompactionsQueuedCount() |
(package private) void |
decrMemStoreSize(long dataSizeDelta,
long heapSizeDelta,
long offHeapSizeDelta,
int cellsCountDelta) |
(package private) void |
decrMemStoreSize(MemStoreSize mss) |
void |
delete(Delete delete)
Deletes the specified cells/row.
|
(package private) void |
delete(NavigableMap<byte[],List<Cell>> familyMap,
Durability durability)
This is used only by unit tests.
|
void |
deregisterChildren(ConfigurationManager manager)
Needs to be called to deregister the children from the manager.
|
private void |
doAbortFlushToWAL(WAL wal,
long flushOpSeqId,
Map<byte[],List<org.apache.hadoop.fs.Path>> committedFiles) |
private void |
doBatchMutate(Mutation mutation) |
private boolean |
doCheckAndRowMutate(byte[] row,
byte[] family,
byte[] qualifier,
CompareOperator op,
ByteArrayComparable comparator,
TimeRange timeRange,
RowMutations rowMutations,
Mutation mutation)
checkAndMutate and checkAndRowMutate are 90% the same.
|
private Map<byte[],List<HStoreFile>> |
doClose(boolean abort,
MonitoredTask status) |
private Result |
doCoprocessorPreCall(Region.Operation op,
Mutation mutation)
Do coprocessor pre-increment or pre-append call.
|
private Result |
doDelta(Region.Operation op,
Mutation mutation,
long nonceGroup,
long nonce,
boolean returnResults)
Add "deltas" to Cells.
|
private MemStoreSize |
doDropStoreMemStoreContentsForSeqId(HStore s,
long currentSeqId) |
private void |
doMiniBatchMutate(HRegion.BatchOperation<?> batchOp)
Called to do a piece of the batch that came in to
batchMutate(Mutation[], long, long)
In here we also handle replay of edits on region recover. |
private void |
doProcessRowWithTimeout(RowProcessor<?,?> processor,
long now,
HRegion region,
List<Mutation> mutations,
WALEdit walEdit,
long timeout) |
protected void |
doRegionCompactionPrep()
Do preparation for pending compaction.
|
private static void |
doSyncOfUnflushedWALChanges(WAL wal,
RegionInfo hri)
Sync unflushed WAL changes.
|
private MultiVersionConcurrencyControl.WriteEntry |
doWALAppend(WALEdit walEdit,
Durability durability,
List<UUID> clusterIds,
long now,
long nonceGroup,
long nonce) |
private MultiVersionConcurrencyControl.WriteEntry |
doWALAppend(WALEdit walEdit,
Durability durability,
List<UUID> clusterIds,
long now,
long nonceGroup,
long nonce,
long origLogSeqNum) |
private MultiVersionConcurrencyControl.WriteEntry |
doWALAppend(WALEdit walEdit,
Durability durability,
long nonceGroup,
long nonce) |
MemStoreSize |
dropMemStoreContents()
Be careful, this method will drop all data in the memstore of this region.
|
private MemStoreSize |
dropMemStoreContentsForSeqId(long seqId,
HStore store)
Drops the memstore contents after replaying a flush descriptor or region open event replay
if the memstore edits have seqNums smaller than the given seq id
|
private void |
dropPrepareFlushIfPossible()
If all stores ended up dropping their snapshots, we can safely drop the prepareFlushResult
|
boolean |
equals(Object o) |
com.google.protobuf.Message |
execService(com.google.protobuf.RpcController controller,
org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceCall call)
Executes a single protocol buffer coprocessor endpoint
Service method using
the registered protocol handlers. |
HRegion.FlushResult |
flush(boolean force)
Flush the cache.
|
HRegion.FlushResultImpl |
flushcache(boolean forceFlushAllStores,
boolean writeFlushRequestWalMarker,
FlushLifeCycleTracker tracker)
Flush the cache.
|
(package private) void |
forceSplit(byte[] sp) |
Result |
get(Get get)
Do a get based on the get parameter.
|
List<Cell> |
get(Get get,
boolean withCoprocessor)
Do a get based on the get parameter.
|
List<Cell> |
get(Get get,
boolean withCoprocessor,
long nonceGroup,
long nonce) |
private List<Cell> |
get(Mutation mutation,
HStore store,
List<Cell> coordinates,
IsolationLevel isolation,
TimeRange tr)
Do a specific Get on passed
columnFamily and column qualifiers. |
(package private) org.apache.hadoop.conf.Configuration |
getBaseConf()
A split takes the config from the parent region & passes it to the daughter
region's constructor.
|
long |
getBlockedRequestsCount() |
CellComparator |
getCellComparator()
The comparator to be used with the region
|
long |
getCheckAndMutateChecksFailed() |
long |
getCheckAndMutateChecksPassed() |
CompactionState |
getCompactionState() |
int |
getCompactPriority() |
RegionCoprocessorHost |
getCoprocessorHost() |
long |
getDataInMemoryWithoutWAL() |
long |
getEarliestFlushTimeForAllStores() |
protected Durability |
getEffectiveDurability(Durability d)
Returns effective durability from the passed durability and
the table descriptor.
|
(package private) byte[] |
getExplicitSplitPoint() |
org.apache.hadoop.fs.FileSystem |
getFilesystem() |
long |
getFilteredReadRequestsCount() |
HDFSBlocksDistribution |
getHDFSBlocksDistribution() |
org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionLoadStats |
getLoadStatistics() |
ConcurrentHashMap<HashedBytes,HRegion.RowLockContext> |
getLockedRows() |
private static long |
getLongValue(Cell cell) |
long |
getMaxFlushedSeqId() |
Map<byte[],Long> |
getMaxStoreSeqId() |
long |
getMemStoreDataSize() |
long |
getMemStoreFlushSize() |
long |
getMemStoreHeapSize() |
long |
getMemStoreOffHeapSize() |
MetricsRegion |
getMetrics() |
MultiVersionConcurrencyControl |
getMVCC() |
protected long |
getNextSequenceId(WAL wal)
Method to safely get the next sequence number.
|
long |
getNumMutationsWithoutWAL() |
long |
getOldestHfileTs(boolean majorCompactionOnly)
This can be used to determine the last time all files of this region were major compacted.
|
long |
getOldestSeqIdOfStore(byte[] familyName) |
(package private) static ThreadPoolExecutor |
getOpenAndCloseThreadPool(int maxThreads,
String threadNamePrefix) |
long |
getOpenSeqNum() |
(package private) HRegion.PrepareFlushResult |
getPrepareFlushResult() |
int |
getReadLockCount() |
long |
getReadPoint() |
long |
getReadPoint(IsolationLevel isolationLevel) |
long |
getReadRequestsCount() |
static org.apache.hadoop.fs.Path |
getRegionDir(org.apache.hadoop.fs.Path tabledir,
String name)
Deprecated.
For tests only; to be removed.
|
HRegionFileSystem |
getRegionFileSystem() |
RegionInfo |
getRegionInfo() |
(package private) RegionServerServices |
getRegionServerServices() |
RegionServicesForStores |
getRegionServicesForStores() |
(package private) HRegionFileSystem |
getRegionWALFileSystem() |
NavigableMap<byte[],Integer> |
getReplicationScope() |
Region.RowLock |
getRowLock(byte[] row)
Get an exclusive ( write lock ) lock on a given row.
|
Region.RowLock |
getRowLock(byte[] row,
boolean readLock)
Get a row lock for the specified row.
|
protected Region.RowLock |
getRowLockInternal(byte[] row,
boolean readLock,
Region.RowLock prevRowLock) |
HRegion.RegionScannerImpl |
getScanner(Scan scan)
Return an iterator that scans over the HRegion, returning the indicated
columns and rows specified by the
Scan . |
HRegion.RegionScannerImpl |
getScanner(Scan scan,
List<KeyValueScanner> additionalScanners)
Return an iterator that scans over the HRegion, returning the indicated columns and rows
specified by the
Scan . |
private HRegion.RegionScannerImpl |
getScanner(Scan scan,
List<KeyValueScanner> additionalScanners,
long nonceGroup,
long nonce) |
long |
getSmallestReadPoint() |
RegionSplitPolicy |
getSplitPolicy() |
HStore |
getStore(byte[] column)
Return the Store for the given family
|
private HStore |
getStore(Cell cell)
Return HStore instance.
|
List<String> |
getStoreFileList(byte[][] columns) |
protected ThreadPoolExecutor |
getStoreFileOpenAndCloseThreadPool(String threadNamePrefix) |
private NavigableMap<byte[],List<org.apache.hadoop.fs.Path>> |
getStoreFiles() |
protected ThreadPoolExecutor |
getStoreOpenAndCloseThreadPool(String threadNamePrefix) |
List<HStore> |
getStores()
Return the list of Stores managed by this region
|
TableDescriptor |
getTableDescriptor() |
WAL |
getWAL() |
(package private) org.apache.hadoop.fs.FileSystem |
getWalFileSystem() |
org.apache.hadoop.fs.Path |
getWALRegionDir() |
long |
getWriteRequestsCount() |
int |
hashCode() |
private static boolean |
hasMultipleColumnFamilies(Collection<Pair<byte[],String>> familyPaths)
Determines whether multiple column families are present
Precondition: familyPaths is not null
|
boolean |
hasReferences() |
long |
heapSize() |
(package private) void |
incMemStoreSize(long dataSizeDelta,
long heapSizeDelta,
long offHeapSizeDelta,
int cellsCountDelta) |
(package private) void |
incMemStoreSize(MemStoreSize mss)
Increase the size of mem store in this region and the size of global mem
store
|
Result |
increment(Increment increment)
Perform one or more increment operations on a row.
|
Result |
increment(Increment mutation,
long nonceGroup,
long nonce) |
void |
incrementCompactionsQueuedCount() |
void |
incrementFlushesQueuedCount() |
long |
initialize()
Deprecated.
use HRegion.createHRegion() or HRegion.openHRegion()
|
(package private) long |
initialize(CancelableProgressable reporter)
Initialize this region.
|
private long |
initializeRegionInternals(CancelableProgressable reporter,
MonitoredTask status) |
private long |
initializeStores(CancelableProgressable reporter,
MonitoredTask status)
Open all Stores.
|
private void |
initializeWarmup(CancelableProgressable reporter) |
protected HStore |
instantiateHStore(ColumnFamilyDescriptor family) |
protected RegionScanner |
instantiateRegionScanner(Scan scan,
List<KeyValueScanner> additionalScanners) |
protected HRegion.RegionScannerImpl |
instantiateRegionScanner(Scan scan,
List<KeyValueScanner> additionalScanners,
long nonceGroup,
long nonce) |
private HRegion.FlushResultImpl |
internalFlushcache(Collection<HStore> storesToFlush,
MonitoredTask status,
boolean writeFlushWalMarker,
FlushLifeCycleTracker tracker)
Flushing given stores.
|
private HRegion.FlushResult |
internalFlushcache(MonitoredTask status)
Flushing all stores.
|
protected HRegion.FlushResultImpl |
internalFlushcache(WAL wal,
long myseqid,
Collection<HStore> storesToFlush,
MonitoredTask status,
boolean writeFlushWalMarker,
FlushLifeCycleTracker tracker)
Flush the memstore.
|
protected HRegion.FlushResultImpl |
internalFlushCacheAndCommit(WAL wal,
MonitoredTask status,
HRegion.PrepareFlushResult prepareResult,
Collection<HStore> storesToFlush) |
protected HRegion.PrepareFlushResult |
internalPrepareFlushCache(WAL wal,
long myseqid,
Collection<HStore> storesToFlush,
MonitoredTask status,
boolean writeFlushWalMarker,
FlushLifeCycleTracker tracker) |
private boolean |
isAllFamilies(Collection<HStore> families) |
boolean |
isAvailable() |
boolean |
isClosed() |
boolean |
isClosing() |
private boolean |
isFlushSize(MemStoreSize size) |
boolean |
isLoadingCfsOnDemandDefault() |
boolean |
isMergeable() |
boolean |
isReadOnly() |
boolean |
isSplittable() |
private static boolean |
isZeroLengthThenDelete(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path p) |
private void |
lock(Lock lock) |
private void |
lock(Lock lock,
int multiplier)
Try to acquire a lock.
|
private void |
logFatLineOnFlush(Collection<HStore> storesToFlush,
long sequenceId)
Utility method broken out of internalPrepareFlushCache so that method is smaller.
|
private void |
logRegionFiles() |
private boolean |
matches(CompareOperator op,
int compareResult) |
(package private) void |
metricsUpdateForGet(List<Cell> results,
long before) |
void |
mutateRow(RowMutations rm)
Performs multiple mutations atomically on a single row.
|
void |
mutateRowsWithLocks(Collection<Mutation> mutations,
Collection<byte[]> rowsToLock,
long nonceGroup,
long nonce)
Perform atomic (all or none) mutations within the region.
|
(package private) static HRegion |
newHRegion(org.apache.hadoop.fs.Path tableDir,
WAL wal,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.conf.Configuration conf,
RegionInfo regionInfo,
TableDescriptor htd,
RegionServerServices rsServices)
A utility method to create new instances of HRegion based on the
HConstants.REGION_IMPL configuration property. |
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. |
protected HRegion |
openHRegion(CancelableProgressable reporter)
Open HRegion.
|
static HRegion |
openHRegion(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootDir,
org.apache.hadoop.fs.Path tableDir,
RegionInfo info,
TableDescriptor htd,
WAL wal,
RegionServerServices rsServices,
CancelableProgressable reporter)
Open a Region.
|
static HRegion |
openHRegion(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootDir,
RegionInfo info,
TableDescriptor htd,
WAL wal)
Open a Region.
|
static HRegion |
openHRegion(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootDir,
RegionInfo info,
TableDescriptor htd,
WAL wal,
RegionServerServices rsServices,
CancelableProgressable reporter)
Open a Region.
|
static HRegion |
openHRegion(HRegion other,
CancelableProgressable reporter)
Useful when reopening a closed region (normally for unit tests)
|
static HRegion |
openHRegion(org.apache.hadoop.fs.Path rootDir,
RegionInfo info,
TableDescriptor htd,
WAL wal,
org.apache.hadoop.conf.Configuration conf)
Open a Region.
|
static HRegion |
openHRegion(org.apache.hadoop.fs.Path rootDir,
RegionInfo info,
TableDescriptor htd,
WAL wal,
org.apache.hadoop.conf.Configuration conf,
RegionServerServices rsServices,
CancelableProgressable reporter)
Open a Region.
|
static Region |
openHRegion(Region other,
CancelableProgressable reporter) |
static HRegion |
openHRegion(RegionInfo info,
TableDescriptor htd,
WAL wal,
org.apache.hadoop.conf.Configuration conf)
Open a Region.
|
static HRegion |
openHRegion(RegionInfo info,
TableDescriptor htd,
WAL wal,
org.apache.hadoop.conf.Configuration conf,
RegionServerServices rsServices,
CancelableProgressable reporter)
Open a Region.
|
static HRegion |
openReadOnlyFileSystemHRegion(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path tableDir,
RegionInfo info,
TableDescriptor htd)
Open a Region on a read-only file-system (like hdfs snapshots)
|
void |
prepareDelete(Delete delete)
Prepare a delete for a row mutation processor
|
void |
prepareDeleteTimestamps(Mutation mutation,
Map<byte[],List<Cell>> familyMap,
byte[] byteNow)
Set up correct timestamps in the KVs in Delete object.
|
(package private) void |
prepareGet(Get get) |
private void |
preProcess(RowProcessor<?,?> processor,
WALEdit walEdit) |
void |
processRowsWithLocks(RowProcessor<?,?> processor)
Performs atomic multiple reads and writes on a given row.
|
void |
processRowsWithLocks(RowProcessor<?,?> processor,
long nonceGroup,
long nonce)
Performs atomic multiple reads and writes on a given row.
|
void |
processRowsWithLocks(RowProcessor<?,?> processor,
long timeout,
long nonceGroup,
long nonce)
Performs atomic multiple reads and writes on a given row.
|
(package private) void |
put(byte[] row,
byte[] family,
List<Cell> edits)
Add updates first to the wal and then add values to memstore.
|
void |
put(Put put)
Puts some data in the table.
|
private static Cell |
reckonDelta(Cell delta,
Cell currentCell,
byte[] columnFamily,
long now,
Mutation mutation,
Function<Cell,byte[]> supplier) |
private WALEdit |
reckonDeltas(Region.Operation op,
Mutation mutation,
Durability effectiveDurability,
Map<HStore,List<Cell>> forMemStore,
List<Cell> results)
Reckon the Cells to apply to WAL, memstore, and to return to the Client; these Sets are not
always the same dependent on whether to write WAL.
|
private List<Cell> |
reckonDeltasByStore(HStore store,
Region.Operation op,
Mutation mutation,
Durability effectiveDurability,
long now,
List<Cell> deltas,
List<Cell> results)
Reckon the Cells to apply to WAL, memstore, and to return to the Client in passed
column family/Store.
|
private void |
recordMutationWithoutWal(Map<byte[],List<Cell>> familyMap)
Update LongAdders for number of puts without wal and the size of possible data loss.
|
boolean |
refreshStoreFiles()
Check the region's underlying store files, open the files that have not
been opened yet, and remove the store file readers for store files no
longer available.
|
protected boolean |
refreshStoreFiles(boolean force) |
void |
registerChildren(ConfigurationManager manager)
Needs to be called to register the children to the manager.
|
boolean |
registerService(com.google.protobuf.Service instance)
Registers a new protocol buffer
Service subclass as a coprocessor endpoint to
be available for handling Region#execService(com.google.protobuf.RpcController,
org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CoprocessorServiceCall) calls. |
private void |
releaseRowLocks(List<Region.RowLock> rowLocks) |
private void |
replayFlushInStores(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush,
HRegion.PrepareFlushResult prepareFlushResult,
boolean dropMemstoreSnapshot)
Replays the given flush descriptor by opening the flush files in stores and dropping the
memstore snapshots if requested.
|
private long |
replayRecoveredEdits(org.apache.hadoop.fs.Path edits,
Map<byte[],Long> maxSeqIdInStores,
CancelableProgressable reporter,
org.apache.hadoop.fs.FileSystem fs) |
private long |
replayRecoveredEditsForPaths(long minSeqIdForTheRegion,
org.apache.hadoop.fs.FileSystem fs,
NavigableSet<org.apache.hadoop.fs.Path> files,
CancelableProgressable reporter,
org.apache.hadoop.fs.Path regionDir) |
protected long |
replayRecoveredEditsIfAny(Map<byte[],Long> maxSeqIdInStores,
CancelableProgressable reporter,
MonitoredTask status)
Read the edits put under this region by wal splitting process.
|
(package private) void |
replayWALBulkLoadEventMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.BulkLoadDescriptor bulkLoadEvent) |
(package private) void |
replayWALCompactionMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.CompactionDescriptor compaction,
boolean pickCompactionFiles,
boolean removeFiles,
long replaySeqId)
Call to complete a compaction.
|
private void |
replayWALFlushAbortMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush) |
private void |
replayWALFlushCannotFlushMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush,
long replaySeqId) |
(package private) void |
replayWALFlushCommitMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush) |
(package private) void |
replayWALFlushMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush,
long replaySeqId) |
(package private) HRegion.PrepareFlushResult |
replayWALFlushStartMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush)
Replay the flush marker from primary region by creating a corresponding snapshot of
the store memstores, only if the memstores do not have a higher seqId from an earlier wal
edit (because the events may be coming out of order).
|
(package private) void |
replayWALRegionEventMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.RegionEventDescriptor regionEvent) |
void |
reportCompactionRequestEnd(boolean isMajor,
int numFiles,
long filesSizeCompacted) |
void |
reportCompactionRequestFailure() |
void |
reportCompactionRequestStart(boolean isMajor) |
void |
requestCompaction(byte[] family,
String why,
int priority,
boolean major,
CompactionLifeCycleTracker tracker)
Request compaction for the given family
|
void |
requestCompaction(String why,
int priority,
boolean major,
CompactionLifeCycleTracker tracker)
Request compaction on this region.
|
private void |
requestFlush() |
void |
requestFlush(FlushLifeCycleTracker tracker)
Request flush on this region.
|
private void |
requestFlush0(FlushLifeCycleTracker tracker) |
private void |
requestFlushIfNeeded() |
protected void |
restoreEdit(HStore s,
Cell cell,
MemStoreSizing memstoreAccounting)
Used by tests
|
(package private) void |
rewriteCellTags(Map<byte[],List<Cell>> familyMap,
Mutation m)
Possibly rewrite incoming cell tags.
|
static boolean |
rowIsInRange(RegionInfo info,
byte[] row)
Determines if the specified row is within the row range specified by the
specified RegionInfo
|
static boolean |
rowIsInRange(RegionInfo info,
byte[] row,
int offset,
short length) |
void |
setClosing(boolean closing)
Exposed for some very specific unit tests.
|
(package private) org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos.RegionLoad.Builder |
setCompleteSequenceId(org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos.RegionLoad.Builder regionLoadBldr) |
void |
setCoprocessorHost(RegionCoprocessorHost coprocessorHost) |
(package private) void |
setHTableSpecificConf() |
void |
setReadsEnabled(boolean readsEnabled) |
(package private) void |
setTableDescriptor(TableDescriptor desc) |
void |
setTimeoutForWriteLock(long timeoutForWriteLock)
The
doClose(boolean, org.apache.hadoop.hbase.monitoring.MonitoredTask) will block forever if someone tries proving the dead lock via the unit test. |
(package private) boolean |
shouldFlush(StringBuilder whyFlush)
Should the memstore be flushed now
|
(package private) boolean |
shouldFlushStore(HStore store)
Should the store be flushed because it is old enough.
|
(package private) boolean |
shouldForceSplit() |
private boolean |
shouldSyncWAL()
Check whether we should sync the wal from the table's durability settings
|
private static List<Cell> |
sort(List<Cell> cells,
CellComparator comparator) |
private void |
startBulkRegionOperation(boolean writeLockNeeded)
This method needs to be called before any public call that reads or
modifies stores in bulk.
|
void |
startRegionOperation()
This method needs to be called before any public call that reads or
modifies data.
|
void |
startRegionOperation(Region.Operation op)
This method needs to be called before any public call that reads or
modifies data.
|
private void |
sync(long txid,
Durability durability)
Calls sync with the given transaction ID
|
(package private) void |
throwException(String title,
String regionName) |
String |
toString() |
void |
unblockUpdates() |
private static void |
updateCellTimestamps(Iterable<List<Cell>> cellItr,
byte[] now)
Replace any cell timestamps set to
HConstants.LATEST_TIMESTAMP
provided current timestamp. |
(package private) void |
updateDeleteLatestVersionTimestamp(Cell cell,
Get get,
int count,
byte[] byteNow) |
private void |
updateSequenceId(Iterable<List<Cell>> cellItr,
long sequenceId) |
void |
waitForFlushes()
Wait for all current flushes of the region to complete
|
boolean |
waitForFlushes(long timeout)
Wait for all current flushes of the region to complete
|
void |
waitForFlushesAndCompactions()
Wait for all current flushes and compactions of the region to complete
|
static void |
warmupHRegion(RegionInfo info,
TableDescriptor htd,
WAL wal,
org.apache.hadoop.conf.Configuration conf,
RegionServerServices rsServices,
CancelableProgressable reporter) |
private boolean |
worthPreFlushing() |
private boolean |
writeFlushRequestMarkerToWAL(WAL wal,
boolean writeFlushWalMarker)
Writes a marker to WAL indicating a flush is requested but cannot be complete due to various
reasons.
|
private void |
writeRegionCloseMarker(WAL wal) |
private void |
writeRegionOpenMarker(WAL wal,
long openSeqId) |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
checkAndMutate, checkAndRowMutate
private static final org.slf4j.Logger LOG
public static final String LOAD_CFS_ON_DEMAND_CONFIG_KEY
public static final String HBASE_MAX_CELL_SIZE_KEY
public static final int DEFAULT_MAX_CELL_SIZE
public static final String HBASE_REGIONSERVER_MINIBATCH_SIZE
public static final int DEFAULT_HBASE_REGIONSERVER_MINIBATCH_SIZE
private static final Durability DEFAULT_DURABILITY
final AtomicBoolean closed
final AtomicBoolean closing
private volatile long maxFlushedSeqId
private volatile long lastFlushOpSeqId
maxFlushedSeqId
when flushing a single column family. In this case,
maxFlushedSeqId
will be older than the oldest edit in memory.protected volatile long lastReplayedOpenRegionSeqId
protected volatile long lastReplayedCompactionSeqId
private final ConcurrentHashMap<HashedBytes,HRegion.RowLockContext> lockedRows
private Map<String,com.google.protobuf.Service> coprocessorServiceHandlers
private final MemStoreSizing memStoreSizing
RegionServicesForStores regionServicesForStores
final LongAdder numMutationsWithoutWAL
final LongAdder dataInMemoryWithoutWAL
final LongAdder checkAndMutateChecksPassed
final LongAdder checkAndMutateChecksFailed
final LongAdder readRequestsCount
final LongAdder filteredReadRequestsCount
final LongAdder writeRequestsCount
private final LongAdder blockedRequestsCount
final LongAdder compactionsFinished
final LongAdder compactionsFailed
final LongAdder compactionNumFilesCompacted
final LongAdder compactionNumBytesCompacted
final LongAdder compactionsQueued
final LongAdder flushesQueued
private final HRegionFileSystem fs
protected final org.apache.hadoop.conf.Configuration conf
private final org.apache.hadoop.conf.Configuration baseConf
private final int rowLockWaitDuration
static final int DEFAULT_ROWLOCK_WAIT_DURATION
private org.apache.hadoop.fs.Path regionDir
private org.apache.hadoop.fs.FileSystem walFS
final long busyWaitDuration
static final long DEFAULT_BUSY_WAIT_DURATION
final int maxBusyWaitMultiplier
final long maxBusyWaitDuration
final long maxCellSize
private final int miniBatchSize
static final long DEFAULT_ROW_PROCESSOR_TIMEOUT
final ExecutorService rowProcessorExecutor
private final ConcurrentHashMap<RegionScanner,Long> scannerReadPoints
private long openSeqNum
private boolean isLoadingCfsOnDemandDefault
private final AtomicInteger majorInProgress
private final AtomicInteger minorInProgress
Map<byte[],Long> maxSeqIdInStores
private HRegion.PrepareFlushResult prepareFlushResult
private volatile Optional<ConfigurationManager> configurationManager
private volatile Long timeoutForWriteLock
final HRegion.WriteState writestate
long memstoreFlushSize
final long timestampSlop
final long rowProcessorTimeout
private final ConcurrentMap<HStore,Long> lastStoreFlushTimeMap
final RegionServerServices rsServices
private RegionServerAccounting rsAccounting
private long flushCheckInterval
private long flushPerChanges
private long blockingMemStoreSize
final ReentrantReadWriteLock lock
private final ReentrantReadWriteLock updatesLock
private boolean splitRequest
private byte[] explicitSplitPoint
private final MultiVersionConcurrencyControl mvcc
private RegionCoprocessorHost coprocessorHost
private TableDescriptor htableDescriptor
private RegionSplitPolicy splitPolicy
private FlushPolicy flushPolicy
private final MetricsRegion metricsRegion
private final MetricsRegionWrapperImpl metricsRegionWrapper
private final Durability regionDurability
private final boolean regionStatsEnabled
private final NavigableMap<byte[],Integer> replicationScope
public static final String MEMSTORE_PERIODIC_FLUSH_INTERVAL
public static final int DEFAULT_CACHE_FLUSH_INTERVAL
public static final int SYSTEM_CACHE_FLUSH_INTERVAL
public static final String MEMSTORE_FLUSH_PER_CHANGES
public static final long DEFAULT_FLUSH_PER_CHANGES
public static final long MAX_FLUSH_PER_CHANGES
private static final byte[] FOR_UNIT_TESTS_ONLY
public static final long FIXED_OVERHEAD
public static final long DEEP_OVERHEAD
private static final List<Cell> MOCKED_LIST
@Deprecated public HRegion(org.apache.hadoop.fs.Path tableDir, WAL wal, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.conf.Configuration confParam, RegionInfo regionInfo, TableDescriptor htd, RegionServerServices rsServices)
createHRegion(org.apache.hadoop.hbase.client.RegionInfo, org.apache.hadoop.fs.Path, org.apache.hadoop.conf.Configuration, org.apache.hadoop.hbase.client.TableDescriptor, org.apache.hadoop.hbase.wal.WAL, boolean)
or openHRegion(org.apache.hadoop.hbase.client.RegionInfo, org.apache.hadoop.hbase.client.TableDescriptor, org.apache.hadoop.hbase.wal.WAL, org.apache.hadoop.conf.Configuration)
method.tableDir
- qualified path of directory where region should be located,
usually the table directory.wal
- The WAL is the outbound log for any updates to the HRegion
The wal file is a logfile from the previous execution that's
custom-computed for this HRegion. The HRegionServer computes and sorts the
appropriate wal info for this HRegion. If there is a previous wal file
(implying that the HRegion has been written-to before), then read it from
the supplied path.fs
- is the filesystem.confParam
- is global configuration settings.regionInfo
- - RegionInfo that describes the region
is new), then read them from the supplied path.htd
- the table descriptorrsServices
- reference to RegionServerServices
or nullpublic HRegion(HRegionFileSystem fs, WAL wal, org.apache.hadoop.conf.Configuration confParam, TableDescriptor htd, RegionServerServices rsServices)
createHRegion(org.apache.hadoop.hbase.client.RegionInfo, org.apache.hadoop.fs.Path, org.apache.hadoop.conf.Configuration, org.apache.hadoop.hbase.client.TableDescriptor, org.apache.hadoop.hbase.wal.WAL, boolean)
or openHRegion(org.apache.hadoop.hbase.client.RegionInfo, org.apache.hadoop.hbase.client.TableDescriptor, org.apache.hadoop.hbase.wal.WAL, org.apache.hadoop.conf.Configuration)
method.fs
- is the filesystem.wal
- The WAL is the outbound log for any updates to the HRegion
The wal file is a logfile from the previous execution that's
custom-computed for this HRegion. The HRegionServer computes and sorts the
appropriate wal info for this HRegion. If there is a previous wal file
(implying that the HRegion has been written-to before), then read it from
the supplied path.confParam
- is global configuration settings.htd
- the table descriptorrsServices
- reference to RegionServerServices
or nullpublic long getSmallestReadPoint()
void setHTableSpecificConf()
@Deprecated public long initialize() throws IOException
IOException
- elong initialize(CancelableProgressable reporter) throws IOException
reporter
- Tickle every so often if initialize is taking a while.IOException
- eprivate long initializeRegionInternals(CancelableProgressable reporter, MonitoredTask status) throws IOException
IOException
private long initializeStores(CancelableProgressable reporter, MonitoredTask status) throws IOException
reporter
- status
- IOException
private void initializeWarmup(CancelableProgressable reporter) throws IOException
IOException
private NavigableMap<byte[],List<org.apache.hadoop.fs.Path>> getStoreFiles()
private void writeRegionOpenMarker(WAL wal, long openSeqId) throws IOException
IOException
private void writeRegionCloseMarker(WAL wal) throws IOException
IOException
public boolean hasReferences()
public void blockUpdates()
public void unblockUpdates()
public HDFSBlocksDistribution getHDFSBlocksDistribution()
public static HDFSBlocksDistribution computeHDFSBlocksDistribution(org.apache.hadoop.conf.Configuration conf, TableDescriptor tableDescriptor, RegionInfo regionInfo) throws IOException
conf
- configurationtableDescriptor
- TableDescriptor of the tableregionInfo
- encoded name of the regionIOException
public static HDFSBlocksDistribution computeHDFSBlocksDistribution(org.apache.hadoop.conf.Configuration conf, TableDescriptor tableDescriptor, RegionInfo regionInfo, org.apache.hadoop.fs.Path tablePath) throws IOException
conf
- configurationtableDescriptor
- TableDescriptor of the tableregionInfo
- encoded name of the regiontablePath
- the table directoryIOException
void incMemStoreSize(MemStoreSize mss)
void incMemStoreSize(long dataSizeDelta, long heapSizeDelta, long offHeapSizeDelta, int cellsCountDelta)
void decrMemStoreSize(MemStoreSize mss)
void decrMemStoreSize(long dataSizeDelta, long heapSizeDelta, long offHeapSizeDelta, int cellsCountDelta)
private void checkNegativeMemStoreDataSize(long memStoreDataSize, long delta)
public RegionInfo getRegionInfo()
getRegionInfo
in interface Region
RegionServerServices getRegionServerServices()
RegionServerServices
used by this HRegion.
Can be null.public long getReadRequestsCount()
getReadRequestsCount
in interface Region
public long getFilteredReadRequestsCount()
getFilteredReadRequestsCount
in interface Region
public long getWriteRequestsCount()
getWriteRequestsCount
in interface Region
public long getMemStoreDataSize()
getMemStoreDataSize
in interface Region
public long getMemStoreHeapSize()
getMemStoreHeapSize
in interface Region
public long getMemStoreOffHeapSize()
getMemStoreOffHeapSize
in interface Region
public RegionServicesForStores getRegionServicesForStores()
public long getNumMutationsWithoutWAL()
getNumMutationsWithoutWAL
in interface Region
public long getDataInMemoryWithoutWAL()
getDataInMemoryWithoutWAL
in interface Region
public long getBlockedRequestsCount()
getBlockedRequestsCount
in interface Region
public long getCheckAndMutateChecksPassed()
getCheckAndMutateChecksPassed
in interface Region
public long getCheckAndMutateChecksFailed()
getCheckAndMutateChecksFailed
in interface Region
public MetricsRegion getMetrics()
public boolean isClosed()
public boolean isClosing()
public boolean isReadOnly()
isReadOnly
in interface Region
public boolean isAvailable()
isAvailable
in interface Region
public boolean isSplittable()
isSplittable
in interface Region
public boolean isMergeable()
isMergeable
in interface Region
public boolean areWritesEnabled()
public MultiVersionConcurrencyControl getMVCC()
public long getMaxFlushedSeqId()
getMaxFlushedSeqId
in interface Region
public long getReadPoint(IsolationLevel isolationLevel)
null
for defaultpublic boolean isLoadingCfsOnDemandDefault()
public Map<byte[],List<HStoreFile>> close() throws IOException
This method could take some time to execute, so don't call it from a time-sensitive thread.
IOException
- eDroppedSnapshotException
- Thrown when replay of wal is required
because a Snapshot was not properly persisted. The region is put in closing mode, and the
caller MUST abort after this.public Map<byte[],List<HStoreFile>> close(boolean abort) throws IOException
abort
- true if server is aborting (only during testing)IOException
- eDroppedSnapshotException
- Thrown when replay of wal is required
because a Snapshot was not properly persisted. The region is put in closing mode, and the
caller MUST abort after this.public void setClosing(boolean closing)
public void setTimeoutForWriteLock(long timeoutForWriteLock)
doClose(boolean, org.apache.hadoop.hbase.monitoring.MonitoredTask)
will block forever if someone tries proving the dead lock via the unit test.
Instead of blocking, the doClose(boolean, org.apache.hadoop.hbase.monitoring.MonitoredTask)
will throw exception if you set the timeout.timeoutForWriteLock
- the second time to wait for the write lock in doClose(boolean, org.apache.hadoop.hbase.monitoring.MonitoredTask)
private Map<byte[],List<HStoreFile>> doClose(boolean abort, MonitoredTask status) throws IOException
IOException
public void waitForFlushesAndCompactions()
public void waitForFlushes()
public boolean waitForFlushes(long timeout)
Region
waitForFlushes
in interface Region
timeout
- The maximum time to wait in milliseconds.protected ThreadPoolExecutor getStoreOpenAndCloseThreadPool(String threadNamePrefix)
protected ThreadPoolExecutor getStoreFileOpenAndCloseThreadPool(String threadNamePrefix)
static ThreadPoolExecutor getOpenAndCloseThreadPool(int maxThreads, String threadNamePrefix)
private boolean worthPreFlushing()
public TableDescriptor getTableDescriptor()
getTableDescriptor
in interface Region
void setTableDescriptor(TableDescriptor desc)
public RegionSplitPolicy getSplitPolicy()
org.apache.hadoop.conf.Configuration getBaseConf()
public org.apache.hadoop.fs.FileSystem getFilesystem()
FileSystem
being used by this regionpublic HRegionFileSystem getRegionFileSystem()
HRegionFileSystem
used by this regionHRegionFileSystem getRegionWALFileSystem() throws IOException
HRegionFileSystem
used by this regionIOException
org.apache.hadoop.fs.FileSystem getWalFileSystem() throws IOException
FileSystem
being used by this regionIOException
public org.apache.hadoop.fs.Path getWALRegionDir() throws IOException
IOException
- if there is an error getting WALRootDirpublic long getEarliestFlushTimeForAllStores()
getEarliestFlushTimeForAllStores
in interface Region
public long getOldestHfileTs(boolean majorCompactionOnly) throws IOException
Region
getOldestHfileTs
in interface Region
majorCompactionOnly
- Only consider HFile that are the result of major compactionIOException
org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos.RegionLoad.Builder setCompleteSequenceId(org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos.RegionLoad.Builder regionLoadBldr)
protected void doRegionCompactionPrep() throws IOException
IOException
public void compact(boolean majorCompaction) throws IOException
This operation could block for a long time, so don't call it from a time-sensitive thread.
Note that no locks are taken to prevent possible conflicts between compaction and splitting activities. The regionserver does not normally compact and split in parallel. However by calling this method you may introduce unexpected and unhandled concurrency. Don't do this unless you know what you are doing.
majorCompaction
- True to force a major compaction regardless of thresholdsIOException
public void compactStores() throws IOException
It is used by utilities and testing
IOException
void compactStore(byte[] family, ThroughputController throughputController) throws IOException
It is used by utilities and testing
IOException
public boolean compact(CompactionContext compaction, HStore store, ThroughputController throughputController) throws IOException
This operation could block for a long time, so don't call it from a time-sensitive thread. Note that no locking is necessary at this level because compaction only conflicts with a region split, and that cannot happen because the region server does them sequentially and not in parallel.
compaction
- Compaction details, obtained by requestCompaction()throughputController
- IOException
public boolean compact(CompactionContext compaction, HStore store, ThroughputController throughputController, User user) throws IOException
IOException
public HRegion.FlushResult flush(boolean force) throws IOException
When this method is called the cache will be flushed unless:
This method may block for some time, so it should not be called from a time-sensitive thread.
force
- whether we want to force a flush of all storesIOException
- general io exceptions
because a snapshot was not properly persisted.public HRegion.FlushResultImpl flushcache(boolean forceFlushAllStores, boolean writeFlushRequestWalMarker, FlushLifeCycleTracker tracker) throws IOException
This method may block for some time, so it should not be called from a time-sensitive thread.
forceFlushAllStores
- whether we want to flush all storeswriteFlushRequestWalMarker
- whether to write the flush request marker to WALtracker
- used to track the life cycle of this flushIOException
- general io exceptionsDroppedSnapshotException
- Thrown when replay of wal is required
because a Snapshot was not properly persisted. The region is put in closing mode, and the
caller MUST abort after this.boolean shouldFlushStore(HStore store)
Every FlushPolicy should call this to determine whether a store is old enough to flush (except that you always flush all stores). Otherwise the method will always returns true which will make a lot of flush requests.
boolean shouldFlush(StringBuilder whyFlush)
private HRegion.FlushResult internalFlushcache(MonitoredTask status) throws IOException
private HRegion.FlushResultImpl internalFlushcache(Collection<HStore> storesToFlush, MonitoredTask status, boolean writeFlushWalMarker, FlushLifeCycleTracker tracker) throws IOException
protected HRegion.FlushResultImpl internalFlushcache(WAL wal, long myseqid, Collection<HStore> storesToFlush, MonitoredTask status, boolean writeFlushWalMarker, FlushLifeCycleTracker tracker) throws IOException
This method may block for some time. Every time you call it, we up the regions sequence id even if we don't flush; i.e. the returned region id will be at least one larger than the last edit applied to this region. The returned id does not refer to an actual edit. The returned id can be used for say installing a bulk loaded file just ahead of the last hfile that was the result of this flush, etc.
wal
- Null if we're NOT to go via wal.myseqid
- The seqid to use if wal
is null writing out flush file.storesToFlush
- The list of stores to flush.IOException
- general io exceptionsDroppedSnapshotException
- Thrown when replay of WAL is required.protected HRegion.PrepareFlushResult internalPrepareFlushCache(WAL wal, long myseqid, Collection<HStore> storesToFlush, MonitoredTask status, boolean writeFlushWalMarker, FlushLifeCycleTracker tracker) throws IOException
IOException
private void logFatLineOnFlush(Collection<HStore> storesToFlush, long sequenceId)
private void doAbortFlushToWAL(WAL wal, long flushOpSeqId, Map<byte[],List<org.apache.hadoop.fs.Path>> committedFiles)
private static void doSyncOfUnflushedWALChanges(WAL wal, RegionInfo hri) throws IOException
IOException
private boolean isAllFamilies(Collection<HStore> families)
private boolean writeFlushRequestMarkerToWAL(WAL wal, boolean writeFlushWalMarker)
wal
- protected HRegion.FlushResultImpl internalFlushCacheAndCommit(WAL wal, MonitoredTask status, HRegion.PrepareFlushResult prepareResult, Collection<HStore> storesToFlush) throws IOException
IOException
protected long getNextSequenceId(WAL wal) throws IOException
IOException
public HRegion.RegionScannerImpl getScanner(Scan scan) throws IOException
Region
Scan
.
This Iterator must be closed by the caller.
getScanner
in interface Region
scan
- configured Scan
IOException
- read exceptionspublic HRegion.RegionScannerImpl getScanner(Scan scan, List<KeyValueScanner> additionalScanners) throws IOException
Region
Scan
. The scanner will also include the additional scanners passed
along with the scanners for the specified Scan instance. Should be careful with the usage to
pass additional scanners only within this Region
This Iterator must be closed by the caller.
getScanner
in interface Region
scan
- configured Scan
additionalScanners
- Any additional scanners to be usedIOException
- read exceptionsprivate HRegion.RegionScannerImpl getScanner(Scan scan, List<KeyValueScanner> additionalScanners, long nonceGroup, long nonce) throws IOException
IOException
protected RegionScanner instantiateRegionScanner(Scan scan, List<KeyValueScanner> additionalScanners) throws IOException
IOException
protected HRegion.RegionScannerImpl instantiateRegionScanner(Scan scan, List<KeyValueScanner> additionalScanners, long nonceGroup, long nonce) throws IOException
IOException
public void prepareDelete(Delete delete) throws IOException
delete
- The passed delete is modified by this method. WARNING!IOException
public void delete(Delete delete) throws IOException
Region
delete
in interface Region
IOException
void delete(NavigableMap<byte[],List<Cell>> familyMap, Durability durability) throws IOException
familyMap
- map of family to edits for the given family.IOException
public void prepareDeleteTimestamps(Mutation mutation, Map<byte[],List<Cell>> familyMap, byte[] byteNow) throws IOException
Caller should have the row and region locks.
mutation
- familyMap
- byteNow
- IOException
void updateDeleteLatestVersionTimestamp(Cell cell, Get get, int count, byte[] byteNow) throws IOException
IOException
public void put(Put put) throws IOException
Region
put
in interface Region
IOException
public OperationStatus[] batchMutate(Mutation[] mutations, long nonceGroup, long nonce) throws IOException
IOException
public OperationStatus[] batchMutate(Mutation[] mutations, boolean atomic, long nonceGroup, long nonce) throws IOException
IOException
public OperationStatus[] batchMutate(Mutation[] mutations) throws IOException
Region
Note this supports only Put and Delete mutations and will ignore other types passed.
batchMutate
in interface Region
mutations
- the list of mutationsIOException
public OperationStatus[] batchReplay(WALSplitter.MutationReplay[] mutations, long replaySeqId) throws IOException
IOException
OperationStatus[] batchMutate(HRegion.BatchOperation<?> batchOp) throws IOException
Durability.SKIP_WAL
.
This function is called from #batchReplay(WALSplitUtil.MutationReplay[], long)
with
HRegion.ReplayBatchOperation
instance and batchMutate(Mutation[], long, long)
with
HRegion.MutationBatchOperation
instance as an argument. As the processing of replay batch
and mutation batch is very similar, lot of code is shared by providing generic methods in
base class HRegion.BatchOperation
. The logic for this method and
doMiniBatchMutate(BatchOperation)
is implemented using methods in base class which
are overridden by derived classes to implement special behavior.
batchOp
- contains the list of mutationsIOException
- if an IO problem is encounteredprivate void doMiniBatchMutate(HRegion.BatchOperation<?> batchOp) throws IOException
batchMutate(Mutation[], long, long)
In here we also handle replay of edits on region recover. Also gets change in size brought
about by applying batchOp
.IOException
protected Durability getEffectiveDurability(Durability d)
public boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator, TimeRange timeRange, Mutation mutation) throws IOException
Region
checkAndMutate
in interface Region
row
- to checkfamily
- column family to checkqualifier
- column qualifier to checkop
- the comparison operatorcomparator
- the expected valuetimeRange
- time range to checkmutation
- data to put if check succeedsIOException
public boolean checkAndRowMutate(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator, TimeRange timeRange, RowMutations rm) throws IOException
Region
checkAndRowMutate
in interface Region
row
- to checkfamily
- column family to checkqualifier
- column qualifier to checkop
- the comparison operatorcomparator
- the expected valuetimeRange
- time range to checkrm
- data to put if check succeedsIOException
private boolean doCheckAndRowMutate(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator, TimeRange timeRange, RowMutations rowMutations, Mutation mutation) throws IOException
IOException
private void checkMutationType(Mutation mutation, byte[] row) throws DoNotRetryIOException
DoNotRetryIOException
private boolean matches(CompareOperator op, int compareResult)
private void doBatchMutate(Mutation mutation) throws IOException
IOException
public void addRegionToSnapshot(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription desc, ForeignExceptionSnare exnSnare) throws IOException
ForeignExceptionSnare
arg. (In the future other cancellable HRegion methods could eventually add a
ForeignExceptionSnare
, or we could do something fancier).desc
- snapshot description objectexnSnare
- ForeignExceptionSnare that captures external exceptions in case we need to
bail out. This is allowed to be null and will just be ignored in that case.IOException
- if there is an external or internal error causing the snapshot to failprivate void updateSequenceId(Iterable<List<Cell>> cellItr, long sequenceId) throws IOException
IOException
private static void updateCellTimestamps(Iterable<List<Cell>> cellItr, byte[] now) throws IOException
HConstants.LATEST_TIMESTAMP
provided current timestamp.cellItr
- now
- IOException
void rewriteCellTags(Map<byte[],List<Cell>> familyMap, Mutation m)
void checkResources() throws RegionTooBusyException
RegionTooBusyException
protected void checkReadOnly() throws IOException
IOException
- Throws exception if region is in read-only mode.protected void checkReadsEnabled() throws IOException
IOException
public void setReadsEnabled(boolean readsEnabled)
void put(byte[] row, byte[] family, List<Cell> edits) throws IOException
edits
- Cell updates by columnIOException
private void applyToMemStore(HStore store, List<Cell> cells, boolean delta, MemStoreSizing memstoreAccounting) throws IOException
delta
- If we are doing delta changes -- e.g. increment/append -- then this flag will be
set; when set we will run operations that make sense in the increment/append scenario
but that do not make sense otherwise.IOException
applyToMemStore(HStore, Cell, MemStoreSizing)
private void applyToMemStore(HStore store, Cell cell, MemStoreSizing memstoreAccounting) throws IOException
IOException
applyToMemStore(HStore, List, boolean, MemStoreSizing)
public void checkFamilies(Collection<byte[]> families) throws NoSuchColumnFamilyException
families
- NoSuchColumnFamilyException
public void checkTimestamps(Map<byte[],List<Cell>> familyMap, long now) throws FailedSanityCheckException
familyMap
- now
- current timestampFailedSanityCheckException
private boolean isFlushSize(MemStoreSize size)
protected long replayRecoveredEditsIfAny(Map<byte[],Long> maxSeqIdInStores, CancelableProgressable reporter, MonitoredTask status) throws IOException
We can ignore any wal message that has a sequence ID that's equal to or lower than minSeqId. (Because we know such messages are already reflected in the HFiles.)
While this is running we are putting pressure on memory yet we are outside of our usual accounting because we are not yet an onlined region (this stuff is being run as part of Region initialization). This means that if we're up against global memory limits, we'll not be flagged to flush because we are not online. We can't be flushed by usual mechanisms anyways; we're not yet online so our relative sequenceids are not yet aligned with WAL sequenceids -- not till we come up online, post processing of split edits.
But to help relieve memory pressure, at least manage our own heap size flushing if are in excess of per-region limits. Flushing, though, we have to be careful and avoid using the regionserver/wal sequenceid. Its running on a different line to whats going on in here in this region context so if we crashed replaying these edits, but in the midst had a flush that used the regionserver wal with a sequenceid in excess of whats going on in here in this region and with its split editlogs, then we could miss edits the next time we go to recover. So, we have to flush inline, using seqids that make sense in a this single region context only -- until we online.
maxSeqIdInStores
- Any edit found in split editlogs needs to be in excess of
the maxSeqId for the store to be applied, else its skipped.minSeqId
if nothing added from editlogs.IOException
private long replayRecoveredEditsForPaths(long minSeqIdForTheRegion, org.apache.hadoop.fs.FileSystem fs, NavigableSet<org.apache.hadoop.fs.Path> files, CancelableProgressable reporter, org.apache.hadoop.fs.Path regionDir) throws IOException
IOException
private long replayRecoveredEdits(org.apache.hadoop.fs.Path edits, Map<byte[],Long> maxSeqIdInStores, CancelableProgressable reporter, org.apache.hadoop.fs.FileSystem fs) throws IOException
IOException
void replayWALCompactionMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.CompactionDescriptor compaction, boolean pickCompactionFiles, boolean removeFiles, long replaySeqId) throws IOException
IOException
void replayWALFlushMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush, long replaySeqId) throws IOException
IOException
HRegion.PrepareFlushResult replayWALFlushStartMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush) throws IOException
IOException
void replayWALFlushCommitMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush) throws IOException
IOException
private void replayFlushInStores(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush, HRegion.PrepareFlushResult prepareFlushResult, boolean dropMemstoreSnapshot) throws IOException
flush
- prepareFlushResult
- dropMemstoreSnapshot
- IOException
public MemStoreSize dropMemStoreContents() throws IOException
IOException
private MemStoreSize dropMemStoreContentsForSeqId(long seqId, HStore store) throws IOException
IOException
private MemStoreSize doDropStoreMemStoreContentsForSeqId(HStore s, long currentSeqId) throws IOException
IOException
private void replayWALFlushAbortMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush)
private void replayWALFlushCannotFlushMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush, long replaySeqId)
HRegion.PrepareFlushResult getPrepareFlushResult()
void replayWALRegionEventMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.RegionEventDescriptor regionEvent) throws IOException
IOException
void replayWALBulkLoadEventMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.BulkLoadDescriptor bulkLoadEvent) throws IOException
IOException
private void dropPrepareFlushIfPossible()
public boolean refreshStoreFiles() throws IOException
Region
refreshStoreFiles
in interface Region
IOException
protected boolean refreshStoreFiles(boolean force) throws IOException
IOException
private void logRegionFiles()
private void checkTargetRegion(byte[] encodedRegionName, String exceptionMsg, Object payload) throws WrongRegionException
WrongRegionException
protected void restoreEdit(HStore s, Cell cell, MemStoreSizing memstoreAccounting)
s
- Store to add edit too.cell
- Cell to add.private static boolean isZeroLengthThenDelete(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path p) throws IOException
p
- File to check.IOException
protected HStore instantiateHStore(ColumnFamilyDescriptor family) throws IOException
IOException
public HStore getStore(byte[] column)
Region
Use with caution. Exposed for use of fixup utilities.
private HStore getStore(Cell cell)
public List<HStore> getStores()
Region
Use with caution. Exposed for use of fixup utilities.
public List<String> getStoreFileList(byte[][] columns) throws IllegalArgumentException
getStoreFileList
in interface Region
IllegalArgumentException
void checkRow(byte[] row, String op) throws IOException
IOException
public Region.RowLock getRowLock(byte[] row) throws IOException
row
- Which row to lock.IOException
public Region.RowLock getRowLock(byte[] row, boolean readLock) throws IOException
Region
The obtained locks should be released after use by Region.RowLock.release()
NOTE: the boolean passed here has changed. It used to be a boolean that stated whether or not to wait on the lock. Now it is whether it an exclusive lock is requested.
getRowLock
in interface Region
row
- The row actions will be performed againstreadLock
- is the lock reader or writer. True indicates that a non-exclusive
lock is requestedIOException
Region.startRegionOperation()
,
Region.startRegionOperation(Operation)
protected Region.RowLock getRowLockInternal(byte[] row, boolean readLock, Region.RowLock prevRowLock) throws IOException
IOException
private void releaseRowLocks(List<Region.RowLock> rowLocks)
public int getReadLockCount()
public ConcurrentHashMap<HashedBytes,HRegion.RowLockContext> getLockedRows()
private static boolean hasMultipleColumnFamilies(Collection<Pair<byte[],String>> familyPaths)
familyPaths
- List of (column family, hfilePath)public Map<byte[],List<org.apache.hadoop.fs.Path>> bulkLoadHFiles(Collection<Pair<byte[],String>> familyPaths, boolean assignSeqId, HRegion.BulkLoadListener bulkLoadListener) throws IOException
familyPaths
- List of Pair<byte[] column family, String hfilePath>bulkLoadListener
- Internal hooks enabling massaging/preparation of a
file about to be bulk loadedassignSeqId
- IOException
- if failed unrecoverably.public Map<byte[],List<org.apache.hadoop.fs.Path>> bulkLoadHFiles(Collection<Pair<byte[],String>> familyPaths, boolean assignSeqId, HRegion.BulkLoadListener bulkLoadListener, boolean copyFile) throws IOException
familyPaths
- List of Pair<byte[] column family, String hfilePath>assignSeqId
- bulkLoadListener
- Internal hooks enabling massaging/preparation of a
file about to be bulk loadedcopyFile
- always copy hfiles if trueIOException
- if failed unrecoverably.static HRegion newHRegion(org.apache.hadoop.fs.Path tableDir, WAL wal, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.conf.Configuration conf, RegionInfo regionInfo, TableDescriptor htd, RegionServerServices rsServices)
HConstants.REGION_IMPL
configuration property.tableDir
- qualified path of directory where region should be located,
usually the table directory.wal
- The WAL is the outbound log for any updates to the HRegion
The wal file is a logfile from the previous execution that's
custom-computed for this HRegion. The HRegionServer computes and sorts the
appropriate wal info for this HRegion. If there is a previous file
(implying that the HRegion has been written-to before), then read it from
the supplied path.fs
- is the filesystem.conf
- is global configuration settings.regionInfo
- - RegionInfo that describes the region
is new), then read them from the supplied path.htd
- the table descriptorpublic static HRegion createHRegion(RegionInfo info, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.conf.Configuration conf, TableDescriptor hTableDescriptor, WAL wal, boolean initialize) throws IOException
info
- Info for region to create.rootDir
- Root directory for HBase instancewal
- shared WALinitialize
- - true to initialize the regionIOException
public static HRegionFileSystem createRegionDir(org.apache.hadoop.conf.Configuration configuration, RegionInfo ri, org.apache.hadoop.fs.Path rootDir) throws IOException
IOException
public static HRegion createHRegion(RegionInfo info, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.conf.Configuration conf, TableDescriptor hTableDescriptor, WAL wal) throws IOException
IOException
public static HRegion openHRegion(RegionInfo info, TableDescriptor htd, WAL wal, org.apache.hadoop.conf.Configuration conf) throws IOException
info
- Info for region to be opened.wal
- WAL for region to use. This method will call
WAL#setSequenceNumber(long) passing the result of the call to
HRegion#getMinSequenceId() to ensure the wal id is properly kept
up. HRegionStore does this every time it opens a new region.IOException
public static HRegion openHRegion(RegionInfo info, TableDescriptor htd, WAL wal, org.apache.hadoop.conf.Configuration conf, RegionServerServices rsServices, CancelableProgressable reporter) throws IOException
info
- Info for region to be openedhtd
- the table descriptorwal
- WAL for region to use. This method will call
WAL#setSequenceNumber(long) passing the result of the call to
HRegion#getMinSequenceId() to ensure the wal id is properly kept
up. HRegionStore does this every time it opens a new region.conf
- The Configuration object to use.rsServices
- An interface we can request flushes against.reporter
- An interface we can report progress against.IOException
public static HRegion openHRegion(org.apache.hadoop.fs.Path rootDir, RegionInfo info, TableDescriptor htd, WAL wal, org.apache.hadoop.conf.Configuration conf) throws IOException
rootDir
- Root directory for HBase instanceinfo
- Info for region to be opened.htd
- the table descriptorwal
- WAL for region to use. This method will call
WAL#setSequenceNumber(long) passing the result of the call to
HRegion#getMinSequenceId() to ensure the wal id is properly kept
up. HRegionStore does this every time it opens a new region.conf
- The Configuration object to use.IOException
public static HRegion openHRegion(org.apache.hadoop.fs.Path rootDir, RegionInfo info, TableDescriptor htd, WAL wal, org.apache.hadoop.conf.Configuration conf, RegionServerServices rsServices, CancelableProgressable reporter) throws IOException
rootDir
- Root directory for HBase instanceinfo
- Info for region to be opened.htd
- the table descriptorwal
- WAL for region to use. This method will call
WAL#setSequenceNumber(long) passing the result of the call to
HRegion#getMinSequenceId() to ensure the wal id is properly kept
up. HRegionStore does this every time it opens a new region.conf
- The Configuration object to use.rsServices
- An interface we can request flushes against.reporter
- An interface we can report progress against.IOException
public static HRegion openHRegion(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootDir, RegionInfo info, TableDescriptor htd, WAL wal) throws IOException
conf
- The Configuration object to use.fs
- Filesystem to userootDir
- Root directory for HBase instanceinfo
- Info for region to be opened.htd
- the table descriptorwal
- WAL for region to use. This method will call
WAL#setSequenceNumber(long) passing the result of the call to
HRegion#getMinSequenceId() to ensure the wal id is properly kept
up. HRegionStore does this every time it opens a new region.IOException
public static HRegion openHRegion(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootDir, RegionInfo info, TableDescriptor htd, WAL wal, RegionServerServices rsServices, CancelableProgressable reporter) throws IOException
conf
- The Configuration object to use.fs
- Filesystem to userootDir
- Root directory for HBase instanceinfo
- Info for region to be opened.htd
- the table descriptorwal
- WAL for region to use. This method will call
WAL#setSequenceNumber(long) passing the result of the call to
HRegion#getMinSequenceId() to ensure the wal id is properly kept
up. HRegionStore does this every time it opens a new region.rsServices
- An interface we can request flushes against.reporter
- An interface we can report progress against.IOException
public static HRegion openHRegion(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.fs.Path tableDir, RegionInfo info, TableDescriptor htd, WAL wal, RegionServerServices rsServices, CancelableProgressable reporter) throws IOException
conf
- The Configuration object to use.fs
- Filesystem to userootDir
- Root directory for HBase instanceinfo
- Info for region to be opened.htd
- the table descriptorwal
- WAL for region to use. This method will call
WAL#setSequenceNumber(long) passing the result of the call to
HRegion#getMinSequenceId() to ensure the wal id is properly kept
up. HRegionStore does this every time it opens a new region.rsServices
- An interface we can request flushes against.reporter
- An interface we can report progress against.IOException
public NavigableMap<byte[],Integer> getReplicationScope()
public static HRegion openHRegion(HRegion other, CancelableProgressable reporter) throws IOException
other
- original objectreporter
- An interface we can report progress against.IOException
public static Region openHRegion(Region other, CancelableProgressable reporter) throws IOException
IOException
protected HRegion openHRegion(CancelableProgressable reporter) throws IOException
this
IOException
public static HRegion openReadOnlyFileSystemHRegion(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path tableDir, RegionInfo info, TableDescriptor htd) throws IOException
conf
- The Configuration object to use.fs
- Filesystem to useinfo
- Info for region to be opened.htd
- the table descriptorIOException
public static void warmupHRegion(RegionInfo info, TableDescriptor htd, WAL wal, org.apache.hadoop.conf.Configuration conf, RegionServerServices rsServices, CancelableProgressable reporter) throws IOException
IOException
private void checkCompressionCodecs() throws IOException
IOException
private void checkEncryption() throws IOException
IOException
private void checkClassLoading() throws IOException
IOException
@Deprecated public static org.apache.hadoop.fs.Path getRegionDir(org.apache.hadoop.fs.Path tabledir, String name)
tabledir
- qualified path for tablename
- ENCODED region namepublic static boolean rowIsInRange(RegionInfo info, byte[] row)
info
- RegionInfo that specifies the row rangerow
- row to be checkedpublic static boolean rowIsInRange(RegionInfo info, byte[] row, int offset, short length)
public Result get(Get get) throws IOException
Region
get
in interface Region
get
- query parametersIOException
void prepareGet(Get get) throws IOException
IOException
public List<Cell> get(Get get, boolean withCoprocessor) throws IOException
Region
get
in interface Region
get
- query parameterswithCoprocessor
- invoke coprocessor or not. We don't want to
always invoke cp.IOException
public List<Cell> get(Get get, boolean withCoprocessor, long nonceGroup, long nonce) throws IOException
IOException
void metricsUpdateForGet(List<Cell> results, long before)
public void mutateRow(RowMutations rm) throws IOException
Region
mutateRow
in interface Region
rm
- object that specifies the set of mutations to perform atomicallyIOException
public void mutateRowsWithLocks(Collection<Mutation> mutations, Collection<byte[]> rowsToLock, long nonceGroup, long nonce) throws IOException
mutateRowsWithLocks
in interface Region
mutations
- The list of mutations to perform.
mutations
can contain operations for multiple rows.
Caller has to ensure that all rows are contained in this region.rowsToLock
- Rows to locknonceGroup
- Optional nonce group of the operation (client Id)nonce
- Optional nonce of the operation (unique random id to ensure "more idempotence")
If multiple rows are locked care should be taken that
rowsToLock
is sorted in order to avoid deadlocks.IOException
public org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionLoadStats getLoadStatistics()
public void processRowsWithLocks(RowProcessor<?,?> processor) throws IOException
Region
processRowsWithLocks
in interface Region
processor
- The object defines the reads and writes to a row.IOException
public void processRowsWithLocks(RowProcessor<?,?> processor, long nonceGroup, long nonce) throws IOException
Region
processRowsWithLocks
in interface Region
processor
- The object defines the reads and writes to a row.nonceGroup
- Optional nonce group of the operation (client Id)nonce
- Optional nonce of the operation (unique random id to ensure "more idempotence")IOException
public void processRowsWithLocks(RowProcessor<?,?> processor, long timeout, long nonceGroup, long nonce) throws IOException
Region
processRowsWithLocks
in interface Region
processor
- The object defines the reads and writes to a row.timeout
- The timeout of the processor.process() execution
Use a negative number to switch off the time boundnonceGroup
- Optional nonce group of the operation (client Id)nonce
- Optional nonce of the operation (unique random id to ensure "more idempotence")IOException
private void preProcess(RowProcessor<?,?> processor, WALEdit walEdit) throws IOException
IOException
private void doProcessRowWithTimeout(RowProcessor<?,?> processor, long now, HRegion region, List<Mutation> mutations, WALEdit walEdit, long timeout) throws IOException
IOException
public Result append(Append append) throws IOException
Region
append
in interface Region
IOException
public Result append(Append mutation, long nonceGroup, long nonce) throws IOException
IOException
public Result increment(Increment increment) throws IOException
Region
increment
in interface Region
IOException
public Result increment(Increment mutation, long nonceGroup, long nonce) throws IOException
IOException
private Result doDelta(Region.Operation op, Mutation mutation, long nonceGroup, long nonce, boolean returnResults) throws IOException
op
.
If increment, add deltas to current values or if an append, then append the deltas to the current Cell values.
Append and Increment code paths are mostly the same. They differ in just a few places.
This method does the code path for increment and append and then in key spots, switches
on the passed in op
to do increment or append specific paths.
IOException
private MultiVersionConcurrencyControl.WriteEntry doWALAppend(WALEdit walEdit, Durability durability, long nonceGroup, long nonce) throws IOException
IOException
private MultiVersionConcurrencyControl.WriteEntry doWALAppend(WALEdit walEdit, Durability durability, List<UUID> clusterIds, long now, long nonceGroup, long nonce) throws IOException
IOException
private MultiVersionConcurrencyControl.WriteEntry doWALAppend(WALEdit walEdit, Durability durability, List<UUID> clusterIds, long now, long nonceGroup, long nonce, long origLogSeqNum) throws IOException
IOException
private Result doCoprocessorPreCall(Region.Operation op, Mutation mutation) throws IOException
IOException
private WALEdit reckonDeltas(Region.Operation op, Mutation mutation, Durability effectiveDurability, Map<HStore,List<Cell>> forMemStore, List<Cell> results) throws IOException
results
- Fill in here what goes back to the Client if it is non-null (if null, client
doesn't want results).forMemStore
- Fill in here what to apply to the MemStore (by Store).IOException
private List<Cell> reckonDeltasByStore(HStore store, Region.Operation op, Mutation mutation, Durability effectiveDurability, long now, List<Cell> deltas, List<Cell> results) throws IOException
op
- Whether Increment or Appendmutation
- The encompassing Mutation objectdeltas
- Changes to apply to this Store; either increment amount or data to appendresults
- In here we accumulate all the Cells we are to return to the client. If null,
client doesn't want results returned.deltas
have been applied to current
values. Side effect is our filling out of the results
List.IOException
private static Cell reckonDelta(Cell delta, Cell currentCell, byte[] columnFamily, long now, Mutation mutation, Function<Cell,byte[]> supplier) throws IOException
IOException
private static long getLongValue(Cell cell) throws DoNotRetryIOException
DoNotRetryIOException
private List<Cell> get(Mutation mutation, HStore store, List<Cell> coordinates, IsolationLevel isolation, TimeRange tr) throws IOException
columnFamily
and column qualifiers.mutation
- Mutation we are doing this Get for.store
- Which column family on row (TODO: Go all Gets in one go)coordinates
- Cells from mutation
used as coordinates applied to Get.IOException
private static List<Cell> sort(List<Cell> cells, CellComparator comparator)
cells
using comparator
void checkFamily(byte[] family) throws NoSuchColumnFamilyException
NoSuchColumnFamilyException
public long heapSize()
public boolean registerService(com.google.protobuf.Service instance)
Service
subclass as a coprocessor endpoint to
be available for handling Region#execService(com.google.protobuf.RpcController,
org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CoprocessorServiceCall) calls.
Only a single instance may be registered per region for a given Service
subclass (the
instances are keyed on Descriptors.ServiceDescriptor.getFullName()
.
After the first registration, subsequent calls with the same service name will fail with
a return value of false
.
instance
- the Service
subclass instance to expose as a coprocessor endpointtrue
if the registration was successful, false
otherwisepublic com.google.protobuf.Message execService(com.google.protobuf.RpcController controller, org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceCall call) throws IOException
Service
method using
the registered protocol handlers. Service
implementations must be registered via the
registerService(com.google.protobuf.Service)
method before they are available.controller
- an RpcContoller
implementation to pass to the invoked servicecall
- a CoprocessorServiceCall
instance identifying the service, method,
and parameters for the method invocationMessage
instance containing the method's resultIOException
- if no registered service handler is found or an error
occurs during the invocationregisterService(com.google.protobuf.Service)
boolean shouldForceSplit()
byte[] getExplicitSplitPoint()
void forceSplit(byte[] sp)
void clearSplit()
public byte[] checkSplit()
public int getCompactPriority()
public RegionCoprocessorHost getCoprocessorHost()
public void setCoprocessorHost(RegionCoprocessorHost coprocessorHost)
coprocessorHost
- the new coprocessor hostpublic void startRegionOperation() throws IOException
Region
Region.closeRegionOperation()
MUST then always be called after
the operation has completed, whether it succeeded or failed.
startRegionOperation
in interface Region
IOException
public void startRegionOperation(Region.Operation op) throws IOException
Region
Region.closeRegionOperation()
MUST then always be called after
the operation has completed, whether it succeeded or failed.
startRegionOperation
in interface Region
op
- The operation is about to be taken on the regionIOException
public void closeRegionOperation() throws IOException
Region
closeRegionOperation
in interface Region
IOException
public void closeRegionOperation(Region.Operation operation) throws IOException
Region
Region.startRegionOperation(Operation)
closeRegionOperation
in interface Region
IOException
private void startBulkRegionOperation(boolean writeLockNeeded) throws NotServingRegionException, RegionTooBusyException, InterruptedIOException
NotServingRegionException
- when the region is closing or closedRegionTooBusyException
- if failed to get the lock in timeInterruptedIOException
- if interrupted while waiting for a lockprivate void closeBulkRegionOperation()
private void recordMutationWithoutWal(Map<byte[],List<Cell>> familyMap)
private void lock(Lock lock) throws RegionTooBusyException, InterruptedIOException
private void lock(Lock lock, int multiplier) throws RegionTooBusyException, InterruptedIOException
private void sync(long txid, Durability durability) throws IOException
txid
- should sync up to which transactionIOException
- If anything goes wrong with DFSprivate boolean shouldSyncWAL()
public long getOpenSeqNum()
public Map<byte[],Long> getMaxStoreSeqId()
getMaxStoreSeqId
in interface Region
public long getOldestSeqIdOfStore(byte[] familyName)
public CompactionState getCompactionState()
getCompactionState
in interface Region
public void reportCompactionRequestStart(boolean isMajor)
public void reportCompactionRequestEnd(boolean isMajor, int numFiles, long filesSizeCompacted)
public void reportCompactionRequestFailure()
public void incrementCompactionsQueuedCount()
public void decrementCompactionsQueuedCount()
public void incrementFlushesQueuedCount()
public long getReadPoint()
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 CellComparator getCellComparator()
Region
getCellComparator
in interface Region
public long getMemStoreFlushSize()
void throwException(String title, String regionName)
public void requestCompaction(String why, int priority, boolean major, CompactionLifeCycleTracker tracker) throws IOException
Region
requestCompaction
in interface Region
IOException
public void requestCompaction(byte[] family, String why, int priority, boolean major, CompactionLifeCycleTracker tracker) throws IOException
Region
requestCompaction
in interface Region
IOException
private void requestFlushIfNeeded() throws RegionTooBusyException
RegionTooBusyException
private void requestFlush()
private void requestFlush0(FlushLifeCycleTracker tracker)
public void requestFlush(FlushLifeCycleTracker tracker) throws IOException
Region
requestFlush
in interface Region
IOException
static void decorateRegionConfiguration(org.apache.hadoop.conf.Configuration conf)
conf
- region configurationsCopyright © 2007–2019 The Apache Software Foundation. All rights reserved.