feat: support name=host:port format in controller --peers
- xce_candidate_t gains name[] field for logical peer identity - parse_peers stores name prefix before '=' (empty when omitted) - cluster_init matches own identity by name first, hostname as fallback enabling multiple controllers on the same dev host via --peers ctrl-1=10.0.1.1:7000,ctrl-2=10.0.1.2:7001
This commit is contained in:
parent
59597e105e
commit
a05c9bd344
3 changed files with 23 additions and 8 deletions
|
|
@ -650,9 +650,13 @@ int cluster_init(cluster_t* c)
|
|||
if (pcfg->candidates_count > 0) {
|
||||
my_priority = pcfg->candidates_count - 1; /* default: last = lowest */
|
||||
for (int i = 0; i < pcfg->candidates_count; i++) {
|
||||
if (strncmp(pcfg->candidates[i].hostname,
|
||||
c->myconf->name,
|
||||
XCE_MAXHOSTNAME_LEN - 1) == 0) {
|
||||
/* Match by logical name first (supports multiple controllers
|
||||
* on the same dev host via name=host:port syntax). Fall back
|
||||
* to hostname match when no name was specified. */
|
||||
const char* key = pcfg->candidates[i].name[0]
|
||||
? pcfg->candidates[i].name
|
||||
: pcfg->candidates[i].hostname;
|
||||
if (strncmp(key, c->myconf->name, XCE_MAXNAME_LEN - 1) == 0) {
|
||||
my_priority = i;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue