In org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider, in the constructor, there's a map <nameservice : < service-id : service-rpc-address > > (DFSUtil.getHaNnRpcAddresses). It's a LinkedHashMap of HashMaps. The order is kept for nameservices. Then to find active namenode, for nameservice, we get HashMap of <service-id : service-rpc-address > for requested nameservice (taken from URI request), And for this HashMap we get values - order of this collection is not strictly defined! In the code:
And then we put these values (in not defined order) into ArrayList of proxies, and then in getProxy we start from first proxy in the list and failover to next if needed.
It would make sense for ConfiguredFailoverProxyProvider to keep order of proxies/namenodes defined in hdfs-site.xml.