Search code examples
javadockeramazon-ecsignite

Make Apache Ignite DiscoverSPI configuration over AWS ecs


I want to configure some cluster over Amazon ECS, the problem is that the TcpDiscoveryJdbcIpFinder persist into the table select * from tbl_addrs; the wrong address. it uses the ip network of the docker, but the ip should be the private ip over ec2 instances to communicate with other dockers nodes in another instances. So I have this configuration

public TcpDiscoverySpi getTcpDiscoverySpi(){

    TcpDiscoverySpi spi = new TcpDiscoverySpi();

    String host = System.getenv("CONTAINER_HOST");
    System.out.println("Starting apache ignite on host -> " + host);
    spi.setLocalAddress(host);
    spi.setLocalPort(this.getDockerPort());

    TcpDiscoveryJdbcIpFinder ipFinder = new TcpDiscoveryJdbcIpFinder();

    ipFinder.setDataSource(this.dataSource);
    spi.setIpFinder(ipFinder);

    return spi;
  }

And I put the IP address of the ec2 instance which I'm getting from http://169.254.169.254/latest/meta-data/local-ipv4 I have the next exception

throw new IgniteSpiException("Failed to bind TCP server socket (possibly all ports in range " +
                "are in use) [firstPort=" + spi.locPort + ", lastPort=" + lastPort +
                ", addr=" + spi.locHost + ']');

And if I try to use the default network settings I get some ips of type 172.0.. and the nodes can't see each other.


Solution

  • I would expect that spi.setLocalAddress will do the trick, but you can also try igniteCfg.setLocalHost().

    Have you tried AWS S3 or AWS ELB discovery? I think it is more appropriate here.