mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
synced 2025-11-01 11:17:51 +00:00
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
This commit is contained in:
@@ -33,6 +33,17 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
void MicroService::Exit(int Reason) { std::exit(Reason); }
|
void MicroService::Exit(int Reason) { std::exit(Reason); }
|
||||||
|
|
||||||
|
static std::string MakeServiceListString(const Types::MicroServiceMetaMap &Services) {
|
||||||
|
std::string SvcList;
|
||||||
|
for (const auto &Svc : Services) {
|
||||||
|
if (SvcList.empty())
|
||||||
|
SvcList = Svc.second.Type;
|
||||||
|
else
|
||||||
|
SvcList += ", " + Svc.second.Type;
|
||||||
|
}
|
||||||
|
return SvcList;
|
||||||
|
}
|
||||||
|
|
||||||
void MicroService::BusMessageReceived([[maybe_unused]] const std::string &Key,
|
void MicroService::BusMessageReceived([[maybe_unused]] const std::string &Key,
|
||||||
const std::string &Payload) {
|
const std::string &Payload) {
|
||||||
std::lock_guard G(InfraMutex_);
|
std::lock_guard G(InfraMutex_);
|
||||||
@@ -84,15 +95,16 @@ namespace OpenWifi {
|
|||||||
.toString(),
|
.toString(),
|
||||||
.LastUpdate = Utils::Now()};
|
.LastUpdate = Utils::Now()};
|
||||||
|
|
||||||
|
auto s1 = MakeServiceListString(Services_);
|
||||||
Services_[PrivateEndPoint] = ServiceInfo;
|
Services_[PrivateEndPoint] = ServiceInfo;
|
||||||
if(Event == KafkaTopics::ServiceEvents::EVENT_JOIN) {
|
if(Event == KafkaTopics::ServiceEvents::EVENT_JOIN) {
|
||||||
poco_information(
|
poco_information(
|
||||||
logger(),
|
logger(),
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"Service {} ID={} is joining the system.",
|
"Service {} ID={} is joining the system. old={}",
|
||||||
Object->get(KafkaTopics::ServiceEvents::Fields::PRIVATE)
|
Object->get(KafkaTopics::ServiceEvents::Fields::PRIVATE)
|
||||||
.toString(),
|
.toString(),
|
||||||
ID));
|
ID, s1));
|
||||||
std::string SvcList;
|
std::string SvcList;
|
||||||
for (const auto &Svc : Services_) {
|
for (const auto &Svc : Services_) {
|
||||||
if (SvcList.empty())
|
if (SvcList.empty())
|
||||||
@@ -135,13 +147,19 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
auto ServiceHint = Services_.begin();
|
auto ServiceHint = Services_.begin();
|
||||||
auto now = Utils::Now();
|
auto now = Utils::Now();
|
||||||
|
auto si1 = Services_.size();
|
||||||
|
auto ss1 = MakeServiceListString(Services_);
|
||||||
while(ServiceHint!=Services_.end()) {
|
while(ServiceHint!=Services_.end()) {
|
||||||
if ((now - ServiceHint->second.LastUpdate) > 120) {
|
if ((now - ServiceHint->second.LastUpdate) > 120) {
|
||||||
poco_information(logger(), fmt::format("ZombieService: Removing service {}, ", ServiceHint->second.PublicEndPoint));
|
poco_information(Logger_, fmt::format("ZombieService: Removing service {}, ", ServiceHint->second.PublicEndPoint));
|
||||||
ServiceHint = Services_.erase(ServiceHint);
|
ServiceHint = Services_.erase(ServiceHint);
|
||||||
} else
|
} else
|
||||||
++ServiceHint;
|
++ServiceHint;
|
||||||
}
|
}
|
||||||
|
if(Services_.size() != si1) {
|
||||||
|
auto ss2 = MakeServiceListString(Services_);
|
||||||
|
poco_information(Logger_, fmt::format("Current list of microservices: {} -> {}", ss1, ss2));
|
||||||
|
}
|
||||||
|
|
||||||
} catch (const Poco::Exception &E) {
|
} catch (const Poco::Exception &E) {
|
||||||
logger().log(E);
|
logger().log(E);
|
||||||
|
|||||||
Reference in New Issue
Block a user