GridGain™ 2.1.0
Java API Specification

org.gridgain.grid.spi.discovery.mail
Class GridMailDiscoverySpi

java.lang.Object
  extended by org.gridgain.grid.spi.GridSpiAdapter
      extended by org.gridgain.grid.spi.discovery.mail.GridMailDiscoverySpi
All Implemented Interfaces:
GridDiscoverySpi, GridMailDiscoverySpiMBean, GridSpi, GridSpiManagementMBean

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

Email implementation of GridDiscoverySpi. Email discovery is provided for cases where nodes from different networks need to participate in a grid. When working with email discovery, make sure that maximum send/receive limit set by mail server is not exceeded. Sometimes it is better to configure your own mail server to avoid such limitations.

Configuration

Mandatory

The following configuration parameters are mandatory:

Optional

The following configuration parameters are optional.

Java Example

GridMailDiscoverySpi needs to be explicitly configured to override default Multicast discovery SPI.
 GridMailDiscoverySpi spi = new GridMailDiscoverySpi();

 // Inbox configuration.
 spi.setInHost("pop.google.com");

 // Outbox configuration.
 spi.setOutHost("smtp.google.com");

 // Incoming/outgoing e-mail address configuration.
 spi.setFromAddress("grid@google.com");

 // Broadcast address.
 spi.setBroadcastAddress("grid-broadcast@google.com")

 GridConfigurationAdapter cfg = new GridConfigurationAdapter();

 // Override default discovery SPI.
 cfg.setDiscoverySpi(spi);

 // Start grid.
 GridFactory.start(cfg);
 

Spring Example

GridMailDiscoverySpi 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.discovery.mail.GridMailDiscoverySpi">
                 <property name="outHost" value="smtp.google.com"/>
                 <property name="inHost" value="pop.google.com"/>
                 <property name="fromAddress" value="grid@google.com"/>
                 <property name="broadcastAddress" value="grid-broadcast@google.com"/>
             </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:
GridDiscoverySpi
 

Field Summary
static long DFLT_HEARTBEAT_FREQ
          Default heartbeat delay (value is 60000).
static long DFLT_LEAVE_MSGS_ON_SERVER
          Leave messages on server in milliseconds (value is (GridMailDiscoverySpi.DFLT_MAX_MISSED_HEARTBEATS + 2) * GridMailDiscoverySpi.DFLT_HEARTBEAT_FREQ).
static String DFLT_MAIL_SUBJECT
          Default subject of email (value is grid.email.discovery.msg).
static int DFLT_MAX_MISSED_HEARTBEATS
          Default number of heartbeat messages that could be missed (value is 3).
static long DFLT_PING_WAIT
          Default ping wait timeout (value is GridMailDiscoverySpi.DFLT_RECEIVER_DELAY * 2).
static long DFLT_RECEIVER_DELAY
          Delay in milliseconds between receiving email (value is 30000).
static String DFLT_STORE_FILE_NAME
          Default local storage file name (value is grid-email-discovery-msgs.dat).
 
Constructor Summary
GridMailDiscoverySpi()
          Creates discovery SPI.
 
Method Summary
 String getBroadcastAddress()
          Gets broadcast address used for sending broadcast messages.
