Click on Javadoc link to open Javadoc documentation.
Package
org.gridgain.grid.spi.communication.jgroups ![]()
Description
GridJgroupsCommunicationSpi ![]()
![]()
.
To enable communication with other nodes, this SPI adds GridJgroupsCommuncationSpi.ATTR_ADDR ![]()
At startup, this SPI will load JGroups configuration file from specified path, create a JGroups channel and connect to the group specified. Both, configuration path and group name are configurable. Note that JGroups SPI implementation uses multiplexer (re-using the same channel) since 2.0.0.
Configuration
The following configuration parameters can be used to configure GridJgroupsCommunicationSpi
Up to version 1.6.1 configuration looks as following:
| Setter Method | Description | Optional | Default |
|---|---|---|---|
| setConfigurationFile(String) |
Sets either absolute or relative to GridGain home path to JGroups XML configuration file. | Yes | ${GRIDGAIN_HOME}/config/jgroups/communication/jgroups.xml specified by GridJgroupsCommunicationSpi.DFLT_CONFIG_FILE |
| setGroupName(String) |
Sets JGroups group name. In order to communicate with each other, nodes must have the same group name. | Yes | grid.comm.jgroups.channel specified by GridJgroupsCommunicationSpi.DFLT_GRP_NAME |
| setSendTimeout(long) |
Sets time limit in milliseconds to wait for message acknowledgements from remote nodes. | Yes | 10000 milliseconds specified by GridJgroupsCommunicationSpi.DFLT_SEND_TIMEOUT |
Starting from version 2.0 we added some new parameters as we use JGroups multiplexer.
| Setter Method | Description | Optional | Default |
|---|---|---|---|
| setConfigurationFile(String) |
Sets either absolute or relative to GridGain home path to JGroups XML configuration file. | Yes | ${GRIDGAIN_HOME}/config/jgroups/multicast/jgroups.xml specified by GridJgroupsCommunicationSpi.DFLT_CONFIG_FILE |
| setGroupName(String) |
Sets JGroups group name. In order to communicate with each other, nodes must have the same group name. | Yes | grid.comm.jgroups specified by GridJgroupsCommunicationSpi.DFLT_GRP_NAME |
| setStackName(String) |
Sets JGroups stack name. In order to use multiplexor over the same channel SPIs must have the same stack name. Stack name is a name of configuration in the configuration file. | Yes | grid.jgroups.stack specified by GridJgroupsCommunicationSpi.DFLT_STACK_NAME |
| setSendTimeout(long) |
Sets time limit in milliseconds to wait for message acknowledgements from remote nodes. | Yes | 10000 milliseconds specified by GridJgroupsCommunicationSpi.DFLT_SEND_TIMEOUT |
| IPv4 vs IPv6 Note, if you have an OS with IPv6 enabled, Java applications may try to route IP multicast traffic over IPv6. Use "-Djava.net.preferIPv4Stack=true" system property at VM startup to prevent this. You may also wish to specify local bind address in JGroups configuration file to make sure that JGroups binds to correct network interface. |
| JGroups and Linux We had a number of issues with configuring JGroups on Linux (mostly with getting IP multicast to work). We highly recommend to consult JGroups documentation |
Examples
GridJgroupsCommunicationSpi needs to be explicitely configured to override default TCP communication SPI.
GridJgroupsCommunicationSpi commSpi = new GridJgroupsCommunicationSpi(); // Override default JGroups configuration file. commSpi.setConfigurationFile("/my/config/path/jgroups.xml"); GridConfigurationAdapter cfg = new GridConfigurationAdapter(); // Override default communication SPI. cfg.setCommunicationSpi(commSpi); // Start grid. GridFactory.start(cfg);
or from Spring configuration file
<bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfigurationAdapter" singleton="true"> ... <property name="communicationSpi"> <bean class="org.gridgain.grid.spi.communication.jgroups.GridJgroupsCommunicationSpi"> <property name="configurationFile" value="/my/config/path/jgroups.xml"/> </bean> </property> ... </bean>

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