amaliujia commented on a change in pull request #1725:
URL: https://github.com/apache/ozone/pull/1725#discussion_r558613616
##########
File path:
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMStateMachine.java
##########
@@ -89,4 +119,30 @@ private Message process(final SCMRatisRequest request)
}
}
+ @Override
+ public long takeSnapshot() throws IOException {
+ long startTime = Time.monotonicNow();
+ TermIndex lastTermIndex = getLastAppliedTermIndex();
+ long lastAppliedIndex = lastTermIndex.getIndex();
+ SCMTransactionInfo lastAppliedTrxInfo =
+ SCMTransactionInfo.fromTermIndex(lastTermIndex);
+ if (transactionBuffer.getLatestTrxInfo()
+ .compareTo(lastAppliedTrxInfo) < 0) {
+ transactionBuffer.updateLatestTrxInfo(
+ SCMTransactionInfo.builder()
+ .setCurrentTerm(lastTermIndex.getTerm())
+ .setTransactionIndex(lastTermIndex.getIndex())
+ .build());
+ transactionBuffer.setLatestSnapshot(
+ transactionBuffer.getLatestTrxInfo().toSnapshotInfo());
+ } else {
+ lastAppliedIndex =
+ transactionBuffer.getLatestTrxInfo().getTransactionIndex();
+ }
+
+ transactionBuffer.flush();
+ LOG.info("Current Snapshot Index {}, takeSnapshot took {} ms",
+ getLastAppliedTermIndex(), Time.monotonicNow() - startTime);
+ return lastAppliedIndex;
Review comment:
O the code here is keeping the lastAppliedIndex in buffer to equal to
the getLastAppliedTermIndex() actually.
```
LOG.info("Current Snapshot Index {}, takeSnapshot took {} ms",
getLastAppliedTermIndex(), Time.monotonicNow() - startTime);
```
is wrong.
I should replace `getLastAppliedTermIndex()` with `lastAppliedIndex` to make
it clear.
We need the `lastAppliedIndex` in buffer keep updated so that will be
written into DB.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]