ChenSammi commented on code in PR #9272:
URL: https://github.com/apache/ozone/pull/9272#discussion_r2525791249
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/SCMDeletedBlockTransactionStatusManager.java:
##########
@@ -415,6 +450,76 @@ private boolean alreadyExecuted(DatanodeID dnId, long
txId) {
.contains(dnId);
}
+ @VisibleForTesting
+ public void addTransactions(ArrayList<DeletedBlocksTransaction> txList)
throws IOException {
+ if (txList.isEmpty()) {
+ return;
+ }
+ if
(VersionedDatanodeFeatures.isFinalized(HDDSLayoutFeature.STORAGE_SPACE_DISTRIBUTION)
&&
+ !disableDataDistributionForTest) {
+ for (DeletedBlocksTransaction tx: txList) {
+ if (tx.hasTotalBlockSize()) {
+ if (!isFirstTxIdForDataDistributionSet) {
+ // set the first transaction ID for data distribution
+ isFirstTxIdForDataDistributionSet = true;
+ firstTxIdForDataDistribution = tx.getTxID();
+ }
+ incrDeletedBlocksSummary(tx);
+ }
+ }
+ deletedBlockLogStateManager.addTransactionsToDB(txList, getSummary());
+ return;
+ }
+ deletedBlockLogStateManager.addTransactionsToDB(txList);
+ }
+
+ private void incrDeletedBlocksSummary(DeletedBlocksTransaction tx) {
+ totalTxCount.addAndGet(1);
+ totalBlockCount.addAndGet(tx.getLocalIDCount());
+ totalBlocksSize.addAndGet(tx.getTotalBlockSize());
+ totalReplicatedBlocksSize.addAndGet(tx.getTotalBlockReplicatedSize());
+ }
+
+ @VisibleForTesting
+ public void removeTransactions(ArrayList<Long> txIDs) throws IOException {
+ if (txIDs.isEmpty()) {
+ return;
+ }
+ if
(VersionedDatanodeFeatures.isFinalized(HDDSLayoutFeature.STORAGE_SPACE_DISTRIBUTION)
&&
+ !disableDataDistributionForTest) {
+ ArrayList<Long> txToQueryList = new ArrayList<>();
+ for (Long txID: txIDs) {
+ if (txID >= firstTxIdForDataDistribution) {
Review Comment:
This is for below cases in the below comments. If map doesn't have txId,
sometimes we need to get the tx info from DB. The firstTxIdForDataDistribution
check here is to avoid unnecessary db fetch for those old transactions.
// Fetch the transaction from DB to get the size. This happens during
// 1. SCM leader transfer, deletion command send by one SCM,
// while the deletion ack received by a different SCM
// 2. SCM restarts, txBlockInfoMap is empty, while receiving the deletion
ack from DN
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]