protected void drainCache ( ) { // Route the tuples to correct places Map < Integer , List < HeronTuples . HeronTupleSet > > cache = tupleCache . getCache ( ) ; if ( ! isSendTuplesToInstance ( new LinkedList < Integer > ( cache . keySet ( ) ) ) ) { // Check whether we could send tuples return ; } for ( Map . Entry < Integer , List < HeronTuples . HeronTupleSet > > entry : cache . entrySet ( ) ) { int taskId = entry . getKey ( ) ; for ( HeronTuples . HeronTupleSet message : entry . getValue ( ) ) { sendInBound ( taskId , message ) ; } } // Reset the tupleCache tupleCache . clear ( ) ; }
Drain the TupleCache if there are room in destination tasks