public class GridEventsImpl extends Object implements GridEvents
GridEvents implementation.| Constructor and Description |
|---|
GridEventsImpl(GridKernalContext ctx,
GridProjection prj) |
| Modifier and Type | Method and Description |
|---|---|
void |
disableLocal(int[] types)
Disables provided events.
|
int[] |
enabledEvents()
Gets types of enabled events.
|
void |
enableLocal(int[] types)
Enables provided events.
|
boolean |
isEnabled(int type)
Check if event is enabled.
|
void |
localListen(GridPredicate<? extends GridEvent> lsnr,
int[] types)
Adds an event listener for local events.
|
<T extends GridEvent> |
localQuery(GridPredicate<T> p,
int... types)
Queries local node for events using passed-in predicate filter for event selection.
|
GridProjection |
projection()
Gets grid projection to which this
GridMessaging instance belongs. |
void |
recordLocal(GridEvent evt)
Records customer user generated event.
|
<T extends GridEvent> |
remoteListen(GridBiPredicate<UUID,T> locLsnr,
GridPredicate<T> rmtFilter,
int... types)
Adds event listener for specified events to all nodes in the projection (possibly including
local node if it belongs to the projection as well).
|
<T extends GridEvent> |
remoteListen(int bufSize,
long interval,
boolean autoUnsubscribe,
GridBiPredicate<UUID,T> locLsnr,
GridPredicate<T> rmtFilter,
int... types)
Adds event listener for specified events to all nodes in the projection (possibly including
local node if it belongs to the projection as well).
|
<T extends GridEvent> |
remoteQuery(GridPredicate<T> p,
long timeout,
int... types)
Asynchronously queries nodes in this projection for events using passed in predicate filter for event
selection.
|
boolean |
stopLocalListen(GridPredicate<? extends GridEvent> lsnr,
int... types)
Removes local event listener.
|
GridFuture<?> |
stopRemoteListen(UUID opId)
Stops listening to remote events.
|
<T extends GridEvent> |
waitForLocal(GridPredicate<T> filter,
int... types)
Gets event future that allows for asynchronous waiting for the specified events.
|
public GridEventsImpl(GridKernalContext ctx, GridProjection prj)
ctx - Kernal context.prj - Projection.public GridProjection projection()
GridMessaging instance belongs.projection in interface GridEventsGridMessaging instance belongs.public <T extends GridEvent> GridFuture<List<T>> remoteQuery(GridPredicate<T> p, long timeout, @Nullable int... types)
remoteQuery in interface GridEventsp - Predicate filter used to query events on remote nodes.timeout - Maximum time to wait for result, 0 to wait forever.types - Event types to be queried.public <T extends GridEvent> GridFuture<UUID> remoteListen(@Nullable GridBiPredicate<UUID,T> locLsnr, @Nullable GridPredicate<T> rmtFilter, @Nullable int... types)
The listener can be unsubscribed automatically if local node stops, if locLsnr callback
returns false or if GridEvents.stopRemoteListen(UUID) is called.
remoteListen in interface GridEventsT - Type of the event.locLsnr - Listener callback that is called on local node. If null, this events will be handled
on remote nodes by passed in rmtFilter.rmtFilter - Filter callback that is called on remote node. Only events that pass the remote filter
will be sent to local node. If null, all events of specified types will
be sent to local node. This remote filter can be used to pre-handle events remotely,
before they are passed in to local callback. It will be auto-unsubsribed on the node
where event occurred in case if it returns false.types - Types of events to listen for. If not provided, all events that pass the
provided remote filter will be sent to local node.operation ID
that can be passed to GridEvents.stopRemoteListen(UUID) method to stop listening.public <T extends GridEvent> GridFuture<UUID> remoteListen(int bufSize, long interval, boolean autoUnsubscribe, @Nullable GridBiPredicate<UUID,T> locLsnr, @Nullable GridPredicate<T> rmtFilter, @Nullable int... types)
remoteListen in interface GridEventsT - Type of the event.bufSize - Remote events buffer size. Events from remote nodes won't be sent until buffer
is full or time interval is exceeded.interval - Maximum time interval after which events from remote node will be sent. Events
from remote nodes won't be sent until buffer is full or time interval is exceeded.autoUnsubscribe - Flag indicating that event listeners on remote nodes should be
automatically unregistered if master node (node that initiated event listening) leaves
topology. If this flag is false, listeners will be unregistered only when
GridEvents.stopRemoteListen(UUID) method is called, or the 'callback (locLsnr)'
passed in returns false.locLsnr - Callback that is called on local node. If this predicate returns true,
the implementation will continue listening to events. Otherwise, events
listening will be stopped and listeners will be unregistered on all nodes
in the projection. If null, this events will be handled on remote nodes by
passed in rmtFilter until local node stops (if 'autoUnsubscribe' is true)
or until GridEvents.stopRemoteListen(UUID) is called.rmtFilter - Filter callback that is called on remote node. Only events that pass the remote filter
will be sent to local node. If null, all events of specified types will
be sent to local node. This remote filter can be used to pre-handle events remotely,
before they are passed in to local callback. It will be auto-unsubsribed on the node
where event occurred in case if it returns false.types - Types of events to listen for. If not provided, all events that pass the
provided remote filter will be sent to local node.operation ID
that can be passed to GridEvents.stopRemoteListen(UUID) method to stop listening.GridEvents.stopRemoteListen(UUID)public GridFuture<?> stopRemoteListen(UUID opId)
GridEvents.projection().stopRemoteListen in interface GridEventsopId - Operation ID that was returned from
GridEvents.remoteListen(GridBiPredicate, GridPredicate, int...) method.GridEvents.remoteListen(GridBiPredicate, GridPredicate, int...)public <T extends GridEvent> GridFuture<T> waitForLocal(@Nullable GridPredicate<T> filter, @Nullable int... types)
get methods will block
and wait for the specified event (either indefinitely or with provided timeout).waitForLocal in interface GridEventsfilter - Optional filtering predicate. Only if predicates evaluates to true will the event
end the wait.types - Types of the events to wait for. If not provided, all events will be passed to the filter.public <T extends GridEvent> Collection<T> localQuery(GridPredicate<T> p, @Nullable int... types)
localQuery in interface GridEventsp - Predicate to filter events. All predicates must be satisfied for the
event to be returned.types - Event types to be queried.public void recordLocal(GridEvent evt)
NOTE: all types in range from 1 to 1000 are reserved for
internal GridGain events and should not be used by user-defined events.
Attempt to record internal event with this method will cause IllegalArgumentException
to be thrown.
recordLocal in interface GridEventsevt - Locally generated event.public void localListen(GridPredicate<? extends GridEvent> lsnr, int[] types)
localListen in interface GridEventslsnr - Predicate that is called on each received event. If predicate returns false,
it will be unregistered and will stop receiving events.types - Event types for which this listener will be notified.public boolean stopLocalListen(GridPredicate<? extends GridEvent> lsnr, @Nullable int... types)
stopLocalListen in interface GridEventslsnr - Local event listener to remove.types - Types of events for which to remove listener. If not specified,
then listener will be removed for all types it was registered for.true if listener was removed, false otherwise.public void enableLocal(int[] types)
enableLocal in interface GridEventstypes - Events to enable.public void disableLocal(int[] types)
disableLocal in interface GridEventstypes - Events to disable.public int[] enabledEvents()
enabledEvents in interface GridEventspublic boolean isEnabled(int type)
isEnabled in interface GridEventstype - Event type.True if event of passed in type is enabled.Copyright © 2014. All rights reserved.