Click on Javadoc link to open Javadoc documentation.
Package
org.gridgain.grid.spi.communication.tcp Javadoc![]()
Description
GridTcpCommunicationSpi ![]()
To enable communication with other nodes, this SPI adds GridTcpCommuncationSpi.ATTR_ADDR ![]()
![]()
![]()
![]()
At startup, this SPI tries to start listening to local port specified by GridTcpCommuncationSpi.setLocalPort(int) ![]()
![]()
Configuration
The following configuration parameters can be used to configure GridTcpCommuncationSpi
| Setter Method | Description | Optional | Default |
|---|---|---|---|
| setLocalAddress(String) |
Sets local host address for socket binding. | Yes | Any available local IP address. |
| setLocalPort(int) |
Sets local port for socket binding. | Yes | 47100 (specified in GridTcpCommunicationSpi.DFLT_PORT |
| setLocalPortRange(int) |
Controls maximum number of local ports tried if all previously tried ports are occupied. | Yes | 10 (specified in GridTcpCommunicationSpi.DFLT_PORT_RANGE |
| setParallelSendCount(int) |
Sets number of messages sent concurrently to remote nodes. Used in GridTcpCommuncationSpi.sendMessage(Collection<GridNode>, Serializable) to send message concurrently to remote nodes | Yes | 10 (specified in GridTcpCommunicationSpi.DFLT_PARALLEL_SEND_COUNT |
| setDirectBuffer(boolean) |
Switches between using NIO direct and NIO heap allocation buffers. Although direct buffers perform better, in some cases (especially on Windows) they may cause JVM crashes. If that happens in your environment, set this property to false. | Yes | true |
Examples
GridTcpCommunicationSpi is used by default and should be explicitly configured only if some SPI configuration parameters need to be overridden.
GridTcpCommunicationSpi commSpi = new GridTcpCommunicationSpi(); // Override local port. commSpi.setLocalPort(4321); 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.tcp.GridTcpCommunicationSpi"> <!-- Override local port. --> <property name="localPort" value="4321"/> </bean> </property> ... </bean>

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