This is due to a setting in yarn-site.xml:yarn.resourcemanager.fs.state-store.retry-policy-spec
Here is an example:
It is specified in pairs of sleep-time and number-of-retries
This will mean that Hive Client will try connecting to nn1 for 500 times at an interval of 2000 Milliseconds.
Contingent on the fact that it could not connect to nn1 for 500 times at an interval of 2000 Milliseconds, it will then try connecting to nn2.
Resolution/Workaround: Lower the value of yarn.resourcemanager.fs.state-store.retry-policy-spec to 1000,10.