code: public static void updateZooKeeper(Configuration originalConf, Configuration conf,
        boolean toOverwrite, String serviceName, String primaryInstance) throws IOException {
      String connection = conf.get(FSConstants.FS_HA_ZOOKEEPER_QUORUM);
      if (connection == null)
        return;
      AvatarZooKeeperClient zk = new AvatarZooKeeperClient(conf, null);
      if (registerClientProtocolAddress(zk, originalConf, conf, toOverwrite)) {
        return;
      }
      registerDnProtocolAddress(zk, originalConf, conf, toOverwrite);
      registerHttpAddress(zk, originalConf, conf, toOverwrite);
      for (ZookeeperKey key : ZookeeperKey.values()) {
        zk.registerPrimary(getZnodeName(conf, serviceName, Avatar.ACTIVE, key),
            key.getIpPortString(conf), true);
      }
      if(primaryInstance.equalsIgnoreCase(StartupOption.NODEZERO.getName())){
        primaryInstance = StartupOption.NODEONE.getName();
      } else {
        primaryInstance = StartupOption.NODEZERO.getName();
      }
      Configuration tempConf = AvatarZKShell.updateConf(primaryInstance, originalConf);
      for (ZookeeperKey key : ZookeeperKey.values()) {
        zk.registerPrimary(getZnodeName(tempConf, serviceName, Avatar.STANDBY, key),
            key.getIpPortString(tempConf), true);
      }
    }
docs: This method tries to update the information in ZooKeeper For every address
  of the NameNode it is being run for (fs.default.name,
  dfs.namenode.dn-address, dfs.namenode.http.address) if they are present. It
  also creates information for aliases in ZooKeeper for lists of strings in
  fs.default.name.aliases, dfs.namenode.dn-address.aliases and
  dfs.namenode.http.address.aliases
  
  Each address it transformed to the address of the zNode to be created by
  substituting all . and : characters to /. The slash is also added in the
  front to make it a valid zNode address. So dfs.domain.com:9000 will be
  /dfs/domain/com/9000
  
  If any part of the path does not exist it is created automatically