class_docstr: HDFS connector class where failover logic is implemented.  Facilitates testing. 
docstr: Instead of returning an inline function, this protected class method implements the
  failover logic: circling between namenodes using the supplied index as the last
  index into the name nodes list.
  
  :param list_of_namenodes: a required list of name node URLs to connect to.
  :param user: String denoting username when connecting to HDFS. None implies login user.
  :return: a tuple of (new index into list, actual pyarrow HDFS connection object), or raise
          a HdfsConnectError if no successful connection can be established.
code: def _try_next_namenode(
      cls, index_of_nn, list_of_namenodes, user=None
  ):
      """
      Instead of returning an inline function, this protected class method implements the
      failover logic: circling between namenodes using the supplied index as the last
      index into the name nodes list.
  
      :param list_of_namenodes: a required list of name node URLs to connect to.
      :param user: String denoting username when connecting to HDFS. None implies login user.
      :return: a tuple of (new index into list, actual pyarrow HDFS connection object), or raise
              a HdfsConnectError if no successful connection can be established.
      """
      nn_len = len(list_of_namenodes)
      if nn_len > 0:
          for i in range(1, nn_len + 1):
              # Use a modulo mechanism to hit the "next" name node, as opposed to always
              # starting from the first entry in the list
              idx = (index_of_nn + i) % nn_len
              host = list_of_namenodes[idx]
              try:
                  return idx, cls.hdfs_connect_namenode(
                      urlparse("hdfs://" + str(host or "default")),
                      user=user,
                  )
              except ArrowIOError as e:
                  # This is an expected error if the namenode we are trying to connect to is
                  # not the active one
                  logger.debug(
                      "Attempted to connect to namenode %s but failed: %e",
                      host,
                      str(e),
                  )
      # It is a problem if we cannot connect to either of the namenodes when tried back-to-back,
      # so better raise an error.
      raise HdfsConnectError("Unable to connect to HDFS cluster!")
  
imports: import functools
  import inspect
  import logging
  import os
  from distutils.version import LooseVersion
  from xml.etree import ElementTree
  import pyarrow
  import six
  from pyarrow.hdfs import HadoopFileSystem
  from pyarrow.lib import ArrowIOError
  from six.moves.urllib.parse import urlparse
label_desc: Use image node_id 3 for calling the HdfsConnector obj's underlying member method code with example usage: obj._try_next_namenode(cls, index_of_nn, list_of_namenodes, user) and returns: idx,  cls