private void failHeartbeat ( ) { raft . checkThread ( ) ; // Iterate through pending timestamped heartbeat futures and fail futures that have been pending longer // than an election timeout. long currentTimestamp = System . currentTimeMillis ( ) ; Iterator < TimestampedFuture < Long > > iterator = heartbeatFutures . iterator ( ) ; while ( iterator . hasNext ( ) ) { TimestampedFuture < Long > future = iterator . next ( ) ; if ( currentTimestamp - future . timestamp > electionTimeout ) { future . completeExceptionally ( new RaftException . ProtocolException ( "Failed to reach consensus" ) ) ; iterator . remove ( ) ; } } }
Records a failed heartbeat .