public synchronized void onServerAvailable ( final String id , final String role ) { logger . debug ( "[onServerAvailable] id = {}, role = {}" , id , role ) ; Server server = getServerById ( id ) ; boolean isMaster = role . equals ( "master" ) ; boolean isSlave = role . equals ( "slave" ) ; if ( server == null ) { return ; } if ( server . isAvailable ( ) ) { if ( server . isMaster ( ) && isMaster ) return ; if ( ! server . isMaster ( ) && isSlave ) return ; } if ( isMaster || isSlave ) { server . setAvailable ( true ) ; try { server . connect ( ) ; } catch ( Exception e ) { logger . error ( "[onServerAvailable]" , e ) ; } } server . setAvailable ( true ) ; if ( isMaster ) { setWriteServer ( server ) ; } refreshServers ( ) ; }
Adds a server to the list of available servers .