private synchronized void resetAllIndexes ( ) { Collection < RaftSessionState > sessions = Lists . newArrayList ( this . sessions . values ( ) ) ; // If no sessions are open, skip the keep-alive. if ( sessions . isEmpty ( ) ) { return ; } // Allocate session IDs, command response sequence numbers, and event index arrays. long [ ] sessionIds = new long [ sessions . size ( ) ] ; long [ ] commandResponses = new long [ sessions . size ( ) ] ; long [ ] eventIndexes = new long [ sessions . size ( ) ] ; // For each session that needs to be kept alive, populate batch request arrays. int i = 0 ; for ( RaftSessionState sessionState : sessions ) { sessionIds [ i ] = sessionState . getSessionId ( ) . id ( ) ; commandResponses [ i ] = sessionState . getCommandResponse ( ) ; eventIndexes [ i ] = sessionState . getEventIndex ( ) ; i ++ ; } log . trace ( "Resetting {} sessions" , sessionIds . length ) ; KeepAliveRequest request = KeepAliveRequest . builder ( ) . withSessionIds ( sessionIds ) . withCommandSequences ( commandResponses ) . withEventIndexes ( eventIndexes ) . build ( ) ; connection . keepAlive ( request ) ; }
Resets indexes for all sessions .