Package org.apache.ignite.events

## Class CacheRebalancingEvent

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

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

      public class CacheRebalancingEvent
      extends EventAdapter

  In-memory database (cache) rebalancing event. Rebalance event happens every time there is a change in grid topology, which means that a node has either joined or left the grid.

  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(IgnitePredicate, long, int...)` - asynchronously querying events occurred on the nodes specified, including remote nodes.
  - `IgniteEvents.localQuery(IgnitePredicate, int...)` - querying only local events stored on this local node.
  - `IgniteEvents.localListen(IgnitePredicate, int...)` - listening to local grid events (events from remote nodes not included).
  User can also wait for events using method `IgniteEvents.waitForLocal(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_CACHE_REBALANCE_PART_LOADED`, `EventType.EVT_CACHE_REBALANCE_PART_UNLOADED`, `EventType.EVT_CACHE_REBALANCE_STARTED`, `EventType.EVT_CACHE_REBALANCE_STOPPED`, `EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST`, `EventType.EVT_CACHE_REBALANCE_PART_SUPPLIED`, `EventType.EVT_CACHE_REBALANCE_PART_MISSED`, Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `CacheRebalancingEvent​(String cacheName, ClusterNode node, String msg, int type, int part, ClusterNode discoNode, int discoEvtType, long discoTs)` | Constructs cache event.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `String` | `cacheName()` | Gets cache name.
    `String` | `discoveryEventName()` | Gets name of discovery event that triggered this rebalancing event.
    `int` | `discoveryEventType()` | Gets type of discovery event that triggered this rebalancing event.
    `ClusterNode` | `discoveryNode()` | Gets shadow of the node that triggered this rebalancing event.
    `long` | `discoveryTimestamp()` | Gets timestamp of discovery event that caused this rebalancing event.
    `int` | `partition()` | Gets partition for the event.
    `String` | `shortDisplay()` | Gets a shortened version of `toString()` result.
    `String` | `toString()`

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

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

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

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

- - ### Constructor Detail

    - #### CacheRebalancingEvent

          public CacheRebalancingEvent​(String cacheName,
                                       ClusterNode node,
                                       String msg,
                                       int type,
                                       int part,
                                       ClusterNode discoNode,
                                       int discoEvtType,
                                       long discoTs)

      Constructs cache event.
      Parameters:
        `cacheName` - Cache name.
        `node` - Event node.
        `msg` - Event message.
        `type` - Event type.
        `part` - Partition for the event (usually the partition the key belongs to).
        `discoNode` - Node that triggered this rebalancing event.
        `discoEvtType` - Discovery event type that triggered this rebalancing event.
        `discoTs` - Timestamp of discovery event that triggered this rebalancing event.

  - ### Method Detail

    - #### cacheName

          public String cacheName()

      Gets cache name.
      Returns:
        Cache name.

    - #### partition

          public int partition()

      Gets partition for the event.
      Returns:
        Partition for the event.

    - #### discoveryNode

          public ClusterNode discoveryNode()

      Gets shadow of the node that triggered this rebalancing event.
      Returns:
        Shadow of the node that triggered this rebalancing event.

    - #### discoveryEventType

          public int discoveryEventType()

      Gets type of discovery event that triggered this rebalancing event.
      Returns:
        Type of discovery event that triggered this rebalancing event.
      See Also:
        `EventAdapter.type()`

    - #### discoveryEventName

          public String discoveryEventName()

      Gets name of discovery event that triggered this rebalancing event.
      Returns:
        Name of discovery event that triggered this rebalancing event.
      See Also:
        `EventAdapter.name()`

    - #### discoveryTimestamp

          public long discoveryTimestamp()

      Gets timestamp of discovery event that caused this rebalancing event.
      Returns:
        Timestamp of discovery event that caused this rebalancing event.

    - #### 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.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `EventAdapter`