GridGain™ 2.1.0
Java API Specification

org.gridgain.grid.spi.eventstorage.memory
Class GridMemoryEventStorageSpi

java.lang.Object
  extended by org.gridgain.grid.spi.GridSpiAdapter
      extended by org.gridgain.grid.spi.eventstorage.memory.GridMemoryEventStorageSpi
All Implemented Interfaces:
GridEventStorageSpi, GridMemoryEventStorageSpiMBean, GridSpi, GridSpiManagementMBean

@GridSpiInfo(author="GridGain Systems",
             url="www.gridgain.org",
             email="support@gridgain.com",
             version="x.x")
@GridSpiMultipleInstancesSupport(value=true)
public class GridMemoryEventStorageSpi
extends GridSpiAdapter
implements GridEventStorageSpi, GridMemoryEventStorageSpiMBean

In-memory GridEventStorageSpi implementation. All events are kept in the FIFO queue. If no configuration is provided a default expiration GridMemoryEventStorageSpi.DFLT_EXPIRE_AGE_MS and default count GridMemoryEventStorageSpi.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

GridMemoryEventStorageSpi 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.
 GridMemoryEventStorageSpispi = new GridMemoryEventStorageSpi();
 
 // Init own events size.
 spi.setExpireCount(2000);
 
 GridConfigurationAdapter cfg = new GridConfigurationAdapter();
 
 // Override default event storage SPI.
 cfg.setEventStorageSpi(spi);
 
 // Start grid.
 GridFactory.start(cfg); 
 

Spring Example

GridMemoryEventStorageSpi can be configured from Spring XML configuration file:
 <bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfigurationAdapter" singleton="true">
         ...
         <property name="discoverySpi">
             <bean class="org.gridgain.grid.spi.eventstorage.memory.GridMemoryEventStorageSpi">
                 <property name="expireCount" value="2000"/>
             </bean>
         </property>
         ...
 </bean>
 


For information about Spring framework visit www.springframework.org



See Also:

  Documentation
  Email Support
  Online Forums
  Issue Tracking

Author:   2005-2008 Copyright © GridGain Systems. All Rights Reserved. ver. 2.1.0

See Also:
GridEventStorageSpi
 

Field Summary
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).
 
Constructor Summary
GridMemoryEventStorageSpi()
           
 
Method Summary
 void clearAll()
          Removes all events from the event queue.
 long getExpireAgeMs()
          Gets event time-to-live value.
 long getExpireCount()
          Gets maximum event queue size.
 List<GridEvent> queryLocalEvents(GridEventFilter filter)
          Queries locally-stored events only.
 void record(GridEvent evt)
          Records single event.
 void setExpireAgeMs(long expireAgeMs)
          Sets events expiration time.
 void setExpireCount(long expireCnt)
          Sets events queue size.
 void spiStart(String gridName)
          This method is called to start SPI.
 void spiStop()
          This method is called to stop SPI.
 String toString()
          
 
Methods inherited from class org.gridgain.grid.spi.GridSpiAdapter
assertParameter, configInfo, createSpiAttributeName, getAuthor, getConsistentAttributeNames, getGridGainHome, getLocalNodeId, getName, getNodeAttributes, getSpiContext, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted, getVendorEmail, getVendorUrl, getVersion, onContextDestroyed, onContextInitialized, registerMBean, setName, setSpiContext, 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.gridgain.grid.spi.GridSpi
getName, getNodeAttributes, onContextDestroyed, onContextInitialized
 
Methods inherited from interface org.gridgain.grid.spi.GridSpiManagementMBean
getAuthor, getGridGainHome, getLocalNodeId, getName, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted, getVendorEmail, getVendorUrl, getVersion
 

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

GridMemoryEventStorageSpi

public GridMemoryEventStorageSpi()
Method Detail

spiStart

public void spiStart(String gridName)
              throws GridSpiException
This method is called to start SPI. After this method returns successfully kernel assumes that SPI is fully operational.

Specified by:
spiStart in interface GridSpi
Throws:
GridSpiException - Throws in case of any error during SPI start.
Parameters:
gridName - Name of grid instance this SPI is being started for (null for default grid).

spiStop

public void spiStop()
             throws GridSpiException
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 GridSpi
Throws:
GridSpiException - Thrown in case of any error during SPI stop.

setExpireAgeMs

@GridSpiConfiguration(optional=true)
public void 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 GridMemoryEventStorageSpi.DFLT_EXPIRE_AGE_MS.

Parameters:
expireAgeMs - Expiration time in milliseconds.

setExpireCount

@GridSpiConfiguration(optional=true)
public void setExpireCount(long expireCnt)
Sets events queue size. Events will be filtered out when new request comes.

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

Parameters:
expireCnt - Maximum queue size.

getExpireAgeMs

public long getExpireAgeMs()
Gets event time-to-live value. Implementation must guarantee that event would not be accessible if its lifetime exceeds this value.

Specified by:
getExpireAgeMs in interface GridMemoryEventStorageSpiMBean
Returns:
Event time-to-live.

getExpireCount

public long getExpireCount()
Gets maximum event queue size. New incoming events will oust oldest ones if queue size exceeds this limit.

Specified by:
getExpireCount in interface GridMemoryEventStorageSpiMBean
Returns:
Maximum event queue size.

clearAll

public void clearAll()
Removes all events from the event queue.

Specified by:
clearAll in interface GridMemoryEventStorageSpiMBean

queryLocalEvents

public List<GridEvent> queryLocalEvents(GridEventFilter filter)
Queries locally-stored events only. Events could be filtered out by given filter.

Specified by:
queryLocalEvents in interface GridEventStorageSpi
Parameters:
filter - Event filter or null to use no filter and return all events.
Returns:
Collection of events.

record

public void record(GridEvent evt)
            throws GridSpiException
Records single event.

Specified by:
record in interface GridEventStorageSpi
Throws:
GridSpiException - If event recording failed for any reason.
Parameters:
evt - Event that should be recorded.

toString

public String toString()

Overrides:
toString in class Object

GridGain™ 2.1.0
Java API Specification

GridGain™ - Grid Computing Made Simple, ver. 2.1.0.19122008
2005-2008 Copyright © GridGain Systems. All Rights Reserved.