Skip to content

Commit

Permalink
Retrieve physrep tier from comdb2db.cfg
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Hannum <mhannum72@gmail.com>
  • Loading branch information
markhannum committed May 25, 2024
1 parent c4e064a commit 4dda14e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
10 changes: 10 additions & 0 deletions cdb2api/cdb2api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1663,6 +1663,16 @@ static int read_available_comdb2db_configs(cdb2_hndl_tp *hndl, char comdb2db_hos
return 0;
}

int cdb2_get_comdb2db(char **comdb2dbname, char **default_type)
{
if (!strlen(cdb2_comdb2dbname)) {
read_available_comdb2db_configs(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0);
}
(*comdb2dbname) = strdup(cdb2_comdb2dbname);
(*default_type) = strdup(cdb2_default_cluster);
return 0;
}

/* populate comdb2db_hosts based on hostname info of comdb2db_name
* returns -1 if error or no osts wa found
* returns 0 if hosts were found
Expand Down
1 change: 1 addition & 0 deletions cdb2api/cdb2api.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ typedef struct cdb2_effects_type effects_tp;

void cdb2_set_comdb2db_config(const char *cfg_file);
void cdb2_set_comdb2db_info(const char *cfg_info);
int cdb2_get_comdb2db(char **comdb2db_name, char **default_type);

int cdb2_open(cdb2_hndl_tp **hndl, const char *dbname, const char *type,
int flags);
Expand Down
18 changes: 6 additions & 12 deletions db/phys_rep.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,18 +205,12 @@ static int append_quoted_source_hosts(char *buf, int buf_len, int *rc) {
const char *query = "select m.name from machines as m, clusters as c, databases as d"
" where c.name=@dbname and c.cluster_name=@class and "
" m.cluster=c.cluster_machs and d.name=@dbname";
const char *comdb2dbclass = get_my_mach_class_str();
const char *comdb2dbname;

// Point to the right 'comdb2db' that we need to query
if ((strncasecmp(comdb2dbclass, "test", 4) == 0) ||
(strncasecmp(comdb2dbclass, "dev", 3) == 0) ||
(strncasecmp(comdb2dbclass, "fuzz", 4) == 0)) {
comdb2dbname = "comdb3db";
comdb2dbclass = "dev";
} else {
comdb2dbname = "comdb2db";
comdb2dbclass = "prod";

static char *comdb2dbclass = NULL;
static char *comdb2dbname = NULL;

if (!comdb2dbname) {
cdb2_get_comdb2db(&comdb2dbname, &comdb2dbclass);
}

// Also fix the 'source tier' in case it is one of the following
Expand Down

0 comments on commit 4dda14e

Please sign in to comment.