rolandweber / Pityoulish

A collection of programming/debugging exercises to support a course on Distributed Systems.
Creative Commons Zero v1.0 Universal
7 stars 0 forks source link

Failover when connecting sockets #32

Closed rolandweber closed 6 years ago

rolandweber commented 8 years ago

The SocketBackendHandler currently resolves the target hostname to a single IP address and connects there, either synchronously or asynchronously. Instead, look up all IP addresses for the hostname and try them in a loop. If none of the addresses responds, throw an exception and use Throwable.addSuppressed to attach the exceptions for all the failed attempts.

Note that this is a place where the students have to fill a gap, so the gap will have to be revised. Lookup code should be shared between the synchronous and asynchronous cases. Ideally, error handling code is shared as well. But some copy'n'paste from the asynchronous to the synchronous case is acceptable.

For testing the scenario, play around with /etc/hosts or the Windows equivalent. Define a hostname there, with some IP addresses pointing to wrong hosts or nowhere. Use debug output to verify that connection attempts fail before the correct host is contacted.

rolandweber commented 6 years ago

Too complicated for the classroom. Neither sockets nor hostname lookups are in the focus of my lectures.