Class TaskEventDispatcher
- java.lang.Object
-
- org.apache.flink.runtime.io.network.TaskEventDispatcher
-
- All Implemented Interfaces:
TaskEventPublisher
public class TaskEventDispatcher extends Object implements TaskEventPublisher
The task event dispatcher dispatches events flowing backwards from a consuming task to the task producing the consumed result.Backwards events only work for tasks, which produce pipelined results, where both the producing and consuming task are running at the same time.
-
-
Constructor Summary
Constructors Constructor Description TaskEventDispatcher()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearAll()
Removes all registered event handlers.boolean
publish(ResultPartitionID partitionId, TaskEvent event)
Publishes the event to the registeredEventListener
instances.void
registerPartition(ResultPartitionID partitionId)
Registers the given partition for incoming task events allowing calls tosubscribeToEvent(ResultPartitionID, EventListener, Class)
.void
subscribeToEvent(ResultPartitionID partitionId, EventListener<TaskEvent> eventListener, Class<? extends TaskEvent> eventType)
Subscribes a listener to this dispatcher for events on a partition.void
unregisterPartition(ResultPartitionID partitionId)
Removes the given partition from listening to incoming task events, thus forbidding calls tosubscribeToEvent(ResultPartitionID, EventListener, Class)
.
-
-
-
Method Detail
-
registerPartition
public void registerPartition(ResultPartitionID partitionId)
Registers the given partition for incoming task events allowing calls tosubscribeToEvent(ResultPartitionID, EventListener, Class)
.- Parameters:
partitionId
- the partition ID
-
unregisterPartition
public void unregisterPartition(ResultPartitionID partitionId)
Removes the given partition from listening to incoming task events, thus forbidding calls tosubscribeToEvent(ResultPartitionID, EventListener, Class)
.- Parameters:
partitionId
- the partition ID
-
subscribeToEvent
public void subscribeToEvent(ResultPartitionID partitionId, EventListener<TaskEvent> eventListener, Class<? extends TaskEvent> eventType)
Subscribes a listener to this dispatcher for events on a partition.- Parameters:
partitionId
- ID of the partition to subscribe for (must be registered viaregisterPartition(ResultPartitionID)
first!)eventListener
- the event listener to subscribeeventType
- event type to subscribe to
-
publish
public boolean publish(ResultPartitionID partitionId, TaskEvent event)
Publishes the event to the registeredEventListener
instances.This method is either called directly from a
LocalInputChannel
or the network I/O thread on behalf of aRemoteInputChannel
.- Specified by:
publish
in interfaceTaskEventPublisher
- Parameters:
partitionId
- the partition ID to get registered handlersevent
- the task event to be published to the handlers- Returns:
- whether the event was published to a registered event handler (initiated via
registerPartition(ResultPartitionID)
) or not
-
clearAll
public void clearAll()
Removes all registered event handlers.
-
-