Class HRegion.MutationBatchOperation
java.lang.Object
org.apache.hadoop.hbase.regionserver.HRegion.BatchOperation<Mutation>
org.apache.hadoop.hbase.regionserver.HRegion.MutationBatchOperation
- Enclosing class:
- HRegion
Batch of mutation operations. Base class is shared with
HRegion.ReplayBatchOperation as most of
the logic is same.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.regionserver.HRegion.BatchOperation
HRegion.BatchOperation.Visitor -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprivate longprivate longprivate booleanFields inherited from class org.apache.hadoop.hbase.regionserver.HRegion.BatchOperation
atomic, durability, familyCellMaps, nextIndexToProcess, observedExceptions, operations, region, results, retCodeDetails, walEditsFromCoprocessors -
Constructor Summary
ConstructorsConstructorDescriptionMutationBatchOperation(HRegion region, Mutation[] operations, boolean atomic, long nonceGroup, long nonce) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddNonSkipWALMutationsToWALEdit(MiniBatchOperationInProgress<Mutation> miniBatchOp, WALEdit walEdit, List<ExtendedCell> cellsFromCP, Map<byte[], List<ExtendedCell>> familyCellMap) private voidattachRegionReplicationToMVCCEntry(MiniBatchOperationInProgress<Mutation> miniBatchOp, MultiVersionConcurrencyControl.WriteEntry mvccWriteEntry, long now) CreateWALKeyImpland getWALEditfrom miniBatchOp and attachRegionReplicationSink.add(org.apache.hadoop.hbase.wal.WALKeyImpl, org.apache.hadoop.hbase.wal.WALEdit, org.apache.hadoop.hbase.ipc.ServerCall<?>)to the mvccWriteEntry.buildWALEdits(MiniBatchOperationInProgress<Mutation> miniBatchOp) Builds separate WALEdit per nonce by applying input mutations.protected voidcacheSkipWALMutationForRegionReplication(MiniBatchOperationInProgress<Mutation> miniBatchOp, List<Pair<NonceKey, WALEdit>> nonceKeyAndWALEdits, Map<byte[], List<ExtendedCell>> familyCellMap) Here is for HBASE-26993,in order to make the new framework for region replication could work for SKIP_WAL, we save theMutationwhichMutation.getDurability()isDurability.SKIP_WALin miniBatchOp.private voidcallPreMutateCPHook(int index, WALEdit walEdit, int[] metrics) Runs prePut/preDelete/preIncrement/preAppend coprocessor hook for input mutation in a batchprivate voidcheckAndMergeCPMutations(MiniBatchOperationInProgress<Mutation> miniBatchOp, List<Region.RowLock> acquiredRowLocks, long timestamp) voidValidates each mutation and prepares a batch for write.voidImplement any Put request specific check and prepare logic here.voidvoidcompleteMiniBatchOperations(MiniBatchOperationInProgress<Mutation> miniBatchOp, MultiVersionConcurrencyControl.WriteEntry writeEntry) This method completes mini-batch operations by calling postBatchMutate() CP hook (if required) and completing mvcc.private WALEditcreateWALEditForReplicateSkipWAL(MiniBatchOperationInProgress<Mutation> miniBatchOp, List<Pair<NonceKey, WALEdit>> nonceKeyAndWALEdits) private WALKeyImplcreateWALKey(long now) voiddoPostOpCleanupForMiniBatch(MiniBatchOperationInProgress<Mutation> miniBatchOp, WALEdit walEdit, boolean success) private voidendNonceOperation(boolean success) Ends nonce operation for a mutation, if needed.private static longgetLongValue(Cell cell) Returns Get the long out of the passed in CellgetMutation(int index) Mutation[]This method is potentially expensive and useful mostly for non-replay CP path.longgetNonce(int index) longgetNonceGroup(int index) longbooleanprivate voidmergeFamilyMaps(Map<byte[], List<ExtendedCell>> familyMap, Map<byte[], List<ExtendedCell>> toBeMerged) 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.private static ExtendedCellreckonDelta(ExtendedCell delta, ExtendedCell currentCell, byte[] columnFamily, long now, Mutation mutation, Function<ExtendedCell, byte[]> supplier) private Map<byte[],List<ExtendedCell>> reckonDeltas(Mutation mutation, List<ExtendedCell> results, long now) private List<ExtendedCell>reckonDeltasByStore(HStore store, Mutation mutation, long now, List<ExtendedCell> deltas, List<ExtendedCell> results) Reckon the Cells to apply to WAL, memstore, and to return to the Client in passed column family/Store.private booleanStarts the nonce operation for a mutation, if needed.voidprivate static GetwriteMiniBatchOperationsToMemStore(MiniBatchOperationInProgress<Mutation> miniBatchOp, MultiVersionConcurrencyControl.WriteEntry writeEntry, long now) Write mini-batch operations to MemStoreMethods inherited from class org.apache.hadoop.hbase.regionserver.HRegion.BatchOperation
applyFamilyMapToMemStore, checkAndPrepareMutation, checkAndPrepareMutation, createMiniBatch, createWALEdit, doAddCellsToWALEdit, getClusterIds, isAtomic, isDone, isOperationPending, lockRowsAndBuildMiniBatch, size, visitBatchOperations, writeMiniBatchOperationsToMemStore
-
Field Details
-
nonceGroup
-
nonce
-
canProceed
-
regionReplicateEnable
-
-
Constructor Details
-
MutationBatchOperation
public MutationBatchOperation(HRegion region, Mutation[] operations, boolean atomic, long nonceGroup, long nonce)
-
-
Method Details
-
getMutation
- Specified by:
getMutationin classHRegion.BatchOperation<Mutation>
-
getNonceGroup
- Specified by:
getNonceGroupin classHRegion.BatchOperation<Mutation>
-
getNonce
- Specified by:
getNoncein classHRegion.BatchOperation<Mutation>
-
getMutationsForCoprocs
Description copied from class:HRegion.BatchOperationThis method is potentially expensive and useful mostly for non-replay CP path.- Specified by:
getMutationsForCoprocsin classHRegion.BatchOperation<Mutation>
-
isInReplay
- Specified by:
isInReplayin classHRegion.BatchOperation<Mutation>
-
getOrigLogSeqNum
- Specified by:
getOrigLogSeqNumin classHRegion.BatchOperation<Mutation>
-
startRegionOperation
- Specified by:
startRegionOperationin classHRegion.BatchOperation<Mutation>- Throws:
IOException
-
closeRegionOperation
- Specified by:
closeRegionOperationin classHRegion.BatchOperation<Mutation>- Throws:
IOException
-
checkAndPreparePut
Description copied from class:HRegion.BatchOperationImplement any Put request specific check and prepare logic here. Please refer toHRegion.BatchOperation.checkAndPrepareMutation(Mutation, long)for how its used.- Specified by:
checkAndPreparePutin classHRegion.BatchOperation<Mutation>- Throws:
IOException
-
checkAndPrepare
Description copied from class:HRegion.BatchOperationValidates 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 methodHRegion.BatchOperation.checkAndPrepareMutation(int, long)in a 'for' loop over mutations.- Specified by:
checkAndPreparein classHRegion.BatchOperation<Mutation>- Throws:
IOException
-
prepareMiniBatchOperations
public void prepareMiniBatchOperations(MiniBatchOperationInProgress<Mutation> miniBatchOp, long timestamp, List<Region.RowLock> acquiredRowLocks) throws IOException Description copied from class:HRegion.BatchOperationIf 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.- Specified by:
prepareMiniBatchOperationsin classHRegion.BatchOperation<Mutation>- Throws:
IOException
-
startNonceOperation
Starts the nonce operation for a mutation, if needed.- Returns:
- whether to proceed this mutation.
- Throws:
IOException
-
endNonceOperation
Ends nonce operation for a mutation, if needed.- Parameters:
success- Whether the operation for this nonce has succeeded.
-
toGet
- Throws:
IOException
-
reckonDeltas
private Map<byte[],List<ExtendedCell>> reckonDeltas(Mutation mutation, List<ExtendedCell> results, long now) throws IOException - Throws:
IOException
-
reckonDeltasByStore
private List<ExtendedCell> reckonDeltasByStore(HStore store, Mutation mutation, long now, List<ExtendedCell> deltas, List<ExtendedCell> results) throws IOException Reckon the Cells to apply to WAL, memstore, and to return to the Client in passed column family/Store. Does Get of current value and then adds passed in deltas for this Store returning the result.- Parameters:
mutation- The encompassing Mutation objectdeltas- Changes to apply to this Store; either increment amount or data to appendresults- In here we accumulate all the Cells we are to return to the client. If null, client doesn't want results returned.- Returns:
- Resulting Cells after
deltashave been applied to current values. Side effect is our filling out of theresultsList. - Throws:
IOException
-
reckonDelta
private static ExtendedCell reckonDelta(ExtendedCell delta, ExtendedCell currentCell, byte[] columnFamily, long now, Mutation mutation, Function<ExtendedCell, byte[]> supplier) throws IOException- Throws:
IOException
-
getLongValue
Returns Get the long out of the passed in Cell- Throws:
DoNotRetryIOException
-
buildWALEdits
public List<Pair<NonceKey,WALEdit>> buildWALEdits(MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException Description copied from class:HRegion.BatchOperationBuilds separate WALEdit per nonce by applying input mutations. If WALEdits from CP are present, they are merged to result WALEdit.- Overrides:
buildWALEditsin classHRegion.BatchOperation<Mutation>- Throws:
IOException
-
cacheSkipWALMutationForRegionReplication
protected void cacheSkipWALMutationForRegionReplication(MiniBatchOperationInProgress<Mutation> miniBatchOp, List<Pair<NonceKey, WALEdit>> nonceKeyAndWALEdits, Map<byte[], List<ExtendedCell>> familyCellMap) Here is for HBASE-26993,in order to make the new framework for region replication could work for SKIP_WAL, we save theMutationwhichMutation.getDurability()isDurability.SKIP_WALin miniBatchOp.- Specified by:
cacheSkipWALMutationForRegionReplicationin classHRegion.BatchOperation<Mutation>
-
createWALEditForReplicateSkipWAL
private WALEdit createWALEditForReplicateSkipWAL(MiniBatchOperationInProgress<Mutation> miniBatchOp, List<Pair<NonceKey, WALEdit>> nonceKeyAndWALEdits) -
addNonSkipWALMutationsToWALEdit
protected void addNonSkipWALMutationsToWALEdit(MiniBatchOperationInProgress<Mutation> miniBatchOp, WALEdit walEdit, List<ExtendedCell> cellsFromCP, Map<byte[], List<ExtendedCell>> familyCellMap) - Overrides:
addNonSkipWALMutationsToWALEditin classHRegion.BatchOperation<Mutation>
-
writeMiniBatchOperationsToMemStore
public MultiVersionConcurrencyControl.WriteEntry writeMiniBatchOperationsToMemStore(MiniBatchOperationInProgress<Mutation> miniBatchOp, @Nullable MultiVersionConcurrencyControl.WriteEntry writeEntry, long now) throws IOException Description copied from class:HRegion.BatchOperationWrite mini-batch operations to MemStore- Specified by:
writeMiniBatchOperationsToMemStorein classHRegion.BatchOperation<Mutation>- Throws:
IOException
-
createWALKey
-
attachRegionReplicationToMVCCEntry
private void attachRegionReplicationToMVCCEntry(MiniBatchOperationInProgress<Mutation> miniBatchOp, MultiVersionConcurrencyControl.WriteEntry mvccWriteEntry, long now) throws IOException CreateWALKeyImpland getWALEditfrom miniBatchOp and attachRegionReplicationSink.add(org.apache.hadoop.hbase.wal.WALKeyImpl, org.apache.hadoop.hbase.wal.WALEdit, org.apache.hadoop.hbase.ipc.ServerCall<?>)to the mvccWriteEntry.- Throws:
IOException
-
completeMiniBatchOperations
public void completeMiniBatchOperations(MiniBatchOperationInProgress<Mutation> miniBatchOp, MultiVersionConcurrencyControl.WriteEntry writeEntry) throws IOException Description copied from class:HRegion.BatchOperationThis method completes mini-batch operations by calling postBatchMutate() CP hook (if required) and completing mvcc.- Overrides:
completeMiniBatchOperationsin classHRegion.BatchOperation<Mutation>- Throws:
IOException
-
doPostOpCleanupForMiniBatch
public void doPostOpCleanupForMiniBatch(MiniBatchOperationInProgress<Mutation> miniBatchOp, WALEdit walEdit, boolean success) throws IOException - Overrides:
doPostOpCleanupForMiniBatchin classHRegion.BatchOperation<Mutation>- Throws:
IOException
-
callPreMutateCPHook
Runs prePut/preDelete/preIncrement/preAppend coprocessor hook for input mutation in a batch- Parameters:
metrics- Array of 2 ints. index 0: count of puts, index 1: count of deletes, index 2: count of increments and 3: count of appends- Throws:
IOException
-
checkAndMergeCPMutations
private void checkAndMergeCPMutations(MiniBatchOperationInProgress<Mutation> miniBatchOp, List<Region.RowLock> acquiredRowLocks, long timestamp) throws IOException - Throws:
IOException
-
mergeFamilyMaps
private void mergeFamilyMaps(Map<byte[], List<ExtendedCell>> familyMap, Map<byte[], List<ExtendedCell>> toBeMerged)
-