Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [dsdp-tcf-dev] Handling errors when opening a channel

Hi Ken,

> But now I'm curious about the role of the two channel listeners.

Protocol.ChannelOpenListener allows a TCF client to get pointers to
channel objects that were opened by somebody else. If a client open a
channel itself, it already has the pointer and don't need
Protocol.ChannelOpenListener. If a channel is created, for example, by
remote peer connecting to the client, the only way to get the pointer is
Protocol.ChannelOpenListener.

> Our code originally looked like your example but I wondered if
IChannel.IChannelListener.onChannelOpened could be reliable since
opening a channel is asynchronous and might happen before the listener
could be installed.

Yes, it is absolutely reliable, as long as you call peer.openChannel()
and channel.addChannelListener() in same event dispatch cycle. Since all
work is sequenced by single event executed, it guaranties proper
synchronization and absence of racing in situations like this.

> The test case I'm working on involves having an agent shut down but
the client attempts to connect to it before the LocatorService's peer
list is updated. Is there a way to either force the peer list to refresh
or for the agent to provoke this when it shuts down?

No, currently there is no way force the peer list to refresh. Our
thinking was that it is better to keep peer information for a while to
be able to survive intermittent problems, like discovery UDP packet
lost, or peer restart, reboot, power cycle, etc.

Regards,
Eugene.


-----Original Message-----
From: dsdp-tcf-dev-bounces@xxxxxxxxxxx
[mailto:dsdp-tcf-dev-bounces@xxxxxxxxxxx] On Behalf Of
ken.ryall@xxxxxxxxx
Sent: Thursday, April 30, 2009 10:04 PM
To: dsdp-tcf-dev@xxxxxxxxxxx
Subject: Re: [dsdp-tcf-dev] Handling errors when opening a channel

Eugene,

Thanks, that makes sense. But now I'm curious about the role of the two
channel listeners. It seems like Protocol.ChannelOpenListener tells you
about any new channel when it is opened, and then I suppose you could
add a IChannel.IChannelListener to the channels you are interested in to
find out when they close down, but it would seem simpler to have a
Protocol.ChannelCloseListener as well.

Our code originally looked like your example but I wondered if
IChannel.IChannelListener.onChannelOpened could be reliable since
opening a channel is asynchronous and might happen before the listener
could be installed.

The test case I'm working on involves having an agent shut down but the
client attempts to connect to it before the LocatorService's peer list
is updated. Is there a way to either force the peer list to refresh or
for the agent to provoke this when it shuts down?

Thanks - Ken

> From: "ext Tarassov, Eugene" <eugene.tarassov@xxxxxxxxxxxxx>
> Reply-To: DSDP TCF dev list <dsdp-tcf-dev@xxxxxxxxxxx>
> Date: Fri, 1 May 2009 00:30:02 +0200
> To: DSDP TCF dev list <dsdp-tcf-dev@xxxxxxxxxxx>
> Subject: RE: [dsdp-tcf-dev] Handling errors when opening a channel
> 
> Hi Ken,
> 
> The code is supposed to look like this:
> 
> channel = peer.openChannel();
> channel.addChannelListener(new IChannel.IChannelListener() {
> 
>   public void onChannelOpened() {
>   }
> 
>   public void congestionLevel(int level) {
>   }
> 
>   public void onChannelClosed(Throwable error) {
> 
>     ... handle Connection refused (and all other errors) here ...
> 
>   }
> });
> 
> 
> Regards,
> Eugene
> 
> ________________________________
> 
> From: dsdp-tcf-dev-bounces@xxxxxxxxxxx 
> [mailto:dsdp-tcf-dev-bounces@xxxxxxxxxxx] On Behalf Of 
> ken.ryall@xxxxxxxxx
> Sent: Thursday, April 30, 2009 3:19 PM
> To: dsdp-tcf-dev@xxxxxxxxxxx
> Subject: [dsdp-tcf-dev] Handling errors when opening a channel
> 
> 
> I'd appreciate some advice on how to handle errors when opening a 
> channel. I'm calling IPeer.openChannel but in this case the peer has 
> shutdown and is no longer available.
> 
> java.net.ConnectException: Connection refused: connect
>     at java.net.PlainSocketImpl.socketConnect(Native Method)
>     at java.net.PlainSocketImpl.doConnect(Unknown Source)
>     at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
>     at java.net.PlainSocketImpl.connect(Unknown Source)
>     at java.net.SocksSocketImpl.connect(Unknown Source)
>     at java.net.Socket.connect(Unknown Source)
>     at java.net.Socket.connect(Unknown Source)
>     at java.net.Socket.<init>(Unknown Source)
>     at java.net.Socket.<init>(Unknown Source)
>     at org.eclipse.tm.tcf.core.ChannelTCP$1.run(ChannelTCP.java:70)
> 
> I've installed a ChannelOpenListener but that only tells you when it 
> has been opened, not when something goes wrong. I'm looking for the 
> best place to detect this. It looks like the channel gets terminated 
> but I'm not sure how to listen for that.
> 
> Thanks - Ken
> _______________________________________________
> dsdp-tcf-dev mailing list
> dsdp-tcf-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/dsdp-tcf-dev

_______________________________________________
dsdp-tcf-dev mailing list
dsdp-tcf-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dsdp-tcf-dev


Back to the top