def read_cluster_status(hosts, jolokia_port, jolokia_prefix):
    """Read and return the number of under replicated partitions and
    missing brokers from the specified hosts.

    :param hosts: list of brokers ip addresses
    :type hosts: list of strings
    :param jolokia_port: HTTP port for Jolokia
    :type jolokia_port: integer
    :param jolokia_prefix: HTTP prefix on the server for the Jolokia queries
    :type jolokia_prefix: string
    :returns: tuple of integers
    """
    under_replicated = 0
    missing_brokers = 0
    for host, request in generate_requests(hosts, jolokia_port, jolokia_prefix):
        try:
            response = request.result()
            if 400 <= response.status_code <= 599:
                print("Got status code {0}. Exiting.".format(response.status_code))
                sys.exit(1)
            json = response.json()
            under_replicated += json['value']
        except RequestException as e:
            print("Broker {0} is down: {1}."
                  "This maybe because it is starting up".format(host, e), file=sys.stderr)
            missing_brokers += 1
        except KeyError:
            print("Cannot find the key, Kafka is probably still starting up", file=sys.stderr)
            missing_brokers += 1
    return under_replicated, missing_brokers
def read_cluster_status ( hosts , jolokia_port , jolokia_prefix ) : under_replicated = 0 missing_brokers = 0 for host , request in generate_requests ( hosts , jolokia_port , jolokia_prefix ) : try : response = request . result ( ) if 400 <= response . status_code <= 599 : print ( "Got status code {0}. Exiting." . format ( response . status_code ) ) sys . exit ( 1 ) json = response . json ( ) under_replicated += json [ 'value' ] except RequestException as e : print ( "Broker {0} is down: {1}." "This maybe because it is starting up" . format ( host , e ) , file = sys . stderr ) missing_brokers += 1 except KeyError : print ( "Cannot find the key, Kafka is probably still starting up" , file = sys . stderr ) missing_brokers += 1 return under_replicated , missing_brokers
Read and return the number of under replicated partitions and
    missing brokers from the specified hosts.

    :param hosts: list of brokers ip addresses
    :type hosts: list of strings
    :param jolokia_port: HTTP port for Jolokia
    :type jolokia_port: integer
    :param jolokia_prefix: HTTP prefix on the server for the Jolokia queries
    :type jolokia_prefix: string
    :returns: tuple of integers