CompletableFuture < Void > resetIndexes ( SessionId sessionId ) { RaftSessionState sessionState = sessions . get ( sessionId . id ( ) ) ; if ( sessionState == null ) { return Futures . exceptionalFuture ( new IllegalArgumentException ( "Unknown session: " + sessionId ) ) ; } CompletableFuture < Void > future = new CompletableFuture <> ( ) ; KeepAliveRequest request = KeepAliveRequest . builder ( ) . withSessionIds ( new long [ ] { sessionId . id ( ) } ) . withCommandSequences ( new long [ ] { sessionState . getCommandResponse ( ) } ) . withEventIndexes ( new long [ ] { sessionState . getEventIndex ( ) } ) . build ( ) ; connection . keepAlive ( request ) . whenComplete ( ( response , error ) -> { if ( error == null ) { if ( response . status ( ) == RaftResponse . Status . OK ) { future . complete ( null ) ; } else { future . completeExceptionally ( response . error ( ) . createException ( ) ) ; } } else { future . completeExceptionally ( error ) ; } } ) ; return future ; }
Resets indexes for the given session .