You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "이희승 (Trustin Lee)" <tr...@gmail.com> on 2008/02/18 05:57:42 UTC

Asynchronous DNS query as a separate submodule

Hi,

I thought about incorporating asynchronous DNS query feature into MINA
core, and reached to the temporary conclusion that it might be a better
idea to keep it as a separate submodule.

The reasoning behind this idea is that InetSocketAddress() doesn't query
DNS server at all if an IP address is specified.  For example, new
InetSocketAddress("gleamynode.net", 8080) causes a DNS lookup, but new
InetSocketAddress("123.123.123.123", 8080) doesn't, which means that we
can still keep SocketAddress as a standard interface to represent an
endpoint.

In the separate module, user could request asynchronous DNS query like
the following:

DnsResolver resolver = ...;
Future<InetAddress> f = resolver.query("gleamynode.net");
// returns an InetAddress with an IP address rather than with host name.
InetAddress address = f.get();

By providing this submodule rather than changing the core:

1) Most users are happy that they don't need to change anything.
2) Some users who needs asynchronous domain name resolution can use the
submodule for better simultaneous, asynchronous, complicated domain
resolution.

We could provide it as a subproject, but in this case, providing it as a
submodule will make MINA more complete network application framework.
On the other point, it's also the implementation of DNS protocol, so it
might be a better idea to provide it as a subproject.

WDYT?

-- 
Trustin Lee - Principal Software Engineer, JBoss, Red Hat
--
what we call human nature is actually human habit
--
http://gleamynode.net/

Re: Asynchronous DNS query as a separate submodule

Posted by Stefano Bagnara <ap...@bago.org>.
In jSPF library (james.apache.org/jspf/) we use dnsjnio [1] (an 
anynchronous/SEDA wrapper for dnsjava). It is opensource and licensed 
under the Apache License v2.

It may also worth remembering this past discussion:
http://www.mail-archive.com/dev@directory.apache.org/msg14110.html
http://www.mail-archive.com/dev@mina.apache.org/msg02892.html

Stefano

[1] http://sourceforge.net/projects/dnsjnio

이희승 (Trustin Lee) ha scritto:
> Hi,
> 
> I thought about incorporating asynchronous DNS query feature into MINA
> core, and reached to the temporary conclusion that it might be a better
> idea to keep it as a separate submodule.
> 
> The reasoning behind this idea is that InetSocketAddress() doesn't query
> DNS server at all if an IP address is specified.  For example, new
> InetSocketAddress("gleamynode.net", 8080) causes a DNS lookup, but new
> InetSocketAddress("123.123.123.123", 8080) doesn't, which means that we
> can still keep SocketAddress as a standard interface to represent an
> endpoint.
> 
> In the separate module, user could request asynchronous DNS query like
> the following:
> 
> DnsResolver resolver = ...;
> Future<InetAddress> f = resolver.query("gleamynode.net");
> // returns an InetAddress with an IP address rather than with host name.
> InetAddress address = f.get();
> 
> By providing this submodule rather than changing the core:
> 
> 1) Most users are happy that they don't need to change anything.
> 2) Some users who needs asynchronous domain name resolution can use the
> submodule for better simultaneous, asynchronous, complicated domain
> resolution.
> 
> We could provide it as a subproject, but in this case, providing it as a
> submodule will make MINA more complete network application framework.
> On the other point, it's also the implementation of DNS protocol, so it
> might be a better idea to provide it as a subproject.
> 
> WDYT?



Re: Asynchronous DNS query as a separate submodule

Posted by Daniel Cheng <gm...@sdiz.net>.
Hi,

There is a pure java DNS client/server on
  http://www.dnsjava.org/

It is BSD-like licensed. Maybe you can adopt some code from it?

이희승 (Trustin Lee) wrote:
> Hi,
> 
> I thought about incorporating asynchronous DNS query feature into MINA
> core, and reached to the temporary conclusion that it might be a better
> idea to keep it as a separate submodule.
> 
> The reasoning behind this idea is that InetSocketAddress() doesn't query
> DNS server at all if an IP address is specified.  For example, new
> InetSocketAddress("gleamynode.net", 8080) causes a DNS lookup, but new
> InetSocketAddress("123.123.123.123", 8080) doesn't, which means that we
> can still keep SocketAddress as a standard interface to represent an
> endpoint.
> 
> In the separate module, user could request asynchronous DNS query like
> the following:
> 
> DnsResolver resolver = ...;
> Future<InetAddress> f = resolver.query("gleamynode.net");
> // returns an InetAddress with an IP address rather than with host name.
> InetAddress address = f.get();
> 
> By providing this submodule rather than changing the core:
> 
> 1) Most users are happy that they don't need to change anything.
> 2) Some users who needs asynchronous domain name resolution can use the
> submodule for better simultaneous, asynchronous, complicated domain
> resolution.
> 
> We could provide it as a subproject, but in this case, providing it as a
> submodule will make MINA more complete network application framework.
> On the other point, it's also the implementation of DNS protocol, so it
> might be a better idea to provide it as a subproject.
> 
> WDYT?
> 


-- 
This space was intended to be left blank.


Re: Asynchronous DNS query as a separate submodule

Posted by "Alan D. Cabrera" <li...@toolazydogs.com>.
+1


Regards,
Alan

On Feb 17, 2008, at 8:57 PM, 이희승 (Trustin Lee) wrote:

