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
Modifier and TypeClassDescription(package private) static interface
Visitor interface for batch operations -
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected Durability
protected final Map<byte[],
List<ExtendedCell>>[] protected int
protected final HRegion.ObservedExceptionsInBatch
protected final T[]
protected final HRegion
protected final Result[]
protected final OperationStatus[]
protected final WALEdit[]
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addNonSkipWALMutationsToWALEdit
(MiniBatchOperationInProgress<Mutation> miniBatchOp, WALEdit walEdit, List<ExtendedCell> cellsFromCP, Map<byte[], List<ExtendedCell>> familyCellMap) protected void
applyFamilyMapToMemStore
(Map<byte[], List<ExtendedCell>> 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.protected abstract void
cacheSkipWALMutationForRegionReplication
(MiniBatchOperationInProgress<Mutation> miniBatchOp, List<Pair<NonceKey, WALEdit>> walEdits, Map<byte[], List<ExtendedCell>> familyCellMap) abstract void
Validates each mutation and prepares a batch for write.protected void
checkAndPrepareMutation
(int index, long timestamp) protected void
checkAndPrepareMutation
(Mutation mutation, long timestamp) Helper method that checks and prepares only one mutation.protected abstract void
Implement any Put request specific check and prepare logic here.abstract void
void
completeMiniBatchOperations
(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) protected WALEdit
createWALEdit
(MiniBatchOperationInProgress<Mutation> miniBatchOp) protected static void
doAddCellsToWALEdit
(WALEdit walEdit, List<ExtendedCell> cellsFromCP, Map<byte[], List<ExtendedCell>> familyCellMap) private void
doFinishHotnessProtector
(MiniBatchOperationInProgress<Mutation> miniBatchOp) void
doPostOpCleanupForMiniBatch
(MiniBatchOperationInProgress<Mutation> miniBatchOp, WALEdit walEdit, boolean success) abstract Mutation
getMutation
(int index) abstract Mutation[]
This method is potentially expensive and useful mostly for non-replay CP path.abstract long
getNonce
(int index) abstract long
getNonceGroup
(int index) abstract long
(package private) boolean
isAtomic()
boolean
isDone()
abstract boolean
boolean
isOperationPending
(int index) lockRowsAndBuildMiniBatch
(List<Region.RowLock> acquiredRowLocks) Creates Mini-batch of all operations [nextIndexToProcess, lastIndexExclusive) for which a row lock can be acquired.abstract void
prepareMiniBatchOperations
(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.int
size()
abstract void
void
visitBatchOperations
(boolean pendingOnly, int lastIndexExclusive, HRegion.BatchOperation.Visitor visitor) Helper method for visiting pending/ all batch operationsprotected void
writeMiniBatchOperationsToMemStore
(MiniBatchOperationInProgress<Mutation> miniBatchOp, long writeNumber) writeMiniBatchOperationsToMemStore
(MiniBatchOperationInProgress<Mutation> miniBatchOp, MultiVersionConcurrencyControl.WriteEntry writeEntry, long now) 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, long now) 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.BatchOperation
and contains contiguous pending operations.- Parameters:
acquiredRowLocks
- keeps track of rowLocks acquired.- Throws:
IOException
-
createMiniBatch
protected MiniBatchOperationInProgress<Mutation> createMiniBatch(int lastIndexExclusive, int readyToWriteCount) -
createWALEdit
-
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
-
addNonSkipWALMutationsToWALEdit
protected void addNonSkipWALMutationsToWALEdit(MiniBatchOperationInProgress<Mutation> miniBatchOp, WALEdit walEdit, List<ExtendedCell> cellsFromCP, Map<byte[], List<ExtendedCell>> familyCellMap) -
doAddCellsToWALEdit
protected static void doAddCellsToWALEdit(WALEdit walEdit, List<ExtendedCell> cellsFromCP, Map<byte[], List<ExtendedCell>> familyCellMap) -
cacheSkipWALMutationForRegionReplication
protected abstract void cacheSkipWALMutationForRegionReplication(MiniBatchOperationInProgress<Mutation> miniBatchOp, List<Pair<NonceKey, WALEdit>> walEdits, Map<byte[], List<ExtendedCell>> familyCellMap) -
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<ExtendedCell>> 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
-