Sorry I made a mistake. DNS protocol resolve domain name with several IP.
In java a call to InetAddress.getAllByName( "www.google.com" ) send you
back all the IP address :
www.google.com/173.194.34.18
www.google.com/173.194.34.16
www.google.com/173.194.34.19
www.google.com/173.194.34.17
www.google.com/173.194.34.20
You can't use this method with Mina ?


2012/12/19 Suhas Sutar <[email protected]>

> In my simple test, I have below code:
> SocketAddress socketAddress = new InetSocketAddress(hostAddressString,
> hostPortNumber);
>
> Java documentation mentions that this class performs DNS lookups and
> maintains the DNS cache. I turned the cache off using Java system
> property "networkaddress.cache.ttl=0".
>
> When this line is executed, Java does a DNS lookup and DNS returns two
> IPs. Please see attached network capture.
>
> The InetSocketAddress class provides only one method to get the IP
> address back and to work with MINA, an instance of this class is provided.
>
> Now the fact that one IP went down is not reflected in DNS so even though
> you force DNS lookup, it will return two IPs. The InetSocketAddress.
> getAddress() returns one of these IPs and there is no guarantee that it
> would not give me the IP which went down.
>
> Thanks
> Suhas
>
>
>
> On Wed, Dec 19, 2012 at 11:03 AM, Jean-Yves Linet <[email protected]>wrote:
>
>> Well I don't know how it could be possible for Java to do a DNS lookup and
>> receive more than one IP. Is this kind of request included in DNS protocol
>> ?? If not it is not a Java limitation, it is just not possible to do.
>> In your case you could insert two domain name in your client app or you
>> could add your own load balancing protocol.
>> BTW did you try to lookup your DNS server with a non java application and
>> see what you get ?
>>
>>
>>
>>
>> 2012/12/19 Suhas Sutar <[email protected]>
>>
>> > After little more testing, I have concluded that it is not MINA issue.
>> To
>> > open a connection to target server, I use below code with MINA:
>> >
>> > ======================================
>> > ExecutorService ioExecutor = Executors.newCachedThreadPool();
>> > IoConnector ioConnector = new SocketConnector(Runtime.getRuntime()
>> > .availableProcessors()
>> > + 1, ioExecutor);
>> > SocketAddress socketAddress = new InetSocketAddress(hostAddressString,
>> > hostPortNumber);
>> > ConnectFuture future = ioConnector.connect(socketAddress);
>> > ======================================
>> >
>> > The InetSocketAddress class internally does a DNS lookup and maintains a
>> > cache of the IP addresses. But it seems that there is no way to retrieve
>> > all the IP addresses associated with a host name. The
>> > method InetSocketAddress.getAddress() returns only one IP address and
>> even
>> > though one of the IPs is unavailable, it would not cycle through the
>> next
>> > one. I even turned off the DNS caching using Java system property
>> > "networkaddress.cache.ttl=0".
>> >
>> > Again, it is not caching issue in my opinion. Even though I want to
>> handle
>> > it in the application code, the Java APIs does not provide me a way to
>> know
>> > that there are multiple IP addresses for a given host.
>> >
>> > I am not sure how application developers are handling this situation.
>> >
>> >
>> >
>> > On Wed, Dec 19, 2012 at 6:14 AM, Emmanuel Lécharny <[email protected]
>> > >wrote:
>> >
>> > > Le 12/19/12 11:15 AM, Jean-Yves Linet a écrit :
>> > > > Hi,
>> > > > Well your problem can have multiple explanations :
>> > > > Do you remove the down host IP from the DNS list ? Otherwise DNS
>> server
>> > > > will continue to use it.
>> > > > DNS resolution can be cached somewhere. (see networkaddress.cache in
>> > Java
>> > > > properties)
>> > > > I doubt that this could be a MINA issue.
>> > > I was about to do the exact same answer.
>> > >
>> > >
>> > >
>> > > --
>> > > Regards,
>> > > Cordialement,
>> > > Emmanuel Lécharny
>> > > www.iktek.com
>> > >
>> > >
>> >
>>
>
>

Reply via email to