Description
Each grid node stores all events that have happened on this node locally. It is important to understand that when a grid task is executing it may travel the grid and events for this task's execution can be scattered around the grid. GridGain provides an API to query the grid in a distributed fashion for such events.
Local Events
Unlike remote events, local events can be listened to asynchronously by registering a listener via Grid.addLocalEventListener(GridLocalEventListener) ![]()
![]()
Remote Events
To avoid network of constantly exchanging events between nodes, grid stores all grid events locally. Whenever it is needed to find out what events took place on remote nodes, remote events can be queried using Grid.queryEvents(GridEventFilter, Collection<GridNode>, long) ![]()
Here is an example of an GridEventFilter ![]()
private static class EventFilter implements GridEventFilter { /** Serial version UID. */ private static final long serialVersionUID = 5982379841291591385L; /** * @see GridEventFilter#accept(GridEvent) */ public boolean accept(GridEvent evt) { // Accept only TASK_STARTED events. return evt.getType() == GridEventType.TASK_STARTED; } }
| Starting with version 2.1 peer-class-loading is enabled for event filters. You can simply call Grid.queryEvents(GridEventFilter, Collection<GridNode>, long) |
Event Storage SPI
As almost all kernel level functionality in GridGain the functionality of storing and querying events locally is designed as event storage SPI (Service Provider Interface). It consists of the public API and one or more implementations. Event storing happens automatically inside of the GridGain and querying functionality is exposed as user-level API:
