mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 17:18:20 +00:00
Merge remote-tracking branch 'origin/topic/johanna/table-changes'
* origin/topic/johanna/table-changes: (26 commits) TableSync: try to make test more robust & add debug output Increase timeouts to see if FreeBSD will be happy with this. Try to make FreeBSD test happy with larger timeout. TableSync: refactor common functionality into function TableSync: don't raise &on_change, smaller fixes TableSync: rename auto_store -> table_store SyncTables: address feedback part 1 - naming (broker and zeek) BrokerStore <-> Zeek Tables: cleanup and bug workaround Zeek Table<->Brokerstore: cleanup, documentation, small fixes BrokerStore<->Zeek table: adopt to recent Zeek API changes BrokerStore<->Zeek Tables Fix a few small test failures. BrokerStore<->Zeek tables: allow setting storage location & tests BrokerStore<->Zeek tables: &backend works for in-memory stores. BrokerStore<->Zeek table - introdude &backend attribute BrokerStore<->Zeek tables: test for clones synchronizing to a master BrokerStore<->Zeek tables: load persistent tables on startup. Brokerstore<->Tables: attribute conflicts Zeek/Brokerstore updates: expiration Zeek/Brokerstore updates: add test that includes updates from clones Zeek/Brokerstore updates: first working end-to-end test ...
This commit is contained in:
commit
c3f4971eb2
50 changed files with 2290 additions and 78 deletions
117
src/Attr.cc
117
src/Attr.cc
|
@ -7,6 +7,7 @@
|
|||
#include "Desc.h"
|
||||
#include "Val.h"
|
||||
#include "IntrusivePtr.h"
|
||||
#include "input/Manager.h"
|
||||
#include "threading/SerialTypes.h"
|
||||
|
||||
namespace zeek::detail {
|
||||
|
@ -19,7 +20,8 @@ const char* attr_name(AttrTag t)
|
|||
"&read_expire", "&write_expire", "&create_expire",
|
||||
"&raw_output", "&priority",
|
||||
"&group", "&log", "&error_handler", "&type_column",
|
||||
"(&tracked)", "&on_change", "&deprecated",
|
||||
"(&tracked)", "&on_change", "&broker_store",
|
||||
"&broker_allow_complex_type", "&backend", "&deprecated",
|
||||
};
|
||||
|
||||
return attr_names[int(t)];
|
||||
|
@ -456,6 +458,15 @@ void Attributes::CheckAttr(Attr* a)
|
|||
break;
|
||||
|
||||
case ATTR_EXPIRE_READ:
|
||||
{
|
||||
if ( Find(ATTR_BROKER_STORE) )
|
||||
Error("&broker_store and &read_expire cannot be used simultaneously");
|
||||
|
||||
if ( Find(ATTR_BACKEND) )
|
||||
Error("&backend and &read_expire cannot be used simultaneously");
|
||||
}
|
||||
// fallthrough
|
||||
|
||||
case ATTR_EXPIRE_WRITE:
|
||||
case ATTR_EXPIRE_CREATE:
|
||||
{
|
||||
|
@ -534,14 +545,22 @@ void Attributes::CheckAttr(Attr* a)
|
|||
|
||||
if ( ! e_ft->CheckArgs(&expected_args) )
|
||||
Error("&expire_func argument type clash");
|
||||
}
|
||||
|
||||
if ( Find(ATTR_BROKER_STORE ) )
|
||||
Error("&broker_store and &expire_func cannot be used simultaneously");
|
||||
|
||||
if ( Find(ATTR_BACKEND ) )
|
||||
Error("&backend and &expire_func cannot be used simultaneously");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case ATTR_ON_CHANGE:
|
||||
{
|
||||
if ( type->Tag() != TYPE_TABLE )
|
||||
{
|
||||
Error("&on_change only applicable to tables");
|
||||
Error("&on_change only applicable to sets/tables");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -602,6 +621,98 @@ void Attributes::CheckAttr(Attr* a)
|
|||
}
|
||||
break;
|
||||
|
||||
case ATTR_BACKEND:
|
||||
{
|
||||
if ( ! global_var || type->Tag() != TYPE_TABLE )
|
||||
{
|
||||
Error("&backend only applicable to global sets/tables");
|
||||
break;
|
||||
}
|
||||
|
||||
// cannot do better equality check - the Broker types are not
|
||||
// actually existing yet when we are here. We will do that
|
||||
// later - before actually attaching to a broker store
|
||||
if ( a->GetExpr()->GetType()->Tag() != TYPE_ENUM )
|
||||
{
|
||||
Error("&backend must take an enum argument");
|
||||
break;
|
||||
}
|
||||
|
||||
// Temporary since Broker does not support ListVals - and we
|
||||
// cannot easily convert to set/vector
|
||||
if ( type->AsTableType()->GetIndexTypes().size() != 1 )
|
||||
Error("&backend only supports one-element set/table indexes");
|
||||
|
||||
// Only support atomic types for the moment, unless
|
||||
// explicitly overriden
|
||||
if ( ! type->AsTableType()->IsSet() &&
|
||||
! input::Manager::IsCompatibleType(type->AsTableType()->Yield().get(), true) &&
|
||||
! Find(ATTR_BROKER_STORE_ALLOW_COMPLEX) )
|
||||
{
|
||||
Error("&backend only supports atomic types as table value");
|
||||
}
|
||||
|
||||
if ( Find(ATTR_EXPIRE_FUNC ) )
|
||||
Error("&backend and &expire_func cannot be used simultaneously");
|
||||
|
||||
if ( Find(ATTR_EXPIRE_READ) )
|
||||
Error("&backend and &read_expire cannot be used simultaneously");
|
||||
|
||||
if ( Find(ATTR_BROKER_STORE) )
|
||||
Error("&backend and &broker_store cannot be used simultaneously");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ATTR_BROKER_STORE:
|
||||
{
|
||||
if ( type->Tag() != TYPE_TABLE )
|
||||
{
|
||||
Error("&broker_store only applicable to sets/tables");
|
||||
break;
|
||||
}
|
||||
|
||||
if ( a->GetExpr()->GetType()->Tag() != TYPE_STRING )
|
||||
{
|
||||
Error("&broker_store must take a string argument");
|
||||
break;
|
||||
}
|
||||
|
||||
// Temporary since Broker does not support ListVals - and we
|
||||
// cannot easily convert to set/vector
|
||||
if ( type->AsTableType()->GetIndexTypes().size() != 1 && ! Find(ATTR_BROKER_STORE_ALLOW_COMPLEX) )
|
||||
Error("&broker_store only supports one-element set/table indexes");
|
||||
|
||||
// Only support atomic types for the moment, unless
|
||||
// explicitly overriden
|
||||
if ( ! type->AsTableType()->IsSet() &&
|
||||
! input::Manager::IsCompatibleType(type->AsTableType()->Yield().get(), true) &&
|
||||
! Find(ATTR_BROKER_STORE_ALLOW_COMPLEX) )
|
||||
{
|
||||
Error("&broker_store only supports atomic types as table value");
|
||||
}
|
||||
|
||||
if ( Find(ATTR_EXPIRE_FUNC ) )
|
||||
Error("&broker_store and &expire_func cannot be used simultaneously");
|
||||
|
||||
if ( Find(ATTR_EXPIRE_READ) )
|
||||
Error("&broker_store and &read_expire cannot be used simultaneously");
|
||||
|
||||
if ( Find(ATTR_BACKEND) )
|
||||
Error("&backend and &broker_store cannot be used simultaneously");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ATTR_BROKER_STORE_ALLOW_COMPLEX:
|
||||
{
|
||||
if ( type->Tag() != TYPE_TABLE )
|
||||
{
|
||||
Error("&broker_allow_complex_type only applicable to sets/tables");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case ATTR_TRACKED:
|
||||
// FIXME: Check here for global ID?
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue