Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions cdb2api/cdb2api.c
Original file line number Diff line number Diff line change
Expand Up @@ -8118,6 +8118,26 @@ static int cdb2_get_dbhosts(cdb2_hndl_tp *hndl)
}
}

/* Try BMS discovery before falling back to comdb2db DNS lookup. */
if (cdb2_use_bmsd && (*cdb2_bmssuffix != '\0') && !hndl->num_shards && strcasecmp(hndl->type, "local") != 0) {
int bmsd_rc = -1;
if (cdb2_has_room_distance)
bmsd_rc =
bms_srv_lookup(hndl->hosts, hndl->dbname, hndl->type, &hndl->num_hosts, &hndl->num_hosts_sameroom);
else
bmsd_rc = bms_ip_lookup(hndl->hosts, hndl->dbname, cdb2_machine_room, hndl->type, &hndl->num_hosts,
&hndl->num_hosts_sameroom, 0);
if (bmsd_rc == 0 && hndl->num_hosts > 0) {
rc = 0;
goto after_callback;
}
if (!cdb2_comdb2db_fallback) {
sprintf(hndl->errstr, "cdb2_get_dbhosts: BMS lookup failed for %s/%s.", hndl->dbname, hndl->type);
rc = -1;
goto after_callback;
}
}

if ((cdb2_default_cluster[0] != '\0') && (cdb2_comdb2dbname[0] != '\0')) {
strcpy(comdb2db_name, cdb2_comdb2dbname);
}
Expand Down
Loading