> Hi,
>
> I thought about incorporating asynchronous DNS query feature into MINA
> core, and reached to the temporary conclusion that it might be a  
> better
> idea to keep it as a separate submodule.
>
> The reasoning behind this idea is that InetSocketAddress() doesn't  
> query
> DNS server at all if an IP address is specified.  For example, new
> InetSocketAddress("gleamynode.net", 8080) causes a DNS lookup, but new
> InetSocketAddress("123.123.123.123", 8080) doesn't, which means that  
> we
> can still keep SocketAddress as a standard interface to represent an
> endpoint.
>
> In the separate module, user could request asynchronous DNS query like
> the following:
>
> DnsResolver resolver = ...;
> Future<InetAddress> f = resolver.query("gleamynode.net");
> // returns an InetAddress with an IP address rather than with host  
> name.
> InetAddress address = f.get();
>
> By providing this submodule rather than changing the core:
>
> 1) Most users are happy that they don't need to change anything.
> 2) Some users who needs asynchronous domain name resolution can use  
> the
> submodule for better simultaneous, asynchronous, complicated domain
> resolution.
>
> We could provide it as a subproject, but in this case, providing it  
> as a
> submodule will make MINA more complete network application framework.
> On the other point, it's also the implementation of DNS protocol, so  
> it
> might be a better idea to provide it as a subproject.
>
> WDYT?
>
> -- 
> Trustin Lee - Principal Software Engineer, JBoss, Red Hat
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/


Re: Asynchronous DNS query as a separate submodule

Posted by Julien Vermillard <jv...@archean.fr>.
Hi 

+1 for the API. I think it's reasonable because most of users won't care
of async DNS resolution.

+1 for the DNS subproject.

Julien


On Mon, 18 Feb 2008 13:57:42 +0900
이희승 "(Trustin Lee)" <tr...@gmail.com> wrote:

> Hi,
> 
> I thought about incorporating asynchronous DNS query feature into MINA
> core, and reached to the temporary conclusion that it might be a
> better idea to keep it as a separate submodule.
> 
> The reasoning behind this idea is that InetSocketAddress() doesn't
> query DNS server at all if an IP address is specified.  For example,
> new InetSocketAddress("gleamynode.net", 8080) causes a DNS lookup,
> but new InetSocketAddress("123.123.123.123", 8080) doesn't, which
> means that we can still keep SocketAddress as a standard interface to
> represent an endpoint.
> 
> In the separate module, user could request asynchronous DNS query like
> the following:
> 
> DnsResolver resolver = ...;
> Future<InetAddress> f = resolver.query("gleamynode.net");
> // returns an InetAddress with an IP address rather than with host
> name. InetAddress address = f.get();
> 
> By providing this submodule rather than changing the core:
> 
> 1) Most users are happy that they don't need to change anything.
> 2) Some users who needs asynchronous domain name resolution can use
> the submodule for better simultaneous, asynchronous, complicated
> domain resolution.
> 
> We could provide it as a subproject, but in this case, providing it
> as a submodule will make MINA more complete network application
> framework. On the other point, it's also the implementation of DNS
> protocol, so it might be a better idea to provide it as a subproject.
> 
> WDYT?
> 

Re: Asynchronous DNS query as a separate submodule

Posted by Matteo Merli <ma...@gmail.com>.
Hi,

as I've said in another mail, I've done some work on building an
asyncronous DNS client because I needed in building a HTTP caching
proxy.

Now I've done some API refactoring and there is a module that uses an
API like the one proposed by Trustin.

DnsResolver resolver = new DnsResolver(); // This istance will be shared

DnsFuture f = resolver.resolve( "www.google.com" );
f.addListener(new IoFutureListener<DnsFuture>() {
            public void operationComplete(DnsFuture future) {
                if ( ! future.isNameError() )
                {
                        InetAddress address = future.get();
                        .......
                }
            }
        });

or:

f.await();
f.getAll(); // Returns a List<InetAddress> with all the addresses for the host


The implementations is not complete yes as :

 * Only uses first DNS server (primary), as read from /etc/resolv.conf
 * Does not work on Windows ( I don't know how to get the nameservers list )
 * Can cache DNS addresses, but.. caches forever as no expiration is applied
 * Does not use (cache) aliases

The code can be found here:
http://alijo.googlecode.com/svn/trunk/protocol-dns/

The codecs are based on ApacheDirectory DNS codecs.

I would be happy if this code will be useful, and accept any comment
on API and implementation.

Regards,
Matteo

On Feb 18, 2008 5:57 AM, 이희승 (Trustin Lee) <tr...@gmail.com> wrote:
> Hi,
>
> I thought about incorporating asynchronous DNS query feature into MINA
> core, and reached to the temporary conclusion that it might be a better
> idea to keep it as a separate submodule.
>
> The reasoning behind this idea is that InetSocketAddress() doesn't query
> DNS server at all if an IP address is specified.  For example, new
> InetSocketAddress("gleamynode.net", 8080) causes a DNS lookup, but new
> InetSocketAddress("123.123.123.123", 8080) doesn't, which means that we
> can still keep SocketAddress as a standard interface to represent an
> endpoint.
>
> In the separate module, user could request asynchronous DNS query like
> the following:
>
> DnsResolver resolver = ...;
> Future<InetAddress> f = resolver.query("gleamynode.net");
> // returns an InetAddress with an IP address rather than with host name.
> InetAddress address = f.get();
>
> By providing this submodule rather than changing the core:
>
> 1) Most users are happy that they don't need to change anything.
> 2) Some users who needs asynchronous domain name resolution can use the
> submodule for better simultaneous, asynchronous, complicated domain
> resolution.
>
> We could provide it as a subproject, but in this case, providing it as a
> submodule will make MINA more complete network application framework.
> On the other point, it's also the implementation of DNS protocol, so it
> might be a better idea to provide it as a subproject.
>
> WDYT?
>
> --
> Trustin Lee - Principal Software Engineer, JBoss, Red Hat
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
>



-- 
Matteo Merli
<ma...@gmail.com>