static String getPrimaryRegistration ( Configuration startupConf , Configuration conf , String fsname ) throws IOException { AvatarZooKeeperClient zk = null ; int maxTries = startupConf . getInt ( "dfs.avatarnode.zk.retries" , 3 ) ; for ( int i = 0 ; i < maxTries ; i ++ ) { try { zk = new AvatarZooKeeperClient ( conf , null , false ) ; String zkRegistry = zk . getPrimaryAvatarAddress ( fsname , new Stat ( ) , false ) ; return zkRegistry ; } catch ( Exception e ) { LOG . error ( "Got Exception when reading primary registration. Will retry..." , e ) ; } finally { shutdownZkClient ( zk ) ; } } throw new IOException ( "Cannot connect to zk" ) ; }
Obtain the registration of the primary from zk .