Search code examples
javaignite

How to add a new host to existing Apache Ignite instance?


I am trying few examples with Apache Ignite. I am feeding the addresses for my Ignite node in this format

ipFinderTcpIp.setAddresses(memberStrings); // ipFinderTcpIp is of TcpDiscoveryVmIpFinder class
spi.setIpFinder(ipFinderTcpIp); //spi is of TcpDiscoverySpi class 
config.setDiscoverySpi(spi); //config is of IgniteConfiguration class
//memberStrings contains the ipv4 addresses in String format. It is a collection. 

Ignite ignite = Ignition.start(config);

The values for memberStrings are taken from an input file I want to add an address dynamically to the ignite node. For the sake of simplicity let us say ignite is already running in addresses A and B, both of which are present in memberStrings. The topology snapshot looks like

Topology snapshot [ver=1, servers=2, clients=0, CPUs=8, offheap=4.5GB, heap=3.6GB]

Let's say i add a new address 'C' to the input file. I have a running thread which detects this change and makes the change in memberStrings. How do i make sure C is also present in the topology without stopping and restarting the ignite instance to run the above piece of code again??


Solution

  • Basically, you don't need to add this address 'C' to the configuration of the first node. At the moment of start, node C will try to connect to the all addresses from its list and it doesn't need to have its address in config of the node 'A'. So, the node will join the cluster without any problem.

    In some cases may be useful to share all IP addresses between all nodes, using 'shared' flag: https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/spi/discovery/tcp/ipfinder/vm/TcpDiscoveryVmIpFinder.html#setShared-boolean- i.e., this flag can be used for clients - at the moment of reconnecting, it will try to reconnect to all nodes in cluster.

    Additionally, if you don't know all the addresses before start, you can use other implementations of IpFinder: https://apacheignite.readme.io/docs/tcpip-discovery