Dashboard > GridGain User Guide > Table Of Contents > GridGain Book > Discovery SPI > GridTcpDiscoverySpi
GridTcpDiscoverySpi
Added by Yakov Zhdanov, last edited by Yakov Zhdanov on Jun 16, 2011  (view change)
Labels: 
(None)


Click on Javadoc link to open Javadoc documentation.

Please note, that in release 3.0.5 and before this SPI was named as org.gridgain.grid.spi.discovery.tcplite.GridTcpLiteDiscoverySpi.

Also note, that the following implementations of the GridTcpDiscoveryIpFinder Javadoc , GridTcpDiscoveryMetricsStore Javadoc and GridTcpDiscoveryTopologyStore Javadoc are available in Enterprise edition only:

  • GridTcpDiscoverySharedFsIpFinder Javadoc
  • GridTcpDiscoveryS3IpFinder Javadoc
  • GridTcpDiscoveryJdbcIpFinder Javadoc
  • GridTcpDiscoverySharedFsMetricsStore Javadoc
  • GridTcpDiscoveryS3MetricsStore Javadoc
  • GridTcpDiscoveryJdbcMetricsStore Javadoc
  • GridTcpDiscoverySharedFsTopologyStore Javadoc
  • GridTcpDiscoveryJdbcTopologyStore Javadoc

Package

org.gridgain.grid.spi.discovery.tcp Javadoc

Description

This Discovery preserves order of nodes added, this means that if two nodes A and B are added to the topology in some order, then other nodes in the topology get NODE_JOINED event in the same order exactly. All nodes in topology are organized in a ring. Topology has coordinator node (this is an ordinary node, no extra-configuration required) that is responsible for issuing heartbeat messages, adding new nodes to topology and for cleaning IP finder (in case it is shared), metrics store (if one is used) and topology store (if one is used). Coordinator may leave or fail, in this case one of the rest nodes will take the role.

Configuration

The following configuration parameters can be used to configure GridTcpDiscoverySpi:

Setter Method Description Optional Default
setIpFinder(GridTcpDiscoveryIpFinder) Javadoc IP finder that is used to share info about nodes IP addresses. No No value. User should provide value explicitly.
Provided implementations can be used (for configuration details refer to Javadocs):
  • GridTcpDiscoverySharedFsIpFinder Javadoc (Available in Enterprise edition only);
  • GridTcpDiscoveryS3IpFinder Javadoc (Available in Enterprise edition only);
  • GridTcpDiscoveryJdbcIpFinder Javadoc (Available in Enterprise edition only);
  • GridTcpDiscoveryVmIpFinder Javadoc .
setMetricsStore(GridTcpDiscoveryMetricsStore) Javadoc When metrics store is provided metrics are not sent via heartbeat messages, they are stored in the store and are requested by nodes on demand. Each node updates its metrics in the store once a heartbeat period. Under certain conditions using of the metrics store may save network bandwidth. Yes No value. If not provided metrics are updated via heartbeat messages.
Provided implementations can be used (for configuration details refer to Javadocs):
  • GridTcpDiscoverySharedFsMetricsStore Javadoc (Available in Enterprise edition only);
  • GridTcpDiscoveryS3MetricsStore Javadoc (Available in Enterprise edition only);
  • GridTcpDiscoveryJdbcMetricsStore Javadoc (Available in Enterprise edition only);
  • GridTcpDiscoveryVmMetricsStore Javadoc .
setTopologyStore(GridTcpDiscoveryTopologyStore) Javadoc When topology store is provided nodes get topology info from the store. The key difference from the basic discovery is that several nodes may be added to local topologies at a time, therefore there are no extra network connections established. This leads to significant time economy when large topologies are starting. Yes No value. If not provided basic discovery mechanism is used.
Provided implementations can be used (for configuration details refer to Javadocs):
  • GridTcpDiscoverySharedFsTopologyStore Javadoc (Available in Enterprise edition only);
  • GridTcpDiscoveryJdbcTopologyStore Javadoc (Available in Enterprise edition only);
  • GridTcpDiscoveryVmTopologyStore Javadoc .
setLocalAddress(String) Javadoc Sets local host IP address that discovery SPI uses. Yes If not provided, by default a first found non-loopback address will be used. If there is no non-loopback address available, then java.net.InetAddress.getLocalHost() will be used.
setLocalPort(int) Javadoc Port the SPI listens to. Yes 47500 (specified by GridTcpDiscoverySpi.DFLT_PORT Javadoc )
setLocalPortRange(int) Javadoc Local port range. Local node will try to bind on first available port starting from local port up until local port + local port range. Yes 100 (specified by GridTcpDiscoverySpi.DFLT_PORT_RANGE Javadoc )
setHeartbeatFrequency(int) Javadoc Delay in milliseconds between heartbeat issuing of heartbeat messages. SPI sends messages in configurable time interval to other nodes to notify them about its state. Yes 3000 (specified by GridTcpDiscoverySpi.DFLT_HEARTBEAT_FREQ Javadoc )
setMaxMissedHeartbeats(int) Javadoc Number of heartbeat requests that could be missed before local node initiates status check. Yes 3 (specified by GridTcpDiscoverySpi.DFLT_MAX_MISSED_HEARTBEATS Javadoc )
setReconnectCount(int) Javadoc Number of times node tries to (re)establish connection to another node. Yes 2 (specified by GridTcpDiscoverySpi.DFLT_RECONNECT_CNT Javadoc )
setNetworkTimeout(int) Javadoc Sets maximum network timeout in milliseconds to use for network operations. Yes 3000 (specified by GridTcpDiscoverySpi.DFLT_NETWORK_TIMEOUT Javadoc )
setThreadPriority(int) Javadoc Thread priority for threads started by SPI. Yes 7 (specified by GridTcpDiscoverySpi.DFLT_THREAD_PRI Javadoc )
setStoresCleanFrequency(int) Javadoc IP finder and Metrics Store clean frequency in milliseconds. Coordinator will clean IP finder and metrics store once a period. Yes 60000 (specified by GridTcpDiscoverySpi.DFLT_STORES_CLEAN_FREQ Javadoc )
setStatisticsPrintFrequency(int) Javadoc Statistics print frequency in milliseconds. 0 indicates that no print is required. If value is greater than 0 and log is not quiet then stats are printed out with INFO level once a period. This may be very helpful for tracing topology problems. Yes 0 (specified by GridTcpDiscoverySpi.DFLT_STATS_PRINT_FREQ Javadoc )

Using Metrics Store

Using of metrics store can increase network performance (especially in large topologies) and save network bandwidth since metrics are not sent via heartbeat messages, they are stored in the store and are requested by nodes on demand. Each node updates its metrics in the store once a heartbeat period.

Without metrics store heartbeat message may grow a bit too much to be quickly and efficiently transferred across all nodes in topology, so for better performance we recommend using metrics store.

Provided implementations can be used (for configuration details refer to Javadocs):

  • GridTcpDiscoverySharedFsMetricsStore Javadoc (Available in Enterprise edition only);
  • GridTcpDiscoveryS3MetricsStore Javadoc (Available in Enterprise edition only);
  • GridTcpDiscoveryJdbcMetricsStore Javadoc (Available in Enterprise edition only);
  • GridTcpDiscoveryVmMetricsStore Javadoc .

Using Topology Store

When topology store is provided nodes get topology info from the store. The key difference from the basic discovery is that several nodes may be added to local topologies at a time, therefore there are no extra network connections established. This leads to significant time economy when large topologies are starting.

Provided implementations can be used (for configuration details refer to Javadocs):

  • GridTcpDiscoverySharedFsTopologyStore Javadoc (Available in Enterprise edition only);
  • GridTcpDiscoveryJdbcTopologyStore Javadoc (Available in Enterprise edition only);
  • GridTcpDiscoveryVmTopologyStore Javadoc .

Using TCP Discovery With Large Topologies

When you are going to launch significant amount of nodes (100 and more) in your grid, it is recommended to configure SPI using topology and metrics stores.

Please refer to the following table for SPI configuration:

Property Value
networkTimeout 30000
heartbeatFrequency 10000

Examples

Java example

GridTcpDiscoverySpi spi = new GridTcpDiscoverySpi();

GridTcpDiscoveryVmIpFinder ipFinder = new GridTcpDiscoveryVmIpFinder();

ipFinder.setAddresses(Arrays.asList("127.0.0.1", "1.2.3.4:47520"));

// IP finder is required.
spi.setIpFinder(ipFinder);

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.tcp.GridTcpDiscoverySpi">
                <property name="ipFinder">
                    <bean class="org.gridgain.grid.spi.discovery.tcp.ipfinder.vm.GridTcpDiscoveryVmIpFinder">
                        <property name="addresses">
                            <list>
                                <value>1.2.3.4:47500</value>
                            </list>
                        </property>
                        <property name="segmentCheckAddrs">
                            <list>
                                <bean class="java.net.InetAddress" factory-method="getByName">
                                    <constructor-arg value="2.3.4.5"/>
                                </bean>
                            </list>
                        </property>
                    </bean>
                </property>
            </bean>
        </property>
        ...
</bean>

or from or from Spring config file using JSON configuration

<bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfigurationAdapter" singleton="true">
        ...
        <property name="discoverySpi">
            <bean class="org.gridgain.grid.spi.discovery.tcp.GridTcpDiscoverySpi">
                <property name="json" value="{heartbeatFrequency: 5000; networkTimeout: 4000; 
                    ipFinder: {addresses: ['1.2.3.4:47500'];
                    @class:'org.gridgain.grid.spi.discovery.tcp.ipfinder.vm.GridTcpDiscoveryVmIpFinder'}}"/>
            </bean>
        </property>
        ...
</bean>

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