hanishakoneru commented on a change in pull request #316: WIP:HDDS-2680. Fix 
updating lastAppliedIndex in OzoneManagerStateMachine.
URL: https://github.com/apache/hadoop-ozone/pull/316#discussion_r354610622
 
 

 ##########
 File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerStateMachine.java
 ##########
 @@ -349,22 +357,51 @@ private Message runCommand(OMRequest request, long 
trxLogIndex) {
   /**
    * Update lastAppliedIndex term and it's corresponding term in the
    * stateMachine.
+   * @param flushedEpochs
+   */
+  public void updateLastAppliedIndex(List<Long> flushedEpochs) {
+    Preconditions.checkArgument(flushedEpochs.size() > 0);
+    updateLastAppliedIndex(flushedEpochs.get(flushedEpochs.size() -1),
+        -1L, flushedEpochs, true);
+  }
+
+  /**
+   * Update State machine lastAppliedTermIndex.
    * @param lastFlushedIndex
+   * @param currentTerm
+   * @param flushedEpochs - list of ratis transactions flushed to DB. If it
+   * is just one index and term, this can be set to null.
+   * @param checkMap - if true check applyTransactionMap, ratisTransaction
+   * Map and update lastAppliedTermIndex accordingly, else check
+   * lastAppliedTermIndex and update it.
    */
-  public synchronized void updateLastAppliedIndex(long lastFlushedIndex) {
-    Long appliedTerm = null;
-    long appliedIndex = -1;
-    for(long i = getLastAppliedTermIndex().getIndex() + 1;
-        i <= lastFlushedIndex; i++) {
-      final Long removed = applyTransactionMap.remove(i);
-      if (removed == null) {
-        break;
+  private synchronized void updateLastAppliedIndex(long lastFlushedIndex,
+      long currentTerm, List<Long> flushedEpochs, boolean checkMap) {
 
 Review comment:
   Can we rename this method to something else? This is very confusing with 
BaseStateMachine's updateLastAppliedTermIndex.
   Maybe computeAndUpdateLastAppliedIndex?

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org

Reply via email to