Class MemoryEventStorageSpi

  • All Implemented Interfaces:
    EventStorageSpi, IgniteSpi

    @IgniteSpiMultipleInstancesSupport(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:

    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 Detail

      • 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.
      • 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()
        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()
        Returns:
        Maximum event queue size.
      • 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 EventCollection<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.