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 GridMailDiscoverySpiMBean
Returns:
Outgoing mail protocol.

setOutProtocol

@GridSpiConfiguration(optional=true)
public void setOutProtocol(GridMailDiscoveryOutProtocol proto)
Sets outgoing mail protocol. Should be one of the following:

If not provided the default value is GridMailDiscoveryOutProtocol.SMTP.

Parameters:
proto - Outgoing mail protocol.

getOutHost

public String getOutHost()
Gets outgoing host name for sending email.

Specified by:
getOutHost in interface GridMailDiscoverySpiMBean
Returns:
Outgoing email host name.

setOutHost

@GridSpiConfiguration(optional=false)
public void setOutHost(String host)
Sets outgoing host name for sending email messages (usually either SMTP or IMAP).

There is no default value for the parameter.

Parameters:
host - Outgoing email host name.

getOutPort

public int getOutPort()
Gets port number for outgoing mail.

Specified by:
getOutPort in interface GridMailDiscoverySpiMBean
Returns:
Outgoing email port number.

setOutPort

@GridSpiConfiguration(optional=true)
public void setOutPort(int port)
Sets port number for outgoing mail.

If not provided the default value is 25.

Parameters:
port - Outgoing email port number.

getOutUsername

public String getOutUsername()
Gets username for outgoing mail authentication.

Specified by:
getOutUsername in interface GridMailDiscoverySpiMBean
Returns:
Outbox username.

setOutUsername

@GridSpiConfiguration(optional=true)
public void setOutUsername(String username)
Sets username for outgoing mail authentication. If provided, then password should also be provided. Username with null value means that no authentication will be used.

If not provided the default value is null.

Parameters:
username - Outbox username.

setOutPassword

@GridSpiConfiguration(optional=true)
public void setOutPassword(String pswd)
Sets password for outgoing mail authentication. If provided, then username should also be provided.

If not provided the default value is null.

Parameters:
pswd - Outbox password.

getInConnectionTypeFormatted

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

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

setInConnectionType

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

If not provided the default value is GridMailDiscoveryType.NONE.

Parameters:
type - Connection type.

getReadBatchSize

public int getReadBatchSize()
Gets number of messages fetched from mail server at a time.

Specified by:
getReadBatchSize in interface GridMailDiscoverySpiMBean
Returns:
Number of fetched messages.

setReadBatchSize

@GridSpiConfiguration(optional=true)
public void setReadBatchSize(int readBatchSize)
Sets number of messages fetched from mail server at a time.

If not provided the default value is 100.

Parameters:
readBatchSize - Number of fetched messages.

getInProtocolFormatted

public String getInProtocolFormatted()
Gets incoming mail protocol. Could be one of the following:

Specified by:
getInProtocolFormatted in interface GridMailDiscoverySpiMBean
Returns:
Incoming protocol.

setInProtocol

@GridSpiConfiguration(optional=true)
public void setInProtocol(GridMailDiscoveryInProtocol proto)
Sets incoming mail protocol. Should be one of the following:

If not provided the default value is GridMailDiscoveryInProtocol.POP3.

Parameters:
proto - Incoming protocol.

getInHost

public String getInHost()
Gets incoming host name for receiving email.

Specified by:
getInHost in interface GridMailDiscoverySpiMBean
Returns:
Incoming email host name.

setInHost

@GridSpiConfiguration(optional=false)
public void setInHost(String host)
Sets incoming host name for receiving email messages (usually either POP or IMAP).

There is no default value.

Parameters:
host - Incoming email host name. There is no default value.

getInPort

public int getInPort()
Gets port number for incoming mail.

Specified by:
getInPort in interface GridMailDiscoverySpiMBean
Returns:
Incoming email port number.

setInPort

@GridSpiConfiguration(optional=true)
public void setInPort(int port)
Sets port number for incoming mail.

If not provided the default value is 110.

Parameters:
port - Incoming email server port number.

getInUsername

public String getInUsername()
Gets username for incoming mail authentication.

Specified by:
getInUsername in interface GridMailDiscoverySpiMBean
Returns:
Inbox username.

setInUsername

@GridSpiConfiguration(optional=true)
public void setInUsername(String username)
Sets username for incoming mail authentication. If provided, then password should also be provided. Username with null value means that no authentication will be used.

If not provided the default value is null.

Parameters:
username - Incoming mailbox username.

setInPassword

@GridSpiConfiguration(optional=true)
public void setInPassword(String pswd)
Sets password for incoming mail authentication. If provided, then username should also be provided.

If not provided the default value is null.

Parameters:
pswd - Incoming mailbox password.

getFolderName

public String getFolderName()
Gets folder name for incoming mail.

Specified by:
getFolderName in interface GridMailDiscoverySpiMBean
Returns:
Incoming email folder name.

setFolderName

@GridSpiConfiguration(optional=true)
public void setFolderName(String folderName)
Sets name of email folder on mail server.

If not provided the default value is Inbox.

Parameters:
folderName - Mail server folder name.

getSubject

public String getSubject()
Gets email message subject.

Specified by:
getSubject in interface GridMailDiscoverySpiMBean
Returns:
Email message subject.

setSubject

@GridSpiConfiguration(optional=true)
public void setSubject(String subj)
Sets email message subject.

