def collect_hosts(hosts, randomize=True):
if isinstance(hosts, six.string_types):<EOL><INDENT>hosts = hosts.strip().split('<STR_LIT:U+002C>')<EOL><DEDENT>result = []<EOL>for host_port in hosts:<EOL><INDENT>res = host_port.split('<STR_LIT::>')<EOL>host = res[<NUM_LIT:0>]<EOL>port = int(res[<NUM_LIT:1>]) if len(res) > <NUM_LIT:1> else DEFAULT_KAFKA_PORT<EOL>result.append((host.strip(), port))<EOL><DEDENT>if randomize:<EOL><INDENT>shuffle(result)<EOL><DEDENT>return result<EOL>
Collects a comma-separated set of hosts (host:port) and optionally
randomize the returned list.