org.apache.ignite.spi.eventstorage.memory

## Class MemoryEventStorageSpi

- java.lang.Object
- - org.apache.ignite.spi.IgniteSpiAdapter
  - - org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi

- All Implemented Interfaces:
    EventStorageSpi, IgniteSpi

      @IgniteSpiMultipleInstancesSupport(value=true)
      public class MemoryEventStorageSpi
      extends IgniteSpiAdapter
      implements EventStorageSpi

  In-memory `EventStorageSpi` implementation. All events are kept in the FIFO queue. If no configuration is provided a default expiration `DFLT_EXPIRE_AGE_MS` and default count `DFLT_EXPIRE_COUNT` will be used.

  It's recommended not to set huge size and unlimited TTL because this might lead to consuming a lot of memory and result in `OutOfMemoryError`. Both event expiration time and maximum queue size could be changed at runtime.

  # Configuration

  ## Mandatory

  This SPI has no mandatory configuration parameters.

  ## Optional

  The following configuration parameters are optional:
  - Event queue size (see `setExpireCount(long)`)
  - Event time-to-live value (see `setExpireAgeMs(long)`)
  - `setFilter(org.apache.ignite.lang.IgnitePredicate)` - Event filter that should be used for decision to accept event.

  ## Java Example

  MemoryEventStorageSpi is used by default and should be explicitly configured only if some SPI configuration parameters need to be overridden. Examples below insert own events queue size value that differs from default 10000.

       MemoryEventStorageSpi = new MemoryEventStorageSpi();

       // Init own events size.
       spi.setExpireCount(2000);

       IgniteConfiguration cfg = new IgniteConfiguration();

       // Override default event storage SPI.
       cfg.setEventStorageSpi(spi);

       // Starts grid.
       G.start(cfg);

  ## Spring Example

  MemoryEventStorageSpi can be configured from Spring XML configuration file:

       <bean id="grid.custom.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" singleton="true">
               ...
               <property name="eventStorageSpi">
                   <bean class="org.apache.ignite.spi.eventStorage.memory.MemoryEventStorageSpi">
                       <property name="expireCount" value="2000"/>
                   </bean>
               </property>
               ...
       </bean>

  For information about Spring framework visit www.springframework.org

  See Also:
    `EventStorageSpi`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static long` | `DFLT_EXPIRE_AGE_MS` Default event time to live value in milliseconds (value is `Long.MAX_VALUE`).
    `static int` | `DFLT_EXPIRE_COUNT` Default expire count (value is `10000`).

    - ### Fields inherited from class org.apache.ignite.spi.IgniteSpiAdapter

      `ignite, igniteInstanceName`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MemoryEventStorageSpi()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clearAll()` Removes all events from the event queue.
    `long` | `getExpireAgeMs()` See `setExpireAgeMs(long)`
    `long` | `getExpireCount()` See `setExpireCount(long)`
    `IgnitePredicate<Event>` | `getFilter()` Gets filter for events to be recorded.
    `long` | `getQueueSize()` Gets current queue size of the event queue.
    `<T extends Event> Collection<T>` | `localEvents(IgnitePredicate<T> p)` Queries locally-stored events only.
    `void` | `record(Event evt)` Records single event.
    `MemoryEventStorageSpi` | `setExpireAgeMs(long expireAgeMs)` Sets events expiration time.
    `MemoryEventStorageSpi` | `setExpireCount(long expireCnt)` Sets events queue size.
    `MemoryEventStorageSpi` | `setFilter(IgnitePredicate<Event> filter)` Sets filter for events to be recorded.
    `MemoryEventStorageSpi` | `setName(String name)` Sets SPI name.
    `void` | `spiStart(String igniteInstanceName)` This method is called to start SPI.
    `void` | `spiStop()` This method is called to stop SPI.
    `String` | `toString()`

    - ### Methods inherited from class org.apache.ignite.spi.IgniteSpiAdapter

      `addTimeoutObject, assertParameter, checkConfigurationConsistency0, clientFailureDetectionTimeout, configInfo, createSpiAttributeName, failureDetectionTimeout, failureDetectionTimeoutEnabled, failureDetectionTimeoutEnabled, getConsistentAttributeNames, getExceptionRegistry, getLocalNode, getName, getNodeAttributes, getSpiContext, ignite, initFailureDetectionTimeout, injectables, injectResources, isNodeStopping, onBeforeStart, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextDestroyed0, onContextInitialized, onContextInitialized0, registerMBean, removeTimeoutObject, started, startInfo, startStopwatch, stopInfo, unregisterMBean`

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

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

    - ### Methods inherited from interface org.apache.ignite.spi.IgniteSpi

      `getName, getNodeAttributes, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextInitialized`

