public CompletableFuture < Void > closeSession ( SessionId sessionId , boolean delete ) { RaftSessionState state = sessions . get ( sessionId . id ( ) ) ; if ( state == null ) { return Futures . exceptionalFuture ( new RaftException . UnknownSession ( "Unknown session: " + sessionId ) ) ; } log . debug ( "Closing session {}" , sessionId ) ; CloseSessionRequest request = CloseSessionRequest . builder ( ) . withSession ( sessionId . id ( ) ) . withDelete ( delete ) . build ( ) ; CompletableFuture < Void > future = new CompletableFuture <> ( ) ; connection . closeSession ( request ) . whenComplete ( ( response , error ) -> { sessions . remove ( sessionId . id ( ) ) ; if ( error == null ) { if ( response . status ( ) == RaftResponse . Status . OK ) { future . complete ( null ) ; } else { future . completeExceptionally ( response . error ( ) . createException ( ) ) ; } } else { future . completeExceptionally ( error ) ; } } ) ; return future ; }
Closes a session .