Remove ShowMainReplica status
This commit is contained in:
parent
3f4ac0dd58
commit
e9c5cc3b82
@ -38,6 +38,7 @@ class CoordinatorData {
|
|||||||
private:
|
private:
|
||||||
mutable utils::RWLock coord_data_lock_{utils::RWLock::Priority::READ};
|
mutable utils::RWLock coord_data_lock_{utils::RWLock::Priority::READ};
|
||||||
HealthCheckCallback main_succ_cb_, main_fail_cb_, replica_succ_cb_, replica_fail_cb_;
|
HealthCheckCallback main_succ_cb_, main_fail_cb_, replica_succ_cb_, replica_fail_cb_;
|
||||||
|
// Must be std::list because we rely on pointer stability
|
||||||
std::list<CoordinatorInstance> registered_instances_;
|
std::list<CoordinatorInstance> registered_instances_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -564,21 +564,6 @@ class CoordQueryHandler final : public query::CoordinatorQueryHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove this method, probably not needed.
|
|
||||||
std::vector<MainReplicaStatus> ShowMainReplicaStatus(
|
|
||||||
const std::vector<coordination::CoordinatorInstanceStatus> &replicas,
|
|
||||||
const std::optional<coordination::CoordinatorInstanceStatus> &main) const override {
|
|
||||||
std::vector<MainReplicaStatus> result{};
|
|
||||||
result.reserve(replicas.size() + 1); // replicas + 1 main
|
|
||||||
std::ranges::transform(replicas, std::back_inserter(result), [](const auto &replica) -> MainReplicaStatus {
|
|
||||||
return {replica.instance_name, replica.socket_address, replica.is_alive, false};
|
|
||||||
});
|
|
||||||
if (main) {
|
|
||||||
result.emplace_back(main->instance_name, main->socket_address, main->is_alive, true);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MG_ENTERPRISE
|
#ifdef MG_ENTERPRISE
|
||||||
@ -1128,16 +1113,19 @@ Callback HandleCoordinatorQuery(CoordinatorQuery *coordinator_query, const Param
|
|||||||
|
|
||||||
callback.header = {"name", "socket_address", "alive", "role"};
|
callback.header = {"name", "socket_address", "alive", "role"};
|
||||||
callback.fn = [handler = CoordQueryHandler{dbms_handler}, replica_nfields = callback.header.size()]() mutable {
|
callback.fn = [handler = CoordQueryHandler{dbms_handler}, replica_nfields = callback.header.size()]() mutable {
|
||||||
const auto result_status =
|
const auto replicas = handler.ShowReplicasOnCoordinator();
|
||||||
handler.ShowMainReplicaStatus(handler.ShowReplicasOnCoordinator(), handler.ShowMainOnCoordinator());
|
const auto main = handler.ShowMainOnCoordinator();
|
||||||
std::vector<std::vector<TypedValue>> result{};
|
std::vector<std::vector<TypedValue>> result{};
|
||||||
result.reserve(result_status.size());
|
result.reserve(replicas.size() + 1);
|
||||||
|
|
||||||
std::ranges::transform(result_status, std::back_inserter(result),
|
std::ranges::transform(replicas, std::back_inserter(result), [](const auto &status) -> std::vector<TypedValue> {
|
||||||
[](const auto &status) -> std::vector<TypedValue> {
|
return {TypedValue{status.instance_name}, TypedValue{status.socket_address}, TypedValue{status.is_alive},
|
||||||
return {TypedValue{status.name}, TypedValue{status.socket_address},
|
TypedValue{"replica"}};
|
||||||
TypedValue{status.alive}, TypedValue{status.is_main ? "main" : "replica"}};
|
});
|
||||||
});
|
if (main) {
|
||||||
|
result.emplace_back(std::vector<TypedValue>{TypedValue{main->instance_name}, TypedValue{main->socket_address},
|
||||||
|
TypedValue{main->is_alive}, TypedValue{"main"}});
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
return callback;
|
return callback;
|
||||||
@ -1161,16 +1149,19 @@ Callback HandleCoordinatorQuery(CoordinatorQuery *coordinator_query, const Param
|
|||||||
callback.fn = [handler = CoordQueryHandler{dbms_handler}]() mutable {
|
callback.fn = [handler = CoordQueryHandler{dbms_handler}]() mutable {
|
||||||
handler.DoFailover();
|
handler.DoFailover();
|
||||||
|
|
||||||
const auto result_status =
|
const auto replicas = handler.ShowReplicasOnCoordinator();
|
||||||
handler.ShowMainReplicaStatus(handler.ShowReplicasOnCoordinator(), handler.ShowMainOnCoordinator());
|
const auto main = handler.ShowMainOnCoordinator();
|
||||||
std::vector<std::vector<TypedValue>> result{};
|
std::vector<std::vector<TypedValue>> result{};
|
||||||
result.reserve(result_status.size());
|
result.reserve(replicas.size() + 1);
|
||||||
|
|
||||||
std::ranges::transform(result_status, std::back_inserter(result),
|
std::ranges::transform(replicas, std::back_inserter(result), [](const auto &status) -> std::vector<TypedValue> {
|
||||||
[](const auto &status) -> std::vector<TypedValue> {
|
return {TypedValue{status.instance_name}, TypedValue{status.socket_address}, TypedValue{status.is_alive},
|
||||||
return {TypedValue{status.name}, TypedValue{status.socket_address},
|
TypedValue{"replica"}};
|
||||||
TypedValue{status.alive}, TypedValue{status.is_main ? "main" : "replica"}};
|
});
|
||||||
});
|
if (main) {
|
||||||
|
result.emplace_back(std::vector<TypedValue>{TypedValue{main->instance_name}, TypedValue{main->socket_address},
|
||||||
|
TypedValue{main->is_alive}, TypedValue{"main"}});
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -125,11 +125,6 @@ class CoordinatorQueryHandler {
|
|||||||
/// @throw QueryRuntimeException if an error ocurred.
|
/// @throw QueryRuntimeException if an error ocurred.
|
||||||
virtual void DoFailover() const = 0;
|
virtual void DoFailover() const = 0;
|
||||||
|
|
||||||
/// @throw QueryRuntimeException if an error ocurred.
|
|
||||||
virtual std::vector<MainReplicaStatus> ShowMainReplicaStatus(
|
|
||||||
const std::vector<coordination::CoordinatorInstanceStatus> &replicas,
|
|
||||||
const std::optional<coordination::CoordinatorInstanceStatus> &main) const = 0;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user