If not provided the default value is GridMailDiscoverySpi.DFLT_MAIL_SUBJECT.

Parameters:
subj - Email message subject.

getOutCustomProperties

public Properties getOutCustomProperties()
Gets custom properties required for outgoing connection.

Specified by:
getOutCustomProperties in interface GridMailDiscoverySpiMBean
Returns:
Properties.

setOutCustomProperties

@GridSpiConfiguration(optional=true)
public void setOutCustomProperties(Properties props)
Sets any custom properties required for outgoing connection.

If not provided the default value is null.

Parameters:
props - Custom parameter.

getInCustomProperties

public Properties getInCustomProperties()
Gets custom properties required for receiving connection.

Specified by:
getInCustomProperties in interface GridMailDiscoverySpiMBean
Returns:
Properties.

setInCustomProperties

@GridSpiConfiguration(optional=true)
public void setInCustomProperties(Properties props)
Sets any custom properties required for receiving connection.

If not provided the default value is null.

Parameters:
props - Custom properties.

getFromAddress

public String getFromAddress()
Gets message field 'From' all email messages.

Specified by:
getFromAddress in interface GridMailDiscoverySpiMBean
Returns:
Message field 'From'.

setFromAddress

@GridSpiConfiguration(optional=false)
public void setFromAddress(String addr)
Sets 'From' address for all email messages.

There is no default value.

Parameters:
addr - Email address for data exchange.

getBroadcastAddress

public String getBroadcastAddress()
Gets broadcast address used for sending broadcast messages.

Specified by:
getBroadcastAddress in interface GridMailDiscoverySpiMBean
Returns:
Broadcast email address.

setBroadcastAddress

@GridSpiConfiguration(optional=false)
public void setBroadcastAddress(String bcastAddr)
Sets broadcast email address used by node to discover each other.

There is no default value.

Parameters:
bcastAddr - Email address.

getStoreFileName

public String getStoreFileName()
Gets locally stored full file name for all read messages. Can be either full path or a path relative to GridGain installation home folder.

Specified by:
getStoreFileName in interface GridMailDiscoverySpiMBean
Returns:
Store file path.

setStoreFileName

@GridSpiConfiguration(optional=true)
public void setStoreFileName(String fileName)
Sets locally stored full file name for all read messages. Can be either full path or a path relative to GridGain installation home folder.

If not provided the default value is GridMailDiscoverySpi.DFLT_STORE_FILE_NAME.

Parameters:
fileName - Local storage file name.

setNodeAttributes

public void setNodeAttributes(Map<String,Serializable> attrs)
Sets node attributes which will be distributed in grid during join process. Note that these attributes cannot be changed and set only once.

Specified by:
setNodeAttributes in interface GridDiscoverySpi
Parameters:
attrs - Map of node attributes.

setListener

public void setListener(GridDiscoveryListener listener)
Sets a listener for discovery events. Refer to GridDiscoveryEventType for a set of all possible discovery events.

Specified by:
setListener in interface GridDiscoverySpi
Parameters:
listener - Listener to discovery events.

setMetricsProvider

public void setMetricsProvider(GridDiscoveryMetricsProvider metricsProvider)
Sets discovery metrics provider. Use metrics provided by GridDiscoveryMetricsProvider.getMetrics() method to exchange dynamic metrics between nodes.

Specified by:
setMetricsProvider in interface GridDiscoverySpi
Parameters:
metricsProvider - Provider of metrics data.

getNodeAttributes

public Map<String,Serializable> getNodeAttributes()
                                           throws GridSpiException
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.

Specified by:
getNodeAttributes in interface GridSpi
Overrides:
getNodeAttributes in class GridSpiAdapter
Throws:
GridSpiException - Throws in case of any error.
Returns:
Map of local node attributes this SPI wants to add.

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.

getRemoteNodes

public List<GridNode> getRemoteNodes()
Gets collection of remote nodes in grid or empty collection if no remote nodes found.

Specified by:
getRemoteNodes in interface GridDiscoverySpi
Returns:
Collection of remote nodes.

getNode

public GridNode getNode(UUID nodeId)
Gets node by ID.

Specified by:
getNode in interface GridDiscoverySpi
Parameters:
nodeId - Node ID.
Returns:
Node with given ID or null if node is not found.

getRemoteNodeIds

public Collection<UUID> getRemoteNodeIds()
Gets collection of remote nodes' IDs.

Specified by:
getRemoteNodeIds in interface GridMailDiscoverySpiMBean
Returns:
Set of remote nodes IDs.

getRemoteNodeCount

public int getRemoteNodeCount()
Gets the number of remote nodes.

Specified by:
getRemoteNodeCount in interface GridMailDiscoverySpiMBean
Returns:
Number of remote nodes.

pingNode

public boolean pingNode(UUID nodeId)
Pings the remote node to see if it's alive.

Specified by:
pingNode in interface GridDiscoverySpi
Parameters:
nodeId - Node Id.
Returns:
true if node alive, false otherwise.

getConsistentAttributeNames

protected List<String> getConsistentAttributeNames()
Returns back list of attributes that should be consistent for this SPI. Consistency means that remote node has to have the same attribute with the same value.

Overrides:
getConsistentAttributeNames in class GridSpiAdapter
Returns:
List or attribute names.

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.