|
GridGain 2.1.0
Java API Specification |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.gridgain.grid.spi.GridSpiAdapter
org.gridgain.grid.spi.communication.mail.GridMailCommunicationSpi
@GridSpiInfo(author="GridGain Systems",
url="www.gridgain.org",
email="support@gridgain.com",
version="x.x")
@GridSpiMultipleInstancesSupport(value=true)
public class GridMailCommunicationSpi
Email implementation of GridCommunicationSpi. Email communication is
provided for cases where nodes from different networks (even different
countries) need to participate in grid task execution together as it usually
can penetrate through any firewall. It supports SMTP/POP and IMAP email access
protocols and can be used to connect to any public or private email server out
there.
When working with email communication, 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.
Note, that due to its nature mail communication is much slower than other
implementations of communication SPI's and measures communication delays in
minutes rather than in seconds. This means that execution of some tasks
can fail more often than with other SPI's due to nodes leaving grid topology.
In most cases user should implement a custom failover resolution in
GridTask implementation, which should check if a node
is still alive using Grid.pingNode(UUID) method. Use this SPI
whenever it is acceptable to react to node topology changes with substantial
delay.
GridMailCommunicationSpi.setOutHost(String)).GridMailCommunicationSpi.setInHost(String)).GridMailCommunicationSpi.setFromAddress(String)).GridMailCommunicationSpi.setOutConnectionType(GridMailCommunicationType))GridMailCommunicationSpi.setOutPort(int)GridMailCommunicationSpi.setOutUsername(String)GridMailCommunicationSpi.setOutPassword(String)GridMailCommunicationSpi.setOutCustomProperties(Properties)GridMailCommunicationSpi.setOutProtocol(GridMailCommunicationOutProtocol) GridMailCommunicationSpi.setInConnectionType(GridMailCommunicationType)GridMailCommunicationSpi.setInPort(int)GridMailCommunicationSpi.setInUsername(String)GridMailCommunicationSpi.setInPassword(String)GridMailCommunicationSpi.setInCustomProperties(Properties)GridMailCommunicationSpi.setInProtocol(GridMailCommunicationInProtocol) GridMailCommunicationSpi.setSubject(String)GridMailCommunicationSpi.setFolderName(String)GridMailCommunicationSpi.setStoreFileName(String) GridMailCommunicationSpi.setReadBatchSize(int)GridMailCommunicationSpi.setReceiverDelay(long)GridMailCommunicationSpi.setLeaveMessagesOnServer(long)
GridMailCommuncationSpi commSpi = new GridMailCommuncationSpi();
// Inbox configuration.
commSpi.setInHost("pop.google.com");
// Outbox configuration.
commSpi.setOutHost("smtp.google.com");
// Incoming/outgoing e-mail address configuration.
commSpi.setFromAddress("grid@google.com");
GridConfigurationAdapter cfg = new GridConfigurationAdapter();
// Override default communication SPI.
cfg.setCommunicationSpi(commSpi);
// Start grid.
GridFactory.start(cfg);
<bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfigurationAdapter" singleton="true">
...
<property name="communicationSpi">
<bean class="org.gridgain.grid.spi.communication.mail.GridMailCommunicationSpi">
<property name="outHost" value="smtp.google.com"/>
<property name="inHost" value="pop.google.com"/>
<property name="fromAddress" value="grid@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
GridCommunicationSpi
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
| Field Summary | |
|---|---|
static String |
ATTR_EMAIL_ADDR
Node email address attribute name (value is comm.email.address). |
static long |
DFLT_LEAVE_MSGS_ON_SERVER
Leave messages on server in milliseconds (value is 86400000). |
static long |
DFLT_RECEIVER_DELAY
Delay in milliseconds between receiving email (value is 10000). |
static String |
DFLT_STORE_FILE_NAME
Default local storage file name (value is grid-email-comm-msgs.dat). |
static String |
DFLT_SUBJ
Default subject of email (value is grid.email.comm.msg). |
| Constructor Summary | |
|---|---|
GridMailCommunicationSpi()
Set SPI default values for mailboxes configurations. |
|
| Method Summary | |
|---|---|
protected List<String> |
getConsistentAttributeNames()
Returns back list of attributes that should be consistent for this SPI. |
String |
getFolderName()
Gets folder name of email folder on mail server. |
String |
getFromAddress()
Gets message field 'From' all email messages. |
String |
getInConnectionTypeFormatted()
Gets type of incoming mail connection. |
Properties |
getInCustomProperties()
Gets custom properties required for receiving connection. |
String |
getInHost()
Gets incoming host name for receiving email (usually either POP or IMAP). |
int |
getInPort()
Gets incoming host port number for receiving email. |
String |
getInProtocolFormatted()
Sets incoming mail protocol. |
String |
getInUsername()
Gets incoming host username for receiving email. |
long |
getLeaveMessagesOnServer()
Gets incoming messages life-time on mail server in milliseconds. |
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 (usually either SMTP or IMAP). |
int |
getOutPort()
Gets port number for outgoing mail. |
String |
getOutProtocolFormatted()
Gets outgoing mail protocol. |
String |
getOutUsername()
Gets username for outgoing mail authentication. |
int |
getReadBatchSize()
Gets number of messages fetched from mail server at a time. |
long |
getReceiverDelay()
Gets interval in milliseconds between checking for new messages. |
String |
getStoreFileName()
Gets locally stored full file name for all read messages. |
String |
getSubject()
Gets email message subject. |
void |
sendMessage(Collection<GridNode> destNodes,
Serializable msg)
Sends given message to destination nodes. |
void |
sendMessage(GridNode destNode,
Serializable msg)
Sends given message to destination node. |
void |
setFolderName(String folderName)
Sets name of email folder on mail server. |
void |
setFromAddress(String addr)
Sets 'From' address for all email messages. |
void |
setInConnectionType(GridMailCommunicationType type)
Sets type of incoming mail connection which should be one of the following: GridMailCommunicationType.NONE
GridMailCommunicationType.SSL
GridMailCommunicationType.STARTTLS
If not provided, default value is GridMailCommunicationType.NONE. |
void |
setInCustomProperties(Properties props)
Sets any custom properties required for receiving connection. |
void |
setInHost(String host)
Sets incoming host name for receiving emails (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(GridMailCommunicationInProtocol 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(GridMessageListener listener)
Set communication listener. |
void |
setOutConnectionType(GridMailCommunicationType type)
Sets type of outgoing mail connection which should be one of the following: GridMailCommunicationType.NONE
GridMailCommunicationType.SSL
GridMailCommunicationType.STARTTLS
If not provided, default value is GridMailCommunicationType.NONE. |
void |
setOutCustomProperties(Properties props)
Sets any custom properties required for outgoing connection. |
void |
setOutHost(String host)
Sets outgoing host name for sending emails (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(GridMailCommunicationOutProtocol proto)
Sets outgoing mail protocol. |
void |
setOutUsername(String username)
Sets username for outgoing mail authentication. |
void |
setReadBatchSize(int size)
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 |
|---|
public static final String DFLT_SUBJ
public static final String DFLT_STORE_FILE_NAME
public static final long DFLT_RECEIVER_DELAY
public static final long DFLT_LEAVE_MSGS_ON_SERVER
public static final String ATTR_EMAIL_ADDR
| Constructor Detail |
|---|
public GridMailCommunicationSpi()
| Method Detail |
|---|
public Map<String,Serializable> getNodeAttributes()
throws GridSpiException
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.
getNodeAttributes in interface GridSpigetNodeAttributes in class GridSpiAdapterGridSpiException - Throws in case of any error.
@GridSpiConfiguration(optional=false) public void setOutHost(String host)
There is no default value for the parameter.
host - Outgoing email host name.@GridSpiConfiguration(optional=true) public void setOutConnectionType(GridMailCommunicationType type)
If not provided, default value is GridMailCommunicationType.NONE.
type - Connection type.@GridSpiConfiguration(optional=true) public void setOutPort(int port)
If not provided, default value is 25.
port - Outgoing email port number.@GridSpiConfiguration(optional=true) public void setOutUsername(String username)
If not provided, default value is null.
username - Outbox username.@GridSpiConfiguration(optional=true) public void setOutPassword(String pswd)
If not provided, default value is null.
pswd - Outbox password.@GridSpiConfiguration(optional=false) public void setInHost(String host)
There is no default value.
host - Incoming email host name.@GridSpiConfiguration(optional=true) public void setInConnectionType(GridMailCommunicationType type)
If not provided, default value is GridMailCommunicationType.NONE.
type - Connection type.@GridSpiConfiguration(optional=true) public void setInPort(int port)
If not provided, default value is 110.
port - Incoming email server port number.@GridSpiConfiguration(optional=true) public void setInUsername(String username)
If not provided, default value is null.
username - Incoming mailbox username.@GridSpiConfiguration(optional=true) public void setInPassword(String pswd)
If not provided, default value is null.
pswd - Incoming mailbox password.@GridSpiConfiguration(optional=true) public void setSubject(String subj)
If not provided, default value is grid.email.comm.msg.
subj - Email message subject.@GridSpiConfiguration(optional=true) public void setFolderName(String folderName)
If not provided, default value is Inbox.
folderName - Mail server folder name.@GridSpiConfiguration(optional=false) public void setFromAddress(String addr)
GridMailCommunicationSpi.ATTR_EMAIL_ADDR node attribute so it can be accessed
on remote nodes. This address is used by other nodes to send email
to this node.
There is no default value.
addr - Email address for data exchange.@GridSpiConfiguration(optional=true) public void setInCustomProperties(Properties props)
If not provided, default value is null.
props - Custom properties.@GridSpiConfiguration(optional=true) public void setOutCustomProperties(Properties props)
If not provided, default value is null.
props - Custom parameter.@GridSpiConfiguration(optional=true) public void setReadBatchSize(int size)
If not provided, default value is 100.
size - Number of fetched messages.@GridSpiConfiguration(optional=true) public void setReceiverDelay(long recvDelay)
If not provided, default value is GridMailCommunicationSpi.DFLT_RECEIVER_DELAY.
recvDelay - Inverval between receiving messages.@GridSpiConfiguration(optional=true) public void setOutProtocol(GridMailCommunicationOutProtocol proto)
If not provided, default value is GridMailCommunicationOutProtocol.SMTP.
proto - Outgoing mail protocol.@GridSpiConfiguration(optional=true) public void setInProtocol(GridMailCommunicationInProtocol proto)
GridMailCommunicationInProtocol.POP3GridMailCommunicationInProtocol.POP3SGridMailCommunicationInProtocol.IMAPGridMailCommunicationInProtocol.IMAPS
If not provided, default value is GridMailCommunicationInProtocol.POP3.
proto - Incoming protocol.@GridSpiConfiguration(optional=true) public void setStoreFileName(String fileName)
If not provided, default value is GridMailCommunicationSpi.DFLT_STORE_FILE_NAME.
fileName - Local storage file name.@GridSpiConfiguration(optional=true) public void setLeaveMessagesOnServer(long leaveMsgsOnServer)
If not provided, default value is GridMailCommunicationSpi.DFLT_LEAVE_MSGS_ON_SERVER.
leaveMsgsOnServer - Time to live for incoming messages.public long getReceiverDelay()
getReceiverDelay in interface GridMailCommunicationSpiMBeanpublic long getLeaveMessagesOnServer()
getLeaveMessagesOnServer in interface GridMailCommunicationSpiMBeanpublic String getOutConnectionTypeFormatted()
getOutConnectionTypeFormatted in interface GridMailCommunicationSpiMBeanpublic String getOutProtocolFormatted()
getOutProtocolFormatted in interface GridMailCommunicationSpiMBeanpublic String getOutHost()
getOutHost in interface GridMailCommunicationSpiMBeanpublic int getOutPort()
getOutPort in interface GridMailCommunicationSpiMBeanpublic String getOutUsername()
getOutUsername in interface GridMailCommunicationSpiMBeanpublic String getInConnectionTypeFormatted()
getInConnectionTypeFormatted in interface GridMailCommunicationSpiMBeanpublic int getReadBatchSize()
getReadBatchSize in interface GridMailCommunicationSpiMBeanpublic String getInProtocolFormatted()
getInProtocolFormatted in interface GridMailCommunicationSpiMBeanpublic String getInHost()
getInHost in interface GridMailCommunicationSpiMBeanpublic int getInPort()
getInPort in interface GridMailCommunicationSpiMBeanpublic String getInUsername()
getInUsername in interface GridMailCommunicationSpiMBeanpublic String getFolderName()
getFolderName in interface GridMailCommunicationSpiMBeanpublic String getSubject()
getSubject in interface GridMailCommunicationSpiMBeanpublic Properties getOutCustomProperties()
getOutCustomProperties in interface GridMailCommunicationSpiMBeanpublic Properties getInCustomProperties()
getInCustomProperties in interface GridMailCommunicationSpiMBeanpublic String getFromAddress()
getFromAddress in interface GridMailCommunicationSpiMBeanpublic String getStoreFileName()
getStoreFileName in interface GridMailCommunicationSpiMBean
public void sendMessage(GridNode destNode,
Serializable msg)
throws GridSpiException
sendMessage in interface GridCommunicationSpiGridSpiException - Thrown in case of any error during sending the message.
Note that this is not guaranteed that failed communication will result
in thrown exception as this is dependant on SPI implementation.destNode - Destination node.msg - Message to send.
public void sendMessage(Collection<GridNode> destNodes,
Serializable msg)
throws GridSpiException
sendMessage in interface GridCommunicationSpiGridSpiException - Thrown in case of any error during sending the message.
Note that this is not guaranteed that failed communication will result
in thrown exception as this is dependant on SPI implementation.destNodes - Destination nodes.msg - Message to send.public void setListener(GridMessageListener listener)
setListener in interface GridCommunicationSpilistener - Listener to set or null to unset the listener.
public void spiStart(String gridName)
throws GridSpiException
spiStart in interface GridSpiGridSpiException - Throws in case of any error during SPI start.gridName - Name of grid instance this SPI is being started for
(null for default grid).
public void spiStop()
throws GridSpiException
spiStop in interface GridSpiGridSpiException - Thrown in case of any error during SPI stop.protected List<String> getConsistentAttributeNames()
getConsistentAttributeNames in class GridSpiAdapterpublic String toString()
toString in class Object
|
GridGain 2.1.0
Java API Specification |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
|
GridGain - Grid Computing Made Simple, ver. 2.1.0.19122008
2005-2008 Copyright © GridGain Systems. All Rights Reserved. |
|
|