/* * Get all the servers --> VAR_allServers */ static void addServer(char **name) { int ii, jj; int flag; confirm_var(VAR_allServers); for (ii = 0; name[ii]; ii++) { flag = TRUE; for (jj = 0; aval(VAR_allServers)[jj]; jj++) { if (strcmp(name[ii], aval(VAR_allServers)[jj]) != 0) continue; else { flag = FALSE; break; } } if (flag) add_val(find_var(VAR_allServers), name[ii]); } }
/* * Parse line and filter only pre-defined variables. * * This blocks any unknow variables to be build within pgxc_ctl structure. */ static void parse_line_select(char *line, char *selectThis[]) { char *varname; char *val; pgxc_ctl_var *newv; int ii; line = get_word(line, &varname); if (!varname || varname[0] == '#') return; for (ii = 0; selectThis[ii]; ii++) { if (strcmp(varname, selectThis[ii]) == 0) { if (!(newv = confirm_var(varname))) return; while((line = get_word(line, &val))) { if (val) add_val(newv, val); } } } }
/* * If pad is NULL, then "none" will be padded. * Returns *val if success, NULL if failed */ void assign_arrayEl(char *name, int idx, char *val, char *pad) { pgxc_ctl_var *var = confirm_var(name); if (pad == NULL) pad = "none"; /* * Pad if needed */ extendVar(name, idx+1, pad); Free(var->val[idx]); var->val[idx] = Strdup(val); }
static void checkConfiguredAndSize(char *names[], char *msg) { int ii; int sz0; for (ii = 0; names[ii]; ii++) { checkIfVarIsConfigured(names[ii]); confirm_var(names[ii]); } sz0 = arraySizeName(names[0]); for (ii = 1; names[ii]; ii++) { if (arraySizeName(names[ii]) != sz0) { anyConfigErrors = TRUE; elog(ERROR, "ERROR: Number of elements in %s definitions are different %s and %s. Check your configuration\n", msg, names[0], names[ii]); } } }
/* * Parse line and create/update a variable. */ static void parse_line(char *line) { char *varname; char *val; pgxc_ctl_var *newv; line = get_word(line, &varname); if (!varname) return; if (!(newv = confirm_var(varname))) return; reset_value(newv); while((line = get_word(line, &val))) { if (val) { add_val(newv, val); } } }
/* * Scans initial configuration and set up "not configured" things. * * If, for example, gtm proxy is not configured, * we set gtmProxy variable to "n". * * When gtmProxy varieble is already set to "n", remove gtm_proxy * configuration information. * * Similar handling will be done for gtm slave, coordinator slaves * and datanode slaves. */ void handle_no_slaves() { int is_empty; int ii; /* GTM Slave */ if (!find_var(VAR_gtmSlave)) reset_var_val(VAR_gtmSlave, "n"); if (!isVarYes(VAR_gtmSlave)) emptyGtmSlave(); else { confirm_var(VAR_gtmSlaveServer); if (!sval(VAR_gtmSlaveServer) || is_none(sval(VAR_gtmSlaveServer))) { emptyGtmSlave(); reset_var_val(VAR_gtmSlaveServer, "n"); } } /* GTM Proxy */ if (!find_var(VAR_gtmProxy)) reset_var_val(VAR_gtmProxy, "n"); if (!isVarYes(VAR_gtmProxy)) emptyGtmProxies(); else { is_empty = TRUE; for (ii = 0; aval(VAR_gtmProxyServers)[ii]; ii++) { if (is_none(aval(VAR_gtmProxyServers)[ii])) continue; else { is_empty = FALSE; break; } } if (is_empty) { reset_var_val(VAR_gtmProxy, "n"); emptyGtmProxies(); } } /* Coordinator Slaves */ if (!find_var(VAR_coordSlave)) reset_var_val(VAR_coordSlave, "n"); if (!isVarYes(VAR_coordSlave)) emptyCoordSlaves(); else { is_empty = TRUE; if (find_var(VAR_coordSlaveServers)) { for (ii = 0; aval(VAR_coordSlaveServers)[ii]; ii++) { if (is_none(aval(VAR_coordSlaveServers)[ii])) continue; else { is_empty = FALSE; break; } } if (is_empty) { reset_var_val(VAR_coordSlave, "n"); emptyCoordSlaves(); } } else { elog(WARNING, "WARNING: coordSlaveServers variable not found where coordSlave is set to \"y\"\n"); reset_var_val(VAR_coordSlave, "n"); emptyCoordSlaves(); } } /* Datanode Slaves */ if (!find_var(VAR_datanodeSlave)) reset_var_val(VAR_datanodeSlave, "n"); if (!isVarYes(VAR_datanodeSlave)) emptyDatanodeSlaves(); else { is_empty = TRUE; if (find_var(VAR_datanodeSlaveServers)) { for (ii = 0; aval(VAR_datanodeSlaveServers)[ii]; ii++) { if (is_none(aval(VAR_datanodeSlaveServers)[ii])) continue; else { is_empty = FALSE; break; } } if (is_empty) { reset_var_val(VAR_datanodeSlave, "n"); emptyDatanodeSlaves(); } } else { elog(WARNING, "WARNING: datanodeSlaveServers variable not found where datanodeSlave is set to \"y\"\n"); reset_var_val(VAR_datanodeSlave, "n"); emptyDatanodeSlaves(); } } }
void reset_var(char *name) { confirm_var(name); reset_value(find_var(name)); }