Class IgniteEventsImpl

    • Constructor Detail

      • IgniteEventsImpl

        public IgniteEventsImpl()
        Required by Externalizable.
      • IgniteEventsImpl

        public IgniteEventsImpl​(GridKernalContext ctx,
                                ClusterGroupAdapter prj,
                                boolean async)
        Parameters:
        ctx - Kernal context.
        prj - Projection.
        async - Async support flag.
    • Method Detail

      • clusterGroup

        public ClusterGroup clusterGroup()
        Gets cluster group to which this IgniteEvents instance belongs.
        Specified by:
        clusterGroup in interface IgniteEvents
        Returns:
        Cluster group to which this IgniteEvents instance belongs.
      • remoteQuery

        public <T extends EventList<T> remoteQuery​(IgnitePredicate<T> p,
                                                     long timeout,
                                                     @Nullable
                                                     @org.jetbrains.annotations.Nullable int... types)
        Queries nodes in this cluster group for events using passed in predicate filter for event selection.
        Specified by:
        remoteQuery in interface IgniteEvents
        Type Parameters:
        T - Type of the result events.
        Parameters:
        p - 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.
        Returns:
        Collection of grid events returned from specified nodes.
      • remoteQueryAsync

        public <T extends EventIgniteFuture<List<T>> remoteQueryAsync​(IgnitePredicate<T> p,
                                                                        long timeout,
                                                                        @Nullable
                                                                        @org.jetbrains.annotations.Nullable int... types)
                                                                 throws IgniteException
        Asynchronously queries nodes in this cluster group for events using passed in predicate filter for event selection.
        Specified by:
        remoteQueryAsync in interface IgniteEvents
        Type Parameters:
        T - Type of the result events.
        Parameters:
        p - 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.
        Returns:
        a Future representing pending completion of the query. The completed future contains collection of grid events returned from specified nodes.
        Throws:
        IgniteException - If query failed.
      • remoteListen

        public <T extends EventUUID remoteListen​(@Nullable
                                                   @Nullable IgniteBiPredicate<UUID,​T> locLsnr,
                                                   @Nullable
                                                   @Nullable IgnitePredicate<T> rmtFilter,
                                                   @Nullable
                                                   @org.jetbrains.annotations.Nullable int... types)
        Adds event listener for specified events to all nodes in the cluster group (possibly including local node if it belongs to the cluster group as well). This means that all events occurring on any node within this cluster group that pass remote filter will be sent to local node for local listener notifications.

        The listener can be unsubscribed automatically if local node stops, if locLsnr callback returns false or if IgniteEvents.stopRemoteListen(UUID) or IgniteEvents.stopRemoteListenAsync(UUID) are called.

        Specified by:
        remoteListen in interface IgniteEvents
        Type Parameters:
        T - Type of the event.
        Parameters:
        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.
        Returns:
        Operation ID that can be passed to IgniteEvents.stopRemoteListen(UUID) or IgniteEvents.stopRemoteListenAsync(UUID) methods to stop listening.
      • remoteListenAsync

        public <T extends EventIgniteFuture<UUID> remoteListenAsync​(@Nullable
                                                                      @Nullable IgniteBiPredicate<UUID,​T> locLsnr,
                                                                      @Nullable
                                                                      @Nullable IgnitePredicate<T> rmtFilter,
                                                                      @Nullable
                                                                      @org.jetbrains.annotations.Nullable int... types)
                                                               throws IgniteException
        Asynchronously adds event listener for specified events to all nodes in the cluster group (possibly including local node if it belongs to the cluster group as well). This means that all events occurring on any node within this cluster group that pass remote filter will be sent to local node for local listener notifications.

        The listener can be unsubscribed automatically if local node stops, if locLsnr callback returns false or if IgniteEvents.stopRemoteListen(UUID) or IgniteEvents.stopRemoteListenAsync(UUID) are called.

        Specified by:
        remoteListenAsync in interface IgniteEvents
        Type Parameters:
        T - Type of the event.
        Parameters:
        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.
        Returns:
        a Future representing pending completion of the operation. The completed future contains Operation ID that can be passed to IgniteEvents.stopRemoteListen(UUID) or IgniteEvents.stopRemoteListenAsync(UUID) methods to stop listening.
        Throws:
        IgniteException - If failed to add listener.
      • remoteListen

        public <T extends EventUUID remoteListen​(int bufSize,
                                                   long interval,
                                                   boolean autoUnsubscribe,
                                                   @Nullable
                                                   @Nullable IgniteBiPredicate<UUID,​T> locLsnr,
                                                   @Nullable
                                                   @Nullable IgnitePredicate<T> rmtFilter,
                                                   @Nullable
                                                   @org.jetbrains.annotations.Nullable int... types)
        Adds event listener for specified events to all nodes in the cluster group (possibly including local node if it belongs to the cluster group as well). This means that all events occurring on any node within this cluster group that pass remote filter will be sent to local node for local listener notification.

        Supports asynchronous execution (see IgniteAsyncSupport).

        Specified by:
        remoteListen in interface IgniteEvents
        Type Parameters:
        T - Type of the event.
        Parameters:
        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 IgniteEvents.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 cluster group. If null, this events will be handled on remote nodes by passed in rmtFilter until local node stops (if 'autoUnsubscribe' is true) or until IgniteEvents.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.
        Returns:
        Operation ID that can be passed to IgniteEvents.stopRemoteListen(UUID) or IgniteEvents.stopRemoteListen(UUID) methods to stop listening.
        See Also:
        IgniteEvents.stopRemoteListen(UUID), IgniteEvents.stopRemoteListenAsync(UUID)
      • remoteListenAsync

        public <T extends EventIgniteFuture<UUID> remoteListenAsync​(int bufSize,
                                                                      long interval,
                                                                      boolean autoUnsubscribe,
                                                                      @Nullable
                                                                      @Nullable IgniteBiPredicate<UUID,​T> locLsnr,
                                                                      @Nullable
                                                                      @Nullable IgnitePredicate<T> rmtFilter,
                                                                      @Nullable
                                                                      @org.jetbrains.annotations.Nullable int... types)
                                                               throws IgniteException
        Asynchronously adds event listener for specified events to all nodes in the cluster group (possibly including local node if it belongs to the cluster group as well). This means that all events occurring on any node within this cluster group that pass remote filter will be sent to local node for local listener notification.
        Specified by:
        remoteListenAsync in interface IgniteEvents
        Type Parameters:
        T - Type of the event.
        Parameters:
        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 IgniteEvents.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 cluster group. If null, this events will be handled on remote nodes by passed in rmtFilter until local node stops (if 'autoUnsubscribe' is true) or until IgniteEvents.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.
        Returns:
        a Future representing pending completion of the operation. The completed future contains Operation ID that can be passed to IgniteEvents.stopRemoteListen(UUID) or IgniteEvents.stopRemoteListen(UUID) methods to stop listening.
        Throws:
        IgniteException - If failed to add listener.
        See Also:
        IgniteEvents.stopRemoteListen(UUID), IgniteEvents.stopRemoteListenAsync(UUID)
      • waitForLocal

        public <T extends Event> T waitForLocal​(@Nullable
                                                @Nullable IgnitePredicate<T> filter,
                                                @Nullable
                                                @org.jetbrains.annotations.Nullable int... types)
        Waits for the specified events.

        Supports asynchronous execution (see IgniteAsyncSupport).

        Specified by:
        waitForLocal in interface IgniteEvents
        Type Parameters:
        T - Type of the result event instance.
        Parameters:
        filter - 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.
        Returns:
        Grid event.
      • waitForLocalAsync

        public <T extends EventIgniteFuture<T> waitForLocalAsync​(@Nullable
                                                                   @Nullable IgnitePredicate<T> filter,
                                                                   @Nullable
                                                                   @org.jetbrains.annotations.Nullable int... types)
                                                            throws IgniteException
        Create future to wait for the specified events.
        Specified by:
        waitForLocalAsync in interface IgniteEvents
        Type Parameters:
        T - type of the result event instance.
        Parameters:
        filter - 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.
        Returns:
        a Future representing pending completion of the operation. The completed future contains grid event.
        Throws:
        IgniteException - If wait was interrupted.
      • localQuery

        public <T extends EventCollection<T> localQuery​(IgnitePredicate<T> p,
                                                          @Nullable
                                                          @org.jetbrains.annotations.Nullable int... types)
        Queries local node for events using passed-in predicate filter for event selection.
        Specified by:
        localQuery in interface IgniteEvents
        Type Parameters:
        T - Type of the result events.
        Parameters:
        p - Predicate to filter events. All predicates must be satisfied for the event to be returned.
        types - Event types to be queried.
        Returns:
        Collection of grid events found on local node.
      • recordLocal

        public void recordLocal​(Event evt)
        Records customer user generated event. All registered local listeners will be notified.

        NOTE: all types in range from 1 to 1000 are reserved for internal Ignite events and should not be used by user-defined events. Attempt to record internal event with this method will cause IllegalArgumentException to be thrown.

        Specified by:
        recordLocal in interface IgniteEvents
        Parameters:
        evt - Locally generated event.
      • localListen

        public void localListen​(IgnitePredicate<? extends Event> lsnr,
                                int[] types)
        Adds an event listener for local events. Note that listener will be added regardless of whether local node is in this cluster group or not.
        Specified by:
        localListen in interface IgniteEvents
        Parameters:
        lsnr - 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.
      • stopLocalListen

        public boolean stopLocalListen​(IgnitePredicate<? extends Event> lsnr,
                                       @Nullable
                                       @org.jetbrains.annotations.Nullable int... types)
        Removes local event listener.
        Specified by:
        stopLocalListen in interface IgniteEvents
        Parameters:
        lsnr - 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.
        Returns:
        true if listener was removed, false otherwise.
      • enableLocal

        public void enableLocal​(int[] types)
        Enables provided events. Allows to start recording events that were disabled before. Note that specified events will be enabled regardless of whether local node is in this cluster group or not.
        Specified by:
        enableLocal in interface IgniteEvents
        Parameters:
        types - Events to enable.
      • disableLocal

        public void disableLocal​(int[] types)
        Disables provided events. Allows to stop recording events that were enabled before. Note that specified events will be disabled regardless of whether local node is in this cluster group or not.
        Specified by:
        disableLocal in interface IgniteEvents
        Parameters:
        types - Events to disable.
      • enabledEvents

        public int[] enabledEvents()
        Gets types of enabled events.
        Specified by:
        enabledEvents in interface IgniteEvents
        Returns:
        Types of enabled events.
      • isEnabled

        public boolean isEnabled​(int type)
        Check if event is enabled.
        Specified by:
        isEnabled in interface IgniteEvents
        Parameters:
        type - Event type.
        Returns:
        True if event of passed in type is enabled.