Search in sources :

Example 81 with TcpDiscoveryVmIpFinder

use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project ignite by apache.

the class AgentClusterDemo method igniteConfiguration.

/**
     * Configure node.
     * @param basePort Base port.
     * @param gridIdx Ignite instance name index.
     * @param client If {@code true} then start client node.
     * @return IgniteConfiguration
     */
private static IgniteConfiguration igniteConfiguration(int basePort, int gridIdx, boolean client) {
    IgniteConfiguration cfg = new IgniteConfiguration();
    cfg.setIgniteInstanceName((client ? "demo-client-" : "demo-server-") + gridIdx);
    cfg.setLocalHost("127.0.0.1");
    cfg.setEventStorageSpi(new MemoryEventStorageSpi());
    cfg.setIncludeEventTypes(EVTS_DISCOVERY);
    cfg.getConnectorConfiguration().setPort(basePort);
    System.setProperty(IGNITE_JETTY_PORT, String.valueOf(basePort + 10));
    TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
    int discoPort = basePort + 20;
    ipFinder.setAddresses(Collections.singletonList("127.0.0.1:" + discoPort + ".." + (discoPort + NODE_CNT - 1)));
    // Configure discovery SPI.
    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
    discoSpi.setLocalPort(discoPort);
    discoSpi.setIpFinder(ipFinder);
    cfg.setDiscoverySpi(discoSpi);
    TcpCommunicationSpi commSpi = new TcpCommunicationSpi();
    commSpi.setSharedMemoryPort(-1);
    commSpi.setMessageQueueLimit(10);
    int commPort = basePort + 30;
    commSpi.setLocalPort(commPort);
    cfg.setCommunicationSpi(commSpi);
    cfg.setGridLogger(new Slf4jLogger(log));
    cfg.setMetricsLogFrequency(0);
    if (client)
        cfg.setClientMode(true);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) Slf4jLogger(org.apache.ignite.logger.slf4j.Slf4jLogger) MemoryEventStorageSpi(org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Aggregations

TcpDiscoveryVmIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder)81 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)69 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)69 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)32 FileSystemConfiguration (org.apache.ignite.configuration.FileSystemConfiguration)16 Ignite (org.apache.ignite.Ignite)12 IgfsGroupDataBlocksKeyMapper (org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper)12 ArrayList (java.util.ArrayList)5 IgfsIpcEndpointConfiguration (org.apache.ignite.igfs.IgfsIpcEndpointConfiguration)5 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 ConnectorConfiguration (org.apache.ignite.configuration.ConnectorConfiguration)4 TcpDiscoveryNode (org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode)4 TcpDiscoveryIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder)4 HashMap (java.util.HashMap)3 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)3 TcpCommunicationSpi (org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)3 TcpDiscoveryMulticastIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder)3 IOException (java.io.IOException)2 InetSocketAddress (java.net.InetSocketAddress)2 Properties (java.util.Properties)2