org.apache.ignite.events

## Class DiscoveryEvent

- java.lang.Object
- - org.apache.ignite.events.EventAdapter
  - - org.apache.ignite.events.DiscoveryEvent

- All Implemented Interfaces:
    Serializable, Comparable<Event>, Event

      public class DiscoveryEvent
      extends EventAdapter

  Grid discovery event.

  Grid events are used for notification about what happens within the grid. Note that by design Ignite keeps all events generated on the local node locally and it provides APIs for performing a distributed queries across multiple nodes:

  - `IgniteEvents.remoteQuery(org.apache.ignite.lang.IgnitePredicate, long, int...)` - asynchronously querying events occurred on the nodes specified, including remote nodes.
  - `IgniteEvents.localQuery(org.apache.ignite.lang.IgnitePredicate, int...)` - querying only local events stored on this local node.
  - `IgniteEvents.localListen(org.apache.ignite.lang.IgnitePredicate, int...)` - listening to local grid events (events from remote nodes not included).
  User can also wait for events using method `IgniteEvents.waitForLocal(org.apache.ignite.lang.IgnitePredicate, int...)`.

  # Events and Performance

  Note that by default all events in Ignite are enabled and therefore generated and stored by whatever event storage SPI is configured. Ignite can and often does generate thousands events per seconds under the load and therefore it creates a significant additional load on the system. If these events are not needed by the application this load is unnecessary and leads to significant performance degradation.

  It is highly recommended to enable only those events that your application logic requires by using `IgniteConfiguration.getIncludeEventTypes()` method in Ignite configuration. Note that certain events are required for Ignite's internal operations and such events will still be generated but not stored by event storage SPI if they are disabled in Ignite configuration.

  See Also:
    `EventType.EVT_NODE_METRICS_UPDATED`, `EventType.EVT_NODE_FAILED`, `EventType.EVT_NODE_JOINED`, `EventType.EVT_NODE_LEFT`, `EventType.EVT_NODE_SEGMENTED`, `EventType.EVTS_DISCOVERY_ALL`, `EventType.EVTS_DISCOVERY`, Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DiscoveryEvent()` No-arg constructor.
    `DiscoveryEvent(ClusterNode node, String msg, int type, ClusterNode evtNode)` Creates new discovery event with given parameters.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `ClusterNode` | `eventNode()` Gets node that caused this event to be generated.
    `void` | `eventNode(ClusterNode evtNode)` Sets node this event is referring to.
    `@Nullable String` | `message()` Gets optional message for this event.
    `void` | `messageTemplate(String msgTemplate)` Template to generate `message()` lazily.
    `String` | `shortDisplay()` Gets a shortened version of `toString()` result.
    `org.apache.ignite.internal.processors.tracing.Span` | `span()` Gets span instance.
    `void` | `span(org.apache.ignite.internal.processors.tracing.Span span)` Set span.
    `Collection<ClusterNode>` | `topologyNodes()` Gets topology nodes from topology snapshot.
    `void` | `topologySnapshot(long topVer, Collection<ClusterNode> topSnapshot)` Sets the topology snapshot.
    `long` | `topologyVersion()` Gets topology version if this event is raised on topology change and configured discovery SPI implementation supports topology versioning.
    `String` | `toString()`

    - ### Methods inherited from class org.apache.ignite.events.EventAdapter

      `compareTo, equals, hashCode, id, localOrder, message, name, node, node, timestamp, type, type`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### DiscoveryEvent

          public DiscoveryEvent()

      No-arg constructor.

    - #### DiscoveryEvent

          public DiscoveryEvent(ClusterNode node,
                                String msg,
                                int type,
                                ClusterNode evtNode)

      Creates new discovery event with given parameters.
      Parameters:
        `node` - Local node.
        `msg` - Optional event message.
        `type` - Event type.
        `evtNode` - Node that caused this event to be generated.

  - ### Method Detail

    - #### shortDisplay

          public String shortDisplay()

      Gets a shortened version of `toString()` result. Suitable for humans to read.
      Specified by:
        `shortDisplay` in interface `Event`
      Overrides:
        `shortDisplay` in class `EventAdapter`
      Returns:
        Shortened version of `toString()` result.

    - #### eventNode

          public void eventNode(ClusterNode evtNode)

      Sets node this event is referring to.
      Parameters:
        `evtNode` - Event node.

    - #### eventNode

          public ClusterNode eventNode()

      Gets node that caused this event to be generated. It is potentially different from the node on which this event was recorded. For example, node `A` locally recorded the event that a remote node `B` joined the topology. In this case this method will return node `B`.
      Returns:
        Event node.

    - #### topologyVersion

          public long topologyVersion()

      Gets topology version if this event is raised on topology change and configured discovery SPI implementation supports topology versioning.
      Returns:
        Topology version or `0` if configured discovery SPI implementation does not support versioning.

    - #### topologyNodes

          public Collection<ClusterNode> topologyNodes()

      Gets topology nodes from topology snapshot. If SPI implementation does not support versioning, the best effort snapshot will be captured.
      Returns:
        Topology snapshot.

    - #### topologySnapshot

          public void topologySnapshot(long topVer,
                                       Collection<ClusterNode> topSnapshot)

      Sets the topology snapshot.
      Parameters:
        `topVer` - Topology version.
        `topSnapshot` - Topology snapshot.

    - #### messageTemplate

          public void messageTemplate(String msgTemplate)

      Template to generate `message()` lazily. Will be joined with `eventNode()` converted to string.
      Parameters:
        `msgTemplate` - Template.

    - #### message

          @Nullable
          public @Nullable String message()

      Gets optional message for this event.
      Specified by:
        `message` in interface `Event`
      Overrides:
        `message` in class `EventAdapter`
      Returns:
        Optional (can be `null`) message for this event.

    - #### span

          public org.apache.ignite.internal.processors.tracing.Span span()

      Gets span instance.
      Returns:
        Span.

    - #### span

          public void span(org.apache.ignite.internal.processors.tracing.Span span)

      Set span.
      Parameters:
        `span` - Span.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `EventAdapter`

2022 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.13.0
Release Date | : April 20 2022