I followed the guide about "Isolated Ignite Clusters on the Same Set of
Machines",
I tried to use xml to start ignite, it is OK.
but when I tried to use java api to start ignite, it failed with the
following info 

"[09:42:47] Failed to connect to any address from IP finder (will retry to
join topology every 2 secs): [/127.0.0.1:48500, /127.0.0.1:48501,
/127.0.0.1:48502, /127.0.0.1:48503, /127.0.0.1:48504, /127.0.0.1:48505,
/127.0.0.1:48506, /127.0.0.1:48507, /127.0.0.1:48508, /127.0.0.1:48509,
/127.0.0.1:48510, /127.0.0.1:48511, /127.0.0.1:48512, /127.0.0.1:48513,
/127.0.0.1:48514, /127.0.0.1:48515, /127.0.0.1:48516, /127.0.0.1:48517,
/127.0.0.1:48518, /127.0.0.1:48519, /127.0.0.1:48520]" 

What is the problem? 

Following is my code: 

import org.apache.ignite.Ignite; 
import org.apache.ignite.IgniteCache; 
import org.apache.ignite.Ignition; 
import org.apache.ignite.configuration.IgniteConfiguration; 
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; 
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; 
import
org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; 

import java.util.Arrays; 

public class Test1 { 

        public static void main(String[] args) { 
        
                Ignition.setClientMode(true); 
                
                IgniteConfiguration cfg1=new IgniteConfiguration(); 
                TcpDiscoverySpi discoverySpi1=new TcpDiscoverySpi(); 
                discoverySpi1.setLocalPort(48500); 
                discoverySpi1.setLocalPortRange(20); 
                
                TcpDiscoveryVmIpFinder ipFinder1=new
TcpDiscoveryVmIpFinder(); 
               
ipFinder1.setAddresses(Arrays.asList("127.0.0.1:48500..48520")); 
                discoverySpi1.setIpFinder(ipFinder1); 
                
                TcpCommunicationSpi commSpi1=new TcpCommunicationSpi(); 
                commSpi1.setLocalPort(48100); 
                cfg1.setDiscoverySpi(discoverySpi1); 
                cfg1.setCommunicationSpi(commSpi1); 

                Ignite ignite1 = Ignition.start(cfg1); 

                IgniteCache<Integer, String> cache1 =
ignite1.getOrCreateCache("myCache1"); 
            for (int i = 0; i < 1000; i++) 
                cache1.put(i, Integer.toString(i)); 
            
                IgniteConfiguration cfg2=new IgniteConfiguration(); 
                TcpDiscoverySpi discoverySpi2=new TcpDiscoverySpi(); 
                discoverySpi2.setLocalPort(49500); 
                discoverySpi2.setLocalPortRange(20); 
                
                TcpDiscoveryVmIpFinder ipFinder2=new
TcpDiscoveryVmIpFinder(); 
               
ipFinder2.setAddresses(Arrays.asList("127.0.0.1:49500..49520")); 
                discoverySpi2.setIpFinder(ipFinder2); 
                
                TcpCommunicationSpi commSpi2=new TcpCommunicationSpi(); 
                commSpi2.setLocalPort(49100); 
                cfg2.setDiscoverySpi(discoverySpi2); 
                cfg2.setCommunicationSpi(commSpi2); 

                Ignite ignite2 = Ignition.start(cfg2); 
        } 
} 



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/How-to-set-isolated-Ignite-Clusters-by-java-API-tp6221.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Reply via email to