You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by David Li <da...@gmail.com> on 2017/08/14 07:18:20 UTC

TcpDiscoveryVmIpFinder handle IP change

Hi all,

Currently I am connecting to an ignite server node
with TcpDiscoveryVmIpFinder, from a client node, using a domain as
hostname, eg. ignite.dev, normally when there is any network issue or
server issue, the client node will reconnect automatically when the network
restore or ignite server node up again. But it cannot reconnect if the IP
address of the server node has changed.

I had a look the TcpDiscoveryVmIpFinder class, when setting the address, it
resolve the ip string (or hostname) as  InetSocketAddress , I guess when
ignite try to reconnect, it directly use the  InetSocketAddress , will not
try to resolve the ip address by the original hostname, so I am thinking
maybe I can extend the TcpDiscoveryVmIpFinder, and make it work for my
scenario, but I am not very sure about the place to change.

Overall, my ignite server node may change its IP address if it up from a
failure, and I want my client node can automatically reconnect itself to
the server node. Any help are appreciated. Thank you.


David
14 Aug

Re: TcpDiscoveryVmIpFinder handle IP change

Posted by dkarachentsev <dk...@gridgain.com>.
Hi,

It looks OK, I don't see any problems here.

Thanks!
-Dmitry.



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/TcpDiscoveryVmIpFinder-handle-IP-change-tp16156p16198.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: TcpDiscoveryVmIpFinder handle IP change

Posted by David Li <da...@gmail.com>.
Based on your info, I work out a solution as extend from
TcpDiscoveryVmIpFinder,

@Override
public synchronized Collection<InetSocketAddress> getRegisteredAddresses() {
    Collection<String> addrs = new LinkedHashSet<>();
    for (InetSocketAddress addr : super.getRegisteredAddresses()) {
        addrs.add(addr.getHostString());
    }
    super.setAddresses(addrs);
    return super.getRegisteredAddresses();
}


I tested, it works fine. I am just not sure if there is any negative
impacts.


On Tue, Aug 15, 2017 at 2:40 AM, Nikolai Tikhonov <nt...@apache.org>
wrote:

> Hi David,
>
> JVM can cache a name service. Could you try to set
> *networkaddress.cache.ttl* to zero?
>
> 1. http://www.myhowto.org/java/42-understanding-host-
> name-resolution-and-dns-behavior-in-java
> 2. http://docs.oracle.com/javase/1.5.0/docs/guide/net/properties.html
>
> On Mon, Aug 14, 2017 at 10:18 AM, David Li <da...@gmail.com> wrote:
>
>> Hi all,
>>
>> Currently I am connecting to an ignite server node
>> with TcpDiscoveryVmIpFinder, from a client node, using a domain as
>> hostname, eg. ignite.dev, normally when there is any network issue or
>> server issue, the client node will reconnect automatically when the network
>> restore or ignite server node up again. But it cannot reconnect if the IP
>> address of the server node has changed.
>>
>> I had a look the TcpDiscoveryVmIpFinder class, when setting the address,
>> it resolve the ip string (or hostname) as  InetSocketAddress , I guess
>> when ignite try to reconnect, it directly use the  InetSocketAddress ,
>> will not try to resolve the ip address by the original hostname, so I am
>> thinking maybe I can extend the TcpDiscoveryVmIpFinder, and make it work
>> for my scenario, but I am not very sure about the place to change.
>>
>> Overall, my ignite server node may change its IP address if it up from a
>> failure, and I want my client node can automatically reconnect itself to
>> the server node. Any help are appreciated. Thank you.
>>
>>
>> David
>> 14 Aug
>>
>>
>

Re: TcpDiscoveryVmIpFinder handle IP change

Posted by Nikolai Tikhonov <nt...@apache.org>.
Hi David,

JVM can cache a name service. Could you try to set
*networkaddress.cache.ttl* to zero?

1.
http://www.myhowto.org/java/42-understanding-host-name-resolution-and-dns-behavior-in-java
2. http://docs.oracle.com/javase/1.5.0/docs/guide/net/properties.html

On Mon, Aug 14, 2017 at 10:18 AM, David Li <da...@gmail.com> wrote:

> Hi all,
>
> Currently I am connecting to an ignite server node
> with TcpDiscoveryVmIpFinder, from a client node, using a domain as
> hostname, eg. ignite.dev, normally when there is any network issue or
> server issue, the client node will reconnect automatically when the network
> restore or ignite server node up again. But it cannot reconnect if the IP
> address of the server node has changed.
>
> I had a look the TcpDiscoveryVmIpFinder class, when setting the address,
> it resolve the ip string (or hostname) as  InetSocketAddress , I guess
> when ignite try to reconnect, it directly use the  InetSocketAddress ,
> will not try to resolve the ip address by the original hostname, so I am
> thinking maybe I can extend the TcpDiscoveryVmIpFinder, and make it work
> for my scenario, but I am not very sure about the place to change.
>
> Overall, my ignite server node may change its IP address if it up from a
> failure, and I want my client node can automatically reconnect itself to
> the server node. Any help are appreciated. Thank you.
>
>
> David
> 14 Aug
>
>