GridGain™ 2.1.0
Java API Specification

org.gridgain.grid.spi.discovery.mule
Class GridMuleDiscoverySpi

java.lang.Object
  extended by org.gridgain.grid.spi.GridSpiAdapter
      extended by org.gridgain.grid.spi.discovery.mule.GridMuleDiscoverySpi
All Implemented Interfaces:
GridDiscoverySpi, GridMuleDiscoverySpiMBean, GridSpi, GridSpiManagementMBean

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

Mule implementation of GridDiscoverySpi SPI. It uses Mule ESB implementation to discover nodes in the grid.

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 GridMuleDiscoverySpi.COMPONENT_NAME). SPI receives all notifications from that component. The component has two input endpoints for getting messages. Names of those endpoints should be declared in component's descriptor properties (see GridMuleDiscoverySpi.HANDSHAKE_ENDPOINT_NAME and GridMuleDiscoverySpi.HEARTBEAT_ENDPOINT_NAME).

Here is an example of Mule configuration file that could be used with this SPI:

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

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

     <!-- Multicast connector configuration. -->
     <connector name="multicastConnector" className="org.mule.providers.multicast.MulticastConnector">
         <properties>
             <property name="loopback" value="true"/>
         </properties>
     </connector>

     <model name="gridgain">
         <mule-descriptor name="GridDiscoveryUMO"
             implementation="org.gridgain.grid.spi.discovery.mule.GridMuleDiscoveryComponent"
             singleton="true">
             <inbound-router>
                 <!-- Listen for handshake data. -->
                 <endpoint name="handshake.id" address="tcp://localhost:11001"/>

                 <!-- Listen for heartbeat data. -->
                 <endpoint name="heartbeat.id" address="multicast://228.1.2.172:30001"/>
             </inbound-router>

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

This SPI has no mandatory parameters.

This SPI has the following optional parameters:

Java Example

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

 // Override default Mule configuration file.
 spi.setConfigurationFile("/my/config/path/mule.xml");

 GridConfigurationAdapter cfg = new GridConfigurationAdapter();

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

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

Spring Example

GridMuleDiscoverySpi 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.mule.GridMuleDiscoverySpi">
                 <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} scripts that's used to set up class path for the main scripts.

Note: When using Mule SPIs (communication or discovery) you cannot start multiple GridGain instances in the same VM due to limitations of Mule. 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:
GridDiscoverySpi
 

Field Summary
static String COMPONENT_NAME
          Name of component declared in Mule configuration (value is GridDiscoveryUMO).
static String DFLT_CONFIG_FILE
          Default Mule 1.x configuration path relative to GridGain installation home folder.
static long DFLT_HEARTBEAT_FREQ
          Default heartbeat delay (value is 3000).
static int DFLT_LEAVE_ATTEMPTS
          Default number of attempts to send leaving notification (value is 3).
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.
static String HANDSHAKE_ENDPOINT_NAME
          Name of property where input endpoint name declared in Mule configuration for attributes handshake.
static String HEARTBEAT_ENDPOINT_NAME
          Name of property where input endpoint name declared in Mule configuration for heartbeats.
 
Constructor Summary
GridMuleDiscoverySpi()
           
 
Method Summary
 String getComponentName()
          Gets name of the component registered in Mule.
 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 getHandshakeEndpointUri()
          Gets component inbound endpoint URI for handshake.
 String getHeartbeatEndpointUri()
          Gets component inbound endpoint URI for heartbeats.
 long getHeartbeatFrequency()
          Gets delay between heartbeat requests.
 int getLeaveAttempts()
          Gets number of attempts to notify another nodes that this one is leaving grid.
 GridNode getLocalNode()
          Gets local node.
 int 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.
 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.
 boolean pingNode(UUID nodeId)
          Pings the remote node to see if it's alive.
 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 setHeartbeatFrequency(long beatFreq)
          Sets delay between heartbeat requests.
 void setLeaveAttempts(int leaveAttempts)
          Sets number of attempts to notify another nodes that this one is leaving grid.
 void setListener(GridDiscoveryListener listener)
          Sets a listener for discovery events.
 void setMaxMissedHeartbeats(int 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 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

COMPONENT_NAME

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

See Also:
Constant Field Values

HANDSHAKE_ENDPOINT_NAME

public static final String HANDSHAKE_ENDPOINT_NAME
Name of property where input endpoint name declared in Mule configuration for attributes handshake. (value is handshake).

See Also:
Constant Field Values

HEARTBEAT_ENDPOINT_NAME

public static final String HEARTBEAT_ENDPOINT_NAME
Name of property where input endpoint name declared in Mule configuration for heartbeats. (value is heartbeat).

See Also:
Constant Field Values

DFLT_HEARTBEAT_FREQ

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

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_ATTEMPTS

public static final int DFLT_LEAVE_ATTEMPTS
Default number of attempts to send leaving notification (value is 3).

See Also:
Constant Field Values

DFLT_PING_WAIT

public static final long DFLT_PING_WAIT
Default ping wait timeout.

See Also:
Constant Field Values
Constructor Detail

GridMuleDiscoverySpi

public GridMuleDiscoverySpi()
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 GridMuleDiscoverySpiMBean
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 GridMuleDiscoverySpi.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 GridMuleDiscoverySpi.DFLT_CONFIG_FILE.

Parameters:
cfgUrl - URL to Mule configuration file.

getHeartbeatEndpointUri

public String getHeartbeatEndpointUri()
Gets component inbound endpoint URI for heartbeats.

Specified by:
getHeartbeatEndpointUri in interface GridMuleDiscoverySpiMBean
Returns:
Inbound endpoint URI.

getHandshakeEndpointUri

public String getHandshakeEndpointUri()
Gets component inbound endpoint URI for handshake.

Specified by:
getHandshakeEndpointUri in interface GridMuleDiscoverySpiMBean
Returns:
Inbound endpoint URI.

setHeartbeatFrequency

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

If not provided, default value is GridMuleDiscoverySpi.DFLT_HEARTBEAT_FREQ.

Parameters:
beatFreq - Time in milliseconds.

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 GridMuleDiscoverySpiMBean
Returns:
Time period in milliseconds.

setMaxMissedHeartbeats

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

If not provided, default value is GridMuleDiscoverySpi.DFLT_MAX_MISSED_HEARTBEATS.

Parameters:
maxMissedBeats - Number of missed requests.

getMaximumMissedHeartbeats

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

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

setLeaveAttempts

@GridSpiConfiguration(optional=true)
public void setLeaveAttempts(int leaveAttempts)
Sets number of attempts to notify another nodes that this one is leaving grid. Multiple leave requests are sent to increase the chance of successful delivery to every node.

If not provided, default value is GridMuleDiscoverySpi.DFLT_LEAVE_ATTEMPTS.

Parameters:
leaveAttempts - Number of attempts.

getLeaveAttempts

public int getLeaveAttempts()
Gets number of attempts to notify another nodes that this one is leaving grid. Multiple leave requests are sent to increase the chance of successful delivery to every node.

Specified by:
getLeaveAttempts in interface GridMuleDiscoverySpiMBean
Returns:
Number of attempts.

getComponentName

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

Specified by:
getComponentName in interface GridMuleDiscoverySpiMBean
Returns:
Component name.

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.

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.

getRemoteNodeIds

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

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

getRemoteNodeCount

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

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

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.

getLocalNode

public GridNode getLocalNode()
Gets local node.

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

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.

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.

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.

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.