Class HRegion
- All Implemented Interfaces:
ConfigurationObserver,PropagatingConfigurationObserver,HeapSize,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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classClass that tracks the progress of a batch operations, accumulating status codes and tracking the index at which processing is proceeding.static interfaceListener class to enable callers of bulkLoadHFile() to perform any necessary pre/post processing of a given bulkload callstatic interfacestatic classObjects from this class are created when flushing to describe all the different states that that method ends up in.private static classBatch of mutation operations.(package private) static classA class that tracks exceptions that have been observed in one batch.protected static classA result object from prepare flush cache stageprivate static final classDeprecated.Since 3.0.0, will be removed in 4.0.0.(package private) classstatic classClass used to represent a lock on a row.(package private) static classNested classes/interfaces inherited from interface org.apache.hadoop.hbase.regionserver.Region
Region.Operation, Region.RowLock -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.apache.hadoop.conf.Configurationprivate BlockCacheprivate final LongAdderprivate long(package private) final longprivate final CellComparator(package private) final LongAdder(package private) final LongAdderstatic final Stringstatic final Stringstatic final String(package private) final AtomicBooleanprivate final Object(package private) final AtomicBooleanstatic final StringParameter name for compaction after bulkload(package private) final LongAdder(package private) final LongAdder(package private) final LongAdder(package private) final LongAdder(package private) final LongAdderprotected final org.apache.hadoop.conf.Configurationprivate ConfigurationManagerprivate RegionCoprocessorHost(package private) final LongAdder(package private) final LongAdderstatic final long(package private) static final longstatic final intDefault interval for the memstore flushstatic final booleanstatic final longstatic final longstatic final booleanstatic final longstatic final intstatic final intstatic final String(package private) static final intstatic final booleanstatic final booleanstatic final StringConf key for fair locking policy(package private) final LongAdderstatic final longprivate long(package private) final LongAdderprivate longprivate FlushPolicyprivate final HRegionFileSystemstatic final Stringstatic final Stringprivate TableDescriptorprivate booleanThe default setting for whether to enable on-demand CF loading for scan requests to this region.private booleanprivate longRecord the sequence id of last flush operation.protected longprotected longThe sequence id of the last replayed open region event from the primary region.private longprivate final ConcurrentMap<HStore,Long> static final String(package private) final ReentrantReadWriteLockprivate final ConcurrentHashMap<HashedBytes,HRegion.RowLockContext> private static final org.slf4j.Loggerprivate final AtomicIntegerstatic final longThe following MAX_FLUSH_PER_CHANGES is large enough because each KeyValue has 20+ bytes overhead.(package private) final long(package private) final int(package private) final longprivate longThe max sequence id of flushed data on this region.static final StringConf key to force a flush if there are already enough changes for one region in memstorestatic final StringConf key for the periodic flush interval(package private) longprivate final MemStoreSizingprivate final MetricsRegionprivate final MetricsRegionWrapperImplprivate MetricsTableRequestsprivate final intprivate final intprivate final AtomicIntegerprivate MobFileCacheprivate final MultiVersionConcurrencyControl(package private) final LongAdderprivate longThe sequence ID that was enLongAddered when this region was opened.private HRegion.PrepareFlushResultSaved state from replaying prepare flush cache(package private) final LongAdderstatic final StringMainly used for master local region, where we will replay the WAL file directly without splitting, so it is possible to have WAL files which are not closed cleanly, in this way, hitting EOF is expected so should not consider it as a critical problem.static final Stringprivate final Durability(package private) final ConcurrentHashMap<Thread,Boolean> protected Optional<RegionReplicationSink>(package private) RegionServicesForStoresprivate final booleanprivate org.apache.hadoop.fs.Pathprivate Lockprivate final NavigableMap<byte[],Integer> private final intprivate RegionServerAccountingprotected RegionServerServices(package private) final ConcurrentHashMap<RegionScanner,Long> (package private) final ReadPointCalculationLockstatic final StringThis is for for using HRegion as a local storage, where we may put the recovered edits in a special place.static final StringConfig for allow split when file count greater than the configured blocking file countprivate RegionSplitPolicyprivate RegionSplitRestrictionprivate final StoreHotnessProtectorstatic final intDefault interval for System tables memstore flushprivate Long(package private) final longprivate final ReentrantReadWriteLockstatic final StringWhether to useMetaCellComparatoreven if we are not meta region.private final WALstatic final Stringprivate org.apache.hadoop.fs.FileSystem(package private) final LongAdder(package private) final HRegion.WriteState -
Constructor Summary
ConstructorsConstructorDescriptionHRegion(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.HRegion(HRegionFileSystem fs, WAL wal, org.apache.hadoop.conf.Configuration confParam, TableDescriptor htd, RegionServerServices rsServices) HRegion constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddReadRequestsCount(long readRequestsCount) voidaddRegionToSnapshot(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription desc, ForeignExceptionSnare exnSnare) Complete taking the snapshot on the region.voidaddWriteRequestsCount(long writeRequestsCount) Perform one or more append operations on a row.private voidapplyToMemStore(HStore store, List<ExtendedCell> cells, boolean delta, MemStoreSizing memstoreAccounting) booleanprivate voidattachRegionReplicationInWALAppend(HRegion.BatchOperation<?> batchOp, MiniBatchOperationInProgress<Mutation> miniBatchOp, WALKeyImpl walKey, WALEdit walEdit, MultiVersionConcurrencyControl.WriteEntry writeEntry) AttachRegionReplicationSink.add(org.apache.hadoop.hbase.wal.WALKeyImpl, org.apache.hadoop.hbase.wal.WALEdit, org.apache.hadoop.hbase.ipc.ServerCall<?>)to the mvcc writeEntry for replicating to region replica.private voidattachRegionReplicationToFlushOpSeqIdMVCCEntry(MultiVersionConcurrencyControl.WriteEntry flushOpSeqIdMVCCEntry, org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor desc, RegionReplicationSink sink) CreateWALEditforWALProtos.FlushDescriptorand attachRegionReplicationSink.add(org.apache.hadoop.hbase.wal.WALKeyImpl, org.apache.hadoop.hbase.wal.WALEdit, org.apache.hadoop.hbase.ipc.ServerCall<?>)to the flushOpSeqIdMVCCEntry.batchMutate(Mutation[] mutations) Perform a batch of mutations.(package private) OperationStatus[]batchMutate(Mutation[] mutations, boolean atomic) batchMutate(Mutation[] mutations, boolean atomic, long nonceGroup, long nonce) private OperationStatus[]batchMutate(HRegion.BatchOperation<?> batchOp) Perform a batch of mutations.(package private) OperationStatus[]batchReplay(WALSplitUtil.MutationReplay[] mutations, long replaySeqId) Deprecated.Since 3.0.0, will be removed in 4.0.0.voidbulkLoadHFiles(Collection<Pair<byte[], String>> familyPaths, boolean assignSeqId, HRegion.BulkLoadListener bulkLoadListener) Attempts to atomically load a group of hfiles.bulkLoadHFiles(Collection<Pair<byte[], String>> familyPaths, boolean assignSeqId, HRegion.BulkLoadListener bulkLoadListener, boolean copyFile, List<String> clusterIds, boolean replicate) Attempts to atomically load a group of hfiles.booleancheckAndMutate(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator, TimeRange timeRange, Mutation mutation) Deprecated.booleancheckAndMutate(byte[] row, Filter filter, TimeRange timeRange, Mutation mutation) Deprecated.checkAndMutate(CheckAndMutate checkAndMutate) Atomically checks if a row matches the conditions and if it does, it performs the actions.checkAndMutate(CheckAndMutate checkAndMutate, long nonceGroup, long nonce) private CheckAndMutateResultcheckAndMutateInternal(CheckAndMutate checkAndMutate, long nonceGroup, long nonce) booleancheckAndRowMutate(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator, TimeRange timeRange, RowMutations rm) Deprecated.booleancheckAndRowMutate(byte[] row, Filter filter, TimeRange timeRange, RowMutations rm) Deprecated.private voidcheckFamilies(Collection<byte[]> families, Durability durability) private voidcheckFamily(byte[] family) private voidcheckFamily(byte[] family, Durability durability) (package private) voidCheck thread interrupt status and throw an exception if interrupted.private voidcheckMutationType(Mutation mutation) private voidcheckNegativeMemStoreDataSize(long memStoreDataSize, long delta) private voidprivate voidprivate voidCheck if resources to support an update.(package private) voidMake sure this is a valid row for the HRegionprivate voidOptional<byte[]>Optional<byte[]>checkSplit(boolean force) Return the split point.private voidcheckTargetRegion(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.voidcheckTimestamps(Map<byte[], List<Cell>> familyMap, long now) Check the collection of families for valid timestampsMap<byte[],List<HStoreFile>> close()Close down this HRegion.Map<byte[],List<HStoreFile>> close(boolean abort) Map<byte[],List<HStoreFile>> close(boolean abort, boolean ignoreStatus) Close this HRegion.Map<byte[],List<HStoreFile>> close(boolean abort, boolean ignoreStatus, boolean isGracefulStop) Close down this HRegion.private voidCloses the lock.voidCloses the region operation lock.voidcloseRegionOperation(Region.Operation operation) Closes the region operation lock.voidcompact(boolean majorCompaction) Synchronously compact all stores in the region.booleancompact(CompactionContext compaction, HStore store, ThroughputController throughputController) Called by compaction thread and after region is opened to compact the HStores if necessary.booleancompact(CompactionContext compaction, HStore store, ThroughputController throughputController, User user) We are trying to remove / relax the region read lock for compaction.(package private) voidcompactStore(byte[] family, ThroughputController throughputController) This is a helper function that compact the given store.voidThis is a helper function that compact all the stores synchronously.static HDFSBlocksDistributioncomputeHDFSBlocksDistribution(org.apache.hadoop.conf.Configuration conf, TableDescriptor tableDescriptor, RegionInfo regionInfo) This is a helper function to compute HDFS block distribution on demandstatic HDFSBlocksDistributioncomputeHDFSBlocksDistribution(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 demandstatic HRegioncreateHRegion(org.apache.hadoop.conf.Configuration conf, RegionInfo regionInfo, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path tableDir, TableDescriptor tableDesc) Create a region under the given table directory.static HRegioncreateHRegion(RegionInfo info, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.conf.Configuration conf, TableDescriptor hTableDescriptor, WAL wal) static HRegioncreateHRegion(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 HRegioncreateHRegion(RegionInfo info, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.conf.Configuration conf, TableDescriptor hTableDescriptor, WAL wal, boolean initialize, RegionServerServices rsRpcServices) Convenience method creating new HRegions.static HRegionFileSystemcreateRegionDir(org.apache.hadoop.conf.Configuration configuration, RegionInfo ri, org.apache.hadoop.fs.Path rootDir) Create the region directory in the filesystem.(package private) io.opentelemetry.api.trace.SpancreateRegionSpan(String name) private WALKeyImplcreateWALKeyForWALAppend(boolean isReplay, HRegion.BatchOperation<?> batchOp, long now, long nonceGroup, long nonce) private static voiddecorateRegionConfiguration(org.apache.hadoop.conf.Configuration conf) This method modifies the region's configuration in order to inject replication-related featuresvoidprotected voidprivate voiddecrMemStoreSize(long dataSizeDelta, long heapSizeDelta, long offHeapSizeDelta, int cellsCountDelta) (package private) voidvoidDeletes the specified cells/row.private voiddeleteRecoveredEdits(org.apache.hadoop.fs.FileSystem fs, Iterable<org.apache.hadoop.fs.Path> files) voidderegisterChildren(ConfigurationManager manager) Needs to be called to deregister the children from the manager.(package private) voidIf a handler thread is eligible for interrupt, make it ineligible.private voiddoAbortFlushToWAL(WAL wal, long flushOpSeqId, Map<byte[], List<org.apache.hadoop.fs.Path>> committedFiles) private voiddoAttachReplicateRegionReplicaAction(WALKeyImpl walKey, WALEdit walEdit, MultiVersionConcurrencyControl.WriteEntry writeEntry) AttachRegionReplicationSink.add(org.apache.hadoop.hbase.wal.WALKeyImpl, org.apache.hadoop.hbase.wal.WALEdit, org.apache.hadoop.hbase.ipc.ServerCall<?>)to the mvcc writeEntry for replicating to region replica.private Map<byte[],List<HStoreFile>> doClose(boolean abort, MonitoredTask status) private MemStoreSizedoDropStoreMemStoreContentsForSeqId(HStore s, long currentSeqId) private voiddoMiniBatchMutate(HRegion.BatchOperation<?> batchOp) Called to do a piece of the batch that came in tobatchMutate(Mutation[])In here we also handle replay of edits on region recover.protected voidDo preparation for pending compaction.private static voiddoSyncOfUnflushedWALChanges(WAL wal, RegionInfo hri) Sync unflushed WAL changes.doWALAppend(WALEdit walEdit, HRegion.BatchOperation<?> batchOp, MiniBatchOperationInProgress<Mutation> miniBatchOp, long now, NonceKey nonceKey) Returns writeEntry associated with this appendprivate MemStoreSizeBe careful, this method will drop all data in the memstore of this region.private MemStoreSizedropMemStoreContentsForSeqId(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 idprivate voidIf all stores ended up dropping their snapshots, we can safely drop the prepareFlushResult(package private) voidIf a handler thread was made ineligible for interrupt via {disableInterrupts(), make it eligible again.booleanorg.apache.hbase.thirdparty.com.google.protobuf.MessageexecService(org.apache.hbase.thirdparty.com.google.protobuf.RpcController controller, org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceCall call) Executes a single protocol buffer coprocessor endpointServicemethod using the registered protocol handlers.flush(boolean flushAllStores) Flush the cache.flushcache(boolean flushAllStores, boolean writeFlushRequestWalMarker, FlushLifeCycleTracker tracker) flushcache(List<byte[]> families, boolean writeFlushRequestWalMarker, FlushLifeCycleTracker tracker) Flush the cache.Do a get based on the get parameter.Do a get based on the get parameter.(package private) org.apache.hadoop.conf.ConfigurationA split takes the config from the parent region & passes it to the daughter region's constructor.longReturns the number of blocked requestsThe comparator to be used with the regionlongReturns the number of failed checkAndMutate guardslongReturns the number of checkAndMutate guards that passedReturns if a given region is in compaction now.intReturns The priority that this region should have in the compaction queueReturns the coprocessor hostlongReturns coprocessor requests count for this regionlongReturns the size of data processed bypassing the WAL, in byteslongprivate DurabilityReturns effective durability from the passed durability and the table descriptor.org.apache.hadoop.fs.FileSystemReturnsFileSystembeing used by this regionlongReturns filtered read requests count for this regiongetInternal(Get get, boolean withCoprocessor, long nonceGroup, long nonce) org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionLoadStatsReturns statistics about the current load of the regionlonglonglonglonglongintThe minimum block size configuration from all relevant column families.getMVCC()protected longgetNextSequenceId(WAL wal) Method to safely get the next sequence number.longReturns the number of mutations processed bypassing the WALlonggetOldestHfileTs(boolean majorCompactionOnly) This can be used to determine the last time all files of this region were major compacted.longgetOldestSeqIdOfStore(byte[] familyName) private static ThreadPoolExecutorgetOpenAndCloseThreadPool(int maxThreads, String threadNamePrefix) longReturns the latest sequence number that was read from storage when this region was opened(package private) HRegion.PrepareFlushResultintorg.apache.hadoop.conf.ConfigurationlonggetReadPoint(IsolationLevel isolationLevel) Returns readpoint considering given IsolationLevel.longReturns read requests count for this regionstatic org.apache.hadoop.fs.PathgetRegionDir(org.apache.hadoop.fs.Path tabledir, String name) Deprecated.For tests only; to be removed.Returns theHRegionFileSystemused by this regionReturns region information for this region(package private) RegionServerServicesReturns Instance ofRegionServerServicesused by this HRegion.Returns store services for this region, to access services required by store level needs(package private) HRegionWALFileSystemReturns the WALHRegionFileSystemused by this regionNavigableMap<byte[],Integer> getRowLock(byte[] row) Get an exclusive ( write lock ) lock on a given row.getRowLock(byte[] row, boolean readLock) Get a row lock for the specified row.private Region.RowLockgetRowLock(byte[] row, boolean readLock, Region.RowLock prevRowLock) protected Region.RowLockgetRowLockInternal(byte[] row, boolean readLock, Region.RowLock prevRowLock) getScanner(Scan scan) Return an iterator that scans over the HRegion, returning the indicated columns and rows specified by theScan.getScanner(Scan scan, List<KeyValueScanner> additionalScanners) Return an iterator that scans over the HRegion, returning the indicated columns and rows specified by theScan.private RegionScannerImplgetScanner(Scan scan, List<KeyValueScanner> additionalScanners, long nonceGroup, long nonce) longprivate Collection<HStore>getSpecificStores(List<byte[]> families) get stores which matches the specified families(package private) RegionSplitPolicyReturns split policy for this region.getStore(byte[] column) Return the Store for the given familyprivate HStoreReturn HStore instance.getStoreFileList(byte[][] columns) Returns list of store file names for the given families(package private) ThreadPoolExecutorgetStoreFileOpenAndCloseThreadPool(String threadNamePrefix) private NavigableMap<byte[],List<org.apache.hadoop.fs.Path>> Returns Map of StoreFiles by column familyprivate ThreadPoolExecutorgetStoreOpenAndCloseThreadPool(String threadNamePrefix) Return the list of Stores managed by this regionprivate Collection<HStore>getStoresToFlush(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flushDesc) Returns table descriptor for this regiongetWAL()Returns WAL in use for this region(package private) org.apache.hadoop.fs.FileSystemReturns the WALFileSystembeing used by this regionorg.apache.hadoop.fs.PathlongReturns write request count for this regionprivate voidhandleException(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path edits, IOException e) inthashCode()private static booleanhasMultipleColumnFamilies(Collection<Pair<byte[], String>> familyPaths) Determines whether multiple column families are present Precondition: familyPaths is not nullbooleanReturns True if this region has references.longheapSize()Return the approximate 'exclusive deep size' of implementing object.(package private) voidincMemStoreSize(long dataSizeDelta, long heapSizeDelta, long offHeapSizeDelta, int cellsCountDelta) private voidIncrease the size of mem store in this region and the size of global mem storePerform one or more increment operations on a row.voidvoidlongDeprecated.use HRegion.createHRegion() or HRegion.openHRegion()(package private) longinitialize(CancelableProgressable reporter) Initialize this region.private longinitializeRegionInternals(CancelableProgressable reporter, MonitoredTask status) private voidinitializeRegionReplicationSink(CancelableProgressable reporter, MonitoredTask status) private longinitializeStores(CancelableProgressable reporter, MonitoredTask status) Open all Stores.private longinitializeStores(CancelableProgressable reporter, MonitoredTask status, boolean warmup) private voidinitializeWarmup(CancelableProgressable reporter) protected HStoreinstantiateHStore(ColumnFamilyDescriptor family, boolean warmup) protected RegionScannerImplinstantiateRegionScanner(Scan scan, List<KeyValueScanner> additionalScanners, long nonceGroup, long nonce) private HRegion.FlushResultImplinternalFlushcache(Collection<HStore> storesToFlush, MonitoredTask status, boolean writeFlushWalMarker, FlushLifeCycleTracker tracker) Flushing given stores.private HRegion.FlushResultinternalFlushcache(MonitoredTask status) Flushing all stores.protected HRegion.FlushResultImplinternalFlushcache(WAL wal, long myseqid, Collection<HStore> storesToFlush, MonitoredTask status, boolean writeFlushWalMarker, FlushLifeCycleTracker tracker) Flush the memstore.(package private) HRegion.FlushResultImplinternalFlushCacheAndCommit(WAL wal, MonitoredTask status, HRegion.PrepareFlushResult prepareResult, Collection<HStore> storesToFlush) protected HRegion.PrepareFlushResultinternalPrepareFlushCache(WAL wal, long myseqid, Collection<HStore> storesToFlush, MonitoredTask status, boolean writeFlushWalMarker, FlushLifeCycleTracker tracker) private voidInterrupt any region options that have acquired the region lock viastartRegionOperation(org.apache.hadoop.hbase.regionserver.Region.Operation), orstartBulkRegionOperation(boolean).private booleanisAllFamilies(Collection<HStore> families) Returns True if passed Set is all families in the region.booleanReturns true if region is available (not closed and not closing)booleanisClosed()Returns true if region is closedbooleanReturns True if closing process has startedprivate booleanisFlushSize(MemStoreSize size) booleanbooleanReturns true if region is mergeablebooleanReturns True if region is read only(package private) booleanbooleanReturns true if region is splittableprivate static booleanisZeroLengthThenDelete(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.FileStatus stat, org.apache.hadoop.fs.Path p) make sure have been through lease recovery before get file status, so the file length can be trusted.private longloadRecoveredHFilesIfAny(Collection<HStore> stores) private voidprivate voidTry to acquire a lock.private voidlogFatLineOnFlush(Collection<HStore> storesToFlush, long sequenceId) Utility method broken out of internalPrepareFlushCache so that method is smaller.private voidprivate booleanmatches(CompareOperator op, int compareResult) (package private) voidprivate OperationStatusprivate OperationStatusprivate OperationStatusPerforms multiple mutations atomically on a single row.mutateRow(RowMutations rm, long nonceGroup, long nonce) voidmutateRowsWithLocks(Collection<Mutation> mutations, Collection<byte[]> rowsToLock, long nonceGroup, long nonce) Perform atomic (all or none) mutations within the region.static HRegionnewHRegion(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 theHConstants.REGION_IMPLconfiguration property.voidonConfigurationChange(org.apache.hadoop.conf.Configuration conf) This method would be called by theConfigurationManagerobject when theConfigurationobject is reloaded from disk.static HRegionopenHRegion(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 HRegionopenHRegion(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 HRegionopenHRegion(org.apache.hadoop.fs.Path rootDir, RegionInfo info, TableDescriptor htd, WAL wal, org.apache.hadoop.conf.Configuration conf) Open a Region.static HRegionopenHRegion(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 HRegionopenHRegion(RegionInfo info, TableDescriptor htd, WAL wal, org.apache.hadoop.conf.Configuration conf) Open a Region.static HRegionopenHRegion(RegionInfo info, TableDescriptor htd, WAL wal, org.apache.hadoop.conf.Configuration conf, RegionServerServices rsServices, CancelableProgressable reporter) Open a Region.static HRegionopenHRegion(HRegion other, CancelableProgressable reporter) Useful when reopening a closed region (normally for unit tests)static RegionopenHRegion(Region other, CancelableProgressable reporter) private HRegionopenHRegion(CancelableProgressable reporter) Open HRegion.static HRegionopenHRegionFromTableDir(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path tableDir, RegionInfo info, TableDescriptor htd, WAL wal, RegionServerServices rsServices, CancelableProgressable reporter) Open a Region.static HRegionopenReadOnlyFileSystemHRegion(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)private voidprepareDelete(Delete delete) Prepare a delete for a row mutation processorprivate voidprepareDeleteTimestamps(Mutation mutation, Map<byte[], List<ExtendedCell>> familyMap, byte[] byteNow) Set up correct timestamps in the KVs in Delete object.(package private) voidprepareGet(Get get) voidPuts some data in the table.private voidrecordMutationWithoutWal(Map<byte[], List<Cell>> familyMap) Update LongAdders for number of puts without wal and the size of possible data loss.booleanCheck 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 booleanrefreshStoreFiles(boolean force) voidregisterChildren(ConfigurationManager manager) Needs to be called to register the children to the manager.booleanregisterService(org.apache.hbase.thirdparty.com.google.protobuf.Service instance) Registers a new protocol bufferServicesubclass as a coprocessor endpoint to be available for handlingexecService(RpcController, CoprocessorServiceCall)calls.private voidreleaseRowLocks(List<Region.RowLock> rowLocks) private voidreplayFlushInStores(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush, HRegion.PrepareFlushResult prepareFlushResult, boolean dropMemstoreSnapshot) Deprecated.Since 3.0.0, will be removed in 4.0.0.private longreplayRecoveredEdits(org.apache.hadoop.fs.Path edits, Map<byte[], Long> maxSeqIdInStores, CancelableProgressable reporter, org.apache.hadoop.fs.FileSystem fs) private longreplayRecoveredEditsForPaths(long minSeqIdForTheRegion, org.apache.hadoop.fs.FileSystem fs, NavigableSet<org.apache.hadoop.fs.Path> files, CancelableProgressable reporter, org.apache.hadoop.fs.Path regionDir) (package private) longreplayRecoveredEditsIfAny(Map<byte[], Long> maxSeqIdInStores, CancelableProgressable reporter, MonitoredTask status) Read the edits put under this region by wal splitting process.private voidreplayWALBatchMutate(Map<byte[], List<ExtendedCell>> family2Cells) Replay the batch mutate for secondary replica.(package private) voidreplayWALBulkLoadEventMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.BulkLoadDescriptor bulkLoadEvent) Deprecated.Since 3.0.0, will be removed in 4.0.0.(package private) voidreplayWALCompactionMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.CompactionDescriptor compaction, boolean pickCompactionFiles, boolean removeFiles, long replaySeqId) Call to complete a compaction.(package private) voidreplayWALEntry(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.WALEntry entry, CellScanner cells) Replay remote wal entry sent by primary replica.private voidreplayWALFlushAbortMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush) private voidreplayWALFlushCannotFlushMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush, long replaySeqId) (package private) voidreplayWALFlushCommitMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush) Deprecated.Since 3.0.0, will be removed in 4.0.0.(package private) voidreplayWALFlushMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush, long replaySeqId) Deprecated.Since 3.0.0, will be removed in 4.0.0.(package private) HRegion.PrepareFlushResultreplayWALFlushStartMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush) Deprecated.Since 3.0.0, will be removed in 4.0.0.private voidreplayWALMetaEdit(Cell cell) Replay the meta edits, i.e, flush marker, compaction marker, bulk load marker, region event marker, etc.(package private) voidreplayWALRegionEventMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.RegionEventDescriptor regionEvent) Deprecated.Since 3.0.0, will be removed in 4.0.0.voidreportCompactionRequestEnd(boolean isMajor, int numFiles, long filesSizeCompacted) voidvoidreportCompactionRequestStart(boolean isMajor) voidrequestCompaction(byte[] family, String why, int priority, boolean major, CompactionLifeCycleTracker tracker) Request compaction for the given familyvoidrequestCompaction(String why, int priority, boolean major, CompactionLifeCycleTracker tracker) Request compaction on this region.private voidvoidrequestFlush(FlushLifeCycleTracker tracker) Request flush on this region.private voidrequestFlush0(FlushLifeCycleTracker tracker) private voidprotected voidrestoreEdit(HStore s, ExtendedCell cell, MemStoreSizing memstoreAccounting) Used by testsprivate voidrewriteCellTags(Map<byte[], List<ExtendedCell>> familyMap, Mutation m) Possibly rewrite incoming cell tags.static booleanrowIsInRange(RegionInfo info, byte[] row) Determines if the specified row is within the row range specified by the specified RegionInfostatic booleanrowIsInRange(RegionInfo info, byte[] row, int offset, short length) voidsetBlockCache(BlockCache blockCache) Only used for unit test which doesn't start region server.voidsetClosing(boolean closing) Exposed for some very specific unit tests.(package private) org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos.RegionLoad.BuildersetCompleteSequenceId(org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos.RegionLoad.Builder regionLoadBldr) voidsetCoprocessorHost(RegionCoprocessorHost coprocessorHost) private voidvoidsetMobFileCache(MobFileCache mobFileCache) Only used for unit test which doesn't start region server.voidsetReadsEnabled(boolean readsEnabled) voidsetRestoredRegion(boolean restoredRegion) voidvoidsetTimeoutForWriteLock(long timeoutForWriteLock) ThedoClose(boolean, org.apache.hadoop.hbase.monitoring.MonitoredTask)will block forever if someone tries proving the dead lock via the unit test.(package private) booleanshouldFlush(StringBuilder whyFlush) Should the memstore be flushed now(package private) booleanshouldFlushStore(HStore store) Should the store be flushed because it is old enough.private booleanprivate booleanCheck whether we should sync the wal from the table's durability settingsprivate voidstartBulkRegionOperation(boolean writeLockNeeded) This method needs to be called before any public call that reads or modifies stores in bulk.voidThis method needs to be called before any public call that reads or modifies data.voidThis method needs to be called before any public call that reads or modifies data.private voidsync(long txid, Durability durability) Calls sync with the given transaction ID(package private) voidthrowException(String title, String regionName) (package private) IOExceptionThrow the correct exception upon interrupttoString()voidprivate static voidupdateCellTimestamps(Iterable<List<ExtendedCell>> cellItr, byte[] now) Replace any cell timestamps set toHConstants.LATEST_TIMESTAMPprovided current timestamp.private voidupdateDeleteLatestVersionTimestamp(Cell cell, Get get, int count, byte[] byteNow) private voidupdateSequenceId(Iterable<List<ExtendedCell>> cellItr, long sequenceId) voidWait for all current flushes of the region to completebooleanwaitForFlushes(long timeout) Wait for all current flushes of the region to completevoidWait for all current flushes and compactions of the region to completestatic HRegionwarmupHRegion(RegionInfo info, TableDescriptor htd, WAL wal, org.apache.hadoop.conf.Configuration conf, RegionServerServices rsServices, CancelableProgressable reporter) private booleanReturns True if its worth doing a flush before we put up the close flag.private booleanwriteCanNotFlushMarkerToWAL(MultiVersionConcurrencyControl.WriteEntry flushOpSeqIdMVCCEntry, WAL wal, boolean writeFlushWalMarker) This method is only used when we flush but the memstore is empty,if writeFlushWalMarker is true,we write theWALProtos.FlushDescriptor.FlushAction.CANNOT_FLUSHflush marker to WAL when the memstore is empty.private voidprotected voidwriteRegionOpenMarker(WAL wal, long openSeqId) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.hadoop.hbase.regionserver.Region
checkAndMutate, checkAndMutate, checkAndRowMutate, checkAndRowMutate
-
Field Details
-
LOG
-
LOAD_CFS_ON_DEMAND_CONFIG_KEY
- See Also:
-
HBASE_MAX_CELL_SIZE_KEY
-
DEFAULT_MAX_CELL_SIZE
- See Also:
-
HBASE_REGIONSERVER_MINIBATCH_SIZE
-
DEFAULT_HBASE_REGIONSERVER_MINIBATCH_SIZE
- See Also:
-
WAL_HSYNC_CONF_KEY
- See Also:
-
DEFAULT_WAL_HSYNC
- See Also:
-
COMPACTION_AFTER_BULKLOAD_ENABLE
Parameter name for compaction after bulkload- See Also:
-
SPLIT_IGNORE_BLOCKING_ENABLED_KEY
Config for allow split when file count greater than the configured blocking file count- See Also:
-
REGION_STORAGE_POLICY_KEY
- See Also:
-
DEFAULT_REGION_STORAGE_POLICY
- See Also:
-
SPECIAL_RECOVERED_EDITS_DIR
This is for for using HRegion as a local storage, where we may put the recovered edits in a special place. Once this is set, we will only replay the recovered edits under this directory and ignore the original replay directory configs.- See Also:
-
RECOVERED_EDITS_IGNORE_EOF
Mainly used for master local region, where we will replay the WAL file directly without splitting, so it is possible to have WAL files which are not closed cleanly, in this way, hitting EOF is expected so should not consider it as a critical problem.- See Also:
-
USE_META_CELL_COMPARATOR
Whether to useMetaCellComparatoreven if we are not meta region. Used when creating master local region.- See Also:
-
DEFAULT_USE_META_CELL_COMPARATOR
- See Also:
-
closed
-
closing
-
maxFlushedSeqId
The max sequence id of flushed data on this region. There is no edit in memory that is less that this sequence id. -
lastFlushOpSeqId
Record the sequence id of last flush operation. Can be in advance ofmaxFlushedSeqIdwhen flushing a single column family. In this case,maxFlushedSeqIdwill be older than the oldest edit in memory. -
lastReplayedOpenRegionSeqId
The sequence id of the last replayed open region event from the primary region. This is used to skip entries before this due to the possibility of replay edits coming out of order from replication. -
lastReplayedCompactionSeqId
-
lockedRows
-
stores
-
coprocessorServiceHandlers
private Map<String,org.apache.hbase.thirdparty.com.google.protobuf.Service> coprocessorServiceHandlers -
memStoreSizing
-
regionServicesForStores
-
numMutationsWithoutWAL
-
dataInMemoryWithoutWAL
-
checkAndMutateChecksPassed
-
checkAndMutateChecksFailed
-
readRequestsCount
-
cpRequestsCount
-
filteredReadRequestsCount
-
writeRequestsCount
-
blockedRequestsCount
-
compactionsFinished
-
compactionsFailed
-
compactionNumFilesCompacted
-
compactionNumBytesCompacted
-
compactionsQueued
-
flushesQueued
-
blockCache
-
mobFileCache
-
wal
-
fs
-
conf
-
baseConf
-
rowLockWaitDuration
-
DEFAULT_ROWLOCK_WAIT_DURATION
- See Also:
-
regionWalDir
-
walFS
-
isRestoredRegion
-
metricsTableRequests
-
busyWaitDuration
-
DEFAULT_BUSY_WAIT_DURATION
- See Also:
-
maxBusyWaitMultiplier
-
maxBusyWaitDuration
-
maxCellSize
-
miniBatchSize
-
scannerReadPoints
-
smallestReadPointCalcLock
-
openSeqNum
The sequence ID that was enLongAddered when this region was opened. -
isLoadingCfsOnDemandDefault
The default setting for whether to enable on-demand CF loading for scan requests to this region. Requests can override it. -
majorInProgress
-
minorInProgress
-
maxSeqIdInStores
Map<byte[],Long> maxSeqIdInStores -
replayLock
-
prepareFlushResult
Saved state from replaying prepare flush cache -
lastReplayedSequenceId
-
configurationManager
-
timeoutForWriteLock
-
cellComparator
-
minBlockSizeBytes
-
writestate
-
memstoreFlushSize
long memstoreFlushSize -
timestampSlop
-
lastStoreFlushTimeMap
-
rsServices
-
rsAccounting
-
flushCheckInterval
-
flushPerChanges
-
blockingMemStoreSize
-
lock
-
regionLockHolders
-
updatesLock
-
mvcc
-
coprocessorHost
-
htableDescriptor
-
splitPolicy
-
splitRestriction
-
flushPolicy
-
metricsRegion
-
metricsRegionWrapper
-
regionDurability
-
regionStatsEnabled
-
replicationScope
-
storeHotnessProtector
-
regionReplicationSink
-
closeLock
-
FAIR_REENTRANT_CLOSE_LOCK
Conf key for fair locking policy- See Also:
-
DEFAULT_FAIR_REENTRANT_CLOSE_LOCK
- See Also:
-
MEMSTORE_PERIODIC_FLUSH_INTERVAL
Conf key for the periodic flush interval -
DEFAULT_CACHE_FLUSH_INTERVAL
Default interval for the memstore flush- See Also:
-
SYSTEM_CACHE_FLUSH_INTERVAL
Default interval for System tables memstore flush- See Also:
-
MEMSTORE_FLUSH_PER_CHANGES
Conf key to force a flush if there are already enough changes for one region in memstore- See Also:
-
DEFAULT_FLUSH_PER_CHANGES
- See Also:
-
MAX_FLUSH_PER_CHANGES
The following MAX_FLUSH_PER_CHANGES is large enough because each KeyValue has 20+ bytes overhead. Therefore, even 1G empty KVs occupy at least 20GB memstore size for a single region- See Also:
-
CLOSE_WAIT_ABORT
- See Also:
-
DEFAULT_CLOSE_WAIT_ABORT
- See Also:
-
CLOSE_WAIT_TIME
- See Also:
-
DEFAULT_CLOSE_WAIT_TIME
- See Also:
-
CLOSE_WAIT_INTERVAL
- See Also:
-
DEFAULT_CLOSE_WAIT_INTERVAL
- See Also:
-
FIXED_OVERHEAD
-
DEEP_OVERHEAD
-
-
Constructor Details
-
HRegion
@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) Deprecated.Use other constructors.HRegion constructor. This constructor should only be used for testing and extensions. Instances of HRegion should be instantiated with thecreateHRegion(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)oropenHRegion(org.apache.hadoop.hbase.client.RegionInfo, org.apache.hadoop.hbase.client.TableDescriptor, org.apache.hadoop.hbase.wal.WAL, org.apache.hadoop.conf.Configuration)method.- Parameters:
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 toRegionServerServicesor null
-
HRegion
public HRegion(HRegionFileSystem fs, WAL wal, org.apache.hadoop.conf.Configuration confParam, TableDescriptor htd, RegionServerServices rsServices) HRegion constructor. This constructor should only be used for testing and extensions. Instances of HRegion should be instantiated with thecreateHRegion(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)oropenHRegion(org.apache.hadoop.hbase.client.RegionInfo, org.apache.hadoop.hbase.client.TableDescriptor, org.apache.hadoop.hbase.wal.WAL, org.apache.hadoop.conf.Configuration)method.- Parameters:
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 toRegionServerServicesor null
-
-
Method Details
-
setRestoredRegion
-
getMetricsTableRequests
-
getSmallestReadPoint
- Returns:
- The smallest mvcc readPoint across all the scanners in this region. Writes older than this readPoint, are included in every read operation.
-
setHTableSpecificConf
-
initialize
Deprecated.use HRegion.createHRegion() or HRegion.openHRegion()Initialize this region. Used only by tests and SplitTransaction to reopen the region. You should use createHRegion() or openHRegion()- Returns:
- What the next sequence (edit) id should be.
- Throws:
IOException- e
-
initialize
Initialize this region.- Parameters:
reporter- Tickle every so often if initialize is taking a while.- Returns:
- What the next sequence (edit) id should be.
- Throws:
IOException
-
initializeRegionInternals
private long initializeRegionInternals(CancelableProgressable reporter, MonitoredTask status) throws IOException - Throws:
IOException
-
initializeRegionReplicationSink
-
initializeStores
private long initializeStores(CancelableProgressable reporter, MonitoredTask status) throws IOException Open all Stores.- Returns:
- Highest sequenceId found out in a Store.
- Throws:
IOException
-
initializeStores
private long initializeStores(CancelableProgressable reporter, MonitoredTask status, boolean warmup) throws IOException - Throws:
IOException
-
initializeWarmup
- Throws:
IOException
-
getStoreFiles
Returns Map of StoreFiles by column family -
writeRegionOpenMarker
- Throws:
IOException
-
writeRegionCloseMarker
- Throws:
IOException
-
hasReferences
Returns True if this region has references. -
blockUpdates
-
unblockUpdates
-
getHDFSBlocksDistribution
-
computeHDFSBlocksDistribution
public static HDFSBlocksDistribution computeHDFSBlocksDistribution(org.apache.hadoop.conf.Configuration conf, TableDescriptor tableDescriptor, RegionInfo regionInfo) throws IOException This is a helper function to compute HDFS block distribution on demand- Parameters:
conf- configurationtableDescriptor- TableDescriptor of the tableregionInfo- encoded name of the region- Returns:
- The HDFS blocks distribution for the given region.
- Throws:
IOException
-
computeHDFSBlocksDistribution
public static HDFSBlocksDistribution computeHDFSBlocksDistribution(org.apache.hadoop.conf.Configuration conf, TableDescriptor tableDescriptor, RegionInfo regionInfo, org.apache.hadoop.fs.Path tablePath) throws IOException This is a helper function to compute HDFS block distribution on demand- Parameters:
conf- configurationtableDescriptor- TableDescriptor of the tableregionInfo- encoded name of the regiontablePath- the table directory- Returns:
- The HDFS blocks distribution for the given region.
- Throws:
IOException
-
incMemStoreSize
Increase the size of mem store in this region and the size of global mem store -
incMemStoreSize
void incMemStoreSize(long dataSizeDelta, long heapSizeDelta, long offHeapSizeDelta, int cellsCountDelta) -
decrMemStoreSize
-
decrMemStoreSize
private void decrMemStoreSize(long dataSizeDelta, long heapSizeDelta, long offHeapSizeDelta, int cellsCountDelta) -
checkNegativeMemStoreDataSize
-
getRegionInfo
Description copied from interface:RegionReturns region information for this region- Specified by:
getRegionInfoin interfaceRegion
-
getRegionServerServices
Returns Instance ofRegionServerServicesused by this HRegion. Can be null. -
getReadRequestsCount
Description copied from interface:RegionReturns read requests count for this region- Specified by:
getReadRequestsCountin interfaceRegion
-
getCpRequestsCount
Description copied from interface:RegionReturns coprocessor requests count for this region- Specified by:
getCpRequestsCountin interfaceRegion
-
getFilteredReadRequestsCount
Description copied from interface:RegionReturns filtered read requests count for this region- Specified by:
getFilteredReadRequestsCountin interfaceRegion
-
getWriteRequestsCount
Description copied from interface:RegionReturns write request count for this region- Specified by:
getWriteRequestsCountin interfaceRegion
-
getMemStoreDataSize
- Specified by:
getMemStoreDataSizein interfaceRegion- Returns:
- memstore size for this region, in bytes. It just accounts data size of cells added to the memstores of this Region. Means size in bytes for key, value and tags within Cells. It wont consider any java heap overhead for the cell objects or any other.
-
getMemStoreHeapSize
- Specified by:
getMemStoreHeapSizein interfaceRegion- Returns:
- memstore heap size for this region, in bytes. It accounts data size of cells added to the memstores of this Region, as well as java heap overhead for the cell objects or any other.
-
getMemStoreOffHeapSize
- Specified by:
getMemStoreOffHeapSizein interfaceRegion- Returns:
- memstore off-heap size for this region, in bytes. It accounts data size of cells added to the memstores of this Region, as well as overhead for the cell objects or any other that is allocated off-heap.
-
getRegionServicesForStores
Returns store services for this region, to access services required by store level needs -
getNumMutationsWithoutWAL
Description copied from interface:RegionReturns the number of mutations processed bypassing the WAL- Specified by:
getNumMutationsWithoutWALin interfaceRegion
-
getDataInMemoryWithoutWAL
Description copied from interface:RegionReturns the size of data processed bypassing the WAL, in bytes- Specified by:
getDataInMemoryWithoutWALin interfaceRegion
-
getBlockedRequestsCount
Description copied from interface:RegionReturns the number of blocked requests- Specified by:
getBlockedRequestsCountin interfaceRegion
-
getCheckAndMutateChecksPassed
Description copied from interface:RegionReturns the number of checkAndMutate guards that passed- Specified by:
getCheckAndMutateChecksPassedin interfaceRegion
-
getCheckAndMutateChecksFailed
Description copied from interface:RegionReturns the number of failed checkAndMutate guards- Specified by:
getCheckAndMutateChecksFailedin interfaceRegion
-
getMetrics
-
isClosed
Description copied from interface:RegionReturns true if region is closed -
isClosing
Description copied from interface:RegionReturns True if closing process has started -
isReadOnly
Description copied from interface:RegionReturns True if region is read only- Specified by:
isReadOnlyin interfaceRegion
-
isAvailable
Description copied from interface:RegionReturns true if region is available (not closed and not closing)- Specified by:
isAvailablein interfaceRegion
-
isSplittable
Description copied from interface:RegionReturns true if region is splittable- Specified by:
isSplittablein interfaceRegion
-
isMergeable
Description copied from interface:RegionReturns true if region is mergeable- Specified by:
isMergeablein interfaceRegion
-
areWritesEnabled
-
getMVCC
-
getMaxFlushedSeqId
- Specified by:
getMaxFlushedSeqIdin interfaceRegion- Returns:
- the max sequence id of flushed data on this region; no edit in memory will have a sequence id that is less that what is returned here.
-
getReadPoint
Returns readpoint considering given IsolationLevel. Passnullfor default -
isLoadingCfsOnDemandDefault
-
close
Close down this HRegion. Flush the cache, shut down each HStore, don't service any more calls.This method could take some time to execute, so don't call it from a time-sensitive thread.
- Returns:
- Vector of all the storage files that the HRegion's component HStores make use of. It's a list of all StoreFile objects. Returns empty vector if already closed and null if judged that it should not close.
- Throws:
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.
-
close
- Throws:
IOException
-
close
Close this HRegion.- Parameters:
abort- true if server is aborting (only during testing)ignoreStatus- true if ignore the status (won't be showed on task list)- Returns:
- Vector of all the storage files that the HRegion's component HStores make use of. It's a list of StoreFile objects. Can be null if we are not to close at this time, or we are already closed.
- Throws:
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.
-
close
public Map<byte[],List<HStoreFile>> close(boolean abort, boolean ignoreStatus, boolean isGracefulStop) throws IOException Close down this HRegion. Flush the cache unless abort parameter is true, Shut down each HStore, don't service any more calls. This method could take some time to execute, so don't call it from a time-sensitive thread.- Parameters:
abort- true if server is aborting (only during testing)ignoreStatus- true if ignore the status (wont be showed on task list)isGracefulStop- true if region is being closed during graceful stop and the blocks in the BucketCache should not be evicted.- Returns:
- Vector of all the storage files that the HRegion's component HStores make use of. It's a list of StoreFile objects. Can be null if we are not to close at this time or we are already closed.
- Throws:
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.
-
setClosing
Exposed for some very specific unit tests. -
setTimeoutForWriteLock
ThedoClose(boolean, org.apache.hadoop.hbase.monitoring.MonitoredTask)will block forever if someone tries proving the dead lock via the unit test. Instead of blocking, thedoClose(boolean, org.apache.hadoop.hbase.monitoring.MonitoredTask)will throw exception if you set the timeout.- Parameters:
timeoutForWriteLock- the second time to wait for the write lock indoClose(boolean, org.apache.hadoop.hbase.monitoring.MonitoredTask)
-
doClose
private Map<byte[],List<HStoreFile>> doClose(boolean abort, MonitoredTask status) throws IOException - Throws:
IOException
-
waitForFlushesAndCompactions
Wait for all current flushes and compactions of the region to complete -
waitForFlushes
Wait for all current flushes of the region to complete -
waitForFlushes
Description copied from interface:RegionWait for all current flushes of the region to complete- Specified by:
waitForFlushesin interfaceRegion- Parameters:
timeout- The maximum time to wait in milliseconds.- Returns:
- False when timeout elapsed but flushes are not over. True when flushes are over within max wait time period.
-
getReadOnlyConfiguration
- Specified by:
getReadOnlyConfigurationin interfaceRegion- Returns:
- a read only configuration of this region; throws
UnsupportedOperationExceptionif you try to set a configuration.
-
getMinBlockSizeBytes
Description copied from interface:RegionThe minimum block size configuration from all relevant column families. This is used when estimating quota consumption.- Specified by:
getMinBlockSizeBytesin interfaceRegion
-
getStoreOpenAndCloseThreadPool
-
getStoreFileOpenAndCloseThreadPool
-
getOpenAndCloseThreadPool
private static ThreadPoolExecutor getOpenAndCloseThreadPool(int maxThreads, String threadNamePrefix) -
worthPreFlushing
Returns True if its worth doing a flush before we put up the close flag. -
getTableDescriptor
Description copied from interface:RegionReturns table descriptor for this region- Specified by:
getTableDescriptorin interfaceRegion
-
setTableDescriptor
-
getWAL
Returns WAL in use for this region -
getBlockCache
-
setBlockCache
Only used for unit test which doesn't start region server. -
getMobFileCache
-
setMobFileCache
Only used for unit test which doesn't start region server. -
getSplitPolicy
Returns split policy for this region. -
getBaseConf
org.apache.hadoop.conf.Configuration getBaseConf()A split takes the config from the parent region & passes it to the daughter region's constructor. If 'conf' was passed, you would end up using the HTD of the parent region in addition to the new daughter HTD. Pass 'baseConf' to the daughter regions to avoid this tricky dedupe problem.- Returns:
- Configuration object
-
getFilesystem
ReturnsFileSystembeing used by this region -
getRegionFileSystem
Returns theHRegionFileSystemused by this region -
getRegionWALFileSystem
Returns the WALHRegionFileSystemused by this region- Throws:
IOException
-
getWalFileSystem
Returns the WALFileSystembeing used by this region- Throws:
IOException
-
getWALRegionDir
- Returns:
- the Region directory under WALRootDirectory
- Throws:
IOException- if there is an error getting WALRootDir
-
getEarliestFlushTimeForAllStores
- Specified by:
getEarliestFlushTimeForAllStoresin interfaceRegion- Returns:
- The earliest time a store in the region was flushed. All other stores in the region would have been flushed either at, or after this time.
-
getOldestHfileTs
Description copied from interface:RegionThis can be used to determine the last time all files of this region were major compacted.- Specified by:
getOldestHfileTsin interfaceRegion- Parameters:
majorCompactionOnly- Only consider HFile that are the result of major compaction- Returns:
- the timestamp of the oldest HFile for all stores of this region
- Throws:
IOException
-
setCompleteSequenceId
org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos.RegionLoad.Builder setCompleteSequenceId(org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos.RegionLoad.Builder regionLoadBldr) -
doRegionCompactionPrep
Do preparation for pending compaction.- Throws:
IOException
-
compact
Synchronously compact all stores in the 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.
- Parameters:
majorCompaction- True to force a major compaction regardless of thresholds- Throws:
IOException
-
compactStores
This is a helper function that compact all the stores synchronously.It is used by utilities and testing
- Throws:
IOException
-
compactStore
This is a helper function that compact the given store.It is used by utilities and testing
- Throws:
IOException
-
compact
public boolean compact(CompactionContext compaction, HStore store, ThroughputController throughputController) throws IOException Called by compaction thread and after region is opened to compact the HStores if necessary.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.
- Parameters:
compaction- Compaction details, obtained by requestCompaction()- Returns:
- whether the compaction completed
- Throws:
IOException
-
shouldForbidMajorCompaction
-
compact
public boolean compact(CompactionContext compaction, HStore store, ThroughputController throughputController, User user) throws IOException We are trying to remove / relax the region read lock for compaction. Let's see what are the potential race conditions among the operations (user scan, region split, region close and region bulk load).
user scan ---> region read lock region split --> region close first --> region write lock region close --> region write lock region bulk load --> region write lock
read lock is compatible with read lock. ---> no problem with user scan/read region bulk load does not cause problem for compaction (no consistency problem, store lock will help the store file accounting). They can run almost concurrently at the region level.
The only remaining race condition is between the region close and compaction. So we will evaluate, below, how region close intervenes with compaction if compaction does not acquire region read lock.
Here are the steps for compaction:
- obtain list of StoreFile's
- create StoreFileScanner's based on list from #1
- perform compaction and save resulting files under tmp dir
- swap in compacted files
#1 is guarded by store lock. This patch does not change this --> no worse or better For #2, we obtain smallest read point (for region) across all the Scanners (for both default compactor and stripe compactor). The read points are for user scans. Region keeps the read points for all currently open user scanners. Compaction needs to know the smallest read point so that during re-write of the hfiles, it can remove the mvcc points for the cells if their mvccs are older than the smallest since they are not needed anymore. This will not conflict with compaction.
For #3, it can be performed in parallel to other operations.
For #4 bulk load and compaction don't conflict with each other on the region level (for multi-family atomicy).
Region close and compaction are guarded pretty well by the 'writestate'. In HRegion#doClose(), we have :
synchronized (writestate) { // Disable compacting and flushing by background threads for this // region. canFlush = !writestate.readOnly; writestate.writesEnabled = false; LOG.debug("Closing " + this + ": disabling compactions & flushes"); waitForFlushesAndCompactions(); }waitForFlushesAndCompactions()would wait forwritestate.compactingto come down to 0. and inHRegion.compact()try { synchronized (writestate) { if (writestate.writesEnabled) { wasStateSet = true; ++writestate.compacting; } else { String msg = "NOT compacting region " + this + ". Writes disabled."; LOG.info(msg); status.abort(msg); return false; } } }Also incompactor.performCompaction(): check periodically to see if a system stop is requestedif (closeChecker != null && closeChecker.isTimeLimit(store, now)) { progress.cancel(); return false; } if (closeChecker != null && closeChecker.isSizeLimit(store, len)) { progress.cancel(); return false; }- Throws:
IOException
-
flush
Flush the cache.When this method is called the cache will be flushed unless:
- the cache is empty
- the region is closed.
- a flush is already in progress
- writes are disabled
This method may block for some time, so it should not be called from a time-sensitive thread.
- Parameters:
flushAllStores- whether we want to force a flush of all stores- Returns:
- FlushResult indicating whether the flush was successful or not and if the region needs compacting
- Throws:
IOException- general io exceptions because a snapshot was not properly persisted.
-
flushcache
public HRegion.FlushResultImpl flushcache(boolean flushAllStores, boolean writeFlushRequestWalMarker, FlushLifeCycleTracker tracker) throws IOException - Throws:
IOException
-
flushcache
public HRegion.FlushResultImpl flushcache(List<byte[]> families, boolean writeFlushRequestWalMarker, FlushLifeCycleTracker tracker) throws IOException Flush the cache. When this method is called the cache will be flushed unless:- the cache is empty
- the region is closed.
- a flush is already in progress
- writes are disabled
This method may block for some time, so it should not be called from a time-sensitive thread.
- Parameters:
families- stores of region to flush.writeFlushRequestWalMarker- whether to write the flush request marker to WALtracker- used to track the life cycle of this flush- Returns:
- whether the flush is success and whether the region needs compacting
- Throws:
IOException- 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.
-
getSpecificStores
get stores which matches the specified families- Returns:
- the stores need to be flushed.
-
shouldFlushStore
Should the store be flushed because it is old enough.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.
-
shouldFlush
Should the memstore be flushed now -
internalFlushcache
Flushing all stores. -
internalFlushcache
private HRegion.FlushResultImpl internalFlushcache(Collection<HStore> storesToFlush, MonitoredTask status, boolean writeFlushWalMarker, FlushLifeCycleTracker tracker) throws IOException Flushing given stores. -
internalFlushcache
protected HRegion.FlushResultImpl internalFlushcache(WAL wal, long myseqid, Collection<HStore> storesToFlush, MonitoredTask status, boolean writeFlushWalMarker, FlushLifeCycleTracker tracker) throws IOException Flush the memstore. Flushing the memstore is a little tricky. We have a lot of updates in the memstore, all of which have also been written to the wal. We need to write those updates in the memstore out to disk, while being able to process reads/writes as much as possible during the flush operation.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.
- Parameters:
wal- Null if we're NOT to go via wal.myseqid- The seqid to use ifwalis null writing out flush file.storesToFlush- The list of stores to flush.- Returns:
- object describing the flush's state
- Throws:
IOException- general io exceptionsDroppedSnapshotException- Thrown when replay of WAL is required.
-
internalPrepareFlushCache
protected HRegion.PrepareFlushResult internalPrepareFlushCache(WAL wal, long myseqid, Collection<HStore> storesToFlush, MonitoredTask status, boolean writeFlushWalMarker, FlushLifeCycleTracker tracker) throws IOException - Throws:
IOException
-
logFatLineOnFlush
Utility method broken out of internalPrepareFlushCache so that method is smaller. -
doAbortFlushToWAL
private void doAbortFlushToWAL(WAL wal, long flushOpSeqId, Map<byte[], List<org.apache.hadoop.fs.Path>> committedFiles) -
doSyncOfUnflushedWALChanges
Sync unflushed WAL changes. See HBASE-8208 for details- Throws:
IOException
-
isAllFamilies
Returns True if passed Set is all families in the region. -
writeCanNotFlushMarkerToWAL
private boolean writeCanNotFlushMarkerToWAL(MultiVersionConcurrencyControl.WriteEntry flushOpSeqIdMVCCEntry, WAL wal, boolean writeFlushWalMarker) This method is only used when we flush but the memstore is empty,if writeFlushWalMarker is true,we write theWALProtos.FlushDescriptor.FlushAction.CANNOT_FLUSHflush marker to WAL when the memstore is empty. Ignores exceptions from WAL. Returns whether the write succeeded.- Returns:
- whether WAL write was successful
-
attachRegionReplicationToFlushOpSeqIdMVCCEntry
private void attachRegionReplicationToFlushOpSeqIdMVCCEntry(MultiVersionConcurrencyControl.WriteEntry flushOpSeqIdMVCCEntry, org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor desc, RegionReplicationSink sink) CreateWALEditforWALProtos.FlushDescriptorand attachRegionReplicationSink.add(org.apache.hadoop.hbase.wal.WALKeyImpl, org.apache.hadoop.hbase.wal.WALEdit, org.apache.hadoop.hbase.ipc.ServerCall<?>)to the flushOpSeqIdMVCCEntry. -
internalFlushCacheAndCommit
HRegion.FlushResultImpl internalFlushCacheAndCommit(WAL wal, MonitoredTask status, HRegion.PrepareFlushResult prepareResult, Collection<HStore> storesToFlush) throws IOException - Throws:
IOException
-
getNextSequenceId
Method to safely get the next sequence number.- Returns:
- Next sequence number unassociated with any actual edit.
- Throws:
IOException
-
getScanner
Description copied from interface:RegionReturn an iterator that scans over the HRegion, returning the indicated columns and rows specified by theScan.This Iterator must be closed by the caller.
- Specified by:
getScannerin interfaceRegion- Parameters:
scan- configuredScan- Throws:
IOException- read exceptions
-
getScanner
public RegionScannerImpl getScanner(Scan scan, List<KeyValueScanner> additionalScanners) throws IOException Description copied from interface:RegionReturn an iterator that scans over the HRegion, returning the indicated columns and rows specified by theScan. 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 RegionThis Iterator must be closed by the caller.
- Specified by:
getScannerin interfaceRegion- Parameters:
scan- configuredScanadditionalScanners- Any additional scanners to be used- Throws:
IOException- read exceptions
-
getScanner
private RegionScannerImpl getScanner(Scan scan, List<KeyValueScanner> additionalScanners, long nonceGroup, long nonce) throws IOException - Throws:
IOException
-
instantiateRegionScanner
protected RegionScannerImpl instantiateRegionScanner(Scan scan, List<KeyValueScanner> additionalScanners, long nonceGroup, long nonce) throws IOException - Throws:
IOException
-
prepareDelete
Prepare a delete for a row mutation processor- Parameters:
delete- The passed delete is modified by this method. WARNING!- Throws:
IOException
-
delete
Description copied from interface:RegionDeletes the specified cells/row.- Specified by:
deletein interfaceRegion- Throws:
IOException
-
prepareDeleteTimestamps
private void prepareDeleteTimestamps(Mutation mutation, Map<byte[], List<ExtendedCell>> familyMap, byte[] byteNow) throws IOExceptionSet up correct timestamps in the KVs in Delete object. Caller should have the row and region locks.- Throws:
IOException
-
updateDeleteLatestVersionTimestamp
private void updateDeleteLatestVersionTimestamp(Cell cell, Get get, int count, byte[] byteNow) throws IOException - Throws:
IOException
-
put
Description copied from interface:RegionPuts some data in the table.- Specified by:
putin interfaceRegion- Throws:
IOException
-
batchMutate
public OperationStatus[] batchMutate(Mutation[] mutations, boolean atomic, long nonceGroup, long nonce) throws IOException - Throws:
IOException
-
batchMutate
Description copied from interface:RegionPerform a batch of mutations.Please do not operate on a same column of a single row in a batch, we will not consider the previous operation in the same batch when performing the operations in the batch.
- Specified by:
batchMutatein interfaceRegion- Parameters:
mutations- the list of mutations- Returns:
- an array of OperationStatus which internally contains the OperationStatusCode and the exceptionMessage if any.
- Throws:
IOException
-
batchMutate
- Throws:
IOException
-
batchReplay
@Deprecated OperationStatus[] batchReplay(WALSplitUtil.MutationReplay[] mutations, long replaySeqId) throws IOException Deprecated.Since 3.0.0, will be removed in 4.0.0. Now we usereplayWALEntry(WALEntry, CellScanner)for replaying edits at secondary replica side.- Throws:
IOException
-
batchMutate
Perform a batch of mutations. Operations in a batch are stored with highest durability specified of for all operations in a batch, except forDurability.SKIP_WAL. This function is called frombatchReplay(WALSplitUtil.MutationReplay[], long)withHRegion.ReplayBatchOperationinstance andbatchMutate(Mutation[])withHRegion.MutationBatchOperationinstance 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 classHRegion.BatchOperation. The logic for this method anddoMiniBatchMutate(BatchOperation)is implemented using methods in base class which are overridden by derived classes to implement special behavior.- Parameters:
batchOp- contains the list of mutations- Returns:
- an array of OperationStatus which internally contains the OperationStatusCode and the exceptionMessage if any.
- Throws:
IOException- if an IO problem is encountered
-
doMiniBatchMutate
Called to do a piece of the batch that came in tobatchMutate(Mutation[])In here we also handle replay of edits on region recover. Also gets change in size brought about by applyingbatchOp.- Throws:
IOException
-
getEffectiveDurability
Returns effective durability from the passed durability and the table descriptor. -
checkAndMutate
@Deprecated public boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator, TimeRange timeRange, Mutation mutation) throws IOException Deprecated.Description copied from interface:RegionAtomically checks if a row/family/qualifier value matches the expected value and if it does, it performs the mutation. If the passed value is null, the lack of column value (ie: non-existence) is used. See checkAndRowMutate to do many checkAndPuts at a time on a single row.- Specified by:
checkAndMutatein interfaceRegion- Parameters:
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 succeeds- Returns:
- true if mutation was applied, false otherwise
- Throws:
IOException
-
checkAndMutate
@Deprecated public boolean checkAndMutate(byte[] row, Filter filter, TimeRange timeRange, Mutation mutation) throws IOException Deprecated.Description copied from interface:RegionAtomically checks if a row value matches the filter and if it does, it performs the mutation. See checkAndRowMutate to do many checkAndPuts at a time on a single row.- Specified by:
checkAndMutatein interfaceRegion- Parameters:
row- to checkfilter- the filtertimeRange- time range to checkmutation- data to put if check succeeds- Returns:
- true if mutation was applied, false otherwise
- Throws:
IOException
-
checkAndRowMutate
@Deprecated public boolean checkAndRowMutate(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator, TimeRange timeRange, RowMutations rm) throws IOException Deprecated.Description copied from interface:RegionAtomically checks if a row/family/qualifier value matches the expected values and if it does, it performs the row mutations. If the passed value is null, the lack of column value (ie: non-existence) is used. Use to do many mutations on a single row. Use checkAndMutate to do one checkAndMutate at a time.- Specified by:
checkAndRowMutatein interfaceRegion- Parameters:
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 succeeds- Returns:
- true if mutations were applied, false otherwise
- Throws:
IOException
-
checkAndRowMutate
@Deprecated public boolean checkAndRowMutate(byte[] row, Filter filter, TimeRange timeRange, RowMutations rm) throws IOException Deprecated.Description copied from interface:RegionAtomically checks if a row matches the filter and if it does, it performs the row mutations. Use to do many mutations on a single row. Use checkAndMutate to do one checkAndMutate at a time.- Specified by:
checkAndRowMutatein interfaceRegion- Parameters:
row- to checkfilter- the filtertimeRange- time range to checkrm- data to put if check succeeds- Returns:
- true if mutations were applied, false otherwise
- Throws:
IOException
-
checkAndMutate
Description copied from interface:RegionAtomically checks if a row matches the conditions and if it does, it performs the actions. Use to do many mutations on a single row. Use checkAndMutate to do one checkAndMutate at a time.- Specified by:
checkAndMutatein interfaceRegion- Parameters:
checkAndMutate- the CheckAndMutate object- Returns:
- true if mutations were applied, false otherwise
- Throws:
IOException- if an error occurred in this method
-
checkAndMutate
public CheckAndMutateResult checkAndMutate(CheckAndMutate checkAndMutate, long nonceGroup, long nonce) throws IOException - Throws:
IOException
-
checkAndMutateInternal
private CheckAndMutateResult checkAndMutateInternal(CheckAndMutate checkAndMutate, long nonceGroup, long nonce) throws IOException - Throws:
IOException
-
checkMutationType
- Throws:
DoNotRetryIOException
-
checkRow
- Throws:
DoNotRetryIOException
-
matches
-
mutate
- Throws:
IOException
-
mutate
- Throws:
IOException
-
mutate
private OperationStatus mutate(Mutation mutation, boolean atomic, long nonceGroup, long nonce) throws IOException - Throws:
IOException
-
addRegionToSnapshot
public void addRegionToSnapshot(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription desc, ForeignExceptionSnare exnSnare) throws IOException Complete taking the snapshot on the region. Writes the region info and adds references to the working snapshot directory. TODO for api consistency, consider adding another version with noForeignExceptionSnarearg. (In the future other cancellable HRegion methods could eventually add aForeignExceptionSnare, or we could do something fancier).- Parameters:
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.- Throws:
IOException- if there is an external or internal error causing the snapshot to fail
-
updateSequenceId
private void updateSequenceId(Iterable<List<ExtendedCell>> cellItr, long sequenceId) throws IOException - Throws:
IOException
-
updateCellTimestamps
private static void updateCellTimestamps(Iterable<List<ExtendedCell>> cellItr, byte[] now) throws IOException Replace any cell timestamps set toHConstants.LATEST_TIMESTAMPprovided current timestamp.- Throws:
IOException
-
rewriteCellTags
Possibly rewrite incoming cell tags. -
checkResources
Check if resources to support an update. We throw RegionTooBusyException if above memstore limit and expect client to retry using some kind of backoff- Throws:
RegionTooBusyException
-
checkReadOnly
- Throws:
IOException- Throws exception if region is in read-only mode.
-
checkReadsEnabled
- Throws:
IOException
-
setReadsEnabled
-
applyToMemStore
private void applyToMemStore(HStore store, List<ExtendedCell> cells, boolean delta, MemStoreSizing memstoreAccounting) - Parameters:
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.
-
checkFamilies
private void checkFamilies(Collection<byte[]> families, Durability durability) throws NoSuchColumnFamilyException, InvalidMutationDurabilityException -
checkFamily
private void checkFamily(byte[] family, Durability durability) throws NoSuchColumnFamilyException, InvalidMutationDurabilityException -
checkFamily
- Throws:
NoSuchColumnFamilyException
-
checkTimestamps
public void checkTimestamps(Map<byte[], List<Cell>> familyMap, long now) throws FailedSanityCheckExceptionCheck the collection of families for valid timestamps- Parameters:
now- current timestamp- Throws:
FailedSanityCheckException
-
isFlushSize
-
deleteRecoveredEdits
private void deleteRecoveredEdits(org.apache.hadoop.fs.FileSystem fs, Iterable<org.apache.hadoop.fs.Path> files) throws IOException - Throws:
IOException
-
replayRecoveredEditsIfAny
long replayRecoveredEditsIfAny(Map<byte[], Long> maxSeqIdInStores, CancelableProgressable reporter, MonitoredTask status) throws IOExceptionRead the edits put under this region by wal splitting process. Put the recovered edits back up into this region.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.
- Parameters:
maxSeqIdInStores- Any edit found in split editlogs needs to be in excess of the maxSeqId for the store to be applied, else its skipped.- Returns:
- the sequence id of the last edit added to this region out of the recovered edits log or
minSeqIdif nothing added from editlogs. - Throws:
IOException
-
handleException
private void handleException(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path edits, IOException e) throws IOException - Throws:
IOException
-
replayRecoveredEdits
private long replayRecoveredEdits(org.apache.hadoop.fs.Path edits, Map<byte[], Long> maxSeqIdInStores, CancelableProgressable reporter, org.apache.hadoop.fs.FileSystem fs) throws IOException- Parameters:
edits- File of recovered edits.maxSeqIdInStores- Maximum sequenceid found in each store. Edits in wal must be larger than this to be replayed for each store.- Returns:
- the sequence id of the last edit added to this region out of the recovered edits log or
minSeqIdif nothing added from editlogs. - Throws:
IOException
-
replayWALCompactionMarker
void replayWALCompactionMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.CompactionDescriptor compaction, boolean pickCompactionFiles, boolean removeFiles, long replaySeqId) throws IOException Call to complete a compaction. Its for the case where we find in the WAL a compaction that was not finished. We could find one recovering a WAL after a regionserver crash. See HBASE-2331.- Throws:
IOException
-
replayWALFlushMarker
@Deprecated void replayWALFlushMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush, long replaySeqId) throws IOException Deprecated.Since 3.0.0, will be removed in 4.0.0. Only for keep compatibility for old region replica implementation.- Throws:
IOException
-
getStoresToFlush
private Collection<HStore> getStoresToFlush(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flushDesc) -
replayWALFlushStartMarker
@Deprecated HRegion.PrepareFlushResult replayWALFlushStartMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush) throws IOException Deprecated.Since 3.0.0, will be removed in 4.0.0. Only for keep compatibility for old region replica implementation.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).- Throws:
IOException
-
replayWALFlushCommitMarker
@Deprecated void replayWALFlushCommitMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush) throws IOException Deprecated.Since 3.0.0, will be removed in 4.0.0. Only for keep compatibility for old region replica implementation.- Throws:
IOException
-
replayFlushInStores
@Deprecated private void replayFlushInStores(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush, HRegion.PrepareFlushResult prepareFlushResult, boolean dropMemstoreSnapshot) throws IOException Deprecated.Since 3.0.0, will be removed in 4.0.0. Only for keep compatibility for old region replica implementation.Replays the given flush descriptor by opening the flush files in stores and dropping the memstore snapshots if requested.- Throws:
IOException
-
loadRecoveredHFilesIfAny
- Throws:
IOException
-
dropMemStoreContents
Be careful, this method will drop all data in the memstore of this region. Currently, this method is used to drop memstore to prevent memory leak when replaying recovered.edits while opening region.- Throws:
IOException
-
dropMemStoreContentsForSeqId
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- Throws:
IOException
-
doDropStoreMemStoreContentsForSeqId
private MemStoreSize doDropStoreMemStoreContentsForSeqId(HStore s, long currentSeqId) throws IOException - Throws:
IOException
-
replayWALFlushAbortMarker
private void replayWALFlushAbortMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush) -
replayWALFlushCannotFlushMarker
private void replayWALFlushCannotFlushMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor flush, long replaySeqId) -
getPrepareFlushResult
-
replayWALRegionEventMarker
@Deprecated void replayWALRegionEventMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.RegionEventDescriptor regionEvent) throws IOException Deprecated.Since 3.0.0, will be removed in 4.0.0. Only for keep compatibility for old region replica implementation.- Throws:
IOException
-
replayWALBulkLoadEventMarker
@Deprecated void replayWALBulkLoadEventMarker(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.BulkLoadDescriptor bulkLoadEvent) throws IOException Deprecated.Since 3.0.0, will be removed in 4.0.0. Only for keep compatibility for old region replica implementation.- Throws:
IOException
-
replayWALBatchMutate
Replay the batch mutate for secondary replica. We will directly apply the cells to the memstore. This is because:- Throws:
IOException
-
replayWALMetaEdit
Replay the meta edits, i.e, flush marker, compaction marker, bulk load marker, region event marker, etc. For all events other than start flush, we will just callrefreshStoreFiles()as the logic is straight-forward and robust. For start flush, we need to snapshot the memstore, so laterrefreshStoreFiles()call could drop the snapshot, otherwise we may run out of memory.- Throws:
IOException
-
replayWALEntry
void replayWALEntry(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.WALEntry entry, CellScanner cells) throws IOException Replay remote wal entry sent by primary replica. Should only call this method on secondary replicas.- Throws:
IOException
-
dropPrepareFlushIfPossible
If all stores ended up dropping their snapshots, we can safely drop the prepareFlushResult -
refreshStoreFiles
Description copied from interface:RegionCheck 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.- Specified by:
refreshStoreFilesin interfaceRegion- Throws:
IOException
-
refreshStoreFiles
- Throws:
IOException
-
logRegionFiles
-
checkTargetRegion
private void checkTargetRegion(byte[] encodedRegionName, String exceptionMsg, Object payload) throws WrongRegionException 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.- Throws:
WrongRegionException
-
restoreEdit
Used by tests- Parameters:
s- Store to add edit too.cell- Cell to add.
-
isZeroLengthThenDelete
private static boolean isZeroLengthThenDelete(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.FileStatus stat, org.apache.hadoop.fs.Path p) throws IOException make sure have been through lease recovery before get file status, so the file length can be trusted.- Parameters:
p- File to check.- Returns:
- True if file was zero-length (and if so, we'll delete it in here).
- Throws:
IOException
-
instantiateHStore
protected HStore instantiateHStore(ColumnFamilyDescriptor family, boolean warmup) throws IOException - Throws:
IOException
-
getStore
Description copied from interface:RegionReturn the Store for the given familyUse with caution. Exposed for use of fixup utilities.
-
getStore
Return HStore instance. Does not do any copy: as the number of store is limited, we iterate on the list. -
getStores
Description copied from interface:RegionReturn the list of Stores managed by this regionUse with caution. Exposed for use of fixup utilities.
-
getStoreFileList
Description copied from interface:RegionReturns list of store file names for the given families- Specified by:
getStoreFileListin interfaceRegion- Throws:
IllegalArgumentException
-
checkRow
Make sure this is a valid row for the HRegion- Throws:
IOException
-
getRowLock
Get an exclusive ( write lock ) lock on a given row.- Parameters:
row- Which row to lock.- Returns:
- A locked RowLock. The lock is exclusive and already aqquired.
- Throws:
IOException
-
getRowLock
Description copied from interface:RegionGet a row lock for the specified row. All locks are reentrant. Before calling this function make sure that a region operation has already been started (the calling thread has already acquired the region-close-guard lock).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.
- Specified by:
getRowLockin interfaceRegion- Parameters:
row- The row actions will be performed againstreadLock- is the lock reader or writer. True indicates that a non-exclusive lock is requested- Throws:
IOException- See Also:
-
createRegionSpan
-
getRowLockInternal
protected Region.RowLock getRowLockInternal(byte[] row, boolean readLock, Region.RowLock prevRowLock) throws IOException - Throws:
IOException
-
getRowLock
private Region.RowLock getRowLock(byte[] row, boolean readLock, Region.RowLock prevRowLock) throws IOException - Throws:
IOException
-
releaseRowLocks
-
getReadLockCount
-
getLockedRows
-
hasMultipleColumnFamilies
Determines whether multiple column families are present Precondition: familyPaths is not null- Parameters:
familyPaths- List of (column family, hfilePath)
-
bulkLoadHFiles
public Map<byte[],List<org.apache.hadoop.fs.Path>> bulkLoadHFiles(Collection<Pair<byte[], String>> familyPaths, boolean assignSeqId, HRegion.BulkLoadListener bulkLoadListener) throws IOExceptionAttempts to atomically load a group of hfiles. This is critical for loading rows with multiple column families atomically.- Parameters:
familyPaths- List of Pair<byte[] column family, String hfilePath>bulkLoadListener- Internal hooks enabling massaging/preparation of a file about to be bulk loaded- Returns:
- Map from family to List of store file paths if successful, null if failed recoverably
- Throws:
IOException- if failed unrecoverably.
-
bulkLoadHFiles
public Map<byte[],List<org.apache.hadoop.fs.Path>> bulkLoadHFiles(Collection<Pair<byte[], String>> familyPaths, boolean assignSeqId, HRegion.BulkLoadListener bulkLoadListener, boolean copyFile, List<String> clusterIds, boolean replicate) throws IOExceptionAttempts to atomically load a group of hfiles. This is critical for loading rows with multiple column families atomically.- Parameters:
familyPaths- List of Pair<byte[] column family, String hfilePath>bulkLoadListener- Internal hooks enabling massaging/preparation of a file about to be bulk loadedcopyFile- always copy hfiles if trueclusterIds- ids from clusters that had already handled the given bulkload event.- Returns:
- Map from family to List of store file paths if successful, null if failed recoverably
- Throws:
IOException- if failed unrecoverably.
-
equals
-
hashCode
-
toString
-
newHRegion
public 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 theHConstants.REGION_IMPLconfiguration property.- Parameters:
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 descriptor- Returns:
- the new instance
-
createHRegion
public 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 Convenience method creating new HRegions. Used by createTable.- Parameters:
info- Info for region to create.rootDir- Root directory for HBase instancewal- shared WALinitialize- - true to initialize the region- Returns:
- new HRegion
- Throws:
IOException
-
createHRegion
public static HRegion createHRegion(RegionInfo info, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.conf.Configuration conf, TableDescriptor hTableDescriptor, WAL wal, boolean initialize, RegionServerServices rsRpcServices) throws IOException Convenience method creating new HRegions. Used by createTable.- Parameters:
info- Info for region to create.rootDir- Root directory for HBase instancewal- shared WALinitialize- - true to initialize the regionrsRpcServices- An interface we can request flushes against.- Returns:
- new HRegion
- Throws:
IOException
-
createHRegion
public static HRegion createHRegion(org.apache.hadoop.conf.Configuration conf, RegionInfo regionInfo, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path tableDir, TableDescriptor tableDesc) throws IOException Create a region under the given table directory.- Throws:
IOException
-
createRegionDir
public static HRegionFileSystem createRegionDir(org.apache.hadoop.conf.Configuration configuration, RegionInfo ri, org.apache.hadoop.fs.Path rootDir) throws IOException Create the region directory in the filesystem.- Throws:
IOException
-
createHRegion
public static HRegion createHRegion(RegionInfo info, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.conf.Configuration conf, TableDescriptor hTableDescriptor, WAL wal) throws IOException - Throws:
IOException
-
openHRegion
public static HRegion openHRegion(RegionInfo info, TableDescriptor htd, WAL wal, org.apache.hadoop.conf.Configuration conf) throws IOException Open a Region.- Parameters:
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.- Returns:
- new HRegion
- Throws:
IOException
-
openHRegion
public static HRegion openHRegion(RegionInfo info, TableDescriptor htd, WAL wal, org.apache.hadoop.conf.Configuration conf, RegionServerServices rsServices, CancelableProgressable reporter) throws IOException Open a Region.- Parameters:
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.- Returns:
- new HRegion
- Throws:
IOException
-
openHRegion
public static HRegion openHRegion(org.apache.hadoop.fs.Path rootDir, RegionInfo info, TableDescriptor htd, WAL wal, org.apache.hadoop.conf.Configuration conf) throws IOException Open a Region.- Parameters:
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.- Returns:
- new HRegion
- Throws:
IOException
-
openHRegion
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 Open a Region.- Parameters:
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.- Returns:
- new HRegion
- Throws:
IOException
-
openHRegion
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 Open a Region.- Parameters:
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.- Returns:
- new HRegion
- Throws:
IOException
-
openHRegion
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 Open a Region.- Parameters:
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.- Returns:
- new HRegion
- Throws:
IOException
-
openHRegionFromTableDir
public static HRegion openHRegionFromTableDir(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path tableDir, RegionInfo info, TableDescriptor htd, WAL wal, RegionServerServices rsServices, CancelableProgressable reporter) throws IOException Open a Region.- Parameters:
conf- The Configuration object to use.fs- Filesystem to useinfo- 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.- Returns:
- new HRegion
- Throws:
NullPointerException- ifinfoisnullIOException
-
getReplicationScope
-
openHRegion
public static HRegion openHRegion(HRegion other, CancelableProgressable reporter) throws IOException Useful when reopening a closed region (normally for unit tests)- Parameters:
other- original objectreporter- An interface we can report progress against.- Returns:
- new HRegion
- Throws:
IOException
-
openHRegion
- Throws:
IOException
-
openHRegion
Open HRegion. Calls initialize and sets sequenceId.- Returns:
- Returns
this - Throws:
IOException
-
openReadOnlyFileSystemHRegion
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 Open a Region on a read-only file-system (like hdfs snapshots)- Parameters:
conf- The Configuration object to use.fs- Filesystem to useinfo- Info for region to be opened.htd- the table descriptor- Returns:
- new HRegion
- Throws:
NullPointerException- ifinfoisnullIOException
-
warmupHRegion
public static HRegion warmupHRegion(RegionInfo info, TableDescriptor htd, WAL wal, org.apache.hadoop.conf.Configuration conf, RegionServerServices rsServices, CancelableProgressable reporter) throws IOException - Throws:
IOException
-
getRegionDir
@Deprecated public static org.apache.hadoop.fs.Path getRegionDir(org.apache.hadoop.fs.Path tabledir, String name) Deprecated.For tests only; to be removed.Computes the Path of the HRegion- Parameters:
tabledir- qualified path for tablename- ENCODED region name- Returns:
- Path of HRegion directory
-
rowIsInRange
Determines if the specified row is within the row range specified by the specified RegionInfo- Parameters:
info- RegionInfo that specifies the row rangerow- row to be checked- Returns:
- true if the row is within the range specified by the RegionInfo
-
rowIsInRange
-
get
Description copied from interface:RegionDo a get based on the get parameter.- Specified by:
getin interfaceRegion- Parameters:
get- query parameters- Returns:
- result of the operation
- Throws:
IOException
-
prepareGet
- Throws:
IOException
-
get
Description copied from interface:RegionDo a get based on the get parameter.- Specified by:
getin interfaceRegion- Parameters:
get- query parameterswithCoprocessor- invoke coprocessor or not. We don't want to always invoke cp.- Returns:
- list of cells resulting from the operation
- Throws:
IOException
-
get
private List<Cell> get(Get get, boolean withCoprocessor, long nonceGroup, long nonce) throws IOException - Throws:
IOException
-
getInternal
private List<Cell> getInternal(Get get, boolean withCoprocessor, long nonceGroup, long nonce) throws IOException - Throws:
IOException
-
metricsUpdateForGet
void metricsUpdateForGet() -
mutateRow
Description copied from interface:RegionPerforms multiple mutations atomically on a single row.- Specified by:
mutateRowin interfaceRegion- Parameters:
rm- object that specifies the set of mutations to perform atomically- Returns:
- results of Increment/Append operations. If no Increment/Append operations, it returns null
- Throws:
IOException
-
mutateRow
- Throws:
IOException
-
mutateRowsWithLocks
public void mutateRowsWithLocks(Collection<Mutation> mutations, Collection<byte[]> rowsToLock, long nonceGroup, long nonce) throws IOException Perform atomic (all or none) mutations within the region.- Specified by:
mutateRowsWithLocksin interfaceRegion- Parameters:
mutations- The list of mutations to perform.mutationscan 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 thatrowsToLockis sorted in order to avoid deadlocks.- Throws:
IOException
-
getLoadStatistics
public org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionLoadStats getLoadStatistics()Returns statistics about the current load of the region -
append
Description copied from interface:RegionPerform one or more append operations on a row.- Specified by:
appendin interfaceRegion- Returns:
- result of the operation
- Throws:
IOException
-
append
- Throws:
IOException
-
increment
Description copied from interface:RegionPerform one or more increment operations on a row.- Specified by:
incrementin interfaceRegion- Returns:
- result of the operation
- Throws:
IOException
-
increment
- Throws:
IOException
-
createWALKeyForWALAppend
private WALKeyImpl createWALKeyForWALAppend(boolean isReplay, HRegion.BatchOperation<?> batchOp, long now, long nonceGroup, long nonce) -
doWALAppend
private MultiVersionConcurrencyControl.WriteEntry doWALAppend(WALEdit walEdit, HRegion.BatchOperation<?> batchOp, MiniBatchOperationInProgress<Mutation> miniBatchOp, long now, NonceKey nonceKey) throws IOException Returns writeEntry associated with this append- Throws:
IOException
-
attachRegionReplicationInWALAppend
private void attachRegionReplicationInWALAppend(HRegion.BatchOperation<?> batchOp, MiniBatchOperationInProgress<Mutation> miniBatchOp, WALKeyImpl walKey, WALEdit walEdit, MultiVersionConcurrencyControl.WriteEntry writeEntry) AttachRegionReplicationSink.add(org.apache.hadoop.hbase.wal.WALKeyImpl, org.apache.hadoop.hbase.wal.WALEdit, org.apache.hadoop.hbase.ipc.ServerCall<?>)to the mvcc writeEntry for replicating to region replica. -
doAttachReplicateRegionReplicaAction
private void doAttachReplicateRegionReplicaAction(WALKeyImpl walKey, WALEdit walEdit, MultiVersionConcurrencyControl.WriteEntry writeEntry) AttachRegionReplicationSink.add(org.apache.hadoop.hbase.wal.WALKeyImpl, org.apache.hadoop.hbase.wal.WALEdit, org.apache.hadoop.hbase.ipc.ServerCall<?>)to the mvcc writeEntry for replicating to region replica. -
heapSize
Description copied from interface:HeapSizeReturn the approximate 'exclusive deep size' of implementing object. Includes count of payload and hosting object sizings. -
registerService
Registers a new protocol bufferServicesubclass as a coprocessor endpoint to be available for handlingexecService(RpcController, CoprocessorServiceCall)calls. Only a single instance may be registered per region for a givenServicesubclass (the instances are keyed onDescriptors.ServiceDescriptor.getFullName().. After the first registration, subsequent calls with the same service name will fail with a return value offalse.- Parameters:
instance- theServicesubclass instance to expose as a coprocessor endpoint- Returns:
trueif the registration was successful,falseotherwise
-
execService
public org.apache.hbase.thirdparty.com.google.protobuf.Message execService(org.apache.hbase.thirdparty.com.google.protobuf.RpcController controller, org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceCall call) throws IOException Executes a single protocol buffer coprocessor endpointServicemethod using the registered protocol handlers.Serviceimplementations must be registered via theregisterService(Service)method before they are available.- Parameters:
controller- anRpcContollerimplementation to pass to the invoked servicecall- aCoprocessorServiceCallinstance identifying the service, method, and parameters for the method invocation- Returns:
- a protocol buffer
Messageinstance containing the method's result - Throws:
IOException- if no registered service handler is found or an error occurs during the invocation- See Also:
-
checkSplit
-
checkSplit
Return the split point. An empty result indicates the region isn't splittable. -
getCompactPriority
Returns The priority that this region should have in the compaction queue -
getCoprocessorHost
Returns the coprocessor host -
setCoprocessorHost
- Parameters:
coprocessorHost- the new coprocessor host
-
startRegionOperation
Description copied from interface:RegionThis method needs to be called before any public call that reads or modifies data. Acquires a read lock and checks if the region is closing or closed.Region.closeRegionOperation()MUST then always be called after the operation has completed, whether it succeeded or failed.- Specified by:
startRegionOperationin interfaceRegion- Throws:
IOException
-
startRegionOperation
Description copied from interface:RegionThis method needs to be called before any public call that reads or modifies data. Acquires a read lock and checks if the region is closing or closed.Region.closeRegionOperation()MUST then always be called after the operation has completed, whether it succeeded or failed.- Specified by:
startRegionOperationin interfaceRegion- Parameters:
op- The operation is about to be taken on the region- Throws:
IOException
-
closeRegionOperation
Description copied from interface:RegionCloses the region operation lock.- Specified by:
closeRegionOperationin interfaceRegion- Throws:
IOException
-
closeRegionOperation
Description copied from interface:RegionCloses the region operation lock. This needs to be called in the finally block corresponding to the try block ofRegion.startRegionOperation(Operation)- Specified by:
closeRegionOperationin interfaceRegion- Throws:
IOException
-
startBulkRegionOperation
This method needs to be called before any public call that reads or modifies stores in bulk. It has to be called just before a try. #closeBulkRegionOperation needs to be called in the try's finally block Acquires a writelock and checks if the region is closing or closed.- Throws:
NotServingRegionException- when the region is closing or closedRegionTooBusyException- if failed to get the lock in timeInterruptedIOException- if interrupted while waiting for a lockIOException
-
closeBulkRegionOperation
Closes the lock. This needs to be called in the finally block corresponding to the try block of #startRegionOperation -
recordMutationWithoutWal
Update LongAdders for number of puts without wal and the size of possible data loss. These information are exposed by the region server metrics. -
lock
- Throws:
IOException
-
lock
Try to acquire a lock. Throw RegionTooBusyException if failed to get the lock in time. Throw InterruptedIOException if interrupted while waiting for the lock.- Throws:
IOException
-
sync
Calls sync with the given transaction ID- Parameters:
txid- should sync up to which transaction- Throws:
IOException- If anything goes wrong with DFS
-
shouldSyncWAL
Check whether we should sync the wal from the table's durability settings -
getOpenSeqNum
Returns the latest sequence number that was read from storage when this region was opened -
getMaxStoreSeqId
- Specified by:
getMaxStoreSeqIdin interfaceRegion- Returns:
- map of column family names to max sequence id that was read from storage when this region was opened
-
getOldestSeqIdOfStore
-
getCompactionState
Description copied from interface:RegionReturns if a given region is in compaction now.- Specified by:
getCompactionStatein interfaceRegion
-
reportCompactionRequestStart
-
reportCompactionRequestEnd
-
reportCompactionRequestFailure
-
incrementCompactionsQueuedCount
-
decrementCompactionsQueuedCount
-
incrementFlushesQueuedCount
-
decrementFlushesQueuedCount
-
disableInterrupts
void disableInterrupts()If a handler thread is eligible for interrupt, make it ineligible. Should be paired with {enableInterrupts(). -
enableInterrupts
void enableInterrupts()If a handler thread was made ineligible for interrupt via {disableInterrupts(), make it eligible again. No-op if interrupts are already enabled. -
interruptRegionOperations
Interrupt any region options that have acquired the region lock viastartRegionOperation(org.apache.hadoop.hbase.regionserver.Region.Operation), orstartBulkRegionOperation(boolean). -
checkInterrupt
Check thread interrupt status and throw an exception if interrupted.- Throws:
NotServingRegionException- if region is closingInterruptedIOException- if interrupted but region is not closing
-
throwOnInterrupt
Throw the correct exception upon interrupt- Parameters:
t- cause
-
onConfigurationChange
This method would be called by theConfigurationManagerobject when theConfigurationobject is reloaded from disk.- Specified by:
onConfigurationChangein interfaceConfigurationObserver
-
registerChildren
Needs to be called to register the children to the manager.- Specified by:
registerChildrenin interfacePropagatingConfigurationObserver- Parameters:
manager- : to register to
-
deregisterChildren
Needs to be called to deregister the children from the manager.- Specified by:
deregisterChildrenin interfacePropagatingConfigurationObserver- Parameters:
manager- : to deregister from
-
getCellComparator
Description copied from interface:RegionThe comparator to be used with the region- Specified by:
getCellComparatorin interfaceRegion
-
getMemStoreFlushSize
-
throwException
-
requestCompaction
public void requestCompaction(String why, int priority, boolean major, CompactionLifeCycleTracker tracker) throws IOException Description copied from interface:RegionRequest compaction on this region.- Specified by:
requestCompactionin interfaceRegion- Throws:
IOException
-
requestCompaction
public void requestCompaction(byte[] family, String why, int priority, boolean major, CompactionLifeCycleTracker tracker) throws IOException Description copied from interface:RegionRequest compaction for the given family- Specified by:
requestCompactionin interfaceRegion- Throws:
IOException
-
requestFlushIfNeeded
- Throws:
RegionTooBusyException
-
requestFlush
-
requestFlush0
-
requestFlush
Description copied from interface:RegionRequest flush on this region.- Specified by:
requestFlushin interfaceRegion- Throws:
IOException
-
decorateRegionConfiguration
This method modifies the region's configuration in order to inject replication-related features- Parameters:
conf- region configurations
-
getRegionReplicationSink
-
addReadRequestsCount
-
addWriteRequestsCount
-
isReadsEnabled
boolean isReadsEnabled()
-