@@ -314,24 +314,42 @@ private boolean mayTsFileLinkedCountReachDangerousThreshold(final PipeRealtimeEv
314314 }
315315
316316 @ Override
317- protected Event doSupply (final PipeRealtimeEvent realtimeEvent ) {
318- // Used to judge the type of the event, not directly for supplying.
319- final Event eventToSupply = realtimeEvent .getEvent ();
320- if (eventToSupply instanceof TabletInsertionEvent ) {
321- return supplyTabletInsertion (realtimeEvent );
322- } else if (eventToSupply instanceof TsFileInsertionEvent ) {
323- return supplyTsFileInsertion (realtimeEvent );
324- } else if (eventToSupply instanceof PipeHeartbeatEvent ) {
325- return supplyHeartbeat (realtimeEvent );
326- } else if (eventToSupply instanceof PipeSchemaRegionWritePlanEvent
327- || eventToSupply instanceof ProgressReportEvent ) {
328- return supplyDirectly (realtimeEvent );
329- } else {
330- throw new UnsupportedOperationException (
331- String .format (
332- "Unsupported event type %s for hybrid realtime extractor %s to supply." ,
333- eventToSupply .getClass (), this ));
317+ public Event supply () {
318+ PipeRealtimeEvent realtimeEvent = (PipeRealtimeEvent ) pendingQueue .directPoll ();
319+
320+ while (realtimeEvent != null ) {
321+ final Event suppliedEvent ;
322+
323+ // Used to judge the type of the event, not directly for supplying.
324+ final Event eventToSupply = realtimeEvent .getEvent ();
325+ if (eventToSupply instanceof TabletInsertionEvent ) {
326+ suppliedEvent = supplyTabletInsertion (realtimeEvent );
327+ } else if (eventToSupply instanceof TsFileInsertionEvent ) {
328+ suppliedEvent = supplyTsFileInsertion (realtimeEvent );
329+ } else if (eventToSupply instanceof PipeHeartbeatEvent ) {
330+ suppliedEvent = supplyHeartbeat (realtimeEvent );
331+ } else if (eventToSupply instanceof PipeSchemaRegionWritePlanEvent
332+ || eventToSupply instanceof ProgressReportEvent ) {
333+ suppliedEvent = supplyDirectly (realtimeEvent );
334+ } else {
335+ throw new UnsupportedOperationException (
336+ String .format (
337+ "Unsupported event type %s for hybrid realtime extractor %s to supply." ,
338+ eventToSupply .getClass (), this ));
339+ }
340+
341+ realtimeEvent .decreaseReferenceCount (
342+ PipeRealtimeDataRegionHybridExtractor .class .getName (), false );
343+
344+ if (suppliedEvent != null ) {
345+ return suppliedEvent ;
346+ }
347+
348+ realtimeEvent = (PipeRealtimeEvent ) pendingQueue .directPoll ();
334349 }
350+
351+ // Means the pending queue is empty.
352+ return null ;
335353 }
336354
337355 private Event supplyTabletInsertion (final PipeRealtimeEvent event ) {
0 commit comments