BrokerStore<->Zeek tables: &backend works for in-memory stores.

Currently this requires using this with a normal cluster - or sending
messages by yourself.

It, in principle, should also work with SQLITE - but that is a bit
nonsensical without being able to change the storage location.
This commit is contained in:
Johanna Amann 2020-07-01 16:38:10 -07:00
parent 318a72c303
commit a220b02722
9 changed files with 118 additions and 33 deletions

View file

@ -49,5 +49,7 @@ redef Broker::log_topic = Cluster::rr_log_topic;
@load ./nodes/worker
@endif
@load ./broker-stores.zeek
@endif
@endif

View file

@ -0,0 +1,46 @@
module Broker;
export {
global announce_masters: event(masters: set[string]);
}
@if ( Cluster::is_enabled() && Cluster::local_node_type() != Cluster::MANAGER )
redef Broker::auto_store_master = F;
@endif
@if ( Broker::auto_store_master )
global broker_backed_ids: set[string];
event zeek_init()
{
local globals = global_ids();
for ( id in globals )
{
if ( globals[id]$broker_backend )
add broker_backed_ids[id];
}
}
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string) &priority=1
{
if ( ! Cluster::is_enabled() )
return;
local e = Broker::make_event(Broker::announce_masters, broker_backed_ids);
Broker::publish(Cluster::nodeid_topic(endpoint$id), e);
}
@else
event Broker::announce_masters(masters: set[string])
{
for ( i in masters )
{
local name = "___sync_store_" + i;
Broker::create_clone(name);
}
}
@endif

View file

@ -249,10 +249,6 @@ export {
global nodeid_topic: function(id: string): string;
}
@if ( Cluster::is_enabled() && Cluster::local_node_type() != Cluster::MANAGER ) )
redef Broker::store_master = T;
@endif
global active_worker_ids: set[string] = set();
type NamedNode: record {