MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / get_comdb2db_hosts

Function get_comdb2db_hosts

cdb2api/cdb2api.c:1718–1755  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1716}
1717
1718static int get_comdb2db_hosts(cdb2_hndl_tp *hndl, char comdb2db_hosts[][CDB2HOSTNAME_LEN], int *comdb2db_ports,
1719 int *master, const char *comdb2db_name, int *num_hosts, int *comdb2db_num,
1720 const char *dbname, char db_hosts[][CDB2HOSTNAME_LEN], int *num_db_hosts, int *dbnum,
1721 int read_cfg, int dbinfo_or_dns)
1722{
1723 int rc;
1724
1725 if (hndl)
1726 debugprint("entering\n");
1727
1728 if (read_cfg) {
1729 rc = read_available_comdb2db_configs(
1730 hndl, comdb2db_hosts, comdb2db_name, num_hosts, comdb2db_num,
1731 dbname, db_hosts, num_db_hosts, dbnum, 0, 0);
1732 if (rc == -1)
1733 return rc;
1734 if (master)
1735 *master = -1;
1736 set_cdb2_timeouts(hndl);
1737 }
1738
1739 if (dbinfo_or_dns) {
1740 /* If previous call to the function successfully retrieved hosts,
1741 return 0. */
1742 if (*num_hosts > 0 || *num_db_hosts > 0)
1743 return 0;
1744 /* If we have a cached connection to comdb2db in the sockpool, use it to
1745 get comdb2db dbinfo. */
1746 rc = cdb2_dbinfo_query(hndl, cdb2_default_cluster, comdb2db_name,
1747 *comdb2db_num, NULL, comdb2db_hosts,
1748 comdb2db_ports, master, num_hosts, NULL);
1749 /* DNS lookup comdb2db hosts. */
1750 if (rc != 0)
1751 rc = get_host_by_name(comdb2db_name, comdb2db_hosts, num_hosts);
1752 }
1753
1754 return rc;
1755}
1756
1757/* SOCKPOOL CODE START */
1758

Callers 2

cdb2_get_dbhostsFunction · 0.85
mainFunction · 0.85

Calls 4

set_cdb2_timeoutsFunction · 0.85
cdb2_dbinfo_queryFunction · 0.70
get_host_by_nameFunction · 0.70

Tested by

no test coverage detected