GridGain™ 2.1.0
Java API Specification

org.gridgain.grid.spi.communication.mule
Class GridMuleCommunicationSpi

java.lang.Object
  extended by org.gridgain.grid.spi.GridSpiAdapter
      extended by org.gridgain.grid.spi.communication.mule.GridMuleCommunicationSpi
All Implemented Interfaces:
GridCommunicationSpi, GridMuleCommunicationSpiMBean, GridSpi, GridSpiManagementMBean

@GridSpiInfo(author="GridGain Systems",
             url="www.gridgain.org",
             email="support@gridgain.com",
             version="x.x")
@GridSpiMultipleInstancesSupport(value=false)
public class GridMuleCommunicationSpi
extends GridSpiAdapter
implements GridCommunicationSpi, GridMuleCommunicationSpiMBean

Mule implementation of GridCommunicationSpi SPI. It uses Mule ESB implementation to communicate with GridGain nodes.

Mule instance may be started before SPI or instantiated during SPI start. SPI uses UMO component which must be declared in Mule configuration file (see GridMuleCommunicationSpi.COMPONENT_NAME). UMO component should have one input endpoint. The name of that input endpoint should be declared in component's descriptor properties (see GridMuleCommunicationSpi.ENDPOINT_NAME).

Here is an example of Mule configuration file with GridMuleCommunicationComponent used by this SPI:

 <mule-configuration version="1.0">
     <mule-environment-properties embedded="true"/>

     <connector name="tcpConnector" className="org.mule.providers.tcp.TcpConnector">
         <properties>
             <property name="tcpProtocolClassName" value="org.mule.providers.tcp.protocols.LengthProtocol"/>
         </properties>
     </connector>

     <model name="gridgain">
         <mule-descriptor name="GridCommunicationUMO"
             implementation="org.gridgain.grid.spi.communication.mule.GridMuleCommunicationComponent"
             singleton="true">
             <inbound-router>
                 <endpoint name="comm.id" address="tcp://localhost:11001"/>
             </inbound-router>

             <properties>
                 <property name="communication" value="comm.id"/>
             </properties>
         </mule-descriptor>
     </model>
 </mule-configuration>

This SPI has no mandatory parameters.

This SPI has the following optional parameters:

Java Example

GridMuleCommunicationSpi needs to be explicitely configured to override default TCP communication SPI.
 GridMuleCommunicationSpi commSpi = new GridMuleCommunicationSpi();

 commSpi.setConfigurationFile("/my/path/to/mule/config/mule.xml");

 GridConfigurationAdapter cfg = new GridConfigurationAdapter();

 // Override default communication SPI.
 cfg.setCommunicationSpi(commSpi);

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

Spring Example

GridMuleCommunicationSpi can be configured from Spring XML configuration file:
 <bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfigurationAdapter" singleton="true">
         ...
         <property name="communicationSpi">
             <bean class="org.gridgain.grid.spi.communication.mule.GridMuleCommunicationSpi">
                 <property name="configurationFile" value="/my/config/path/mule.xml"/>
             </bean>
         </property>
         ...
 </bean>

Note: Mule is not shipped with GridGain. If you don't have Mule, you need to download it separately. See http://www.mulesource.com for more information. Once installed, Mule should be available on the classpath for GridGain. If you use [GRIDGAIN_HOME]/bin/gridgain.{sh|bat} script to start a grid node you can simply add Mule JARs to [GRIDGAIN_HOME]/bin/setenv.{sh|bat} script that is used to set up class path for the main scripts.

Note: When using Mule SPI (communication or discovery) you cannot start multiple GridGain instances in the same VM due to Mule limitation. GridGain runtime will detect this situation and prevent GridGain from starting in such case. See GridSpiMultipleInstancesSupport for details.


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:
GridCommunicationSpi
 

Field Summary
static String ATTR_ADDR
          Name of address attribute added to local node attributes at startup (value is grid.comm.mule.address).
static String COMPONENT_NAME
          Name of component declared in Mule configuration (value is GridCommunicationUMO).
static String DFLT_CONFIG_FILE
          Default Mule 1.x configuration path relative to GridGain installation home folder (value is config/mule1/mule.xml).
static String ENDPOINT_NAME
          Name of property where input endpoint name declared in Mule configuration (value is communication).
 
