@InterfaceAudience.Private public class HRegion extends Object implements HeapSize, PropagatingConfigurationObserver, Region
Modifier and Type | Class and Description |
---|---|
private static class |
HRegion.BatchOperationInProgress<T>
Struct-like class that tracks the progress of a batch operation,
accumulating status codes and tracking the index at which processing
is proceeding.
|
static class |
HRegion.FlushResultImpl
Objects from this class are created when flushing to describe all the different states that
that method ends up in.
|
private static class |
HRegion.MutationBatch |
(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).
|
private static class |
HRegion.ReplayBatch |
(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.BulkLoadListener, Region.FlushResult, Region.Operation, Region.RowLock
Modifier and Type | Field and Description |
---|---|
private org.apache.hadoop.conf.Configuration |
baseConf |
private Counter |
blockedRequestsCount |
private long |
blockingMemStoreSize |
(package private) long |
busyWaitDuration |
(package private) Counter |
checkAndMutateChecksFailed |
(package private) Counter |
checkAndMutateChecksPassed |
(package private) AtomicBoolean |
closed |
private Object |
closeLock |
(package private) AtomicBoolean |
closing |
(package private) AtomicLong |
compactionNumBytesCompacted |
(package private) AtomicLong |
compactionNumFilesCompacted |
(package private) AtomicLong |
compactionsFinished |
private KeyValue.KVComparator |
comparator |
protected org.apache.hadoop.conf.Configuration |
conf |
private com.google.common.base.Optional<ConfigurationManager> |
configurationManager |
private RegionCoprocessorHost |
coprocessorHost |
private Map<String,com.google.protobuf.Service> |
coprocessorServiceHandlers |
(package private) Counter |
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 |
private static int |
DEFAULT_MAX_WAIT_FOR_SEQ_ID |
(package private) static long |
DEFAULT_ROW_PROCESSOR_TIMEOUT |
(package private) static int |
DEFAULT_ROWLOCK_WAIT_DURATION |
private boolean |
disallowWritesInRecovering
Config setting for whether to allow writes when a region is in recovering or not.
|
private Durability |
durability |
private byte[] |
explicitSplitPoint |
static long |
FIXED_OVERHEAD |
private long |
flushCheckInterval |
private long |
flushPerChanges |
private FlushPolicy |
flushPolicy |
private static byte[] |
FOR_UNIT_TESTS_ONLY
Row needed by below method.
|
private HRegionFileSystem |
fs |
private HTableDescriptor |
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<Store,Long> |
lastStoreFlushTimeMap |
static String |
LOAD_CFS_ON_DEMAND_CONFIG_KEY |
(package private) ReentrantReadWriteLock |
lock |
private ConcurrentHashMap<HashedBytes,HRegion.RowLockContext> |
lockedRows |
private static org.apache.commons.logging.Log |
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.
|
private static String |
MAX_WAIT_FOR_SEQ_ID_KEY |
(package private) long |
maxBusyWaitDuration |
(package private) int |
maxBusyWaitMultiplier |
private long |
maxFlushedSeqId
The max sequence id of flushed data on this region.
|
(package private) Map<byte[],Long> |
maxSeqIdInStores |
private int |
maxWaitForSeqId
Longest time we'll wait on a sequenceid.
|
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 AtomicLong |
memstoreSize |
private MetricsRegion |
metricsRegion |
private MetricsRegionWrapperImpl |
metricsRegionWrapper |
private AtomicInteger |
minorInProgress |
private static List<Cell> |
MOCKED_LIST
A mocked list implementation - discards all updates.
|
private MultiVersionConcurrencyControl |
mvcc |
(package private) Counter |
numMutationsWithoutWAL |
private long |
openSeqNum
The sequence ID that was encountered when this region was opened.
|
private HRegion.PrepareFlushResult |
prepareFlushResult
Saved state from replaying prepare flush cache
|
(package private) Counter |
readRequestsCount |
private boolean |
recovering |
private boolean |
regionStatsEnabled |
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[],Store> |
stores |
protected List<Map> |
storeSeqIds |
static int |
SYSTEM_CACHE_FLUSH_INTERVAL
Default interval for System tables memstore flush
|
(package private) long |
threadWakeFrequency |
(package private) long |
timestampSlop |
private ReentrantReadWriteLock |
updatesLock |
private WAL |
wal |
(package private) Counter |
writeRequestsCount |
(package private) HRegion.WriteState |
writestate |
Constructor and Description |
---|
HRegion(HRegionFileSystem fs,
WAL wal,
org.apache.hadoop.conf.Configuration confParam,
HTableDescriptor 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,
HRegionInfo regionInfo,
HTableDescriptor htd,
RegionServerServices rsServices)
Deprecated.
Use other constructors.
|
Modifier and Type | Method and Description |
---|---|
long |
addAndGetGlobalMemstoreSize(long memStoreSize)
Increase the size of mem store in this region and the size of global mem
store
|
private void |
addFamilyMapToWALEdit(Map<byte[],List<Cell>> familyMap,
WALEdit walEdit)
Append the given map of family->edits to a WALEdit data structure.
|
static void |
addRegionToMETA(HRegion meta,
HRegion r)
Inserts a new region's meta information into the passed
meta region. |
void |
addRegionToSnapshot(org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription desc,
ForeignExceptionSnare exnSnare)
Complete taking the snapshot on the region.
|
Result |
append(Append append) |
Result |
append(Append mutate,
long nonceGroup,
long nonce)
Perform one or more append operations on a row.
|
private WALKey |
appendEmptyEdit(WAL wal)
Append a faked WALEdit in order to get a long sequence number and wal syncer will just ignore
the WALEdit append later.
|
private long |
applyFamilyMapToMemstore(Map<byte[],List<Cell>> familyMap,
long mvccNum,
boolean isInReplay)
Atomically apply the given map of family->edits to the memstore.
|
private List<Cell> |
applyIncrementsToColumnFamily(Increment increment,
byte[] columnFamilyName,
List<Cell> sortedIncrements,
long now,
long mvccNum,
List<Cell> allKVs,
IsolationLevel isolation)
Apply increments to a column family.
|
boolean |
areWritesEnabled() |
(package private) OperationStatus[] |
batchMutate(HRegion.BatchOperationInProgress<?> batchOp)
Perform a batch of mutations.
|
OperationStatus[] |
batchMutate(Mutation[] mutations) |
OperationStatus[] |
batchMutate(Mutation[] mutations,
long nonceGroup,
long nonce)
Perform a batch of mutations.
|
OperationStatus[] |
batchReplay(WALSplitter.MutationReplay[] mutations,
long replaySeqId)
Replay a batch of mutations.
|
private Scan |
buildScanForGetWithClosestRowBefore(Get get) |
boolean |
bulkLoadHFiles(Collection<Pair<byte[],String>> familyPaths,
boolean assignSeqId,
Region.BulkLoadListener bulkLoadListener)
Attempts to atomically load a group of hfiles.
|
private static List<Tag> |
carryForwardTags(Cell cell,
List<Tag> tags) |
private static List<Tag> |
carryForwardTTLTag(List<Tag> tagsOrNull,
Mutation mutation) |
private static List<Tag> |
carryForwardTTLTag(Mutation mutation) |
boolean |
checkAndMutate(byte[] row,
byte[] family,
byte[] qualifier,
CompareFilter.CompareOp compareOp,
ByteArrayComparable comparator,
Mutation w,
boolean writeToWAL)
Atomically checks if a row/family/qualifier value matches the expected val
If it does, it performs the row mutations.
|
boolean |
checkAndRowMutate(byte[] row,
byte[] family,
byte[] qualifier,
CompareFilter.CompareOp compareOp,
ByteArrayComparable comparator,
RowMutations rm,
boolean writeToWAL)
Atomically checks if a row/family/qualifier value matches the expected val
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.
|
private void |
checkFamily(byte[] family) |
protected void |
checkReadOnly() |
protected void |
checkReadsEnabled() |
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<StoreFile>> |
close()
Close down this HRegion.
|
Map<byte[],List<StoreFile>> |
close(boolean abort)
Close down this HRegion.
|
private void |
closeBulkRegionOperation()
Closes the lock.
|
static void |
closeHRegion(HRegion r)
This will do the necessary cleanup a call to
createHRegion(HRegionInfo, Path, Configuration, HTableDescriptor)
requires. |
void |
closeRegionOperation()
Closes the region operation lock.
|
void |
closeRegionOperation(Region.Operation operation)
Closes the lock.
|
void |
compact(boolean majorCompaction)
Synchronously compact all stores in the region.
|
boolean |
compact(CompactionContext compaction,
Store store,
CompactionThroughputController throughputController) |
boolean |
compact(CompactionContext compaction,
Store store,
CompactionThroughputController throughputController,
User user) |
(package private) void |
compactStore(byte[] family,
CompactionThroughputController throughputController)
This is a helper function that compact the given store
It is used by utilities and testing
|
void |
compactStores()
This is a helper function that compact all the stores synchronously
It is used by utilities and testing
|
static HDFSBlocksDistribution |
computeHDFSBlocksDistribution(org.apache.hadoop.conf.Configuration conf,
HTableDescriptor tableDescriptor,
HRegionInfo regionInfo)
This is a helper function to compute HDFS block distribution on demand
|
static HDFSBlocksDistribution |
computeHDFSBlocksDistribution(org.apache.hadoop.conf.Configuration conf,
HTableDescriptor tableDescriptor,
HRegionInfo regionInfo,
org.apache.hadoop.fs.Path tablePath)
This is a helper function to compute HDFS block distribution on demand
|
(package private) HRegion |
createDaughterRegionFromSplits(HRegionInfo hri)
Create a daughter region from given a temp directory with the region data.
|
static HRegion |
createHRegion(HRegionInfo info,
org.apache.hadoop.fs.Path rootDir,
org.apache.hadoop.conf.Configuration conf,
HTableDescriptor hTableDescriptor)
Convenience method creating new HRegions.
|
static HRegion |
createHRegion(HRegionInfo info,
org.apache.hadoop.fs.Path rootDir,
org.apache.hadoop.conf.Configuration conf,
HTableDescriptor hTableDescriptor,
WAL wal) |
static HRegion |
createHRegion(HRegionInfo info,
org.apache.hadoop.fs.Path rootDir,
org.apache.hadoop.conf.Configuration conf,
HTableDescriptor hTableDescriptor,
WAL wal,
boolean initialize)
Convenience method creating new HRegions.
|
static HRegion |
createHRegion(HRegionInfo info,
org.apache.hadoop.fs.Path rootDir,
org.apache.hadoop.conf.Configuration conf,
HTableDescriptor hTableDescriptor,
WAL wal,
boolean initialize,
boolean ignoreWAL)
Convenience method creating new HRegions.
|
static HRegion |
createHRegion(HRegionInfo info,
org.apache.hadoop.fs.Path rootDir,
org.apache.hadoop.fs.Path tableDir,
org.apache.hadoop.conf.Configuration conf,
HTableDescriptor hTableDescriptor,
WAL wal,
boolean initialize,
boolean ignoreWAL)
Convenience method creating new HRegions.
|
(package private) HRegion |
createMergedRegionFromMerges(HRegionInfo mergedRegionInfo,
HRegion region_b)
Create a merged region given a temp directory with the region data.
|
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 |
doBatchMutate(Mutation mutation) |
private Map<byte[],List<StoreFile>> |
doClose(boolean abort,
MonitoredTask status) |
private long |
doDropStoreMemstoreContentsForSeqId(Store s,
long currentSeqId) |
private List<Cell> |
doGet(Store store,
byte[] row,
Map.Entry<byte[],List<Cell>> family,
TimeRange tr)
Run a Get against passed in
store on passed row , etc. |
private Result |
doIncrement(Increment increment,
long nonceGroup,
long nonce) |
private long |
doMiniBatchMutation(HRegion.BatchOperationInProgress<?> batchOp) |
private void |
doPreMutationHook(HRegion.BatchOperationInProgress<?> batchOp) |
private void |
doProcessRowWithTimeout(RowProcessor<?,?> processor,
long now,
HRegion region,
List<Mutation> mutations,
WALEdit walEdit,
long timeout) |
protected void |
doRegionCompactionPrep() |
private void |
dropMemstoreContents() |
private long |
dropMemstoreContentsForSeqId(long seqId,
Store 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.protobuf.generated.ClientProtos.CoprocessorServiceCall call)
Executes a single protocol buffer coprocessor endpoint
Service method using
the registered protocol handlers. |
Region.FlushResult |
flush(boolean force)
Flush the cache.
|
Region.FlushResult |
flushcache(boolean forceFlushAllStores,
boolean writeFlushRequestWalMarker)
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.
|
(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() |
long |
getCheckAndMutateChecksFailed() |
long |
getCheckAndMutateChecksPassed() |
Result |
getClosestRowBefore(byte[] row,
byte[] family)
Return all the data for the row that matches row exactly,
or the one that immediately preceeds it, at or immediately before
ts.
|
org.apache.hadoop.hbase.protobuf.generated.AdminProtos.GetRegionInfoResponse.CompactionState |
getCompactionState() |
int |
getCompactPriority() |
KeyValue.KVComparator |
getComparator() |
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() |
HDFSBlocksDistribution |
getHDFSBlocksDistribution() |
private List<Cell> |
getIncrementCurrentValue(Increment increment,
byte[] columnFamily,
List<Cell> increments,
IsolationLevel isolation)
Do a specific Get on passed
columnFamily and column qualifiers
from incrementCoordinates only. |
long |
getLargestHStoreSize() |
ConcurrentHashMap<HashedBytes,HRegion.RowLockContext> |
getLockedRows() |
private static long |
getLongValue(Cell cell) |
long |
getMaxFlushedSeqId() |
Map<byte[],Long> |
getMaxStoreSeqId() |
long |
getMemstoreSize() |
MetricsRegion |
getMetrics() |
MultiVersionConcurrencyControl |
getMVCC() |
private static Cell |
getNewCell(byte[] row,
long ts,
Cell cell,
Cell oldCell,
byte[] tagBytes) |
private static Cell |
getNewCell(Mutation mutate,
Cell cell) |
protected long |
getNextSequenceId(WAL wal)
Method to safely get the next sequence number.
|
long |
getNumMutationsWithoutWAL() |
long |
getOldestHfileTs(boolean majorCompactioOnly)
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() |
long |
getReadpoint(IsolationLevel isolationLevel) |
long |
getReadRequestsCount() |
static org.apache.hadoop.fs.Path |
getRegionDir(org.apache.hadoop.fs.Path rootdir,
HRegionInfo info)
Deprecated.
For tests only; to be removed.
|
static org.apache.hadoop.fs.Path |
getRegionDir(org.apache.hadoop.fs.Path tabledir,
String name)
Deprecated.
For tests only; to be removed.
|
HRegionFileSystem |
getRegionFileSystem() |
HRegionInfo |
getRegionInfo() |
(package private) RegionServerServices |
getRegionServerServices() |
org.apache.hadoop.hbase.protobuf.generated.ClientProtos.RegionLoadStats |
getRegionStats() |
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.
|
Region.RowLock |
getRowLock(byte[] row,
boolean readLock,
boolean waitForLock)
Get a row lock for the specified row.
|
RegionScanner |
getScanner(Scan scan)
Return an iterator that scans over the HRegion, returning the indicated
columns and rows specified by the
Scan . |
RegionScanner |
getScanner(Scan scan,
List<KeyValueScanner> additionalScanners)
Return an iterator that scans over the HRegion, returning the indicated columns and rows
specified by the
Scan . |
long |
getSequenceId()
Do not change this sequence id.
|
long |
getSmallestReadPoint() |
RegionSplitPolicy |
getSplitPolicy() |
Store |
getStore(byte[] column)
Return the Store for the given family
|
private Store |
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<Store> |
getStores()
Return the list of Stores managed by this region
|
HTableDescriptor |
getTableDesc() |
WAL |
getWAL() |
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() |
Result |
increment(Increment increment) |
Result |
increment(Increment mutation,
long nonceGroup,
long nonce)
Perform one or more increment operations on a row.
|
long |
initialize()
Deprecated.
use HRegion.createHRegion() or HRegion.openHRegion()
|
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(HColumnDescriptor family) |
protected RegionScanner |
instantiateRegionScanner(Scan scan,
List<KeyValueScanner> additionalScanners) |
private Region.FlushResult |
internalFlushcache(Collection<Store> storesToFlush,
MonitoredTask status,
boolean writeFlushWalMarker)
Flushing given stores.
|
private Region.FlushResult |
internalFlushcache(MonitoredTask status)
Flushing all stores.
|
protected Region.FlushResult |
internalFlushcache(WAL wal,
long myseqid,
Collection<Store> storesToFlush,
MonitoredTask status,
boolean writeFlushWalMarker)
Flush the memstore.
|
protected Region.FlushResult |
internalFlushCacheAndCommit(WAL wal,
MonitoredTask status,
HRegion.PrepareFlushResult prepareResult,
Collection<Store> storesToFlush) |
protected HRegion.PrepareFlushResult |
internalPrepareFlushCache(WAL wal,
long myseqid,
Collection<Store> storesToFlush,
MonitoredTask status,
boolean writeFlushWalMarker) |
private boolean |
isAllFamilies(Collection<Store> families) |
boolean |
isAvailable() |
boolean |
isClosed() |
boolean |
isClosing() |
private boolean |
isFlushSize(long size) |
boolean |
isLoadingCfsOnDemandDefault() |
boolean |
isMergeable() |
boolean |
isReadOnly() |
boolean |
isRecovering() |
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 |
logRegionFiles() |
static void |
main(String[] args)
Facility for dumping and compacting catalog tables.
|
static HRegion |
merge(HRegion a,
HRegion b)
Merge two regions whether they are adjacent or not.
|
static HRegion |
mergeAdjacent(HRegion srcA,
HRegion srcB)
Merge two HRegions.
|
void |
mutateRow(RowMutations rm)
Performs multiple mutations atomically on a single row.
|
void |
mutateRowsWithLocks(Collection<Mutation> mutations,
Collection<byte[]> rowsToLock)
Perform atomic mutations within the region w/o nonces.
|
void |
mutateRowsWithLocks(Collection<Mutation> mutations,
Collection<byte[]> rowsToLock,
long nonceGroup,
long nonce)
Perform atomic 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,
HRegionInfo regionInfo,
HTableDescriptor 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,
HRegionInfo info,
HTableDescriptor 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,
HRegionInfo info,
HTableDescriptor 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,
org.apache.hadoop.fs.Path tableDir,
HRegionInfo info,
HTableDescriptor 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(HRegionInfo info,
HTableDescriptor htd,
WAL wal,
org.apache.hadoop.conf.Configuration conf)
Open a Region.
|
static HRegion |
openHRegion(HRegionInfo info,
HTableDescriptor htd,
WAL wal,
org.apache.hadoop.conf.Configuration conf,
RegionServerServices rsServices,
CancelableProgressable reporter)
Open a Region.
|
static HRegion |
openHRegion(org.apache.hadoop.fs.Path rootDir,
HRegionInfo info,
HTableDescriptor htd,
WAL wal,
org.apache.hadoop.conf.Configuration conf)
Open a Region.
|
static HRegion |
openHRegion(org.apache.hadoop.fs.Path rootDir,
HRegionInfo info,
HTableDescriptor htd,
WAL wal,
org.apache.hadoop.conf.Configuration conf,
RegionServerServices rsServices,
CancelableProgressable reporter)
Open a Region.
|
static Region |
openHRegion(Region other,
CancelableProgressable reporter) |
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.
|
protected void |
prepareToSplit()
Give the region a chance to prepare before it is split.
|
private static void |
printUsageAndExit(String message) |
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.
|
private static void |
processTable(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path p,
WALFactory walFactory,
org.apache.hadoop.conf.Configuration c,
boolean majorCompact) |
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 void |
recordMutationWithoutWal(Map<byte[],List<Cell>> familyMap)
Update counters 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. |
void |
releaseRowLocks(List<Region.RowLock> rowLocks)
If the given list of row locks is not null, releases all locks.
|
private void |
removeNonExistentColumnFamilyForReplay(Map<byte[],List<Cell>> familyMap)
During replay, there could exist column families which are removed between region server
failure and replay
|
private void |
replayFlushInStores(org.apache.hadoop.hbase.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) |
protected long |
replayRecoveredEditsIfAny(org.apache.hadoop.fs.Path regiondir,
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.protobuf.generated.WALProtos.BulkLoadDescriptor bulkLoadEvent) |
(package private) void |
replayWALCompactionMarker(org.apache.hadoop.hbase.protobuf.generated.WALProtos.CompactionDescriptor compaction,
boolean pickCompactionFiles,
boolean removeFiles,
long replaySeqId)
Call to complete a compaction.
|
private void |
replayWALFlushAbortMarker(org.apache.hadoop.hbase.protobuf.generated.WALProtos.FlushDescriptor flush) |
private void |
replayWALFlushCannotFlushMarker(org.apache.hadoop.hbase.protobuf.generated.WALProtos.FlushDescriptor flush,
long replaySeqId) |
(package private) void |
replayWALFlushCommitMarker(org.apache.hadoop.hbase.protobuf.generated.WALProtos.FlushDescriptor flush) |
(package private) void |
replayWALFlushMarker(org.apache.hadoop.hbase.protobuf.generated.WALProtos.FlushDescriptor flush,
long replaySeqId) |
(package private) HRegion.PrepareFlushResult |
replayWALFlushStartMarker(org.apache.hadoop.hbase.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.protobuf.generated.WALProtos.RegionEventDescriptor regionEvent) |
void |
reportCompactionRequestEnd(boolean isMajor,
int numFiles,
long filesSizeCompacted) |
void |
reportCompactionRequestStart(boolean isMajor) |
private void |
requestFlush() |
protected boolean |
restoreEdit(Store s,
Cell cell)
Used by tests
|
(package private) void |
rewriteCellTags(Map<byte[],List<Cell>> familyMap,
Mutation m)
Possibly rewrite incoming cell tags.
|
private void |
rollbackMemstore(List<Cell> memstoreCells)
Remove all the keys listed in the map from the memstore.
|
static boolean |
rowIsInRange(HRegionInfo info,
byte[] row)
Determines if the specified row is within the row range specified by the
specified HRegionInfo
|
static boolean |
rowIsInRange(HRegionInfo info,
byte[] row,
int offset,
short length) |
void |
setClosing(boolean closing)
Exposed for some very specific unit tests.
|
(package private) org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos.RegionLoad.Builder |
setCompleteSequenceId(org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos.RegionLoad.Builder regionLoadBldr) |
void |
setCoprocessorHost(RegionCoprocessorHost coprocessorHost) |
(package private) void |
setHTableSpecificConf() |
void |
setReadsEnabled(boolean readsEnabled) |
void |
setRecovering(boolean newState)
Reset recovering state of current region
|
(package private) boolean |
shouldFlush(StringBuffer whyFlush)
Should the memstore be flushed now
|
(package private) boolean |
shouldFlushStore(Store 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,
Comparator<Cell> 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 |
syncOrDefer(long txid,
Durability durability)
Calls sync with the given transaction ID if the region's table is not
deferring it.
|
String |
toString() |
void |
triggerMajorCompaction()
Trigger major compaction on all stores in the region.
|
void |
updateCellTimestamps(Iterable<List<Cell>> cellItr,
byte[] now)
Replace any cell timestamps set to HConstants#LATEST_TIMESTAMP with the
provided current timestamp.
|
(package private) void |
updateDeleteLatestVersionTimeStamp(Cell cell,
Get get,
int count,
byte[] byteNow) |
void |
updateReadRequestsCount(long i)
Update the read request count for this region
|
void |
updateWriteRequestsCount(long i)
Update the write request count for this region
|
void |
waitForFlushes() |
void |
waitForFlushesAndCompactions()
Wait for all current flushes and compactions of the region to complete
|
static void |
warmupHRegion(HRegionInfo info,
HTableDescriptor 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) |
private static final org.apache.commons.logging.Log LOG
public static final String LOAD_CFS_ON_DEMAND_CONFIG_KEY
private final int maxWaitForSeqId
private static final String MAX_WAIT_FOR_SEQ_ID_KEY
private static final int DEFAULT_MAX_WAIT_FOR_SEQ_ID
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 AtomicLong memstoreSize
final Counter numMutationsWithoutWAL
final Counter dataInMemoryWithoutWAL
final Counter checkAndMutateChecksPassed
final Counter checkAndMutateChecksFailed
final Counter readRequestsCount
final Counter writeRequestsCount
private final Counter blockedRequestsCount
final AtomicLong compactionsFinished
final AtomicLong compactionNumFilesCompacted
final AtomicLong compactionNumBytesCompacted
private final WAL wal
private final HRegionFileSystem fs
protected final org.apache.hadoop.conf.Configuration conf
private final org.apache.hadoop.conf.Configuration baseConf
private final KeyValue.KVComparator comparator
private final int rowLockWaitDuration
static final int DEFAULT_ROWLOCK_WAIT_DURATION
final long busyWaitDuration
static final long DEFAULT_BUSY_WAIT_DURATION
final int maxBusyWaitMultiplier
final long maxBusyWaitDuration
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
private HRegion.PrepareFlushResult prepareFlushResult
private boolean disallowWritesInRecovering
private volatile boolean recovering
private volatile com.google.common.base.Optional<ConfigurationManager> configurationManager
final HRegion.WriteState writestate
long memstoreFlushSize
final long timestampSlop
final long rowProcessorTimeout
private final ConcurrentMap<Store,Long> lastStoreFlushTimeMap
final RegionServerServices rsServices
private RegionServerAccounting rsAccounting
private long flushCheckInterval
private long flushPerChanges
private long blockingMemStoreSize
final long threadWakeFrequency
final ReentrantReadWriteLock lock
private final ReentrantReadWriteLock updatesLock
private boolean splitRequest
private byte[] explicitSplitPoint
private final MultiVersionConcurrencyControl mvcc
private RegionCoprocessorHost coprocessorHost
private HTableDescriptor htableDescriptor
private RegionSplitPolicy splitPolicy
private FlushPolicy flushPolicy
private final MetricsRegion metricsRegion
private final MetricsRegionWrapperImpl metricsRegionWrapper
private final Durability durability
private final boolean regionStatsEnabled
private final Object closeLock
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
@Deprecated public HRegion(org.apache.hadoop.fs.Path tableDir, WAL wal, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.conf.Configuration confParam, HRegionInfo regionInfo, HTableDescriptor htd, RegionServerServices rsServices)
createHRegion(org.apache.hadoop.hbase.HRegionInfo, org.apache.hadoop.fs.Path, org.apache.hadoop.conf.Configuration, org.apache.hadoop.hbase.HTableDescriptor)
or openHRegion(org.apache.hadoop.hbase.HRegionInfo, org.apache.hadoop.hbase.HTableDescriptor, 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
- - HRegionInfo 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, HTableDescriptor htd, RegionServerServices rsServices)
createHRegion(org.apache.hadoop.hbase.HRegionInfo, org.apache.hadoop.fs.Path, org.apache.hadoop.conf.Configuration, org.apache.hadoop.hbase.HTableDescriptor)
or openHRegion(org.apache.hadoop.hbase.HRegionInfo, org.apache.hadoop.hbase.HTableDescriptor, 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
- eprivate long 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 HDFSBlocksDistribution getHDFSBlocksDistribution()
getHDFSBlocksDistribution
in interface Region
public static HDFSBlocksDistribution computeHDFSBlocksDistribution(org.apache.hadoop.conf.Configuration conf, HTableDescriptor tableDescriptor, HRegionInfo regionInfo) throws IOException
conf
- configurationtableDescriptor
- HTableDescriptor of the tableregionInfo
- encoded name of the regionIOException
public static HDFSBlocksDistribution computeHDFSBlocksDistribution(org.apache.hadoop.conf.Configuration conf, HTableDescriptor tableDescriptor, HRegionInfo regionInfo, org.apache.hadoop.fs.Path tablePath) throws IOException
conf
- configurationtableDescriptor
- HTableDescriptor of the tableregionInfo
- encoded name of the regiontablePath
- the table directoryIOException
public long addAndGetGlobalMemstoreSize(long memStoreSize)
public HRegionInfo getRegionInfo()
getRegionInfo
in interface Region
RegionServerServices getRegionServerServices()
RegionServerServices
used by this HRegion.
Can be null.public long getReadRequestsCount()
getReadRequestsCount
in interface Region
public void updateReadRequestsCount(long i)
Region
updateReadRequestsCount
in interface Region
i
- incrementpublic long getWriteRequestsCount()
getWriteRequestsCount
in interface Region
public void updateWriteRequestsCount(long i)
Region
updateWriteRequestsCount
in interface Region
i
- incrementpublic long getMemstoreSize()
getMemstoreSize
in interface Region
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()
getMetrics
in interface Region
public boolean isClosed()
public boolean isClosing()
public boolean isReadOnly()
isReadOnly
in interface Region
public void setRecovering(boolean newState)
public boolean isRecovering()
isRecovering
in interface Region
public boolean isAvailable()
isAvailable
in interface Region
public boolean isSplittable()
public boolean isMergeable()
public boolean areWritesEnabled()
public MultiVersionConcurrencyControl getMVCC()
public long getMaxFlushedSeqId()
getMaxFlushedSeqId
in interface Region
public long getReadpoint(IsolationLevel isolationLevel)
getReadpoint
in interface Region
public boolean isLoadingCfsOnDemandDefault()
isLoadingCfsOnDemandDefault
in interface Region
public Map<byte[],List<StoreFile>> 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<StoreFile>> 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)
private Map<byte[],List<StoreFile>> doClose(boolean abort, MonitoredTask status) throws IOException
IOException
public void waitForFlushesAndCompactions()
Region
waitForFlushesAndCompactions
in interface Region
public void waitForFlushes()
protected ThreadPoolExecutor getStoreOpenAndCloseThreadPool(String threadNamePrefix)
protected ThreadPoolExecutor getStoreFileOpenAndCloseThreadPool(String threadNamePrefix)
static ThreadPoolExecutor getOpenAndCloseThreadPool(int maxThreads, String threadNamePrefix)
private boolean worthPreFlushing()
public HTableDescriptor getTableDesc()
getTableDesc
in interface Region
public WAL getWAL()
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 regionpublic long getEarliestFlushTimeForAllStores()
getEarliestFlushTimeForAllStores
in interface Region
public long getOldestHfileTs(boolean majorCompactioOnly) throws IOException
Region
getOldestHfileTs
in interface Region
majorCompactioOnly
- Only consider HFile that are the result of major compactionIOException
org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos.RegionLoad.Builder setCompleteSequenceId(org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos.RegionLoad.Builder regionLoadBldr)
public long getLargestHStoreSize()
public KeyValue.KVComparator getComparator()
protected void doRegionCompactionPrep() throws IOException
IOException
public void triggerMajorCompaction() throws IOException
Region
Compaction will be performed asynchronously to this call by the RegionServer's
CompactSplitThread. See also Store.triggerMajorCompaction()
triggerMajorCompaction
in interface Region
IOException
public void compact(boolean majorCompaction) throws IOException
Region
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.
compact
in interface Region
majorCompaction
- True to force a major compaction regardless of thresholdsIOException
public void compactStores() throws IOException
IOException
- evoid compactStore(byte[] family, CompactionThroughputController throughputController) throws IOException
IOException
- epublic boolean compact(CompactionContext compaction, Store store, CompactionThroughputController throughputController) throws IOException
IOException
public boolean compact(CompactionContext compaction, Store store, CompactionThroughputController throughputController, User user) throws IOException
IOException
public Region.FlushResult flush(boolean force) throws IOException
Region
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.
flush
in interface Region
force
- whether we want to force a flush of all storesIOException
- general io exceptions
because a snapshot was not properly persisted.public Region.FlushResult flushcache(boolean forceFlushAllStores, boolean writeFlushRequestWalMarker) 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 WALIOException
- 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(Store 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 #shouldFlush()
method will always
returns true which will make a lot of flush requests.
boolean shouldFlush(StringBuffer whyFlush)
private Region.FlushResult internalFlushcache(MonitoredTask status) throws IOException
IOException
internalFlushcache(Collection, MonitoredTask, boolean)
private Region.FlushResult internalFlushcache(Collection<Store> storesToFlush, MonitoredTask status, boolean writeFlushWalMarker) throws IOException
protected Region.FlushResult internalFlushcache(WAL wal, long myseqid, Collection<Store> storesToFlush, MonitoredTask status, boolean writeFlushWalMarker) 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 because a Snapshot was not
properly persisted.protected HRegion.PrepareFlushResult internalPrepareFlushCache(WAL wal, long myseqid, Collection<Store> storesToFlush, MonitoredTask status, boolean writeFlushWalMarker) throws IOException
IOException
private boolean isAllFamilies(Collection<Store> families)
families
- private boolean writeFlushRequestMarkerToWAL(WAL wal, boolean writeFlushWalMarker)
wal
- protected Region.FlushResult internalFlushCacheAndCommit(WAL wal, MonitoredTask status, HRegion.PrepareFlushResult prepareResult, Collection<Store> storesToFlush) throws IOException
IOException
protected long getNextSequenceId(WAL wal) throws IOException
IOException
public Result getClosestRowBefore(byte[] row, byte[] family) throws IOException
Region
getClosestRowBefore
in interface Region
IOException
public RegionScanner 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 RegionScanner 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 exceptionsprotected RegionScanner instantiateRegionScanner(Scan scan, List<KeyValueScanner> additionalScanners) throws IOException
IOException
public void prepareDelete(Delete delete) throws IOException
Region
prepareDelete
in interface Region
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
Region
Caller should have the row and region locks.
prepareDeleteTimestamps
in interface Region
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
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[] batchMutate(Mutation[] mutations) throws IOException
IOException
public OperationStatus[] batchReplay(WALSplitter.MutationReplay[] mutations, long replaySeqId) throws IOException
Region
batchReplay
in interface Region
mutations
- mutations to replay.IOException
OperationStatus[] batchMutate(HRegion.BatchOperationInProgress<?> batchOp) throws IOException
batchOp
- contains the list of mutationsIOException
private void doPreMutationHook(HRegion.BatchOperationInProgress<?> batchOp) throws IOException
IOException
private long doMiniBatchMutation(HRegion.BatchOperationInProgress<?> batchOp) throws IOException
IOException
protected Durability getEffectiveDurability(Durability d)
public boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, ByteArrayComparable comparator, Mutation w, boolean writeToWAL) throws IOException
Region
checkAndMutate
in interface Region
row
- to checkfamily
- column family to checkqualifier
- column qualifier to checkcompareOp
- the comparison operatorIOException
public boolean checkAndRowMutate(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, ByteArrayComparable comparator, RowMutations rm, boolean writeToWAL) throws IOException
Region
checkAndRowMutate
in interface Region
row
- to checkfamily
- column family to checkqualifier
- column qualifier to checkcompareOp
- the comparison operatorIOException
private void doBatchMutate(Mutation mutation) throws IOException
IOException
public void addRegionToSnapshot(org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.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 failpublic void updateCellTimestamps(Iterable<List<Cell>> cellItr, byte[] now) throws IOException
Region
updateCellTimestamps
in interface Region
IOException
void rewriteCellTags(Map<byte[],List<Cell>> familyMap, Mutation m)
private 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)
private void put(byte[] row, byte[] family, List<Cell> edits) throws IOException
edits
- Cell updates by columnIOException
private long applyFamilyMapToMemstore(Map<byte[],List<Cell>> familyMap, long mvccNum, boolean isInReplay) throws IOException
familyMap
- Map of kvs per familylocalizedWriteEntry
- The WriteEntry of the MVCC for this transaction.
If null, then this method internally creates a mvcc transaction.output
- newly added KVs into memstoreisInReplay
- true when adding replayed KVs into memstoreIOException
private void rollbackMemstore(List<Cell> memstoreCells)
public void checkFamilies(Collection<byte[]> families) throws NoSuchColumnFamilyException
Region
checkFamilies
in interface Region
NoSuchColumnFamilyException
private void removeNonExistentColumnFamilyForReplay(Map<byte[],List<Cell>> familyMap)
public void checkTimestamps(Map<byte[],List<Cell>> familyMap, long now) throws FailedSanityCheckException
Region
checkTimestamps
in interface Region
now
- current timestampFailedSanityCheckException
private void addFamilyMapToWALEdit(Map<byte[],List<Cell>> familyMap, WALEdit walEdit)
familyMap
- map of family->editswalEdit
- the destination entry to append intoprivate void requestFlush()
private boolean isFlushSize(long size)
protected long replayRecoveredEditsIfAny(org.apache.hadoop.fs.Path regiondir, 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 replayRecoveredEdits(org.apache.hadoop.fs.Path edits, Map<byte[],Long> maxSeqIdInStores, CancelableProgressable reporter) throws IOException
IOException
void replayWALCompactionMarker(org.apache.hadoop.hbase.protobuf.generated.WALProtos.CompactionDescriptor compaction, boolean pickCompactionFiles, boolean removeFiles, long replaySeqId) throws IOException
IOException
void replayWALFlushMarker(org.apache.hadoop.hbase.protobuf.generated.WALProtos.FlushDescriptor flush, long replaySeqId) throws IOException
IOException
HRegion.PrepareFlushResult replayWALFlushStartMarker(org.apache.hadoop.hbase.protobuf.generated.WALProtos.FlushDescriptor flush) throws IOException
IOException
void replayWALFlushCommitMarker(org.apache.hadoop.hbase.protobuf.generated.WALProtos.FlushDescriptor flush) throws IOException
IOException
private void replayFlushInStores(org.apache.hadoop.hbase.protobuf.generated.WALProtos.FlushDescriptor flush, HRegion.PrepareFlushResult prepareFlushResult, boolean dropMemstoreSnapshot) throws IOException
flush
- prepareFlushResult
- dropMemstoreSnapshot
- IOException
private long dropMemstoreContentsForSeqId(long seqId, Store store) throws IOException
IOException
private long doDropStoreMemstoreContentsForSeqId(Store s, long currentSeqId) throws IOException
IOException
private void replayWALFlushAbortMarker(org.apache.hadoop.hbase.protobuf.generated.WALProtos.FlushDescriptor flush)
private void replayWALFlushCannotFlushMarker(org.apache.hadoop.hbase.protobuf.generated.WALProtos.FlushDescriptor flush, long replaySeqId)
HRegion.PrepareFlushResult getPrepareFlushResult()
void replayWALRegionEventMarker(org.apache.hadoop.hbase.protobuf.generated.WALProtos.RegionEventDescriptor regionEvent) throws IOException
IOException
void replayWALBulkLoadEventMarker(org.apache.hadoop.hbase.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 boolean restoreEdit(Store s, Cell cell)
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
IOException
protected HStore instantiateHStore(HColumnDescriptor family) throws IOException
IOException
public Store getStore(byte[] column)
Region
Use with caution. Exposed for use of fixup utilities.
private Store getStore(Cell cell)
public List<Store> 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
- if any error occurredpublic Region.RowLock getRowLock(byte[] row, boolean readLock) throws IOException
getRowLock
in interface Region
row
- The row actions will be performed againstreadLock
- is the lock reader or writer. True indicates that a non-exlcusive
lock is requestedIOException
- if any error occurredpublic Region.RowLock getRowLock(byte[] row, boolean readLock, boolean waitForLock) throws IOException
row
- The row actions will be performed againstreadLock
- is the lock reader or writer. True indicates that a non-exlcusive
lock is requestedwaitForLock
- whether should wait for this lockwaitForLock
set to false and tryLock failedIOException
- if any error occurredpublic void releaseRowLocks(List<Region.RowLock> rowLocks)
Region
releaseRowLocks
in interface Region
public ConcurrentHashMap<HashedBytes,HRegion.RowLockContext> getLockedRows()
private static boolean hasMultipleColumnFamilies(Collection<Pair<byte[],String>> familyPaths)
familyPaths
- List of Pairpublic boolean bulkLoadHFiles(Collection<Pair<byte[],String>> familyPaths, boolean assignSeqId, Region.BulkLoadListener bulkLoadListener) throws IOException
Region
bulkLoadHFiles
in interface Region
familyPaths
- List of Pair<byte[] column family, String hfilePath>bulkLoadListener
- Internal hooks enabling massaging/preparation of a
file about to be bulk loadedIOException
- 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, HRegionInfo regionInfo, HTableDescriptor 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
- - HRegionInfo that describes the region
is new), then read them from the supplied path.htd
- the table descriptorpublic static HRegion createHRegion(HRegionInfo info, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.conf.Configuration conf, HTableDescriptor hTableDescriptor) throws IOException
WAL
for the created region. It
needs to be closed explicitly. Use getWAL()
to get
access. When done with a region created using this method, you will
need to explicitly close the WAL
it created too; it will not be
done for you. Not closing the wal will leave at least a daemon thread
running. Call closeHRegion(HRegion)
and it will do
necessary cleanup for you.info
- Info for region to create.rootDir
- Root directory for HBase instanceIOException
public static void closeHRegion(HRegion r) throws IOException
createHRegion(HRegionInfo, Path, Configuration, HTableDescriptor)
requires. This method will close the region and then close its
associated WAL
file. You can still use it if you call the other createHRegion,
the one that takes an WAL
instance but don't be surprised by the
call to the WAL.close()
on the WAL
the
HRegion was carrying.IOException
public static HRegion createHRegion(HRegionInfo info, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.conf.Configuration conf, HTableDescriptor hTableDescriptor, WAL wal, boolean initialize) throws IOException
WAL
for the created region needs to be closed explicitly.
Use getWAL()
to get access.info
- Info for region to create.rootDir
- Root directory for HBase instancewal
- shared WALinitialize
- - true to initialize the regionIOException
public static HRegion createHRegion(HRegionInfo info, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.conf.Configuration conf, HTableDescriptor hTableDescriptor, WAL wal, boolean initialize, boolean ignoreWAL) throws IOException
WAL
for the created region needs to be closed
explicitly, if it is not null.
Use getWAL()
to get access.info
- Info for region to create.rootDir
- Root directory for HBase instancewal
- shared WALinitialize
- - true to initialize the regionignoreWAL
- - true to skip generate new wal if it is null, mostly for createTableIOException
public static HRegion createHRegion(HRegionInfo info, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.fs.Path tableDir, org.apache.hadoop.conf.Configuration conf, HTableDescriptor hTableDescriptor, WAL wal, boolean initialize, boolean ignoreWAL) throws IOException
WAL
for the created region needs to be closed
explicitly, if it is not null.
Use getWAL()
to get access.info
- Info for region to create.rootDir
- Root directory for HBase instancetableDir
- table directorywal
- shared WALinitialize
- - true to initialize the regionignoreWAL
- - true to skip generate new wal if it is null, mostly for createTableIOException
public static HRegion createHRegion(HRegionInfo info, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.conf.Configuration conf, HTableDescriptor hTableDescriptor, WAL wal) throws IOException
IOException
public static HRegion openHRegion(HRegionInfo info, HTableDescriptor 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(HRegionInfo info, HTableDescriptor 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, HRegionInfo info, HTableDescriptor 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, HRegionInfo info, HTableDescriptor 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, HRegionInfo info, HTableDescriptor 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, HRegionInfo info, HTableDescriptor 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, HRegionInfo info, HTableDescriptor 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(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 void warmupHRegion(HRegionInfo info, HTableDescriptor 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
HRegion createDaughterRegionFromSplits(HRegionInfo hri) throws IOException
hri
- Spec. for daughter region to open.IOException
HRegion createMergedRegionFromMerges(HRegionInfo mergedRegionInfo, HRegion region_b) throws IOException
region_b
- another merging regionIOException
public static void addRegionToMETA(HRegion meta, HRegion r) throws IOException
meta
region. Used by the HMaster bootstrap code adding
new table to hbase:meta table.meta
- hbase:meta HRegion to be updatedr
- HRegion to add to meta
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 name@Deprecated public static org.apache.hadoop.fs.Path getRegionDir(org.apache.hadoop.fs.Path rootdir, HRegionInfo info)
rootdir
- qualified path of HBase root directoryinfo
- HRegionInfo for the regionpublic static boolean rowIsInRange(HRegionInfo info, byte[] row)
info
- HRegionInfo that specifies the row rangerow
- row to be checkedpublic static boolean rowIsInRange(HRegionInfo info, byte[] row, int offset, short length)
public static HRegion mergeAdjacent(HRegion srcA, HRegion srcB) throws IOException
IOException
public static HRegion merge(HRegion a, HRegion b) throws IOException
a
- region ab
- region bIOException
public Result get(Get get) throws IOException
Region
get
in interface Region
get
- query parametersIOException
private Scan buildScanForGetWithClosestRowBefore(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 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) throws IOException
mutateRowsWithLocks(Collection, Collection, long, long)
IOException
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.protobuf.generated.ClientProtos.RegionLoadStats getRegionStats()
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 doProcessRowWithTimeout(RowProcessor<?,?> processor, long now, HRegion region, List<Mutation> mutations, WALEdit walEdit, long timeout) throws IOException
IOException
private static List<Tag> carryForwardTags(Cell cell, List<Tag> tags)
cell
- tags
- cell
added.private List<Cell> doGet(Store store, byte[] row, Map.Entry<byte[],List<Cell>> family, TimeRange tr) throws IOException
store
on passed row
, etc.store
- row
- family
- tr
- IOException
public Result append(Append append) throws IOException
IOException
private void dropMemstoreContents() throws IOException
IOException
public Result append(Append mutate, long nonceGroup, long nonce) throws IOException
Region
append
in interface Region
IOException
private static Cell getNewCell(byte[] row, long ts, Cell cell, Cell oldCell, byte[] tagBytes)
public Result increment(Increment increment) throws IOException
IOException
public Result increment(Increment mutation, long nonceGroup, long nonce) throws IOException
Region
increment
in interface Region
IOException
private Result doIncrement(Increment increment, long nonceGroup, long nonce) throws IOException
IOException
private static List<Cell> sort(List<Cell> cells, Comparator<Cell> comparator)
cells
using comparator
private List<Cell> applyIncrementsToColumnFamily(Increment increment, byte[] columnFamilyName, List<Cell> sortedIncrements, long now, long mvccNum, List<Cell> allKVs, IsolationLevel isolation) throws IOException
sortedIncrements
- The passed in increments to apply MUST be sorted so that they match
the order that they appear in the Get results (get results will be sorted on return).
Otherwise, we won't be able to find the existing values if the cells are not specified in
order by the client since cells are in an array list.sortedIncrements
have been applied to current
values (if any -- else passed increment is the final result).IOException
private static long getLongValue(Cell cell) throws DoNotRetryIOException
DoNotRetryIOException
private List<Cell> getIncrementCurrentValue(Increment increment, byte[] columnFamily, List<Cell> increments, IsolationLevel isolation) throws IOException
columnFamily
and column qualifiers
from incrementCoordinates
only.increment
- columnFamily
- incrementCoordinates
- IOException
private static List<Tag> carryForwardTTLTag(List<Tag> tagsOrNull, Mutation mutation)
private void checkFamily(byte[] family) throws NoSuchColumnFamilyException
NoSuchColumnFamilyException
public long heapSize()
private static void printUsageAndExit(String message)
public boolean registerService(com.google.protobuf.Service instance)
Region
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
.
registerService
in interface Region
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.protobuf.generated.ClientProtos.CoprocessorServiceCall call) throws IOException
Region
Service
method using
the registered protocol handlers. Service
implementations must be registered via the
Region.registerService(com.google.protobuf.Service)
method before they are available.execService
in interface Region
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 invocationRegion.registerService(com.google.protobuf.Service)
private static void processTable(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path p, WALFactory walFactory, org.apache.hadoop.conf.Configuration c, boolean majorCompact) throws IOException
IOException
boolean shouldForceSplit()
byte[] getExplicitSplitPoint()
void forceSplit(byte[] sp)
void clearSplit()
protected void prepareToSplit()
public byte[] checkSplit()
public int getCompactPriority()
public RegionCoprocessorHost getCoprocessorHost()
getCoprocessorHost
in interface Region
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.startRegionOperation(Operation)
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 syncOrDefer(long txid, Durability durability) throws IOException
txid
- should sync up to which transactionIOException
- If anything goes wrong with DFSprivate boolean shouldSyncWAL()
public static void main(String[] args) throws IOException
./bin/hbase org.apache.hadoop.hbase.regionserver.HRegion
IOException
public long getOpenSeqNum()
getOpenSeqNum
in interface Region
public Map<byte[],Long> getMaxStoreSeqId()
getMaxStoreSeqId
in interface Region
public long getOldestSeqIdOfStore(byte[] familyName)
getOldestSeqIdOfStore
in interface Region
Region.getMaxFlushedSeqId()
in case where we've flushed a subset of a regions column
familiespublic org.apache.hadoop.hbase.protobuf.generated.AdminProtos.GetRegionInfoResponse.CompactionState getCompactionState()
getCompactionState
in interface Region
public void reportCompactionRequestStart(boolean isMajor)
public void reportCompactionRequestEnd(boolean isMajor, int numFiles, long filesSizeCompacted)
public long getSequenceId()
private WALKey appendEmptyEdit(WAL wal) throws IOException
wal
- IOException
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 RegionSplitPolicy getSplitPolicy()
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.