improve logging with broker store

This commit is contained in:
Mauro Palumbo 2019-07-31 17:40:02 +02:00
parent 1f7f42daea
commit e206347d1a

View file

@ -40,7 +40,7 @@ export {
type AddrPortServTriplet: record { type AddrPortServTriplet: record {
host: addr; host: addr;
p: port; p: port;
serv: vector of string; serv: string;
}; };
## Holds the set of all known services. Keys in the store are ## Holds the set of all known services. Keys in the store are
@ -109,28 +109,29 @@ event service_info_commit(info: ServicesInfo)
if ( ! Known::use_service_store ) if ( ! Known::use_service_store )
return; return;
local v : vector of string; local tempservs = info$service;
for ( s in info$service ) for ( s in tempservs ) {
v += s;
sort(v, strcmp); # sort the vector for proper key comparison in put_unique
local key = AddrPortServTriplet($host = info$host, $p = info$port_num, $serv = v); local key = AddrPortServTriplet($host = info$host, $p = info$port_num, $serv = s);
when ( local r = Broker::put_unique(Known::service_store$store, key, when ( local r = Broker::put_unique(Known::service_store$store, key,
T, Known::service_store_expiry) ) T, Known::service_store_expiry) )
{
if ( r$status == Broker::SUCCESS )
{ {
if ( r$result as bool ) if ( r$status == Broker::SUCCESS )
Log::write(Known::SERVICES_LOG, info); {
if ( r$result as bool ) {
info$service = set(s); # log one service at the time if multiservice
Log::write(Known::SERVICES_LOG, info);
}
}
else
Reporter::error(fmt("%s: data store put_unique failure",
Known::service_store_name));
}
timeout Known::service_store_timeout
{
Log::write(Known::SERVICES_LOG, info);
} }
else
Reporter::error(fmt("%s: data store put_unique failure",
Known::service_store_name));
}
timeout Known::service_store_timeout
{
Log::write(Known::SERVICES_LOG, info);
} }
} }