Constructor Summary
GridMuleCommunicationSpi()
           
 
Method Summary
 String getComponentName()
          Gets name for the component registered in Mule configuration.
 String getConfigurationFile()
          Gets either absolute or relative to GridGain installation home folder path to Mule XML configuration file.
protected  List<String> getConsistentAttributeNames()
          Returns back list of attributes that should be consistent for this SPI.
 String getEndpointUri()
          Gets component input endpoint URI.
 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.
 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 setComponentName(String umoName)
          Sets name for component registered in Mule.
 void setConfigurationFile(String cfgFile)
          Sets either absolute or relative to GridGain installation home folder path to Mule XML configuration file.
 void setConfigurationUrl(URL cfgUrl)
          Sets URL to Mule XML configuration file.
 void setListener(GridMessageListener listener)
          Set communication listener.
 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_CONFIG_FILE

public static final String DFLT_CONFIG_FILE
Default Mule 1.x configuration path relative to GridGain installation home folder (value is config/mule1/mule.xml).

See Also:
Constant Field Values

ATTR_ADDR

public static final String ATTR_ADDR
Name of address attribute added to local node attributes at startup (value is grid.comm.mule.address).

See Also:
Constant Field Values

COMPONENT_NAME

public static final String COMPONENT_NAME
Name of component declared in Mule configuration (value is GridCommunicationUMO).

See Also:
Constant Field Values

ENDPOINT_NAME

public static final String ENDPOINT_NAME
Name of property where input endpoint name declared in Mule configuration (value is communication).

See Also:
Constant Field Values
Constructor Detail

GridMuleCommunicationSpi

public GridMuleCommunicationSpi()
Method Detail

getConfigurationFile

public String getConfigurationFile()
Gets either absolute or relative to GridGain installation home folder path to Mule XML configuration file.

Specified by:
getConfigurationFile in interface GridMuleCommunicationSpiMBean
Returns:
Path to Mule configuration file.

setConfigurationFile

@GridSpiConfiguration(optional=true)
public void setConfigurationFile(String cfgFile)
Sets either absolute or relative to GridGain installation home folder path to Mule XML configuration file. This configuration parameter is optional.

If not provided, default value is GridMuleCommunicationSpi.DFLT_CONFIG_FILE.

Parameters:
cfgFile - Path to Mule configuration file.

setConfigurationUrl

@GridSpiConfiguration(optional=true)
public void setConfigurationUrl(URL cfgUrl)
Sets URL to Mule XML configuration file. This configuration parameter is optional.

If not provided, default value is GridMuleCommunicationSpi.DFLT_CONFIG_FILE.

Parameters:
cfgUrl - URL to Mule configuration file.

getComponentName

public String getComponentName()
Gets name for the component registered in Mule configuration.

Specified by:
getComponentName in interface GridMuleCommunicationSpiMBean
Returns:
Name of the component.

setComponentName

@GridSpiConfiguration(optional=true)
public void setComponentName(String umoName)
Sets name for component registered in Mule. SPI use that name for getting component from Mule instance.

Parameters:
umoName - Name for component registered in Mule.

getEndpointUri

public String getEndpointUri()
Gets component input endpoint URI.

Specified by:
getEndpointUri in interface GridMuleCommunicationSpiMBean
Returns:
Input endpoint URI.

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.

sendMessage

public void sendMessage(GridNode destNode,
                        Serializable msg)
                 throws GridSpiException
Sends given message to destination node. Note that characteristics of the exchange such as durability, guaranteed delivery or error notification is dependant on SPI implementation.

Specified by:
sendMessage in interface GridCommunicationSpi
Throws:
GridSpiException - 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.
Parameters:
destNode - Destination node.
msg - Message to send.

sendMessage

public void sendMessage(Collection<GridNode> destNodes,
                        Serializable msg)
                 throws GridSpiException
Sends given message to destination nodes. Note that characteristics of the exchange such as durability, guaranteed delivery or error notification is dependant on SPI implementation.

Specified by:
sendMessage in interface GridCommunicationSpi
Throws:
GridSpiException - 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.
Parameters:
destNodes - Destination nodes.
msg - Message to send.

setListener

public void setListener(GridMessageListener listener)
Set communication listener.

Specified by:
setListener in interface GridCommunicationSpi
Parameters:
listener - Listener to set or null to unset the listener.

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.