- - ### Field Detail

    - #### DFLT_EXPIRE_AGE_MS

          public static final long DFLT_EXPIRE_AGE_MS

      Default event time to live value in milliseconds (value is `Long.MAX_VALUE`).
      See Also:
        Constant Field Values

    - #### DFLT_EXPIRE_COUNT

          public static final int DFLT_EXPIRE_COUNT

      Default expire count (value is `10000`).
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### MemoryEventStorageSpi

          public MemoryEventStorageSpi()

  - ### Method Detail

    - #### getFilter

          public IgnitePredicate<Event> getFilter()

      Gets filter for events to be recorded.
      Returns:
        Filter to use.

    - #### setFilter

          @IgniteSpiConfiguration(optional=true)
          public MemoryEventStorageSpi setFilter(IgnitePredicate<Event> filter)

      Sets filter for events to be recorded.
      Parameters:
        `filter` - Filter to use.
      Returns:
        `this` for chaining.

    - #### spiStart

          public void spiStart(String igniteInstanceName)
                        throws IgniteSpiException

      This method is called to start SPI. After this method returns successfully kernel assumes that SPI is fully operational.
      Specified by:
        `spiStart` in interface `IgniteSpi`
      Parameters:
        `igniteInstanceName` - Name of Ignite instance this SPI is being started for (`null` for default Ignite instance).
      Throws:
        `IgniteSpiException` - Throws in case of any error during SPI start.

    - #### spiStop

          public void spiStop()
                       throws IgniteSpiException

      This method is called to stop SPI. After this method returns kernel assumes that this SPI is finished and all resources acquired by it are released.

      Note that this method can be called at any point including during recovery of failed start. It should make no assumptions on what state SPI will be in when this method is called.

      Specified by:
        `spiStop` in interface `IgniteSpi`
      Throws:
        `IgniteSpiException` - Thrown in case of any error during SPI stop.

    - #### getExpireAgeMs

          public long getExpireAgeMs()

      See `setExpireAgeMs(long)`
      Returns:
        Event time-to-live.

    - #### setExpireAgeMs

          @IgniteSpiConfiguration(optional=true)
          public MemoryEventStorageSpi setExpireAgeMs(long expireAgeMs)

      Sets events expiration time. All events that exceed this value will be removed from the queue when next event comes.

      If not provided, default value is `DFLT_EXPIRE_AGE_MS`.

      Parameters:
        `expireAgeMs` - Expiration time in milliseconds.
      Returns:
        `this` for chaining.

    - #### getExpireCount

          public long getExpireCount()

      See `setExpireCount(long)`
      Returns:
        Maximum event queue size.

    - #### setExpireCount

          @IgniteSpiConfiguration(optional=true)
          public MemoryEventStorageSpi setExpireCount(long expireCnt)

      Sets events queue size. Events will be filtered out when new request comes.

      If not provided, default value `DFLT_EXPIRE_COUNT` will be used.

      Parameters:
        `expireCnt` - Maximum queue size.
      Returns:
        `this` for chaining.

    - #### getQueueSize

          public long getQueueSize()

      Gets current queue size of the event queue.
      Returns:
        Current queue size of the event queue.

    - #### clearAll

          public void clearAll()

      Removes all events from the event queue.

    - #### localEvents

          public <T extends Event> Collection<T> localEvents(IgnitePredicate<T> p)

      Queries locally-stored events only. Events could be filtered out by given predicate filter.
      Specified by:
        `localEvents` in interface `EventStorageSpi`
      Type Parameters:
        `T` - Type of events.
      Parameters:
        `p` - Event predicate filter.
      Returns:
        Collection of events.

    - #### record

          public void record(Event evt)
                      throws IgniteSpiException

      Records single event.
      Specified by:
        `record` in interface `EventStorageSpi`
      Parameters:
        `evt` - Event that should be recorded.
      Throws:
        `IgniteSpiException` - If event recording failed for any reason.

    - #### setName

          public MemoryEventStorageSpi setName(String name)

      Sets SPI name.
      Overrides:
        `setName` in class `IgniteSpiAdapter`
      Parameters:
        `name` - SPI name.
      Returns:
        `this` for chaining.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

2022 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.12.0
Release Date | : January 10 2022