XenServer 5.0 Update 3 Software Development Kit Guide

Handling pool master changes
1. Subscribe to updates in the list of hosts servers, and maintain a current list of hosts in the pool
2. If the connection to the pool master fails to respond, attempt to connect to all hosts in the list until one
3. The first host to respond will return the HOST_IS_SLAVE error message, which contains the identity of
the new pool master (unless of course the host is the new master)
4. Connect to the new master

// This is an error return code from XenServer. 

// We only use the retry loop to reauthenticate if we receive:
// Otherwise we just rethrow the exception
    if (    !(SESSION_INVALID)
        && !(HOST_IS_SLAVE) )

    {         throw;     }

XenCenter works by remembering the list of hosts in the pool – i.e. what the list of hosts/IPs was at the time of the last XenCenter login. When the one it thinks is master isn’t available, it tries the others in the list to see if any of them have become masters.