public int setAvatar ( String role , boolean noverification , String serviceName , String instance ) throws IOException { Avatar dest ; if ( Avatar . ACTIVE . toString ( ) . equalsIgnoreCase ( role ) ) { dest = Avatar . ACTIVE ; } else if ( Avatar . STANDBY . toString ( ) . equalsIgnoreCase ( role ) ) { throw new IOException ( "setAvatar Command only works to switch avatar" + " from Standby to Primary" ) ; } else { throw new IOException ( "Unknown avatar type " + role ) ; } Avatar current = avatarnode . getAvatar ( ) ; if ( current == dest ) { System . out . println ( "This instance is already in " + current + " avatar." ) ; } else { try { avatarnode . quiesceForFailover ( noverification ) ; } catch ( RemoteException re ) { handleRemoteException ( re ) ; } avatarnode . performFailover ( ) ; updateZooKeeper ( serviceName , instance ) ; } return 0 ; }
Sets the avatar to the specified value