private void reconcile ( ) { // If nonContiguousMsgIds is empty then nothing to reconcile. if ( nonContiguousMsgIds . isEmpty ( ) ) { return ; } // This happens when a passive is started after Active has moved on and // passive starts to see msgIDs starting from a number > 0. // Once the sync is completed, fast forward highestContiguousMsgId. // Post sync completion assuming platform will send all msgIds beyond highestContiguousMsgId. if ( highestContiguousMsgId == - 1L && isSyncCompleted ) { Long min = nonContiguousMsgIds . last ( ) ; LOGGER . info ( "Setting highestContiguousMsgId to {} from -1" , min ) ; highestContiguousMsgId = min ; nonContiguousMsgIds . removeIf ( msgId -> msgId <= min ) ; } for ( long msgId : nonContiguousMsgIds ) { if ( msgId <= highestContiguousMsgId ) { nonContiguousMsgIds . remove ( msgId ) ; } else if ( msgId > highestContiguousMsgId + 1 ) { break ; } else { // the order is important.. highestContiguousMsgId = msgId ; nonContiguousMsgIds . remove ( msgId ) ; } } }
Remove the contiguous seen msgIds from the nonContiguousMsgIds and update highestContiguousMsgId