Using timeout in P2P architecture
I'm writing a P2P application using Java. More specifically I'm using RMI for realizing a token ring like inter-node com开发者_运维技巧munication system For realizing a fault tolerant system I need to detect nodes' crashes. Each node in the ring have to wait for the token for X seconds. After this time the node must wake up and perform some action (for example, it can pull the token). Which method could I use for realizing timeouts in each node?
Thanks in advance!!
This is a classical issue in P2P systems. The short answer is: if you don't get an answer from a remote peer after some chosen delay, you MUST assume that it is unreachable (and take the risk of being wrong).
This does not necessarily mean that the remote peer is offline or crashed, it could simply mean that someone cut a cable deep in the ocean and that there is no alternative way to cross the ocean, or that any alternative channels are overloaded and cannot satisfy your bandwidth/connection request.
The bottom issue is that you can't find out for sure what happened to the connection when you notice some trouble with a remote peer (i.e., did someone cut a cable or did the peer actually crash?), no matter how hard you try.
精彩评论