This is an automated email from the ASF dual-hosted git repository.

msingh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ratis.git


The following commit(s) were added to refs/heads/master by this push:
     new b917001  RATIS-426. StateMachine should be notified about index 
updates when confentry/no op entries are processed. Contributed by Mukul Kumar 
Singh.
b917001 is described below

commit b91700193cc9d153f300a81e1b15bb6e650dcf37
Author: Mukul Kumar Singh <[email protected]>
AuthorDate: Mon Feb 11 14:36:00 2019 +0530

    RATIS-426. StateMachine should be notified about index updates when 
confentry/no op entries are processed. Contributed by Mukul Kumar Singh.
---
 .../java/org/apache/ratis/server/impl/RaftServerImpl.java     |  3 +++
 .../main/java/org/apache/ratis/statemachine/StateMachine.java | 11 +++++++++++
 2 files changed, 14 insertions(+)

diff --git 
a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java 
b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
index 7ec0600..2cd8d40 100644
--- 
a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
+++ 
b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
@@ -1093,6 +1093,9 @@ public class RaftServerImpl implements 
RaftServerProtocol, RaftServerAsynchronou
 
   CompletableFuture<Message> applyLogToStateMachine(LogEntryProto next) {
     final StateMachine stateMachine = getStateMachine();
+    if (!next.hasStateMachineLogEntry()) {
+      stateMachine.notifyIndexUpdate(next.getIndex());
+    }
     if (next.hasConfigurationEntry()) {
       // the reply should have already been set. only need to record
       // the new conf in the metadata file.
diff --git 
a/ratis-server/src/main/java/org/apache/ratis/statemachine/StateMachine.java 
b/ratis-server/src/main/java/org/apache/ratis/statemachine/StateMachine.java
index c52bed1..2f4f20b 100644
--- a/ratis-server/src/main/java/org/apache/ratis/statemachine/StateMachine.java
+++ b/ratis-server/src/main/java/org/apache/ratis/statemachine/StateMachine.java
@@ -184,6 +184,17 @@ public interface StateMachine extends Closeable {
   TransactionContext applyTransactionSerial(TransactionContext trx);
 
   /**
+   * Called to notify state machine about indexes which are processed
+   * internally by Raft Server, this currently happens when conf entries are
+   * processed in raft Server. This keep state machine to keep a track of index
+   * updates.
+   * @param index index which is being updated
+   */
+  default void notifyIndexUpdate(long index) {
+
+  }
+
+  /**
    * Apply a committed log entry to the state machine. This method can be 
called concurrently with
    * the other calls, and there is no guarantee that the calls will be ordered 
according to the
    * log commit order.

Reply via email to