mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Rename the BrokerStore namespace to Broker
This commit is contained in:
parent
9f5c820c7b
commit
f46dfac63a
20 changed files with 217 additions and 217 deletions
|
@ -192,8 +192,8 @@ last modification time.
|
|||
.. btest-include:: ${DOC_ROOT}/frameworks/broker/stores-connector.bro
|
||||
|
||||
In the above example, if a local copy of the store contents isn't
|
||||
needed, just replace the :bro:see:`BrokerStore::create_clone` call with
|
||||
:bro:see:`BrokerStore::create_frontend`. Queries will then be made against
|
||||
needed, just replace the :bro:see:`Broker::create_clone` call with
|
||||
:bro:see:`Broker::create_frontend`. Queries will then be made against
|
||||
the remote master store instead of the local clone.
|
||||
|
||||
Note that all data store queries must be made within Bro's asynchronous
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
|
||||
function dv(d: Broker::Data): Broker::DataVector
|
||||
{
|
||||
|
@ -24,19 +24,19 @@ event Broker::outgoing_connection_established(peer_address: string,
|
|||
{
|
||||
local myset: set[string] = {"a", "b", "c"};
|
||||
local myvec: vector of string = {"alpha", "beta", "gamma"};
|
||||
h = BrokerStore::create_master("mystore");
|
||||
BrokerStore::insert(h, Broker::data("one"), Broker::data(110));
|
||||
BrokerStore::insert(h, Broker::data("two"), Broker::data(223));
|
||||
BrokerStore::insert(h, Broker::data("myset"), Broker::data(myset));
|
||||
BrokerStore::insert(h, Broker::data("myvec"), Broker::data(myvec));
|
||||
BrokerStore::increment(h, Broker::data("one"));
|
||||
BrokerStore::decrement(h, Broker::data("two"));
|
||||
BrokerStore::add_to_set(h, Broker::data("myset"), Broker::data("d"));
|
||||
BrokerStore::remove_from_set(h, Broker::data("myset"), Broker::data("b"));
|
||||
BrokerStore::push_left(h, Broker::data("myvec"), dv(Broker::data("delta")));
|
||||
BrokerStore::push_right(h, Broker::data("myvec"), dv(Broker::data("omega")));
|
||||
h = Broker::create_master("mystore");
|
||||
Broker::insert(h, Broker::data("one"), Broker::data(110));
|
||||
Broker::insert(h, Broker::data("two"), Broker::data(223));
|
||||
Broker::insert(h, Broker::data("myset"), Broker::data(myset));
|
||||
Broker::insert(h, Broker::data("myvec"), Broker::data(myvec));
|
||||
Broker::increment(h, Broker::data("one"));
|
||||
Broker::decrement(h, Broker::data("two"));
|
||||
Broker::add_to_set(h, Broker::data("myset"), Broker::data("d"));
|
||||
Broker::remove_from_set(h, Broker::data("myset"), Broker::data("b"));
|
||||
Broker::push_left(h, Broker::data("myvec"), dv(Broker::data("delta")));
|
||||
Broker::push_right(h, Broker::data("myvec"), dv(Broker::data("omega")));
|
||||
|
||||
when ( local res = BrokerStore::size(h) )
|
||||
when ( local res = Broker::size(h) )
|
||||
{
|
||||
print "master size", res;
|
||||
event ready();
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
global expected_key_count = 4;
|
||||
global key_count = 0;
|
||||
|
||||
function do_lookup(key: string)
|
||||
{
|
||||
when ( local res = BrokerStore::lookup(h, Broker::data(key)) )
|
||||
when ( local res = Broker::lookup(h, Broker::data(key)) )
|
||||
{
|
||||
++key_count;
|
||||
print "lookup", key, res;
|
||||
|
@ -21,9 +21,9 @@ function do_lookup(key: string)
|
|||
|
||||
event ready()
|
||||
{
|
||||
h = BrokerStore::create_clone("mystore");
|
||||
h = Broker::create_clone("mystore");
|
||||
|
||||
when ( local res = BrokerStore::keys(h) )
|
||||
when ( local res = Broker::keys(h) )
|
||||
{
|
||||
print "clone keys", res;
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 0)));
|
||||
|
|
|
@ -54,7 +54,7 @@ export {
|
|||
};
|
||||
}
|
||||
|
||||
module BrokerStore;
|
||||
module Broker;
|
||||
|
||||
export {
|
||||
|
||||
|
@ -76,7 +76,7 @@ export {
|
|||
## The result of a data store query.
|
||||
type QueryResult: record {
|
||||
## Whether the query completed or not.
|
||||
status: BrokerStore::QueryStatus;
|
||||
status: Broker::QueryStatus;
|
||||
## The result of the query. Certain queries may use a particular
|
||||
## data type (e.g. querying store size always returns a count, but
|
||||
## a lookup may return various data types).
|
||||
|
|
|
@ -89,7 +89,7 @@ bool bro_broker::Manager::Enable(Val* broker_endpoint_flags)
|
|||
bro_broker::opaque_of_table_iterator = new OpaqueType("Broker::TableIterator");
|
||||
bro_broker::opaque_of_vector_iterator = new OpaqueType("Broker::VectorIterator");
|
||||
bro_broker::opaque_of_record_iterator = new OpaqueType("Broker::RecordIterator");
|
||||
bro_broker::opaque_of_store_handle = new OpaqueType("BrokerStore::Handle");
|
||||
bro_broker::opaque_of_store_handle = new OpaqueType("Broker::Handle");
|
||||
vector_of_data_type = new VectorType(internal_type("Broker::Data")->Ref());
|
||||
|
||||
auto res = broker::init();
|
||||
|
|
|
@ -14,12 +14,12 @@ OpaqueType* bro_broker::opaque_of_store_handle;
|
|||
|
||||
bro_broker::StoreHandleVal::StoreHandleVal(broker::store::identifier id,
|
||||
bro_broker::StoreType arg_type,
|
||||
broker::util::optional<BifEnum::BrokerStore::BackendType> arg_back,
|
||||
broker::util::optional<BifEnum::Broker::BackendType> arg_back,
|
||||
RecordVal* backend_options, std::chrono::duration<double> resync)
|
||||
: OpaqueVal(opaque_of_store_handle),
|
||||
store(), store_type(arg_type), backend_type(arg_back)
|
||||
{
|
||||
using BifEnum::BrokerStore::BackendType;
|
||||
using BifEnum::Broker::BackendType;
|
||||
std::unique_ptr<broker::store::backend> backend;
|
||||
|
||||
if ( backend_type )
|
||||
|
@ -91,7 +91,7 @@ bro_broker::StoreHandleVal::StoreHandleVal(broker::store::identifier id,
|
|||
|
||||
void bro_broker::StoreHandleVal::ValDescribe(ODesc* d) const
|
||||
{
|
||||
using BifEnum::BrokerStore::BackendType;
|
||||
using BifEnum::Broker::BackendType;
|
||||
d->Add("broker::store::");
|
||||
|
||||
switch ( store_type ) {
|
||||
|
|
|
@ -25,9 +25,9 @@ enum StoreType {
|
|||
};
|
||||
|
||||
/**
|
||||
* Create a BrokerStore::QueryStatus value.
|
||||
* Create a Broker::QueryStatus value.
|
||||
* @param success whether the query status should be set to success or failure.
|
||||
* @return a BrokerStore::QueryStatus value.
|
||||
* @return a Broker::QueryStatus value.
|
||||
*/
|
||||
inline EnumVal* query_status(bool success)
|
||||
{
|
||||
|
@ -37,21 +37,21 @@ inline EnumVal* query_status(bool success)
|
|||
|
||||
if ( ! store_query_status )
|
||||
{
|
||||
store_query_status = internal_type("BrokerStore::QueryStatus")->AsEnumType();
|
||||
success_val = store_query_status->Lookup("BrokerStore", "SUCCESS");
|
||||
failure_val = store_query_status->Lookup("BrokerStore", "FAILURE");
|
||||
store_query_status = internal_type("Broker::QueryStatus")->AsEnumType();
|
||||
success_val = store_query_status->Lookup("Broker", "SUCCESS");
|
||||
failure_val = store_query_status->Lookup("Broker", "FAILURE");
|
||||
}
|
||||
|
||||
return new EnumVal(success ? success_val : failure_val, store_query_status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a BrokerStore::QueryResult value that has a BrokerStore::QueryStatus indicating
|
||||
* @return a Broker::QueryResult value that has a Broker::QueryStatus indicating
|
||||
* a failure.
|
||||
*/
|
||||
inline RecordVal* query_result()
|
||||
{
|
||||
auto rval = new RecordVal(BifType::Record::BrokerStore::QueryResult);
|
||||
auto rval = new RecordVal(BifType::Record::Broker::QueryResult);
|
||||
rval->Assign(0, query_status(false));
|
||||
rval->Assign(1, new RecordVal(BifType::Record::Broker::Data));
|
||||
return rval;
|
||||
|
@ -59,12 +59,12 @@ inline RecordVal* query_result()
|
|||
|
||||
/**
|
||||
* @param data the result of the query.
|
||||
* @return a BrokerStore::QueryResult value that has a BrokerStore::QueryStatus indicating
|
||||
* @return a Broker::QueryResult value that has a Broker::QueryStatus indicating
|
||||
* a success.
|
||||
*/
|
||||
inline RecordVal* query_result(RecordVal* data)
|
||||
{
|
||||
auto rval = new RecordVal(BifType::Record::BrokerStore::QueryResult);
|
||||
auto rval = new RecordVal(BifType::Record::Broker::QueryResult);
|
||||
rval->Assign(0, query_status(true));
|
||||
rval->Assign(1, data);
|
||||
return rval;
|
||||
|
@ -130,7 +130,7 @@ public:
|
|||
|
||||
StoreHandleVal(broker::store::identifier id,
|
||||
bro_broker::StoreType arg_type,
|
||||
broker::util::optional<BifEnum::BrokerStore::BackendType> arg_back,
|
||||
broker::util::optional<BifEnum::Broker::BackendType> arg_back,
|
||||
RecordVal* backend_options,
|
||||
std::chrono::duration<double> resync = std::chrono::seconds(1));
|
||||
|
||||
|
@ -140,7 +140,7 @@ public:
|
|||
|
||||
broker::store::frontend* store;
|
||||
bro_broker::StoreType store_type;
|
||||
broker::util::optional<BifEnum::BrokerStore::BackendType> backend_type;
|
||||
broker::util::optional<BifEnum::Broker::BackendType> backend_type;
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
#include "Trigger.h"
|
||||
%%}
|
||||
|
||||
module BrokerStore;
|
||||
module Broker;
|
||||
|
||||
type BrokerStore::ExpiryTime: record;
|
||||
type Broker::ExpiryTime: record;
|
||||
|
||||
type BrokerStore::QueryResult: record;
|
||||
type Broker::QueryResult: record;
|
||||
|
||||
type BrokerStore::BackendOptions: record;
|
||||
type Broker::BackendOptions: record;
|
||||
|
||||
## Enumerates the possible storage backends.
|
||||
enum BackendType %{
|
||||
|
@ -32,8 +32,8 @@ enum BackendType %{
|
|||
## options: tunes how some storage backends operate.
|
||||
##
|
||||
## Returns: a handle to the data store.
|
||||
function BrokerStore::create_master%(id: string, b: BackendType &default = MEMORY,
|
||||
options: BackendOptions &default = BackendOptions()%): opaque of BrokerStore::Handle
|
||||
function Broker::create_master%(id: string, b: BackendType &default = MEMORY,
|
||||
options: BackendOptions &default = BackendOptions()%): opaque of Broker::Handle
|
||||
%{
|
||||
auto id_str = id->CheckString();
|
||||
auto type = bro_broker::StoreType::MASTER;
|
||||
|
@ -46,7 +46,7 @@ function BrokerStore::create_master%(id: string, b: BackendType &default = MEMOR
|
|||
}
|
||||
|
||||
rval = new bro_broker::StoreHandleVal(id_str, type,
|
||||
static_cast<BifEnum::BrokerStore::BackendType>(b->AsEnum()),
|
||||
static_cast<BifEnum::Broker::BackendType>(b->AsEnum()),
|
||||
options->AsRecordVal());
|
||||
auto added = broker_mgr->AddStore(rval);
|
||||
assert(added);
|
||||
|
@ -75,9 +75,9 @@ function BrokerStore::create_master%(id: string, b: BackendType &default = MEMOR
|
|||
## but updates will be lost until the master is once again available.
|
||||
##
|
||||
## Returns: a handle to the data store.
|
||||
function BrokerStore::create_clone%(id: string, b: BackendType &default = MEMORY,
|
||||
function Broker::create_clone%(id: string, b: BackendType &default = MEMORY,
|
||||
options: BackendOptions &default = BackendOptions(),
|
||||
resync: interval &default = 1sec%): opaque of BrokerStore::Handle
|
||||
resync: interval &default = 1sec%): opaque of Broker::Handle
|
||||
%{
|
||||
auto id_str = id->CheckString();
|
||||
auto type = bro_broker::StoreType::CLONE;
|
||||
|
@ -90,7 +90,7 @@ function BrokerStore::create_clone%(id: string, b: BackendType &default = MEMORY
|
|||
}
|
||||
|
||||
rval = new bro_broker::StoreHandleVal(id_str, type,
|
||||
static_cast<BifEnum::BrokerStore::BackendType>(b->AsEnum()),
|
||||
static_cast<BifEnum::Broker::BackendType>(b->AsEnum()),
|
||||
options->AsRecordVal(),
|
||||
std::chrono::duration<double>(resync));
|
||||
auto added = broker_mgr->AddStore(rval);
|
||||
|
@ -104,7 +104,7 @@ function BrokerStore::create_clone%(id: string, b: BackendType &default = MEMORY
|
|||
## id: the unique name which identifies the master data store.
|
||||
##
|
||||
## Returns: a handle to the data store.
|
||||
function BrokerStore::create_frontend%(id: string%): opaque of BrokerStore::Handle
|
||||
function Broker::create_frontend%(id: string%): opaque of Broker::Handle
|
||||
%{
|
||||
auto id_str = id->CheckString();
|
||||
auto type = bro_broker::StoreType::FRONTEND;
|
||||
|
@ -128,7 +128,7 @@ function BrokerStore::create_frontend%(id: string%): opaque of BrokerStore::Hand
|
|||
##
|
||||
## Returns: true if store was valid and is now closed. The handle can no
|
||||
## longer be used for data store operations.
|
||||
function BrokerStore::close_by_handle%(h: opaque of BrokerStore::Handle%): bool
|
||||
function Broker::close_by_handle%(h: opaque of Broker::Handle%): bool
|
||||
%{
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
|
@ -154,9 +154,9 @@ function BrokerStore::close_by_handle%(h: opaque of BrokerStore::Handle%): bool
|
|||
## e: the expiration time of the key-value pair.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function BrokerStore::insert%(h: opaque of BrokerStore::Handle,
|
||||
function Broker::insert%(h: opaque of Broker::Handle,
|
||||
k: Broker::Data, v: Broker::Data,
|
||||
e: BrokerStore::ExpiryTime &default = BrokerStore::ExpiryTime()%): bool
|
||||
e: Broker::ExpiryTime &default = Broker::ExpiryTime()%): bool
|
||||
%{
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
|
@ -198,7 +198,7 @@ function BrokerStore::insert%(h: opaque of BrokerStore::Handle,
|
|||
## k: the key to remove.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function BrokerStore::erase%(h: opaque of BrokerStore::Handle, k: Broker::Data%): bool
|
||||
function Broker::erase%(h: opaque of Broker::Handle, k: Broker::Data%): bool
|
||||
%{
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
|
@ -215,7 +215,7 @@ function BrokerStore::erase%(h: opaque of BrokerStore::Handle, k: Broker::Data%)
|
|||
## h: the handle of the store to modify.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function BrokerStore::clear%(h: opaque of BrokerStore::Handle%): bool
|
||||
function Broker::clear%(h: opaque of Broker::Handle%): bool
|
||||
%{
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
|
@ -236,7 +236,7 @@ function BrokerStore::clear%(h: opaque of BrokerStore::Handle%): bool
|
|||
## create it with an implicit value of zero before incrementing.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function BrokerStore::increment%(h: opaque of BrokerStore::Handle,
|
||||
function Broker::increment%(h: opaque of Broker::Handle,
|
||||
k: Broker::Data, by: int &default = +1%): bool
|
||||
%{
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
@ -259,7 +259,7 @@ function BrokerStore::increment%(h: opaque of BrokerStore::Handle,
|
|||
## create it with an implicit value of zero before decrementing.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function BrokerStore::decrement%(h: opaque of BrokerStore::Handle,
|
||||
function Broker::decrement%(h: opaque of Broker::Handle,
|
||||
k: Broker::Data, by: int &default = +1%): bool
|
||||
%{
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
@ -282,7 +282,7 @@ function BrokerStore::decrement%(h: opaque of BrokerStore::Handle,
|
|||
## create it with an implicit empty set value before modifying.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function BrokerStore::add_to_set%(h: opaque of BrokerStore::Handle,
|
||||
function Broker::add_to_set%(h: opaque of Broker::Handle,
|
||||
k: Broker::Data, element: Broker::Data%): bool
|
||||
%{
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
@ -306,7 +306,7 @@ function BrokerStore::add_to_set%(h: opaque of BrokerStore::Handle,
|
|||
## implicitly create an empty set value associated with the key.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function BrokerStore::remove_from_set%(h: opaque of BrokerStore::Handle,
|
||||
function Broker::remove_from_set%(h: opaque of Broker::Handle,
|
||||
k: Broker::Data, element: Broker::Data%): bool
|
||||
%{
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
@ -330,7 +330,7 @@ function BrokerStore::remove_from_set%(h: opaque of BrokerStore::Handle,
|
|||
## create an empty vector value before modifying.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function BrokerStore::push_left%(h: opaque of BrokerStore::Handle, k: Broker::Data,
|
||||
function Broker::push_left%(h: opaque of Broker::Handle, k: Broker::Data,
|
||||
items: Broker::DataVector%): bool
|
||||
%{
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
@ -363,7 +363,7 @@ function BrokerStore::push_left%(h: opaque of BrokerStore::Handle, k: Broker::Da
|
|||
## create an empty vector value before modifying.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function BrokerStore::push_right%(h: opaque of BrokerStore::Handle, k: Broker::Data,
|
||||
function Broker::push_right%(h: opaque of Broker::Handle, k: Broker::Data,
|
||||
items: Broker::DataVector%): bool
|
||||
%{
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
@ -401,7 +401,7 @@ static bool prepare_for_query(Val* opaque, Frame* frame,
|
|||
if ( ! (*handle)->store )
|
||||
{
|
||||
reporter->PushLocation(frame->GetCall()->GetLocationInfo());
|
||||
reporter->Error("BrokerStore query has an invalid data store");
|
||||
reporter->Error("Broker query has an invalid data store");
|
||||
reporter->PopLocation();
|
||||
return false;
|
||||
}
|
||||
|
@ -411,7 +411,7 @@ static bool prepare_for_query(Val* opaque, Frame* frame,
|
|||
if ( ! trigger )
|
||||
{
|
||||
reporter->PushLocation(frame->GetCall()->GetLocationInfo());
|
||||
reporter->Error("BrokerStore queries can only be called inside when-condition");
|
||||
reporter->Error("Broker queries can only be called inside when-condition");
|
||||
reporter->PopLocation();
|
||||
return false;
|
||||
}
|
||||
|
@ -421,7 +421,7 @@ static bool prepare_for_query(Val* opaque, Frame* frame,
|
|||
if ( *timeout < 0 )
|
||||
{
|
||||
reporter->PushLocation(frame->GetCall()->GetLocationInfo());
|
||||
reporter->Error("BrokerStore queries must specify a timeout block");
|
||||
reporter->Error("Broker queries must specify a timeout block");
|
||||
reporter->PopLocation();
|
||||
return false;
|
||||
}
|
||||
|
@ -444,8 +444,8 @@ static bool prepare_for_query(Val* opaque, Frame* frame,
|
|||
## k: the key associated with the vector to modify.
|
||||
##
|
||||
## Returns: the result of the query.
|
||||
function BrokerStore::pop_left%(h: opaque of BrokerStore::Handle,
|
||||
k: Broker::Data%): BrokerStore::QueryResult
|
||||
function Broker::pop_left%(h: opaque of Broker::Handle,
|
||||
k: Broker::Data%): Broker::QueryResult
|
||||
%{
|
||||
if ( ! broker_mgr->Enabled() )
|
||||
return bro_broker::query_result();
|
||||
|
@ -474,8 +474,8 @@ function BrokerStore::pop_left%(h: opaque of BrokerStore::Handle,
|
|||
## k: the key associated with the vector to modify.
|
||||
##
|
||||
## Returns: the result of the query.
|
||||
function BrokerStore::pop_right%(h: opaque of BrokerStore::Handle,
|
||||
k: Broker::Data%): BrokerStore::QueryResult
|
||||
function Broker::pop_right%(h: opaque of Broker::Handle,
|
||||
k: Broker::Data%): Broker::QueryResult
|
||||
%{
|
||||
if ( ! broker_mgr->Enabled() )
|
||||
return bro_broker::query_result();
|
||||
|
@ -504,8 +504,8 @@ function BrokerStore::pop_right%(h: opaque of BrokerStore::Handle,
|
|||
## k: the key to lookup.
|
||||
##
|
||||
## Returns: the result of the query.
|
||||
function BrokerStore::lookup%(h: opaque of BrokerStore::Handle,
|
||||
k: Broker::Data%): BrokerStore::QueryResult
|
||||
function Broker::lookup%(h: opaque of Broker::Handle,
|
||||
k: Broker::Data%): Broker::QueryResult
|
||||
%{
|
||||
if ( ! broker_mgr->Enabled() )
|
||||
return bro_broker::query_result();
|
||||
|
@ -534,8 +534,8 @@ function BrokerStore::lookup%(h: opaque of BrokerStore::Handle,
|
|||
## k: the key to check for existence.
|
||||
##
|
||||
## Returns: the result of the query (uses :bro:see:`Broker::BOOL`).
|
||||
function BrokerStore::exists%(h: opaque of BrokerStore::Handle,
|
||||
k: Broker::Data%): BrokerStore::QueryResult
|
||||
function Broker::exists%(h: opaque of Broker::Handle,
|
||||
k: Broker::Data%): Broker::QueryResult
|
||||
%{
|
||||
if ( ! broker_mgr->Enabled() )
|
||||
return bro_broker::query_result();
|
||||
|
@ -562,7 +562,7 @@ function BrokerStore::exists%(h: opaque of BrokerStore::Handle,
|
|||
## h: the handle of the store to query.
|
||||
##
|
||||
## Returns: the result of the query (uses :bro:see:`Broker::VECTOR`).
|
||||
function BrokerStore::keys%(h: opaque of BrokerStore::Handle%): BrokerStore::QueryResult
|
||||
function Broker::keys%(h: opaque of Broker::Handle%): Broker::QueryResult
|
||||
%{
|
||||
double timeout;
|
||||
bro_broker::StoreQueryCallback* cb;
|
||||
|
@ -580,7 +580,7 @@ function BrokerStore::keys%(h: opaque of BrokerStore::Handle%): BrokerStore::Que
|
|||
## h: the handle of the store to query.
|
||||
##
|
||||
## Returns: the result of the query (uses :bro:see:`Broker::COUNT`).
|
||||
function BrokerStore::size%(h: opaque of BrokerStore::Handle%): BrokerStore::QueryResult
|
||||
function Broker::size%(h: opaque of Broker::Handle%): Broker::QueryResult
|
||||
%{
|
||||
if ( ! broker_mgr->Enabled() )
|
||||
return bro_broker::query_result();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
clone keys, [status=BrokerStore::SUCCESS, result=[d=broker::data{[one, two, myset, myvec]}]]
|
||||
lookup, one, [status=BrokerStore::SUCCESS, result=[d=broker::data{111}]]
|
||||
lookup, myset, [status=BrokerStore::SUCCESS, result=[d=broker::data{{a, c, d}}]]
|
||||
lookup, two, [status=BrokerStore::SUCCESS, result=[d=broker::data{222}]]
|
||||
lookup, myvec, [status=BrokerStore::SUCCESS, result=[d=broker::data{[delta, alpha, beta, gamma, omega]}]]
|
||||
clone keys, [status=Broker::SUCCESS, result=[d=broker::data{[one, two, myset, myvec]}]]
|
||||
lookup, two, [status=Broker::SUCCESS, result=[d=broker::data{222}]]
|
||||
lookup, one, [status=Broker::SUCCESS, result=[d=broker::data{111}]]
|
||||
lookup, myvec, [status=Broker::SUCCESS, result=[d=broker::data{[delta, alpha, beta, gamma, omega]}]]
|
||||
lookup, myset, [status=Broker::SUCCESS, result=[d=broker::data{{a, c, d}}]]
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
lookup(two): [status=BrokerStore::SUCCESS, result=[d=broker::data{222}]]
|
||||
lookup(four): [status=BrokerStore::SUCCESS, result=[d=<uninitialized>]]
|
||||
lookup(myset): [status=BrokerStore::SUCCESS, result=[d=broker::data{{a, c, d}}]]
|
||||
lookup(one): [status=BrokerStore::SUCCESS, result=[d=broker::data{111}]]
|
||||
lookup(myvec): [status=BrokerStore::SUCCESS, result=[d=broker::data{[delta, alpha, beta, gamma, omega]}]]
|
||||
exists(one): [status=BrokerStore::SUCCESS, result=[d=broker::data{1}]]
|
||||
exists(two): [status=BrokerStore::SUCCESS, result=[d=broker::data{0}]]
|
||||
exists(myset): [status=BrokerStore::SUCCESS, result=[d=broker::data{1}]]
|
||||
exists(four): [status=BrokerStore::SUCCESS, result=[d=broker::data{0}]]
|
||||
pop_right(myvec): [status=BrokerStore::SUCCESS, result=[d=broker::data{omega}]]
|
||||
pop_left(myvec): [status=BrokerStore::SUCCESS, result=[d=broker::data{delta}]]
|
||||
keys: [status=BrokerStore::SUCCESS, result=[d=broker::data{[myvec, myset, one]}]]
|
||||
size: [status=BrokerStore::SUCCESS, result=[d=broker::data{3}]]
|
||||
size (after clear): [status=BrokerStore::SUCCESS, result=[d=broker::data{0}]]
|
||||
lookup(two): [status=Broker::SUCCESS, result=[d=broker::data{222}]]
|
||||
lookup(myset): [status=Broker::SUCCESS, result=[d=broker::data{{a, c, d}}]]
|
||||
lookup(one): [status=Broker::SUCCESS, result=[d=broker::data{111}]]
|
||||
lookup(myvec): [status=Broker::SUCCESS, result=[d=broker::data{[delta, alpha, beta, gamma, omega]}]]
|
||||
lookup(four): [status=Broker::SUCCESS, result=[d=<uninitialized>]]
|
||||
exists(two): [status=Broker::SUCCESS, result=[d=broker::data{0}]]
|
||||
exists(myset): [status=Broker::SUCCESS, result=[d=broker::data{1}]]
|
||||
exists(one): [status=Broker::SUCCESS, result=[d=broker::data{1}]]
|
||||
exists(four): [status=Broker::SUCCESS, result=[d=broker::data{0}]]
|
||||
pop_left(myvec): [status=Broker::SUCCESS, result=[d=broker::data{delta}]]
|
||||
pop_right(myvec): [status=Broker::SUCCESS, result=[d=broker::data{omega}]]
|
||||
keys: [status=Broker::SUCCESS, result=[d=broker::data{[myvec, myset, one]}]]
|
||||
size: [status=Broker::SUCCESS, result=[d=broker::data{3}]]
|
||||
size (after clear): [status=Broker::SUCCESS, result=[d=broker::data{0}]]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
clone keys, [status=BrokerStore::SUCCESS, result=[d=broker::data{[one, two, myset, myvec]}]]
|
||||
lookup, one, [status=BrokerStore::SUCCESS, result=[d=broker::data{111}]]
|
||||
lookup, two, [status=BrokerStore::SUCCESS, result=[d=broker::data{222}]]
|
||||
lookup, myset, [status=BrokerStore::SUCCESS, result=[d=broker::data{{a, c, d}}]]
|
||||
lookup, myvec, [status=BrokerStore::SUCCESS, result=[d=broker::data{[delta, alpha, beta, gamma, omega]}]]
|
||||
clone keys, [status=Broker::SUCCESS, result=[d=broker::data{[one, two, myset, myvec]}]]
|
||||
lookup, one, [status=Broker::SUCCESS, result=[d=broker::data{111}]]
|
||||
lookup, two, [status=Broker::SUCCESS, result=[d=broker::data{222}]]
|
||||
lookup, myset, [status=Broker::SUCCESS, result=[d=broker::data{{a, c, d}}]]
|
||||
lookup, myvec, [status=Broker::SUCCESS, result=[d=broker::data{[delta, alpha, beta, gamma, omega]}]]
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
lookup(two): [status=BrokerStore::SUCCESS, result=[d=broker::data{222}]]
|
||||
lookup(four): [status=BrokerStore::SUCCESS, result=[d=<uninitialized>]]
|
||||
lookup(myset): [status=BrokerStore::SUCCESS, result=[d=broker::data{{a, c, d}}]]
|
||||
lookup(one): [status=BrokerStore::SUCCESS, result=[d=broker::data{111}]]
|
||||
lookup(myvec): [status=BrokerStore::SUCCESS, result=[d=broker::data{[delta, alpha, beta, gamma, omega]}]]
|
||||
exists(one): [status=BrokerStore::SUCCESS, result=[d=broker::data{1}]]
|
||||
exists(two): [status=BrokerStore::SUCCESS, result=[d=broker::data{0}]]
|
||||
exists(myset): [status=BrokerStore::SUCCESS, result=[d=broker::data{1}]]
|
||||
exists(four): [status=BrokerStore::SUCCESS, result=[d=broker::data{0}]]
|
||||
pop_right(myvec): [status=BrokerStore::SUCCESS, result=[d=broker::data{omega}]]
|
||||
pop_left(myvec): [status=BrokerStore::SUCCESS, result=[d=broker::data{delta}]]
|
||||
keys: [status=BrokerStore::SUCCESS, result=[d=broker::data{[myvec, myset, one]}]]
|
||||
size: [status=BrokerStore::SUCCESS, result=[d=broker::data{3}]]
|
||||
size (after clear): [status=BrokerStore::SUCCESS, result=[d=broker::data{0}]]
|
||||
lookup(two): [status=Broker::SUCCESS, result=[d=broker::data{222}]]
|
||||
lookup(four): [status=Broker::SUCCESS, result=[d=<uninitialized>]]
|
||||
lookup(myset): [status=Broker::SUCCESS, result=[d=broker::data{{a, c, d}}]]
|
||||
lookup(one): [status=Broker::SUCCESS, result=[d=broker::data{111}]]
|
||||
lookup(myvec): [status=Broker::SUCCESS, result=[d=broker::data{[delta, alpha, beta, gamma, omega]}]]
|
||||
exists(one): [status=Broker::SUCCESS, result=[d=broker::data{1}]]
|
||||
exists(two): [status=Broker::SUCCESS, result=[d=broker::data{0}]]
|
||||
exists(myset): [status=Broker::SUCCESS, result=[d=broker::data{1}]]
|
||||
exists(four): [status=Broker::SUCCESS, result=[d=broker::data{0}]]
|
||||
pop_right(myvec): [status=Broker::SUCCESS, result=[d=broker::data{omega}]]
|
||||
pop_left(myvec): [status=Broker::SUCCESS, result=[d=broker::data{delta}]]
|
||||
keys: [status=Broker::SUCCESS, result=[d=broker::data{[myvec, myset, one]}]]
|
||||
size: [status=Broker::SUCCESS, result=[d=broker::data{3}]]
|
||||
size (after clear): [status=Broker::SUCCESS, result=[d=broker::data{0}]]
|
||||
|
|
|
@ -5,7 +5,7 @@ stores-connector.bro
|
|||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
|
||||
function dv(d: Broker::Data): Broker::DataVector
|
||||
{
|
||||
|
@ -28,19 +28,19 @@ event Broker::outgoing_connection_established(peer_address: string,
|
|||
{
|
||||
local myset: set[string] = {"a", "b", "c"};
|
||||
local myvec: vector of string = {"alpha", "beta", "gamma"};
|
||||
h = BrokerStore::create_master("mystore");
|
||||
BrokerStore::insert(h, Broker::data("one"), Broker::data(110));
|
||||
BrokerStore::insert(h, Broker::data("two"), Broker::data(223));
|
||||
BrokerStore::insert(h, Broker::data("myset"), Broker::data(myset));
|
||||
BrokerStore::insert(h, Broker::data("myvec"), Broker::data(myvec));
|
||||
BrokerStore::increment(h, Broker::data("one"));
|
||||
BrokerStore::decrement(h, Broker::data("two"));
|
||||
BrokerStore::add_to_set(h, Broker::data("myset"), Broker::data("d"));
|
||||
BrokerStore::remove_from_set(h, Broker::data("myset"), Broker::data("b"));
|
||||
BrokerStore::push_left(h, Broker::data("myvec"), dv(Broker::data("delta")));
|
||||
BrokerStore::push_right(h, Broker::data("myvec"), dv(Broker::data("omega")));
|
||||
h = Broker::create_master("mystore");
|
||||
Broker::insert(h, Broker::data("one"), Broker::data(110));
|
||||
Broker::insert(h, Broker::data("two"), Broker::data(223));
|
||||
Broker::insert(h, Broker::data("myset"), Broker::data(myset));
|
||||
Broker::insert(h, Broker::data("myvec"), Broker::data(myvec));
|
||||
Broker::increment(h, Broker::data("one"));
|
||||
Broker::decrement(h, Broker::data("two"));
|
||||
Broker::add_to_set(h, Broker::data("myset"), Broker::data("d"));
|
||||
Broker::remove_from_set(h, Broker::data("myset"), Broker::data("b"));
|
||||
Broker::push_left(h, Broker::data("myvec"), dv(Broker::data("delta")));
|
||||
Broker::push_right(h, Broker::data("myvec"), dv(Broker::data("omega")));
|
||||
|
||||
when ( local res = BrokerStore::size(h) )
|
||||
when ( local res = Broker::size(h) )
|
||||
{
|
||||
print "master size", res;
|
||||
event ready();
|
||||
|
|
|
@ -5,13 +5,13 @@ stores-listener.bro
|
|||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
global expected_key_count = 4;
|
||||
global key_count = 0;
|
||||
|
||||
function do_lookup(key: string)
|
||||
{
|
||||
when ( local res = BrokerStore::lookup(h, Broker::data(key)) )
|
||||
when ( local res = Broker::lookup(h, Broker::data(key)) )
|
||||
{
|
||||
++key_count;
|
||||
print "lookup", key, res;
|
||||
|
@ -25,9 +25,9 @@ function do_lookup(key: string)
|
|||
|
||||
event ready()
|
||||
{
|
||||
h = BrokerStore::create_clone("mystore");
|
||||
h = Broker::create_clone("mystore");
|
||||
|
||||
when ( local res = BrokerStore::keys(h) )
|
||||
when ( local res = Broker::keys(h) )
|
||||
{
|
||||
print "clone keys", res;
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 0)));
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
global expected_key_count = 4;
|
||||
global key_count = 0;
|
||||
|
||||
|
@ -21,7 +21,7 @@ global query_timeout = 30sec;
|
|||
|
||||
function do_lookup(key: string)
|
||||
{
|
||||
when ( local res = BrokerStore::lookup(h, Broker::data(key)) )
|
||||
when ( local res = Broker::lookup(h, Broker::data(key)) )
|
||||
{
|
||||
++key_count;
|
||||
print "lookup", key, res;
|
||||
|
@ -38,9 +38,9 @@ function do_lookup(key: string)
|
|||
|
||||
event ready()
|
||||
{
|
||||
h = BrokerStore::create_clone("mystore");
|
||||
h = Broker::create_clone("mystore");
|
||||
|
||||
when ( local res = BrokerStore::keys(h) )
|
||||
when ( local res = Broker::keys(h) )
|
||||
{
|
||||
print "clone keys", res;
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 0)));
|
||||
|
@ -71,7 +71,7 @@ global query_timeout = 15sec;
|
|||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
|
||||
function dv(d: Broker::Data): Broker::DataVector
|
||||
{
|
||||
|
@ -94,19 +94,19 @@ event Broker::outgoing_connection_established(peer_address: string,
|
|||
{
|
||||
local myset: set[string] = {"a", "b", "c"};
|
||||
local myvec: vector of string = {"alpha", "beta", "gamma"};
|
||||
h = BrokerStore::create_master("mystore");
|
||||
BrokerStore::insert(h, Broker::data("one"), Broker::data(110));
|
||||
BrokerStore::insert(h, Broker::data("two"), Broker::data(223));
|
||||
BrokerStore::insert(h, Broker::data("myset"), Broker::data(myset));
|
||||
BrokerStore::insert(h, Broker::data("myvec"), Broker::data(myvec));
|
||||
BrokerStore::increment(h, Broker::data("one"));
|
||||
BrokerStore::decrement(h, Broker::data("two"));
|
||||
BrokerStore::add_to_set(h, Broker::data("myset"), Broker::data("d"));
|
||||
BrokerStore::remove_from_set(h, Broker::data("myset"), Broker::data("b"));
|
||||
BrokerStore::push_left(h, Broker::data("myvec"), dv(Broker::data("delta")));
|
||||
BrokerStore::push_right(h, Broker::data("myvec"), dv(Broker::data("omega")));
|
||||
h = Broker::create_master("mystore");
|
||||
Broker::insert(h, Broker::data("one"), Broker::data(110));
|
||||
Broker::insert(h, Broker::data("two"), Broker::data(223));
|
||||
Broker::insert(h, Broker::data("myset"), Broker::data(myset));
|
||||
Broker::insert(h, Broker::data("myvec"), Broker::data(myvec));
|
||||
Broker::increment(h, Broker::data("one"));
|
||||
Broker::decrement(h, Broker::data("two"));
|
||||
Broker::add_to_set(h, Broker::data("myset"), Broker::data("d"));
|
||||
Broker::remove_from_set(h, Broker::data("myset"), Broker::data("b"));
|
||||
Broker::push_left(h, Broker::data("myvec"), dv(Broker::data("delta")));
|
||||
Broker::push_right(h, Broker::data("myvec"), dv(Broker::data("omega")));
|
||||
|
||||
when ( local res = BrokerStore::size(h) )
|
||||
when ( local res = Broker::size(h) )
|
||||
{ event ready(); }
|
||||
timeout query_timeout
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
global lookup_count = 0;
|
||||
const lookup_expect_count = 5;
|
||||
global exists_count = 0;
|
||||
|
@ -20,13 +20,13 @@ global query_timeout = 30sec;
|
|||
|
||||
event test_clear()
|
||||
{
|
||||
BrokerStore::clear(h);
|
||||
Broker::clear(h);
|
||||
event test_size("after clear");
|
||||
}
|
||||
|
||||
event test_size(where: string)
|
||||
{
|
||||
when ( local res = BrokerStore::size(h) )
|
||||
when ( local res = Broker::size(h) )
|
||||
{
|
||||
if ( where == "" )
|
||||
{
|
||||
|
@ -52,7 +52,7 @@ event test_size(where: string)
|
|||
|
||||
event test_keys()
|
||||
{
|
||||
when ( local res = BrokerStore::keys(h) )
|
||||
when ( local res = Broker::keys(h) )
|
||||
{
|
||||
print fmt("keys: %s", res);
|
||||
event test_size();
|
||||
|
@ -66,7 +66,7 @@ event test_keys()
|
|||
|
||||
event test_pop(key: string)
|
||||
{
|
||||
when ( local lres = BrokerStore::pop_left(h, Broker::data(key)) )
|
||||
when ( local lres = Broker::pop_left(h, Broker::data(key)) )
|
||||
{
|
||||
print fmt("pop_left(%s): %s", key, lres);
|
||||
++pop_count;
|
||||
|
@ -83,7 +83,7 @@ event test_pop(key: string)
|
|||
event test_keys();
|
||||
}
|
||||
|
||||
when ( local rres = BrokerStore::pop_right(h, Broker::data(key)) )
|
||||
when ( local rres = Broker::pop_right(h, Broker::data(key)) )
|
||||
{
|
||||
print fmt("pop_right(%s): %s", key, rres);
|
||||
++pop_count;
|
||||
|
@ -103,7 +103,7 @@ event test_pop(key: string)
|
|||
|
||||
function do_exists(key: string)
|
||||
{
|
||||
when ( local res = BrokerStore::exists(h, Broker::data(key)) )
|
||||
when ( local res = Broker::exists(h, Broker::data(key)) )
|
||||
{
|
||||
print fmt("exists(%s): %s", key, res);
|
||||
++exists_count;
|
||||
|
@ -123,7 +123,7 @@ function do_exists(key: string)
|
|||
|
||||
event test_erase()
|
||||
{
|
||||
BrokerStore::erase(h, Broker::data("two"));
|
||||
Broker::erase(h, Broker::data("two"));
|
||||
do_exists("one");
|
||||
do_exists("two");
|
||||
do_exists("myset");
|
||||
|
@ -132,7 +132,7 @@ event test_erase()
|
|||
|
||||
function do_lookup(key: string)
|
||||
{
|
||||
when ( local res = BrokerStore::lookup(h, Broker::data(key)) )
|
||||
when ( local res = Broker::lookup(h, Broker::data(key)) )
|
||||
{
|
||||
print fmt("lookup(%s): %s", key, res);
|
||||
++lookup_count;
|
||||
|
@ -162,17 +162,17 @@ event bro_init()
|
|||
Broker::enable();
|
||||
local myset: set[string] = {"a", "b", "c"};
|
||||
local myvec: vector of string = {"alpha", "beta", "gamma"};
|
||||
h = BrokerStore::create_master("master");
|
||||
BrokerStore::insert(h, Broker::data("one"), Broker::data(110));
|
||||
BrokerStore::insert(h, Broker::data("two"), Broker::data(223));
|
||||
BrokerStore::insert(h, Broker::data("myset"), Broker::data(myset));
|
||||
BrokerStore::insert(h, Broker::data("myvec"), Broker::data(myvec));
|
||||
BrokerStore::increment(h, Broker::data("one"));
|
||||
BrokerStore::decrement(h, Broker::data("two"));
|
||||
BrokerStore::add_to_set(h, Broker::data("myset"), Broker::data("d"));
|
||||
BrokerStore::remove_from_set(h, Broker::data("myset"), Broker::data("b"));
|
||||
BrokerStore::push_left(h, Broker::data("myvec"), dv(Broker::data("delta")));
|
||||
BrokerStore::push_right(h, Broker::data("myvec"), dv(Broker::data("omega")));
|
||||
h = Broker::create_master("master");
|
||||
Broker::insert(h, Broker::data("one"), Broker::data(110));
|
||||
Broker::insert(h, Broker::data("two"), Broker::data(223));
|
||||
Broker::insert(h, Broker::data("myset"), Broker::data(myset));
|
||||
Broker::insert(h, Broker::data("myvec"), Broker::data(myvec));
|
||||
Broker::increment(h, Broker::data("one"));
|
||||
Broker::decrement(h, Broker::data("two"));
|
||||
Broker::add_to_set(h, Broker::data("myset"), Broker::data("d"));
|
||||
Broker::remove_from_set(h, Broker::data("myset"), Broker::data("b"));
|
||||
Broker::push_left(h, Broker::data("myvec"), dv(Broker::data("delta")));
|
||||
Broker::push_right(h, Broker::data("myvec"), dv(Broker::data("omega")));
|
||||
do_lookup("one");
|
||||
do_lookup("two");
|
||||
do_lookup("myset");
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
global expected_key_count = 4;
|
||||
global key_count = 0;
|
||||
|
||||
function do_lookup(key: string)
|
||||
{
|
||||
when ( local res = BrokerStore::lookup(h, Broker::data(key)) )
|
||||
when ( local res = Broker::lookup(h, Broker::data(key)) )
|
||||
{
|
||||
++key_count;
|
||||
print "lookup", key, res;
|
||||
|
@ -34,9 +34,9 @@ function do_lookup(key: string)
|
|||
|
||||
event ready()
|
||||
{
|
||||
h = BrokerStore::create_clone("mystore");
|
||||
h = Broker::create_clone("mystore");
|
||||
|
||||
when ( local res = BrokerStore::keys(h) )
|
||||
when ( local res = Broker::keys(h) )
|
||||
{
|
||||
print "clone keys", res;
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 0)));
|
||||
|
@ -62,7 +62,7 @@ event bro_init()
|
|||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
|
||||
function dv(d: Broker::Data): Broker::DataVector
|
||||
{
|
||||
|
@ -85,18 +85,18 @@ event Broker::outgoing_connection_established(peer_address: string,
|
|||
{
|
||||
local myset: set[string] = {"a", "b", "c"};
|
||||
local myvec: vector of string = {"alpha", "beta", "gamma"};
|
||||
BrokerStore::insert(h, Broker::data("one"), Broker::data(110));
|
||||
BrokerStore::insert(h, Broker::data("two"), Broker::data(223));
|
||||
BrokerStore::insert(h, Broker::data("myset"), Broker::data(myset));
|
||||
BrokerStore::insert(h, Broker::data("myvec"), Broker::data(myvec));
|
||||
BrokerStore::increment(h, Broker::data("one"));
|
||||
BrokerStore::decrement(h, Broker::data("two"));
|
||||
BrokerStore::add_to_set(h, Broker::data("myset"), Broker::data("d"));
|
||||
BrokerStore::remove_from_set(h, Broker::data("myset"), Broker::data("b"));
|
||||
BrokerStore::push_left(h, Broker::data("myvec"), dv(Broker::data("delta")));
|
||||
BrokerStore::push_right(h, Broker::data("myvec"), dv(Broker::data("omega")));
|
||||
Broker::insert(h, Broker::data("one"), Broker::data(110));
|
||||
Broker::insert(h, Broker::data("two"), Broker::data(223));
|
||||
Broker::insert(h, Broker::data("myset"), Broker::data(myset));
|
||||
Broker::insert(h, Broker::data("myvec"), Broker::data(myvec));
|
||||
Broker::increment(h, Broker::data("one"));
|
||||
Broker::decrement(h, Broker::data("two"));
|
||||
Broker::add_to_set(h, Broker::data("myset"), Broker::data("d"));
|
||||
Broker::remove_from_set(h, Broker::data("myset"), Broker::data("b"));
|
||||
Broker::push_left(h, Broker::data("myvec"), dv(Broker::data("delta")));
|
||||
Broker::push_right(h, Broker::data("myvec"), dv(Broker::data("omega")));
|
||||
|
||||
when ( local res = BrokerStore::size(h) )
|
||||
when ( local res = Broker::size(h) )
|
||||
{ event ready(); }
|
||||
timeout 10sec
|
||||
{ print "timeout"; }
|
||||
|
@ -105,7 +105,7 @@ event Broker::outgoing_connection_established(peer_address: string,
|
|||
event bro_init()
|
||||
{
|
||||
Broker::enable();
|
||||
h = BrokerStore::create_master("mystore");
|
||||
h = Broker::create_master("mystore");
|
||||
Broker::connect("127.0.0.1", broker_port, 1secs);
|
||||
Broker::auto_event("bro/event/ready", ready);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
global lookup_count = 0;
|
||||
const lookup_expect_count = 5;
|
||||
global exists_count = 0;
|
||||
|
@ -20,13 +20,13 @@ global test_size: event(where: string &default = "");
|
|||
|
||||
event test_clear()
|
||||
{
|
||||
BrokerStore::clear(h);
|
||||
Broker::clear(h);
|
||||
event test_size("after clear");
|
||||
}
|
||||
|
||||
event test_size(where: string)
|
||||
{
|
||||
when ( local res = BrokerStore::size(h) )
|
||||
when ( local res = Broker::size(h) )
|
||||
{
|
||||
if ( where == "" )
|
||||
{
|
||||
|
@ -45,7 +45,7 @@ event test_size(where: string)
|
|||
|
||||
event test_keys()
|
||||
{
|
||||
when ( local res = BrokerStore::keys(h) )
|
||||
when ( local res = Broker::keys(h) )
|
||||
{
|
||||
print fmt("keys: %s", res);
|
||||
event test_size();
|
||||
|
@ -56,7 +56,7 @@ event test_keys()
|
|||
|
||||
event test_pop(key: string)
|
||||
{
|
||||
when ( local lres = BrokerStore::pop_left(h, Broker::data(key)) )
|
||||
when ( local lres = Broker::pop_left(h, Broker::data(key)) )
|
||||
{
|
||||
print fmt("pop_left(%s): %s", key, lres);
|
||||
++pop_count;
|
||||
|
@ -67,7 +67,7 @@ event test_pop(key: string)
|
|||
timeout 10sec
|
||||
{ print "timeout"; }
|
||||
|
||||
when ( local rres = BrokerStore::pop_right(h, Broker::data(key)) )
|
||||
when ( local rres = Broker::pop_right(h, Broker::data(key)) )
|
||||
{
|
||||
print fmt("pop_right(%s): %s", key, rres);
|
||||
++pop_count;
|
||||
|
@ -81,7 +81,7 @@ event test_pop(key: string)
|
|||
|
||||
function do_exists(key: string)
|
||||
{
|
||||
when ( local res = BrokerStore::exists(h, Broker::data(key)) )
|
||||
when ( local res = Broker::exists(h, Broker::data(key)) )
|
||||
{
|
||||
print fmt("exists(%s): %s", key, res);
|
||||
++exists_count;
|
||||
|
@ -95,7 +95,7 @@ function do_exists(key: string)
|
|||
|
||||
event test_erase()
|
||||
{
|
||||
BrokerStore::erase(h, Broker::data("two"));
|
||||
Broker::erase(h, Broker::data("two"));
|
||||
do_exists("one");
|
||||
do_exists("two");
|
||||
do_exists("myset");
|
||||
|
@ -104,7 +104,7 @@ event test_erase()
|
|||
|
||||
function do_lookup(key: string)
|
||||
{
|
||||
when ( local res = BrokerStore::lookup(h, Broker::data(key)) )
|
||||
when ( local res = Broker::lookup(h, Broker::data(key)) )
|
||||
{
|
||||
print fmt("lookup(%s): %s", key, res);
|
||||
++lookup_count;
|
||||
|
@ -128,7 +128,7 @@ global did_it = F;
|
|||
event bro_init()
|
||||
{
|
||||
Broker::enable();
|
||||
h = BrokerStore::create_master("master");
|
||||
h = Broker::create_master("master");
|
||||
}
|
||||
|
||||
event new_connection(c: connection)
|
||||
|
@ -137,16 +137,16 @@ event new_connection(c: connection)
|
|||
did_it = T;
|
||||
local myset: set[string] = {"a", "b", "c"};
|
||||
local myvec: vector of string = {"alpha", "beta", "gamma"};
|
||||
BrokerStore::insert(h, Broker::data("one"), Broker::data(110));
|
||||
BrokerStore::insert(h, Broker::data("two"), Broker::data(223));
|
||||
BrokerStore::insert(h, Broker::data("myset"), Broker::data(myset));
|
||||
BrokerStore::insert(h, Broker::data("myvec"), Broker::data(myvec));
|
||||
BrokerStore::increment(h, Broker::data("one"));
|
||||
BrokerStore::decrement(h, Broker::data("two"));
|
||||
BrokerStore::add_to_set(h, Broker::data("myset"), Broker::data("d"));
|
||||
BrokerStore::remove_from_set(h, Broker::data("myset"), Broker::data("b"));
|
||||
BrokerStore::push_left(h, Broker::data("myvec"), dv(Broker::data("delta")));
|
||||
BrokerStore::push_right(h, Broker::data("myvec"), dv(Broker::data("omega")));
|
||||
Broker::insert(h, Broker::data("one"), Broker::data(110));
|
||||
Broker::insert(h, Broker::data("two"), Broker::data(223));
|
||||
Broker::insert(h, Broker::data("myset"), Broker::data(myset));
|
||||
Broker::insert(h, Broker::data("myvec"), Broker::data(myvec));
|
||||
Broker::increment(h, Broker::data("one"));
|
||||
Broker::decrement(h, Broker::data("two"));
|
||||
Broker::add_to_set(h, Broker::data("myset"), Broker::data("d"));
|
||||
Broker::remove_from_set(h, Broker::data("myset"), Broker::data("b"));
|
||||
Broker::push_left(h, Broker::data("myvec"), dv(Broker::data("delta")));
|
||||
Broker::push_right(h, Broker::data("myvec"), dv(Broker::data("omega")));
|
||||
do_lookup("one");
|
||||
do_lookup("two");
|
||||
do_lookup("myset");
|
||||
|
|
|
@ -5,7 +5,7 @@ stores-connector.bro
|
|||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
|
||||
function dv(d: Broker::Data): Broker::DataVector
|
||||
{
|
||||
|
@ -28,19 +28,19 @@ event Broker::outgoing_connection_established(peer_address: string,
|
|||
{
|
||||
local myset: set[string] = {"a", "b", "c"};
|
||||
local myvec: vector of string = {"alpha", "beta", "gamma"};
|
||||
h = BrokerStore::create_master("mystore");
|
||||
BrokerStore::insert(h, Broker::data("one"), Broker::data(110));
|
||||
BrokerStore::insert(h, Broker::data("two"), Broker::data(223));
|
||||
BrokerStore::insert(h, Broker::data("myset"), Broker::data(myset));
|
||||
BrokerStore::insert(h, Broker::data("myvec"), Broker::data(myvec));
|
||||
BrokerStore::increment(h, Broker::data("one"));
|
||||
BrokerStore::decrement(h, Broker::data("two"));
|
||||
BrokerStore::add_to_set(h, Broker::data("myset"), Broker::data("d"));
|
||||
BrokerStore::remove_from_set(h, Broker::data("myset"), Broker::data("b"));
|
||||
BrokerStore::push_left(h, Broker::data("myvec"), dv(Broker::data("delta")));
|
||||
BrokerStore::push_right(h, Broker::data("myvec"), dv(Broker::data("omega")));
|
||||
h = Broker::create_master("mystore");
|
||||
Broker::insert(h, Broker::data("one"), Broker::data(110));
|
||||
Broker::insert(h, Broker::data("two"), Broker::data(223));
|
||||
Broker::insert(h, Broker::data("myset"), Broker::data(myset));
|
||||
Broker::insert(h, Broker::data("myvec"), Broker::data(myvec));
|
||||
Broker::increment(h, Broker::data("one"));
|
||||
Broker::decrement(h, Broker::data("two"));
|
||||
Broker::add_to_set(h, Broker::data("myset"), Broker::data("d"));
|
||||
Broker::remove_from_set(h, Broker::data("myset"), Broker::data("b"));
|
||||
Broker::push_left(h, Broker::data("myvec"), dv(Broker::data("delta")));
|
||||
Broker::push_right(h, Broker::data("myvec"), dv(Broker::data("omega")));
|
||||
|
||||
when ( local res = BrokerStore::size(h) )
|
||||
when ( local res = Broker::size(h) )
|
||||
{
|
||||
print "master size", res;
|
||||
event ready();
|
||||
|
|
|
@ -5,13 +5,13 @@ stores-listener.bro
|
|||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
global expected_key_count = 4;
|
||||
global key_count = 0;
|
||||
|
||||
function do_lookup(key: string)
|
||||
{
|
||||
when ( local res = BrokerStore::lookup(h, Broker::data(key)) )
|
||||
when ( local res = Broker::lookup(h, Broker::data(key)) )
|
||||
{
|
||||
++key_count;
|
||||
print "lookup", key, res;
|
||||
|
@ -25,9 +25,9 @@ function do_lookup(key: string)
|
|||
|
||||
event ready()
|
||||
{
|
||||
h = BrokerStore::create_clone("mystore");
|
||||
h = Broker::create_clone("mystore");
|
||||
|
||||
when ( local res = BrokerStore::keys(h) )
|
||||
when ( local res = Broker::keys(h) )
|
||||
{
|
||||
print "clone keys", res;
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 0)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue