Isolated Ignite clusters on same set of machines

Viewed 66

I'm using Apache.Ignite NET 2.12.0.

I tried several approaches to allow two Ignite clusters to be run separately on the machine:

  1. Approach described here. I specified DiscoverySPI and CommunicationSPI port for each instance of server(I use client-server model) to isolate them, but the server failed to run with this warning:

[05:03:01,968][WARNING][main][TcpDiscoverySpi] Failed to connect to any address from IP finder (make sure IP finder addresses are correct and firewalls are disabled on all host machines): [/127.0.0.1:47501, /127.0.0.1:47502]

In that case, the execution enters Ignition.Start and don't leave it.

  1. I tried to provide IgniteConfiguration.SslContextFactory with different certificates to avoid the different clusters seeing each other, but in that case - they see each other, but the clusters fail to join each other, which prevents them from working.

Is there some easy way to do this?

1 Answers

The approach from the docs works, here is the corresponding C# code, tested with Ignite.NET 2.12:

static IgniteConfiguration GetConfig(int port, int portRange) =>
    new IgniteConfiguration
    {
        DiscoverySpi = new TcpDiscoverySpi
        {
            IpFinder = new TcpDiscoveryStaticIpFinder
            {
                Endpoints = new[]
                {
                    $"127.0.0.1:{port}..{port + portRange}"
                }
            },
            LocalPort = port,
            LocalPortRange = portRange
        },
        CommunicationSpi = new TcpCommunicationSpi
        {
            LocalPort = port - portRange,
            LocalPortRange = portRange
        },
        AutoGenerateIgniteInstanceName = true
    };

var clusterCfg1 = GetConfig(49500, 10);
var clusterCfg2 = GetConfig(49700, 10);

var cluster1Node1 = Ignition.Start(clusterCfg1);
var cluster1Node2 = Ignition.Start(clusterCfg1);

var cluster2Node1 = Ignition.Start(clusterCfg2);
var cluster2Node2 = Ignition.Start(clusterCfg2);
var cluster2Node3 = Ignition.Start(clusterCfg2);

Console.WriteLine("Cluster 1 nodes: " + cluster1Node1.GetCluster().GetNodes().Count);
Console.WriteLine("Cluster 2 nodes: " + cluster2Node1.GetCluster().GetNodes().Count);

Prints:

Cluster 1 nodes: 2
Cluster 2 nodes: 3

Proving that we have two separate clusters.

Related