Class HRegion.BatchOperation<T>
java.lang.Object
org.apache.hadoop.hbase.regionserver.HRegion.BatchOperation<T>
- Direct Known Subclasses:
HRegion.MutationBatchOperation,HRegion.ReplayBatchOperation
- Enclosing class:
- HRegion
Class that tracks the progress of a batch operations, accumulating status codes and tracking
the index at which processing is proceeding. These batch operations may get split into
mini-batches for processing.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static interfaceVisitor interface for batch operations -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected Durabilityprotected intprotected final HRegion.ObservedExceptionsInBatchprotected final T[]protected final HRegionprotected final Result[]protected final OperationStatus[]protected final WALEdit[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapplyFamilyMapToMemStore(Map<byte[], List<Cell>> familyMap, MemStoreSizing memstoreAccounting) Atomically apply the given map of family->edits to the memstore.buildWALEdits(MiniBatchOperationInProgress<Mutation> miniBatchOp) Builds separate WALEdit per nonce by applying input mutations.abstract voidValidates each mutation and prepares a batch for write.protected voidcheckAndPrepareMutation(int index, long timestamp) protected voidcheckAndPrepareMutation(Mutation mutation, long timestamp) Helper method that checks and prepares only one mutation.protected abstract voidImplement any Put request specific check and prepare logic here.abstract voidvoidcompleteMiniBatchOperations(MiniBatchOperationInProgress<Mutation> miniBatchOp, MultiVersionConcurrencyControl.WriteEntry writeEntry) This method completes mini-batch operations by calling postBatchMutate() CP hook (if required) and completing mvcc.protected MiniBatchOperationInProgress<Mutation>createMiniBatch(int lastIndexExclusive, int readyToWriteCount) private voiddoFinishHotnessProtector(MiniBatchOperationInProgress<Mutation> miniBatchOp) voiddoPostOpCleanupForMiniBatch(MiniBatchOperationInProgress<Mutation> miniBatchOp, WALEdit walEdit, boolean success) abstract MutationgetMutation(int index) abstract Mutation[]This method is potentially expensive and useful mostly for non-replay CP path.abstract longgetNonce(int index) abstract longgetNonceGroup(int index) abstract long(package private) booleanisAtomic()booleanisDone()abstract booleanbooleanisOperationPending(int index) lockRowsAndBuildMiniBatch(List<Region.RowLock> acquiredRowLocks) Creates Mini-batch of all operations [nextIndexToProcess, lastIndexExclusive) for which a row lock can be acquired.abstract voidprepareMiniBatchOperations(MiniBatchOperationInProgress<Mutation> miniBatchOp, long timestamp, List<Region.RowLock> acquiredRowLocks) If necessary, calls preBatchMutate() CP hook for a mini-batch and updates metrics, cell count, tags and timestamp for all cells of all operations in a mini-batch.intsize()abstract voidvoidvisitBatchOperations(boolean pendingOnly, int lastIndexExclusive, HRegion.BatchOperation.Visitor visitor) Helper method for visiting pending/ all batch operationsprotected voidwriteMiniBatchOperationsToMemStore(MiniBatchOperationInProgress<Mutation> miniBatchOp, long writeNumber) writeMiniBatchOperationsToMemStore(MiniBatchOperationInProgress<Mutation> miniBatchOp, MultiVersionConcurrencyControl.WriteEntry writeEntry) Write mini-batch operations to MemStore
-
Field Details
-
operations
-
retCodeDetails
-
walEditsFromCoprocessors
-
familyCellMaps
-
results
-
region
-
nextIndexToProcess
-
observedExceptions
-
durability
-
atomic
-
-
Constructor Details
-
BatchOperation
-
-
Method Details
-
visitBatchOperations
public void visitBatchOperations(boolean pendingOnly, int lastIndexExclusive, HRegion.BatchOperation.Visitor visitor) throws IOException Helper method for visiting pending/ all batch operations- Throws:
IOException
-
getMutation
-
getNonceGroup
-
getNonce
-
getMutationsForCoprocs
This method is potentially expensive and useful mostly for non-replay CP path. -
isInReplay
-
getOrigLogSeqNum
-
startRegionOperation
- Throws:
IOException
-
closeRegionOperation
- Throws:
IOException
-
checkAndPrepare
Validates each mutation and prepares a batch for write. If necessary (non-replay case), runs CP prePut()/preDelete()/preIncrement()/preAppend() hooks for all mutations in a batch. This is intended to operate on entire batch and will be called from outside of class to check and prepare batch. This can be implemented by calling helper methodcheckAndPrepareMutation(int, long)in a 'for' loop over mutations.- Throws:
IOException
-
checkAndPreparePut
Implement any Put request specific check and prepare logic here. Please refer tocheckAndPrepareMutation(Mutation, long)for how its used.- Throws:
IOException
-
prepareMiniBatchOperations
public abstract void prepareMiniBatchOperations(MiniBatchOperationInProgress<Mutation> miniBatchOp, long timestamp, List<Region.RowLock> acquiredRowLocks) throws IOException If necessary, calls preBatchMutate() CP hook for a mini-batch and updates metrics, cell count, tags and timestamp for all cells of all operations in a mini-batch.- Throws:
IOException
-
writeMiniBatchOperationsToMemStore
public abstract MultiVersionConcurrencyControl.WriteEntry writeMiniBatchOperationsToMemStore(MiniBatchOperationInProgress<Mutation> miniBatchOp, MultiVersionConcurrencyControl.WriteEntry writeEntry) throws IOException Write mini-batch operations to MemStore- Throws:
IOException
-
writeMiniBatchOperationsToMemStore
protected void writeMiniBatchOperationsToMemStore(MiniBatchOperationInProgress<Mutation> miniBatchOp, long writeNumber) throws IOException - Throws:
IOException
-
isDone
-
size
-
isOperationPending
-
getClusterIds
-
isAtomic
boolean isAtomic() -
checkAndPrepareMutation
Helper method that checks and prepares only one mutation. This can be used to implementcheckAndPrepare()for entire Batch. NOTE: As CP prePut()/preDelete()/preIncrement()/preAppend() hooks may modify mutations, this method should be called after prePut()/preDelete()/preIncrement()/preAppend() CP hooks are run for the mutation- Throws:
IOException
-
checkAndPrepareMutation
- Throws:
IOException
-
lockRowsAndBuildMiniBatch
public MiniBatchOperationInProgress<Mutation> lockRowsAndBuildMiniBatch(List<Region.RowLock> acquiredRowLocks) throws IOException Creates Mini-batch of all operations [nextIndexToProcess, lastIndexExclusive) for which a row lock can be acquired. All mutations with locked rows are considered to be In-progress operations and hence the nameMiniBatchOperationInProgress. Mini batch is window overHRegion.BatchOperationand contains contiguous pending operations.- Parameters:
acquiredRowLocks- keeps track of rowLocks acquired.- Throws:
IOException
-
createMiniBatch
protected MiniBatchOperationInProgress<Mutation> createMiniBatch(int lastIndexExclusive, int readyToWriteCount) -
buildWALEdits
public List<Pair<NonceKey,WALEdit>> buildWALEdits(MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException Builds separate WALEdit per nonce by applying input mutations. If WALEdits from CP are present, they are merged to result WALEdit.- Throws:
IOException
-
completeMiniBatchOperations
public void completeMiniBatchOperations(MiniBatchOperationInProgress<Mutation> miniBatchOp, MultiVersionConcurrencyControl.WriteEntry writeEntry) throws IOException This method completes mini-batch operations by calling postBatchMutate() CP hook (if required) and completing mvcc.- Throws:
IOException
-
doPostOpCleanupForMiniBatch
public void doPostOpCleanupForMiniBatch(MiniBatchOperationInProgress<Mutation> miniBatchOp, WALEdit walEdit, boolean success) throws IOException - Throws:
IOException
-
doFinishHotnessProtector
-
applyFamilyMapToMemStore
protected void applyFamilyMapToMemStore(Map<byte[], List<Cell>> familyMap, MemStoreSizing memstoreAccounting) Atomically apply the given map of family->edits to the memstore. This handles the consistency control on its own, but the caller should already have locked updatesLock.readLock(). This also does not check the families for validity.- Parameters:
familyMap- Map of Cells by family
-