@ GuardedBy ( "lock" ) protected void sendBundledMessages ( ) { for ( Map . Entry < Address , List < Message > > entry : msgs . entrySet ( ) ) { List < Message > list = entry . getValue ( ) ; if ( list . isEmpty ( ) ) continue ; output . position ( 0 ) ; if ( list . size ( ) == 1 ) sendSingleMessage ( list . get ( 0 ) ) ; else { Address dst = entry . getKey ( ) ; sendMessageList ( dst , list . get ( 0 ) . getSrc ( ) , list ) ; if ( transport . statsEnabled ( ) ) transport . incrBatchesSent ( 1 ) ; } } clearMessages ( ) ; count = 0 ; }
Sends all messages in the map . Messages for the same destination are bundled into a message list . The map will be cleared when done .