mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Merge remote-tracking branch 'origin/topic/awelzel/deprecate-broker-auto-publish'
* origin/topic/awelzel/deprecate-broker-auto-publish: sumstats: Remove copy() for Broker::publish() calls broker/Publish: Use event time instead of network time broker/Eventhandler: Deprecate Broker::auto_publish() for v8.1 btest: Remove Broker::auto_publish() usages frameworks/control: Remove Broker::auto_publish() catch-and-release: Remove Broker::auto_publish() ssl/validate-certs: Remove Broker::auto_publish() sumstats: Remove Broker::auto_publish() cluster_started: No Broker::auto_publish() use openflow: Remove Broker::auto_publish() dhcp: Remove Broker::auto_publish() frameworks/notice: Remove Broker::auto_publish() netcontrol: Replace Broker::auto_publish() intel: Switch to Cluster::publish() broker: Support publish() of unspecified set() / table() types: Fix table() resulting in table_type->IsSet() == true
This commit is contained in:
commit
18bfdb8a2b
47 changed files with 705 additions and 279 deletions
|
@ -51,15 +51,6 @@ event fully_connected(n: string)
|
|||
terminate();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "sent fully_connected event";
|
||||
}
|
||||
}
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
Broker::auto_publish(Cluster::logger_topic, fully_connected);
|
||||
}
|
||||
|
||||
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
||||
|
@ -74,16 +65,14 @@ event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
|||
print "termination condition met: shutting down";
|
||||
terminate();
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if ( Cluster::node == "manager-1" )
|
||||
|
||||
local expected_nodes = Cluster::node == "manager-1" ? 5 : 4;
|
||||
if ( peer_count == expected_nodes )
|
||||
{
|
||||
if ( peer_count == 5 )
|
||||
event fully_connected(Cluster::node);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( peer_count == 4 )
|
||||
event fully_connected(Cluster::node);
|
||||
Broker::publish(Cluster::logger_topic, fully_connected, Cluster::node);
|
||||
print "sent fully_connected event";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,6 @@ redef Cluster::nodes = {
|
|||
};
|
||||
@TEST-END-FILE
|
||||
|
||||
global fully_connected: event();
|
||||
|
||||
global peer_count = 0;
|
||||
|
||||
global fully_connected_nodes = 0;
|
||||
|
@ -49,11 +47,6 @@ event fully_connected()
|
|||
}
|
||||
}
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
Broker::auto_publish(Cluster::manager_topic, fully_connected);
|
||||
}
|
||||
|
||||
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
||||
{
|
||||
print "Connected to a peer";
|
||||
|
@ -67,7 +60,7 @@ event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
|||
else
|
||||
{
|
||||
if ( peer_count == 3 )
|
||||
event fully_connected();
|
||||
Broker::publish(Cluster::manager_topic, fully_connected);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,13 +36,6 @@ event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string)
|
|||
terminate();
|
||||
}
|
||||
|
||||
global ready_for_data: event();
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
Broker::auto_publish(Cluster::worker_topic, ready_for_data);
|
||||
}
|
||||
|
||||
@if ( Cluster::node == "worker-1" )
|
||||
event Cluster::Experimental::cluster_started()
|
||||
{
|
||||
|
|
|
@ -38,10 +38,6 @@ global n = 0;
|
|||
|
||||
event ready_for_data()
|
||||
{
|
||||
@if ( Cluster::node == "manager-1" )
|
||||
Config::set_value("testcount", 1);
|
||||
@endif
|
||||
|
||||
@if ( Cluster::node == "worker-1" )
|
||||
Config::set_value("testport", 44/tcp);
|
||||
Config::set_value("teststring", "b", "comment");
|
||||
|
@ -66,7 +62,6 @@ function option_changed(ID: string, new_value: any, location: string): any
|
|||
|
||||
event zeek_init() &priority=5
|
||||
{
|
||||
Broker::auto_publish(Cluster::worker_topic, ready_for_data);
|
||||
Option::set_change_handler("testport", option_changed, -100);
|
||||
Option::set_change_handler("teststring", option_changed, -100);
|
||||
Option::set_change_handler("testcount", option_changed, -100);
|
||||
|
@ -79,9 +74,11 @@ event Cluster::node_up(name: string, id: string) &priority=-5
|
|||
{
|
||||
++peer_count;
|
||||
if ( peer_count == 1 )
|
||||
event ready_for_data();
|
||||
{
|
||||
Config::set_value("testcount", 1);
|
||||
Broker::publish(Cluster::worker_topic, ready_for_data);
|
||||
}
|
||||
}
|
||||
|
||||
@endif
|
||||
|
||||
event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string)
|
||||
|
|
|
@ -50,9 +50,7 @@ event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string)
|
|||
terminate();
|
||||
}
|
||||
|
||||
global ready_for_data: event();
|
||||
|
||||
event ready_for_data()
|
||||
event ready_for_data() &is_used
|
||||
{
|
||||
if ( Cluster::node == "worker-1" )
|
||||
{
|
||||
|
@ -74,8 +72,6 @@ event ready_for_data()
|
|||
SumStats::observe("test", [$host=7.2.1.5], [$num=91]);
|
||||
SumStats::observe("test", [$host=10.10.10.10], [$num=5]);
|
||||
}
|
||||
|
||||
did_data = T;
|
||||
}
|
||||
|
||||
@if ( Cluster::local_node_type() == Cluster::MANAGER )
|
||||
|
@ -91,7 +87,8 @@ event second_test()
|
|||
event send_ready_for_data()
|
||||
{
|
||||
print "Sending ready for data";
|
||||
event ready_for_data();
|
||||
Broker::publish(Cluster::worker_topic, ready_for_data);
|
||||
did_data = T;
|
||||
}
|
||||
|
||||
|
||||
|
@ -104,10 +101,4 @@ event Cluster::Experimental::cluster_started()
|
|||
schedule 5secs { send_ready_for_data() };
|
||||
schedule 10secs { second_test() };
|
||||
}
|
||||
|
||||
event zeek_init() &priority=100
|
||||
{
|
||||
Broker::auto_publish(Cluster::worker_topic, ready_for_data);
|
||||
}
|
||||
|
||||
@endif
|
||||
|
|
71
testing/btest/scripts/base/protocols/dhcp/cluster.zeek
Normal file
71
testing/btest/scripts/base/protocols/dhcp/cluster.zeek
Normal file
|
@ -0,0 +1,71 @@
|
|||
# Test in cluster mode, the manager produces the cluster.log
|
||||
#
|
||||
# @TEST-PORT: BROKER_PORT1
|
||||
# @TEST-PORT: BROKER_PORT2
|
||||
#
|
||||
# @TEST-EXEC: zeek -b --parse-only %INPUT
|
||||
# @TEST-EXEC: btest-bg-run manager-1 "cp ../cluster-layout.zeek . && CLUSTER_NODE=manager-1 zeek -b %INPUT"
|
||||
# @TEST-EXEC: btest-bg-run worker-1 "cp ../cluster-layout.zeek . && CLUSTER_NODE=worker-1 zeek -b --pseudo-realtime -C -r $TRACES/dhcp/dhcp_ack_subscriber_id_and_agent_remote_id.trace %INPUT"
|
||||
|
||||
# @TEST-EXEC: btest-bg-wait 10
|
||||
# @TEST-EXEC: btest-diff worker-1/.stdout
|
||||
# @TEST-EXEC: btest-diff manager-1/.stdout
|
||||
# @TEST-EXEC: btest-diff manager-1/dhcp.log
|
||||
|
||||
@TEST-START-FILE cluster-layout.zeek
|
||||
redef Cluster::nodes = {
|
||||
["manager-1"] = [$node_type=Cluster::MANAGER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT1"))],
|
||||
["worker-1"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT2")), $manager="manager-1"],
|
||||
};
|
||||
@TEST-END-FILE
|
||||
|
||||
@load base/protocols/dhcp
|
||||
@load base/frameworks/broker
|
||||
@load base/frameworks/cluster
|
||||
@load base/frameworks/logging
|
||||
|
||||
redef Log::default_rotation_interval = 0secs;
|
||||
redef Log::default_rotation_postprocessor_cmd = "echo";
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
redef Broker::disable_ssl = T;
|
||||
redef Cluster::manager_is_logger = T;
|
||||
|
||||
event terminate_me() {
|
||||
terminate();
|
||||
}
|
||||
|
||||
@if ( Cluster::local_node_type() == Cluster::WORKER )
|
||||
event zeek_init()
|
||||
{
|
||||
suspend_processing();
|
||||
}
|
||||
|
||||
event Cluster::node_up(name: string, id: string)
|
||||
{
|
||||
print "node_up", name;
|
||||
continue_processing();
|
||||
}
|
||||
|
||||
event dhcp_message(c: connection, is_orig: bool, msg: DHCP::Msg, options: DHCP::Options)
|
||||
{
|
||||
print "dhcp_message", c$uid;
|
||||
}
|
||||
|
||||
event Pcap::file_done(path: string)
|
||||
{
|
||||
print "file_done";
|
||||
terminate();
|
||||
}
|
||||
@else
|
||||
|
||||
event DHCP::aggregate_msgs(ts: time, id: conn_id, uid: string, is_orig: bool, msg: DHCP::Msg, options: DHCP::Options) &priority=5
|
||||
{
|
||||
print "DHCP::aggregate_msgs", ts, uid;
|
||||
}
|
||||
|
||||
event Cluster::node_down(name: string, id: string)
|
||||
{
|
||||
terminate();
|
||||
}
|
||||
@endif
|
Loading…
Add table
Add a link
Reference in a new issue