Thank you for your reply !

When the connected namenode is a standby one (in HA cluster), we will get a WebHDFS::IOError with a message like "{\"RemoteException\":{\"exception\":\"StandbyException\",\"javaClassName\":\"org.apache.hadoop.ipc.StandbyException\",\"message\":\"Operation category READ is not supported in state standby\"}}",
So I think in this case we should try the standby namenode immediately.

But there're many other cases (like machine down or so) that are not easy to know if it's caused by a active namenode failover, so I added the namenode-switch logic in #write which will only be triggered after enough times of failure ( to exclude other reasons as possible).