Dashboard > GridGain User Guide > Table Of Contents > GridGain Book > Discovery SPI > GridMuleDiscoverySpi
GridMuleDiscoverySpi
Added by morpheus, last edited by morpheus on Jul 30, 2007  (view change)
Labels: 
(None)


Click on Javadoc link to open Javadoc documentation.

Package

org.gridgain.grid.spi.discovery.mule Javadoc

Description

GridMuleDiscoverySpi Javadoc 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 Javadoc ). 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 Javadoc and GridMuleDiscoverySpi.HEARTBEAT_ENDPOINT_NAME Javadoc ).

Libraries

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.

Multiple Instances In VM

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 Javadoc for details.

Configuration

The following configuration parameters can be used to configure GridMulticastDiscoverySpi:

Setter Method Description Optional Default
setConfigurationFile(String) Javadoc Mule configuration file used when Mule instance isn't started. Yes config/mule/mule.xml (specified by GridMuleDiscoverySpi.DFLT_CONFIG_FILE Javadoc )
setComponentName(String) Javadoc Name of mule component declared in mule configuration. Yes GridDiscoveryUMO (specified by GridMuleDiscoverySpi.COMPONENT_NAME Javadoc )
setHeartbeatFrequency(long) Javadoc Node heartbeat frequency. Yes 2000ms (specified by GridMuleDiscoverySpi.DFLT_HEARTBEAT_FREQ Javadoc )
setLeaveAttempts(int) Javadoc Number of retries to broadcast notification to other nodes about this node leaving grid. Yes 3 (specified by GridMuleDiscoverySpi.DFLT_LEAVE_ATTEMPTS Javadoc )
setMaxMissedHeartbeats(int) Javadoc Number of heartbeats that could be missed before a node is considered failed. Yes 3 (specified by GridMuleDiscoverySpi.DFLT_MAX_MISSED_HEARTBEATS Javadoc )

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>

Examples

GridCoherenceDiscoverySpi Javadoc needs to be explicitly configured to be used. Here is a configuration example:

GridMuleDiscoverySpi spi = new GridMuleDiscoverySpi();

// Change path to mule configuration file.
spi.setConfigurationFile("/my/config/mule/mule.xml");

GridConfigurationAdapter cfg = new GridConfigurationAdapter();

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

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

or from Spring 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/mule/mule.xml"/>
            </bean>
        </property>
        ...
</bean>


For more information about using Spring framework for configuration click here.

Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.10 Build:#528 Nov 29, 2006) - Bug/feature request - Contact Administrators