| 474 | } |
| 475 | |
| 476 | ConfigureAutoResult parseConfig(StatusObject const& status) { |
| 477 | ConfigureAutoResult result; |
| 478 | StatusObjectReader statusObj(status); |
| 479 | |
| 480 | StatusObjectReader statusObjCluster; |
| 481 | if (!statusObj.get("cluster", statusObjCluster)) |
| 482 | return ConfigureAutoResult(); |
| 483 | |
| 484 | StatusObjectReader statusObjConfig; |
| 485 | if (!statusObjCluster.get("configuration", statusObjConfig)) |
| 486 | return ConfigureAutoResult(); |
| 487 | |
| 488 | if (!statusObjConfig.get("redundancy.factor", result.old_replication)) |
| 489 | return ConfigureAutoResult(); |
| 490 | |
| 491 | result.auto_replication = result.old_replication; |
| 492 | |
| 493 | [[maybe_unused]] int storage_replication; |
| 494 | int log_replication; |
| 495 | if (result.old_replication == "single") { |
| 496 | result.auto_replication = "double"; |
| 497 | storage_replication = 2; |
| 498 | log_replication = 2; |
| 499 | } else if (result.old_replication == "double" || result.old_replication == "fast_recovery_double") { |
| 500 | storage_replication = 2; |
| 501 | log_replication = 2; |
| 502 | } else if (result.old_replication == "triple" || result.old_replication == "fast_recovery_triple") { |
| 503 | storage_replication = 3; |
| 504 | log_replication = 3; |
| 505 | } else if (result.old_replication == "three_datacenter") { |
| 506 | storage_replication = 6; |
| 507 | log_replication = 4; |
| 508 | } else if (result.old_replication == "three_datacenter_fallback") { |
| 509 | storage_replication = 4; |
| 510 | log_replication = 4; |
| 511 | } else if (result.old_replication == "three_data_hall") { |
| 512 | storage_replication = 3; |
| 513 | log_replication = 4; |
| 514 | } else if (result.old_replication == "three_data_hall_fallback") { |
| 515 | storage_replication = 2; |
| 516 | log_replication = 4; |
| 517 | } else |
| 518 | return ConfigureAutoResult(); |
| 519 | |
| 520 | StatusObjectReader machinesMap; |
| 521 | if (!statusObjCluster.get("machines", machinesMap)) |
| 522 | return ConfigureAutoResult(); |
| 523 | |
| 524 | std::map<std::string, std::string> machineid_dcid; |
| 525 | std::set<std::string> datacenters; |
| 526 | int machineCount = 0; |
| 527 | for (auto mach : machinesMap.obj()) { |
| 528 | StatusObjectReader machine(mach.second); |
| 529 | std::string dcId; |
| 530 | if (machine.get("datacenter_id", dcId)) { |
| 531 | machineid_dcid[mach.first] = dcId; |
| 532 | datacenters.insert(dcId); |
| 533 | } |
no test coverage detected