sumstats: Move to Cluster::publish()

This commit is contained in:
Arne Welzel 2024-12-11 18:04:45 +00:00
parent fdf783df65
commit f58a2c2ca8

View file

@ -79,8 +79,8 @@ function data_added(ss: SumStat, key: Key, result: Result)
if ( check_thresholds(ss, key, result, cluster_request_global_view_percent) ) if ( check_thresholds(ss, key, result, cluster_request_global_view_percent) )
{ {
# kick off intermediate update # kick off intermediate update
Broker::publish(Cluster::manager_topic, SumStats::cluster_key_intermediate_response, Cluster::publish(Cluster::manager_topic, SumStats::cluster_key_intermediate_response,
ss$name, key); ss$name, key);
add recent_global_view_keys[ss$name, key]; add recent_global_view_keys[ss$name, key];
} }
} }
@ -91,15 +91,15 @@ event SumStats::get_a_key(uid: string, ss_name: string, cleanup: bool)
{ {
if ( |sending_results[uid]| == 0 ) if ( |sending_results[uid]| == 0 )
{ {
Broker::publish(Cluster::manager_topic, SumStats::send_no_key, Cluster::publish(Cluster::manager_topic, SumStats::send_no_key,
uid, ss_name); uid, ss_name);
} }
else else
{ {
for ( key in sending_results[uid] ) for ( key in sending_results[uid] )
{ {
Broker::publish(Cluster::manager_topic, SumStats::send_a_key, Cluster::publish(Cluster::manager_topic, SumStats::send_a_key,
uid, ss_name, key); uid, ss_name, key);
# break to only send one. # break to only send one.
break; break;
} }
@ -115,8 +115,8 @@ event SumStats::get_a_key(uid: string, ss_name: string, cleanup: bool)
{ {
for ( key in result_store[ss_name] ) for ( key in result_store[ss_name] )
{ {
Broker::publish(Cluster::manager_topic, SumStats::send_a_key, Cluster::publish(Cluster::manager_topic, SumStats::send_a_key,
uid, ss_name, key); uid, ss_name, key);
# break to only send one. # break to only send one.
break; break;
} }
@ -124,8 +124,8 @@ event SumStats::get_a_key(uid: string, ss_name: string, cleanup: bool)
} }
else else
{ {
Broker::publish(Cluster::manager_topic, SumStats::send_no_key, Cluster::publish(Cluster::manager_topic, SumStats::send_no_key,
uid, ss_name); uid, ss_name);
} }
} }
@ -151,31 +151,31 @@ event SumStats::cluster_get_result(uid: string, ss_name: string, key: Key, clean
{ {
if ( uid in sending_results && key in sending_results[uid] ) if ( uid in sending_results && key in sending_results[uid] )
{ {
Broker::publish(Cluster::manager_topic, SumStats::cluster_send_result, Cluster::publish(Cluster::manager_topic, SumStats::cluster_send_result,
uid, ss_name, key, sending_results[uid][key], cleanup); uid, ss_name, key, sending_results[uid][key], cleanup);
delete sending_results[uid][key]; delete sending_results[uid][key];
} }
else else
{ {
# We need to send an empty response if we don't have the data so that the manager # We need to send an empty response if we don't have the data so that the manager
# can know that it heard back from all of the workers. # can know that it heard back from all of the workers.
Broker::publish(Cluster::manager_topic, SumStats::cluster_send_result, Cluster::publish(Cluster::manager_topic, SumStats::cluster_send_result,
uid, ss_name, key, table(), cleanup); uid, ss_name, key, table(), cleanup);
} }
} }
else else
{ {
if ( ss_name in result_store && key in result_store[ss_name] ) if ( ss_name in result_store && key in result_store[ss_name] )
{ {
Broker::publish(Cluster::manager_topic, SumStats::cluster_send_result, Cluster::publish(Cluster::manager_topic, SumStats::cluster_send_result,
uid, ss_name, key, result_store[ss_name][key], cleanup); uid, ss_name, key, result_store[ss_name][key], cleanup);
} }
else else
{ {
# We need to send an empty response if we don't have the data so that the manager # We need to send an empty response if we don't have the data so that the manager
# can know that it heard back from all of the workers. # can know that it heard back from all of the workers.
Broker::publish(Cluster::manager_topic, SumStats::cluster_send_result, Cluster::publish(Cluster::manager_topic, SumStats::cluster_send_result,
uid, ss_name, key, table(), cleanup); uid, ss_name, key, table(), cleanup);
} }
} }
} }
@ -252,14 +252,14 @@ event SumStats::finish_epoch(ss: SumStat)
stats_keys[uid] = set(); stats_keys[uid] = set();
# Request data from peers. # Request data from peers.
Broker::publish(Cluster::worker_topic, SumStats::cluster_ss_request, Cluster::publish(Cluster::worker_topic, SumStats::cluster_ss_request,
uid, ss$name, T); uid, ss$name, T);
done_with[uid] = 0; done_with[uid] = 0;
#print fmt("get_key by uid: %s", uid); #print fmt("get_key by uid: %s", uid);
Broker::publish(Cluster::worker_topic, SumStats::get_a_key, Cluster::publish(Cluster::worker_topic, SumStats::get_a_key,
uid, ss$name, T); uid, ss$name, T);
} }
# Schedule the next finish_epoch event. # Schedule the next finish_epoch event.
@ -274,8 +274,8 @@ function data_added(ss: SumStat, key: Key, result: Result)
if ( check_thresholds(ss, key, result, 1.0) ) if ( check_thresholds(ss, key, result, 1.0) )
{ {
threshold_crossed(ss, key, result); threshold_crossed(ss, key, result);
Broker::publish(Cluster::worker_topic, SumStats::cluster_threshold_crossed, Cluster::publish(Cluster::worker_topic, SumStats::cluster_threshold_crossed,
ss$name, key, threshold_tracker[ss$name][key]); ss$name, key, threshold_tracker[ss$name][key]);
} }
} }
@ -292,8 +292,8 @@ function handle_end_of_result_collection(uid: string, ss_name: string, key: Key,
if ( check_thresholds(ss, key, ir, 1.0) ) if ( check_thresholds(ss, key, ir, 1.0) )
{ {
threshold_crossed(ss, key, ir); threshold_crossed(ss, key, ir);
Broker::publish(Cluster::worker_topic, SumStats::cluster_threshold_crossed, Cluster::publish(Cluster::worker_topic, SumStats::cluster_threshold_crossed,
ss_name, key, threshold_tracker[ss_name][key]); ss_name, key, threshold_tracker[ss_name][key]);
} }
if ( cleanup ) if ( cleanup )
@ -329,8 +329,8 @@ function request_all_current_keys(uid: string, ss_name: string, cleanup: bool)
} }
done_with[uid] = 0; done_with[uid] = 0;
Broker::publish(Cluster::worker_topic, SumStats::cluster_get_result, Cluster::publish(Cluster::worker_topic, SumStats::cluster_get_result,
uid, ss_name, key, cleanup); uid, ss_name, key, cleanup);
delete stats_keys[uid][key]; delete stats_keys[uid][key];
} }
else else
@ -338,8 +338,8 @@ function request_all_current_keys(uid: string, ss_name: string, cleanup: bool)
# Get more keys! And this breaks us out of the evented loop. # Get more keys! And this breaks us out of the evented loop.
done_with[uid] = 0; done_with[uid] = 0;
#print fmt("get_key by uid: %s", uid); #print fmt("get_key by uid: %s", uid);
Broker::publish(Cluster::worker_topic, SumStats::get_a_key, Cluster::publish(Cluster::worker_topic, SumStats::get_a_key,
uid, ss_name, cleanup); uid, ss_name, cleanup);
} }
} }
@ -464,8 +464,8 @@ event SumStats::cluster_key_intermediate_response(ss_name: string, key: Key)
add outstanding_global_views[ss_name][uid]; add outstanding_global_views[ss_name][uid];
done_with[uid] = 0; done_with[uid] = 0;
#print fmt("requesting results for: %s", uid); #print fmt("requesting results for: %s", uid);
Broker::publish(Cluster::worker_topic, SumStats::cluster_get_result, Cluster::publish(Cluster::worker_topic, SumStats::cluster_get_result,
uid, ss_name, key, F); uid, ss_name, key, F);
} }
function request_key(ss_name: string, key: Key): Result function request_key(ss_name: string, key: Key): Result
@ -475,8 +475,8 @@ function request_key(ss_name: string, key: Key): Result
key_requests[uid] = table(); key_requests[uid] = table();
add dynamic_requests[uid]; add dynamic_requests[uid];
Broker::publish(Cluster::worker_topic, SumStats::cluster_get_result, Cluster::publish(Cluster::worker_topic, SumStats::cluster_get_result,
uid, ss_name, key, F); uid, ss_name, key, F);
return when [uid, ss_name, key] ( uid in done_with && return when [uid, ss_name, key] ( uid in done_with &&
Cluster::get_active_node_count(Cluster::WORKER) == done_with[uid] ) Cluster::get_active_node_count(Cluster::WORKER) == done_with[uid] )
{ {