| 1494 | } |
| 1495 | |
| 1496 | [[noreturn]] void Statestore::MonitorUpdateCatalogd() { |
| 1497 | int64_t last_active_catalogd_version = 0; |
| 1498 | // rpc_receivers is used to track subscribers to which statestore need to send RPCs |
| 1499 | // when there is a change in the elected active catalogd. It is updated from |
| 1500 | // subscribers_, and the subscribers will be removed from this list if the RPCs are |
| 1501 | // successfully sent to them. |
| 1502 | vector<std::shared_ptr<Subscriber>> rpc_receivers; |
| 1503 | int64_t timeout_us = |
| 1504 | FLAGS_active_catalogd_designation_monitoring_interval_ms * MICROS_PER_MILLI; |
| 1505 | // Check if the first registered one should be designated with active role. |
| 1506 | while (!catalog_manager_.CheckActiveCatalog()) { |
| 1507 | unique_lock<mutex> l(*catalog_manager_.GetLock()); |
| 1508 | update_catalod_cv_.WaitFor(l, timeout_us); |
| 1509 | } |
| 1510 | SendUpdateCatalogdNotification(&last_active_catalogd_version, rpc_receivers); |
| 1511 | |
| 1512 | // Wait for notification. If new leader is elected due to catalogd is registered or |
| 1513 | // unregistered, send notification to all coordinators and catalogds. |
| 1514 | timeout_us = FLAGS_update_catalogd_rpc_resend_interval_ms * MICROS_PER_MILLI; |
| 1515 | while (1) { |
| 1516 | { |
| 1517 | unique_lock<mutex> l(*catalog_manager_.GetLock()); |
| 1518 | update_catalod_cv_.WaitFor(l, timeout_us); |
| 1519 | } |
| 1520 | SendUpdateCatalogdNotification(&last_active_catalogd_version, rpc_receivers); |
| 1521 | } |
| 1522 | } |
| 1523 | |
| 1524 | void Statestore::SendUpdateCatalogdNotification(int64_t* last_active_catalogd_version, |
| 1525 | vector<std::shared_ptr<Subscriber>>& rpc_receivers) { |
nothing calls this directly
no test coverage detected