protected  List<String> getConsistentAttributeNames()
          Returns back list of attributes that should be consistent for this SPI.
 String getFolderName()
          Gets folder name for incoming mail.
 String getFromAddress()
          Gets message field 'From' all email messages.
 long getHeartbeatFrequency()
          Gets delay between heartbeat requests.
 String getInConnectionTypeFormatted()
          Gets type of ingoing mail connection.
 Properties getInCustomProperties()
          Gets custom properties required for receiving connection.
 String getInHost()
          Gets incoming host name for receiving email.
 int getInPort()
          Gets port number for incoming mail.
 String getInProtocolFormatted()
          Gets incoming mail protocol.
 String getInUsername()
          Gets username for incoming mail authentication.
 long getLeaveMessagesOnServer()
          Gets incoming messages life-time on mail server in milliseconds.
 GridNode getLocalNode()
          Gets local node.
 long getMaximumMissedHeartbeats()
          Gets number of heartbeat requests that could be missed before remote node is considered to be failed.
 GridNode getNode(UUID nodeId)
          Gets node by ID.
 Map<String,Serializable> getNodeAttributes()
          This method is called before SPI starts (before method GridSpi.spiStart(String) is called). It allows SPI implementation to add attributes to a local node. Kernel collects these attributes from all SPI implementations loaded up and then passes it to discovery SPI so that they can be exchanged with other nodes.
 String getOutConnectionTypeFormatted()
          Gets type of outgoing mail connection.
 Properties getOutCustomProperties()
          Gets custom properties required for outgoing connection.
 String getOutHost()
          Gets outgoing host name for sending email.
 int getOutPort()
          Gets port number for outgoing mail.
 String getOutProtocolFormatted()
          Gets outgoing mail protocol.
 String getOutUsername()
          Gets username for outgoing mail authentication.
 long getPingResponseWait()
          Gets ping wait timeout in milliseconds.
 int getReadBatchSize()
          Gets number of messages fetched from mail server at a time.
 long getReceiverDelay()
          Gets interval in milliseconds between checking for new messages.
 int getRemoteNodeCount()
          Gets the number of remote nodes.
 Collection<UUID> getRemoteNodeIds()
          Gets collection of remote nodes' IDs.
 List<GridNode> getRemoteNodes()
          Gets collection of remote nodes in grid or empty collection if no remote nodes found.
 String getStoreFileName()
          Gets locally stored full file name for all read messages.
 String getSubject()
          Gets email message subject.
 boolean pingNode(UUID nodeId)
          Pings the remote node to see if it's alive.
 void setBroadcastAddress(String bcastAddr)
          Sets broadcast email address used by node to discover each other.
 void setFolderName(String folderName)
          Sets name of email folder on mail server.
 void setFromAddress(String addr)
          Sets 'From' address for all email messages.
 void setHeartbeatFrequency(long beatFreq)
          Sets delay between heartbeat requests.
 void setInConnectionType(GridMailDiscoveryType type)
          Sets type of incoming mail connection which should be one of the following: GridMailDiscoveryType.NONE GridMailDiscoveryType.SSL GridMailDiscoveryType.STARTTLS If not provided the default value is GridMailDiscoveryType.NONE.
 void setInCustomProperties(Properties props)
          Sets any custom properties required for receiving connection.
 void setInHost(String host)
          Sets incoming host name for receiving email messages (usually either POP or IMAP).
 void setInPassword(String pswd)
          Sets password for incoming mail authentication.
 void setInPort(int port)
          Sets port number for incoming mail.
 void setInProtocol(GridMailDiscoveryInProtocol proto)
          Sets incoming mail protocol.
 void setInUsername(String username)
          Sets username for incoming mail authentication.
 void setLeaveMessagesOnServer(long leaveMsgsOnServer)
          Sets incoming messages life-time on mail server in milliseconds.
 void setListener(GridDiscoveryListener listener)
          Sets a listener for discovery events.
 void setMaxMissedHeartbeats(long maxMissedBeats)
          Sets number of heartbeat requests that could be missed before remote node is considered to be failed.
 void setMetricsProvider(GridDiscoveryMetricsProvider metricsProvider)
          Sets discovery metrics provider.
 void setNodeAttributes(Map<String,Serializable> attrs)
          Sets node attributes which will be distributed in grid during join process.
 void setOutConnectionType(GridMailDiscoveryType type)
          Sets type of outgoing mail connection which should be one of the following: GridMailDiscoveryType.NONE GridMailDiscoveryType.SSL GridMailDiscoveryType.STARTTLS If not provided the default value is GridMailDiscoveryType.NONE.
 void setOutCustomProperties(Properties props)
          Sets any custom properties required for outgoing connection.
 void setOutHost(String host)
          Sets outgoing host name for sending email messages (usually either SMTP or IMAP).
 void setOutPassword(String pswd)
          Sets password for outgoing mail authentication.
 void setOutPort(int port)
          Sets port number for outgoing mail.
 void setOutProtocol(GridMailDiscoveryOutProtocol proto)
          Sets outgoing mail protocol.
 void setOutUsername(String username)
          Sets username for outgoing mail authentication.
 void setPingResponseWait(long pingWait)
          Sets ping node wait timeout in milliseconds.
 void setReadBatchSize(int readBatchSize)
          Sets number of messages fetched from mail server at a time.
 void setReceiverDelay(long recvDelay)
          Sets interval in milliseconds between checking for new messages.
 void setStoreFileName(String fileName)
          Sets locally stored full file name for all read messages.
 void setSubject(String subj)
          Sets email message subject.
 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, getGridGainHome, getLocalNodeId, getName, 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, 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_HEARTBEAT_FREQ

public static final long DFLT_HEARTBEAT_FREQ
Default heartbeat delay (value is 60000).

See Also:
Constant Field Values

DFLT_RECEIVER_DELAY

public static final long DFLT_RECEIVER_DELAY
Delay in milliseconds between receiving email (value is 30000).

See Also:
Constant Field Values

DFLT_PING_WAIT

public static final long DFLT_PING_WAIT
Default ping wait timeout (value is GridMailDiscoverySpi.DFLT_RECEIVER_DELAY * 2).

See Also:
Constant Field Values

DFLT_MAX_MISSED_HEARTBEATS

public static final int DFLT_MAX_MISSED_HEARTBEATS
Default number of heartbeat messages that could be missed (value is 3).

See Also:
Constant Field Values

DFLT_LEAVE_MSGS_ON_SERVER

public static final long DFLT_LEAVE_MSGS_ON_SERVER
Leave messages on server in milliseconds (value is (GridMailDiscoverySpi.DFLT_MAX_MISSED_HEARTBEATS + 2) * GridMailDiscoverySpi.DFLT_HEARTBEAT_FREQ).

See Also:
Constant Field Values

DFLT_MAIL_SUBJECT

public static final String DFLT_MAIL_SUBJECT
Default subject of email (value is grid.email.discovery.msg).

See Also:
Constant Field Values

DFLT_STORE_FILE_NAME

public static final String DFLT_STORE_FILE_NAME
Default local storage file name (value is grid-email-discovery-msgs.dat).

See Also:
Constant Field Values
Constructor Detail

GridMailDiscoverySpi

public GridMailDiscoverySpi()
Creates discovery SPI.

Method Detail

getHeartbeatFrequency

public long getHeartbeatFrequency()
Gets delay between heartbeat requests. SPI sends broadcast messages in configurable time interval to another nodes to notify them about node state.

Specified by:
getHeartbeatFrequency in interface GridMailDiscoverySpiMBean
Returns:
Time period in milliseconds.

setHeartbeatFrequency

@GridSpiConfiguration(optional=true)
public void setHeartbeatFrequency(long beatFreq)
Sets delay between heartbeat requests. SPI sends broadcast messages in configurable time interval to other nodes to notify them about its state.

If not provided the default value is GridMailDiscoverySpi.DFLT_HEARTBEAT_FREQ.

Parameters:
beatFreq - Time in milliseconds.

getReceiverDelay

public long getReceiverDelay()
Gets interval in milliseconds between checking for new messages.

Specified by:
getReceiverDelay in interface GridMailDiscoverySpiMBean
Returns:
Time period in milliseconds.

setReceiverDelay

@GridSpiConfiguration(optional=true)
public void setReceiverDelay(long recvDelay)
Sets interval in milliseconds between checking for new messages.

If not provided the default value is GridMailDiscoverySpi.DFLT_RECEIVER_DELAY.

Parameters:
recvDelay - Interval between receiving messages.

getPingResponseWait

public long getPingResponseWait()
Gets ping wait timeout in milliseconds.

Specified by:
getPingResponseWait in interface GridMailDiscoverySpiMBean
Returns:
Ping wait timeout in milliseconds

setPingResponseWait

@GridSpiConfiguration(optional=true)
public void setPingResponseWait(long pingWait)
Sets ping node wait timeout in milliseconds.

If not provided the default value is GridMailDiscoverySpi.DFLT_PING_WAIT.

Parameters:
pingWait - Timeout in milliseconds.

getLocalNode

public GridNode getLocalNode()
Gets local node.

Specified by:
getLocalNode in interface GridDiscoverySpi
Returns:
Local node.

getMaximumMissedHeartbeats

public long getMaximumMissedHeartbeats()
Gets number of heartbeat requests that could be missed before remote node is considered to be failed.

Specified by:
getMaximumMissedHeartbeats in interface GridMailDiscoverySpiMBean
Returns:
Number of requests.

setMaxMissedHeartbeats

@GridSpiConfiguration(optional=true)
public void setMaxMissedHeartbeats(long maxMissedBeats)
Sets number of heartbeat requests that could be missed before remote node is considered to be failed.

If not provided the default value is GridMailDiscoverySpi.DFLT_MAX_MISSED_HEARTBEATS.

Parameters:
maxMissedBeats - Number of missed requests.

getLeaveMessagesOnServer

public long getLeaveMessagesOnServer()
Gets incoming messages life-time on mail server in milliseconds.

Specified by:
getLeaveMessagesOnServer in interface GridMailDiscoverySpiMBean
Returns:
Time to live for incoming messages.

setLeaveMessagesOnServer

@GridSpiConfiguration(optional=true)
public void setLeaveMessagesOnServer(long leaveMsgsOnServer)
Sets incoming messages life-time on mail server in milliseconds.

If not provided the default value is GridMailDiscoverySpi.DFLT_LEAVE_MSGS_ON_SERVER.

Parameters:
leaveMsgsOnServer - Time to live for incoming messages.

getOutConnectionTypeFormatted

public String getOutConnectionTypeFormatted()
Gets type of outgoing mail connection. It should be one of the following:

Specified by:
getOutConnectionTypeFormatted in interface GridMailDiscoverySpiMBean
Returns:
Connection type.

setOutConnectionType

@GridSpiConfiguration(optional=true)
public void setOutConnectionType(GridMailDiscoveryType type)
Sets type of outgoing mail connection which should be one of the following:

If not provided the default value is GridMailDiscoveryType.NONE.

Parameters:
type - Connection type.

getOutProtocolFormatted

public String getOutProtocolFormatted()
Gets outgoing mail protocol. Could be one of the following:

Specified by:
getOutProtocolFormatted in interface