|
Home > Archive > Apache Directory Project > November 2005 > [mina] Detecting connect failure without waiting for ConnectFuture
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
[mina] Detecting connect failure without waiting for ConnectFuture
|
|
| Niklas Therning 2005-11-08, 5:45 pm |
| Forgot the [mina] prefix. Sorry.
Hi,
Is there any way I can detect if a connect operation fails without
having to join or poll the ConnectFuture returned by connect()?
/Niklas
| |
| Niklas Therning 2005-11-11, 2:45 am |
| Since I badly needed to be able to detected connect failures without
having to wait for a ConnectFuture I added support for it. See the
attached patch. Basically what I've done is to add an extra callback to
IoHandler:
void connectFailed( Throwable cause, Object mark ) throws Exception;
Then there is an extra connect-method in IoConnector:
ConnectFuture connect( SocketAddress address, SocketAddress localAddress,
IoHandler handler, Object mark ) throws
IOException;
When connect fails for any of the IoConnector implementations they will
notify the IoHandler specified in the call to connect() and pass along
the mark Object. That's it.
NOTE: I had to move the call to sessionCreated in
DatagramConnectorDelegate.regsiterNew() down a bit to make it less
likely that sessionCreated() is called even if connect fails.
Is this something that could be considered for inclusion in Mina?
/Niklas
Niklas Therning wrote:
>Forgot the [mina] prefix. Sorry.
>
>Hi,
>
>Is there any way I can detect if a connect operation fails without
>having to join or poll the ConnectFuture returned by connect()?
>
>/Niklas
>
>
>
>
| |
| Trustin Lee 2005-11-11, 2:45 am |
| What do you think about just using exceptionCaught handler? I think you can
use 'instanceof ConnectException'. Let me know if you like it.
Trustin
2005/11/11, Niklas Therning <niklas-8FIgwK2HfyIwFerOooGFRg@public.gmane.org>:
>
> Since I badly needed to be able to detected connect failures without
> having to wait for a ConnectFuture I added support for it. See the
> attached patch. Basically what I've done is to add an extra callback to
> IoHandler:
>
> void connectFailed( Throwable cause, Object mark ) throws Exception;
>
> Then there is an extra connect-method in IoConnector:
>
> ConnectFuture connect( SocketAddress address, SocketAddress localAddress,
> IoHandler handler, Object mark ) throws
> IOException;
>
> When connect fails for any of the IoConnector implementations they will
> notify the IoHandler specified in the call to connect() and pass along
> the mark Object. That's it.
>
> NOTE: I had to move the call to sessionCreated in
> DatagramConnectorDelegate.regsiterNew() down a bit to make it less
> likely that sessionCreated() is called even if connect fails.
>
> Is this something that could be considered for inclusion in Mina?
>
> /Niklas
>
> Niklas Therning wrote:
>
>
>
>
>
--
what we call human nature is actually human habit
--
http://gleamynode.net/
| |
| Trustin Lee 2005-11-11, 5:45 pm |
| I've added a JIRA issue here:
http://issues.apache.org/jira/browse/DIRMINA-120
I think this is the most convenient and elegant way to handle individual I/O
requests. WDYT?
Trustin
2005/11/11, Trustin Lee <trustin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
>
> What do you think about just using exceptionCaught handler? I think you
> can use 'instanceof ConnectException'. Let me know if you like it.
>
> Trustin
>
> 2005/11/11, Niklas Therning < niklas-8FIgwK2HfyIwFerOooGFRg@public.gmane.org>:
>
>
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
--
what we call human nature is actually human habit
--
http://gleamynode.net/
| |
| Niklas Therning 2005-11-12, 2:45 am |
| I'm afraid exceptionCaught won't work since it expects an IoSession:
void exceptionCaught( IoSession session, Throwable cause ) throws Exception;
When a connect fails there is no session yet. (Well actually there is in
the Datagram case but I'm not sure if it is right to use it before
sessionCreated has been called on it.)
Trustin Lee wrote:
> What do you think about just using exceptionCaught handler? I think
> you can use 'instanceof ConnectException'. Let me know if you like it.
>
> Trustin
>
> 2005/11/11, Niklas Therning < niklas-8FIgwK2HfyIwFerOooGFRg@public.gmane.org
> <mailto:niklas-8FIgwK2HfyIwFerOooGFRg@public.gmane.org>>:
>
> Since I badly needed to be able to detected connect failures without
> having to wait for a ConnectFuture I added support for it. See the
> attached patch. Basically what I've done is to add an extra
> callback to
> IoHandler:
>
> void connectFailed( Throwable cause, Object mark ) throws Exception;
>
> Then there is an extra connect-method in IoConnector:
>
> ConnectFuture connect( SocketAddress address, SocketAddress
> localAddress,
> IoHandler handler, Object mark ) throws
> IOException;
>
> When connect fails for any of the IoConnector implementations they
> will
> notify the IoHandler specified in the call to connect() and pass along
> the mark Object. That's it.
>
> NOTE: I had to move the call to sessionCreated in
> DatagramConnectorDelegate.regsiterNew() down a bit to make it less
> likely that sessionCreated() is called even if connect fails.
>
> Is this something that could be considered for inclusion in Mina?
>
> /Niklas
>
> Niklas Therning wrote:
>
>
>
>
>
>
>
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/ <http://gleamynode.net/>
| |
| Niklas Therning 2005-11-12, 2:45 am |
| Looks great to me. This way you don't have to add any new methods to
IoHandler. I could have a look at it and implement it if you haven't
started on it already. Just let me know.
Trustin Lee wrote:
> I've added a JIRA issue here:
>
> http://issues.apache.org/jira/browse/DIRMINA-120
>
> I think this is the most convenient and elegant way to handle
> individual I/O requests. WDYT?
>
> Trustin
| |
| Irving, Dave 2005-11-12, 7:45 am |
| > Looks great to me. This way you don't have to add any new methods to
IoHandler. I could have a look at it and implement it if you haven't
started on it already. Just let me know.
Im really really sorry - I just saw this email. I checked JIRA earlier
and saw the feature request and submitted a patch as I had half an hour
spare this morning. Didn't realise it had already been claimed :o)
I extended it slightly by adding the ability to listen for the result of
any IoFuture: ConnectFuture expands on this to support the interface
outlined in JIRA.
Dave=20
-----Original Message-----
From: Niklas Therning [mailto:niklas-8FIgwK2HfyIwFerOooGFRg@public.gmane.org]=20
Sent: 12 November 2005 07:43
To: Apache Directory Developers List
Subject: Re: [mina] Detecting connect failure without waiting for
ConnectFuture
Looks great to me. This way you don't have to add any new methods to
IoHandler. I could have a look at it and implement it if you haven't
started on it already. Just let me know.
Trustin Lee wrote:
> I've added a JIRA issue here:
>
> http://issues.apache.org/jira/browse/DIRMINA-120
>
> I think this is the most convenient and elegant way to handle=20
> individual I/O requests. WDYT?
>
> Trustin
This e-mail and any attachment is for authorised use by the intended recipi=
ent(s) only. It may contain proprietary material, confidential information =
and/or be subject to legal privilege. It should not be copied, disclosed to=
, retained or used by, any other party. If you are not an intended recipien=
t then please promptly delete this e-mail and any attachment and all copies=
and inform the sender. Thank you.
| |
| Niklas Therning 2005-11-13, 7:45 am |
| Irving, Dave wrote:
>IoHandler. I could have a look at it and implement it if you haven't
>started on it already. Just let me know.
>
>Im really really sorry - I just saw this email. I checked JIRA earlier
>and saw the feature request and submitted a patch as I had half an hour
>spare this morning. Didn't realise it had already been claimed :o)
>I extended it slightly by adding the ability to listen for the result of
>any IoFuture: ConnectFuture expands on this to support the interface
>outlined in JIRA.
>
>Dave
>
>
It's ok man. Don't worry about it. :-D
BTW, the patch looks really great! Thanks.
/Niklas
|
|
|
|
|