helics
3.5.3
|
#include <BrokerBase.hpp>
Public Member Functions | |
BrokerBase (bool DisableQueue=false) noexcept | |
BrokerBase (std::string_view broker_name, bool DisableQueue=false) | |
int | parseArgs (int argc, char *argv[]) |
int | parseArgs (std::vector< std::string > args) |
int | parseArgs (std::string_view initializationString) |
virtual void | configureBase () |
void | addActionMessage (const ActionMessage &message) |
void | addActionMessage (ActionMessage &&message) |
void | setLoggerFunction (std::function< void(int level, std::string_view identifier, std::string_view message)> logFunction) |
void | logFlush () |
bool | isRunning () const |
void | setLogLevel (int32_t level) |
void | setLogLevels (int32_t consoleLevel, int32_t fileLevel) |
GlobalBrokerId | getGlobalId () const |
std::function< void(int, std::string_view, std::string_view)> | getLoggingCallback () const |
void | joinAllThreads () |
std::size_t | currentMessageCounter () const |
Protected Types | |
enum class | BrokerState : int16_t { CREATED = -10 , CONFIGURING = -7 , CONFIGURED = -6 , CONNECTING = -4 , CONNECTED = -3 , INITIALIZING = -1 , OPERATING = 0 , CONNECTED_ERROR = 3 , TERMINATING = 4 , TERMINATING_ERROR = 5 , TERMINATED = 6 , ERRORED = 7 } |
enum class | TickForwardingReasons : uint32_t { NONE = 0 , NO_COMMS = 0x01 , PING_RESPONSE = 0x02 , QUERY_TIMEOUT = 0x04 , GRANT_TIMEOUT = 0x08 , DISCONNECT_TIMEOUT = 0x10 } |
Protected Member Functions | |
void | setTickForwarding (TickForwardingReasons reason, bool value=true) |
BrokerState | getBrokerState () const |
bool | setBrokerState (BrokerState newState) |
bool | transitionBrokerState (BrokerState expectedState, BrokerState newState) |
virtual void | processDisconnect (bool skipUnregister=false)=0 |
virtual bool | tryReconnect ()=0 |
virtual void | processCommand (ActionMessage &&cmd)=0 |
virtual void | processPriorityCommand (ActionMessage &&command)=0 |
bool | sendToLogger (GlobalFederateId federateID, int logLevel, std::string_view name, std::string_view message, bool fromRemote=false) const |
void | saveProfilingData (std::string_view message) |
void | writeProfilingData () |
void | generateNewIdentifier () |
virtual std::string | generateLocalAddressString () const =0 |
virtual std::shared_ptr< helicsCLI11App > | generateCLI () |
void | setErrorState (int eCode, std::string_view estring) |
void | setLoggingFile (std::string_view lfile) |
bool | getFlagValue (int32_t flag) const |
virtual double | getSimulationTime () const |
std::pair< bool, std::vector< std::string_view > > | processBaseCommands (ActionMessage &command) |
void | addBaseInformation (Json::Value &base, bool hasParent) const |
Static Protected Member Functions | |
static bool | isReasonForTick (std::uint32_t code, TickForwardingReasons reason) |
Protected Attributes | |
std::atomic< GlobalBrokerId > | global_id {parent_broker_id} |
GlobalBrokerId | global_broker_id_local {} |
GlobalBrokerId | higher_broker_id {0} |
the id code of the broker 1 level about this broker | |
std::atomic< int32_t > | maxLogLevel {HELICS_LOG_LEVEL_NO_PRINT} |
int32_t | minFederateCount {1} |
int32_t | minBrokerCount {0} |
int32_t | maxFederateCount {(std::numeric_limits<int32_t>::max)()} |
int32_t | maxBrokerCount {(std::numeric_limits<int32_t>::max)()} |
int32_t | minChildCount {0} |
int32_t | maxIterationCount {10000} |
the maximum number of iterative loops that are allowed | |
Time | tickTimer {5.0} |
the length of each heartbeat tick | |
Time | timeout {30.0} |
timeout to wait to establish a broker connection before giving up | |
Time | networkTimeout {-1.0} |
timeout to establish a socket connection before giving up | |
Time | queryTimeout {15.0} |
Time | errorDelay {0.0} |
time to delay before terminating after error state | |
Time | grantTimeout {-1.0} |
timeout for triggering diagnostic action waiting for a time grant | |
Time | maxCoSimDuration {-1.0} |
the maximum lifetime (wall clock time) of the co-simulation | |
std::string | identifier |
an identifier for the broker | |
std::string | brokerKey |
std::string | address |
network location of the broker | |
std::thread | queueProcessingThread |
std::atomic< bool > | haltOperations {false} |
flag indicating that no further message should be processed | |
bool | restrictive_time_policy {false} |
flag indicating the broker should use a conservative time policy | |
bool | terminate_on_error {false} |
flag indicating that the federation should halt on any error | |
bool | debugging {false} |
flag indicating operation in a user debugging mode | |
bool | observer {false} |
flag indicating that the broker is an observer only | |
bool | globalTime {false} |
flag indicating that the broker should use a global time coordinator | |
bool | asyncTime {false} |
flag indicating the use of async time keeping | |
bool | dynamicFederation {false} |
flag indicating that the broker supports dynamic federates | |
bool | disableDynamicSources {false} |
flag disabling dynamic data sources | |
std::unique_ptr< BaseTimeCoordinator > | timeCoord |
object managing the time control | |
gmlc::containers::BlockingPriorityQueue< ActionMessage > | actionQueue |
primary routing queue | |
std::shared_ptr< LogManager > | mLogManager |
object to handle the logging considerations | |
bool | noAutomaticID {false} |
the broker should not automatically generate an ID | |
bool | hasTimeDependency {false} |
bool | enteredExecutionMode {false} |
flag indicating that the broker has entered execution mode | |
bool | waitingForBrokerPingReply {false} |
flag indicating we are waiting for a ping reply | |
bool | hasFilters {false} |
flag indicating filters come through the broker | |
bool | no_ping {false} |
indicator that the broker is not very responsive to ping requests | |
bool | uuid_like {false} |
will be set to true if the name looks like a uuid | |
bool | useJsonSerialization {false} |
bool | enable_profiling {false} |
indicator that profiling is enabled | |
bool | allowRemoteControl {true} |
bool | errorOnUnmatchedConnections {false} |
error if there are unmatched connections on init | |
decltype(std::chrono::steady_clock::now()) | errorTimeStart |
time when the error condition started; related to the errorDelay | |
decltype(std::chrono::steady_clock::now()) | disconnectTime |
time when the disconnect started | |
std::atomic< int > | lastErrorCode {0} |
storage for last error code | |
std::string | lastErrorString |
storage for last error string | |
Static Protected Attributes | |
static constexpr double | mInvalidSimulationTime {-98763.2} |
Friends | |
class | TimeoutMonitor |
const std::string & | brokerStateName (BrokerState state) |
base class for broker like objects
|
strongprotected |
enumeration of the possible core states
void helics::BrokerBase::addActionMessage | ( | ActionMessage && | message | ) |
move a action Message into the commandQueue
References helics::isPriorityCommand().
void helics::BrokerBase::addActionMessage | ( | const ActionMessage & | message | ) |
add an action Message to the process queue
References helics::isPriorityCommand().
Referenced by helics::CommonCore::addAlias(), helics::CoreBroker::addAlias(), helics::CommonCore::addDependency(), helics::CommonCore::addDestinationFilterToEndpoint(), helics::CoreBroker::addDestinationFilterToEndpoint(), helics::CommonCore::addDestinationTarget(), helics::CommonCore::addSourceFilterToEndpoint(), helics::CoreBroker::addSourceFilterToEndpoint(), helics::CommonCore::addSourceTarget(), helics::CoreBroker::clearTimeBarrier(), helics::CommonCore::closeHandle(), helics::CoreBroker::dataLink(), helics::CommonCore::dataLink(), helics::CommonCore::disconnect(), helics::CoreBroker::disconnect(), helics::CommonCore::enterExecutingMode(), helics::CommonCore::enterInitializingMode(), helics::CommonCore::finalize(), helics::CoreBroker::globalError(), helics::CommonCore::linkEndpoints(), helics::CoreBroker::linkEndpoints(), helics::TimeoutMonitor::pingReply(), helics::TimeoutMonitor::pingSub(), helics::CommonCore::processDisconnect(), helics::CommonCore::registerFederate(), helics::CommonCore::removeTarget(), helics::CommonCore::requestTimeIterative(), helics::CoreBroker::sendCommand(), helics::CommonCore::sendCommand(), helics::CommonCore::sendMessage(), helics::CommonCore::sendTo(), helics::CommonCore::sendToAt(), helics::CommonCore::setFederateTag(), helics::CommonCore::setFlagOption(), helics::CommonCore::setGlobal(), helics::CommonCore::setIntegerProperty(), helics::CommonCore::setInterfaceTag(), helics::CommonCore::setLogFile(), helics::CoreBroker::setLogFile(), helics::CoreBroker::setTimeBarrier(), helics::TimeoutMonitor::tick(), and helics::CommonCore::timeRequest().
|
protected |
add some base information to a json structure
Referenced by helics::CoreBroker::query().
|
virtual |
configure the base of all brokers and cores
References helics::timeZero.
Referenced by helics::CommonCore::configure(), helics::CoreBroker::configure(), helics::CommonCore::configureFromArgs(), helics::CoreBroker::configureFromArgs(), helics::CommonCore::configureFromVector(), and helics::CoreBroker::configureFromVector().
|
inline |
get the number of messages that have been processed internally
|
protectedvirtual |
generate a CLI11 Application for subprocesses for processing of command line arguments
Reimplemented in helics::NetworkCore< COMMS, baseline >, helics::NetworkBroker< COMMS, baseline, tcode >, helics::mpi::MpiCore, helics::mpi::MpiBroker, and helics::CoreBroker.
Referenced by helics::mpi::MpiCore::generateCLI().
|
protectedpure virtual |
generate the local address information
Implemented in helics::NetworkCore< COMMS, baseline >, helics::NetworkBroker< COMMS, baseline, tcode >, helics::mpi::MpiCore, helics::mpi::MpiBroker, and helics::MultiBroker.
Referenced by helics::CommonCore::getAddress(), and helics::CoreBroker::getAddress().
|
protected |
generate a new random id
|
protected |
get the value of a particular flag
References HELICS_FLAG_DUMPLOG, and HELICS_FLAG_FORCE_LOGGING_FLUSH.
Referenced by helics::CommonCore::getFlagOption().
|
inline |
get the internal global broker id
References global_id.
Referenced by helics::CoreBroker::globalError(), helics::CommonCore::sendCommand(), and helics::CommonCore::setFederateTag().
std::function< void(int, std::string_view, std::string_view)> helics::BrokerBase::getLoggingCallback | ( | ) | const |
generate a callback function for the logging purposes
|
inlineprotectedvirtual |
virtual function to return the current simulation time
Reimplemented in helics::CoreBroker, and helics::CommonCore.
|
inlinestaticprotected |
check whether a code contains a specific reason
|
inline |
check if the main processing loop of a broker is running
void helics::BrokerBase::joinAllThreads | ( | ) |
close all the threads
Referenced by helics::CommonCore::~CommonCore(), helics::CommsBroker< COMMS, BrokerT >::~CommsBroker(), and helics::MultiBroker::~MultiBroker().
void helics::BrokerBase::logFlush | ( | ) |
flush the loggers
int helics::BrokerBase::parseArgs | ( | int | argc, |
char * | argv[] | ||
) |
parse configuration information from command line arguments
Referenced by helics::CommonCore::configure(), helics::CoreBroker::configure(), helics::CommonCore::configureFromArgs(), helics::CoreBroker::configureFromArgs(), helics::CommonCore::configureFromVector(), and helics::CoreBroker::configureFromVector().
int helics::BrokerBase::parseArgs | ( | std::string_view | initializationString | ) |
parse configuration information from a string of command line like arguments
int helics::BrokerBase::parseArgs | ( | std::vector< std::string > | args | ) |
parse configuration information from a vector of command line like arguments
|
protected |
process some common commands that can be processed by the broker base
References helics::ActionMessage::payload, and helics::SmallBuffer::to_string().
|
protectedpure virtual |
process a single command action
cmd may be modified by this function
Implemented in helics::CommonCore.
|
protectedpure virtual |
process a disconnect signal
Implemented in helics::CoreBroker, and helics::CommonCore.
|
protectedpure virtual |
function to process a priority command independent of the main queue
called when processing a priority command. The priority command has a response message which gets sent this mainly deals with some of the registration functions
command | the command to process |
Implemented in helics::CommonCore.
|
protected |
save a profiling message
References helics::parent_broker_id, and helics::PROFILING.
|
protected |
send a Message to the logging system
fromRemote | set to true if the message to be logged came from a different object |
Referenced by helics::CommonCore::registerFederate(), and helics::TimeoutMonitor::tick().
|
protected |
set the broker error state and error string
References HELICS_ERROR_TERMINATED, HELICS_ERROR_USER_ABORT, HELICS_LOG_LEVEL_ERROR, and helics::timeZero.
void helics::BrokerBase::setLoggerFunction | ( | std::function< void(int level, std::string_view identifier, std::string_view message)> | logFunction | ) |
set the logging callback function
logFunction | a function with a signature of void(int level, std::string_view identifier, std::string_view message) the function takes a level indicating the logging level string with the source name and a string with the message |
|
protected |
set the logging file if using the default logger
void helics::BrokerBase::setLogLevel | ( | int32_t | level | ) |
set the logging level
void helics::BrokerBase::setLogLevels | ( | int32_t | consoleLevel, |
int32_t | fileLevel | ||
) |
set the logging levels
consoleLevel | the logging level for the console display |
fileLevel | the logging level for the log file |
|
protected |
set tick forwarding for a specific reason
|
protectedpure virtual |
in the case of connection failure with a broker this function will try a reconnect procedure
|
protected |
write profiler data to file
|
friend |
helper function to generate the name of a state as a string
|
protected |
if true allows some remote operation
|
protected |
a key that all joining federates must have to connect if empty no key is required
Referenced by helics::CommonCore::connect().
|
protected |
meant to be the same as global_id but not atomically protected
Referenced by helics::CoreBroker::allInitReady(), helics::CommonCore::checkInFlightQueriesForDisconnect(), helics::TimeoutMonitor::pingSub(), helics::CommonCore::processDisconnect(), and helics::TimeoutMonitor::tick().
|
protected |
the unique identifier for the broker(core or broker)
Referenced by helics::CoreBroker::clearTimeBarrier(), getGlobalId(), helics::CommonCore::logMessage(), helics::TimeoutMonitor::pingSub(), helics::CoreBroker::sendCommand(), helics::CommonCore::sendMessage(), helics::CoreBroker::setAsRoot(), helics::CoreBroker::setGlobal(), helics::CommonCore::setIntegerProperty(), helics::CommonCore::setLogFile(), helics::CoreBroker::setLogFile(), helics::CommonCore::setLoggingCallback(), helics::CoreBroker::setLoggingCallback(), helics::CommonCore::setLoggingLevel(), helics::CoreBroker::setLoggingLevel(), and helics::CoreBroker::setTimeBarrier().
|
protected |
set to true if the broker has Time dependencies
|
protected |
the logging level to use, levels >= this will be ignored
|
protected |
the minimum number of brokers that must connect before entering init mode
Referenced by helics::CoreBroker::allInitReady().
|
protected |
the minimum number of children that must connect before entering init mode
Referenced by helics::CommonCore::allInitReady(), and helics::CoreBroker::allInitReady().
|
protected |
the minimum number of federates that must connect before entering init mode
Referenced by helics::CommonCore::allInitReady(), and helics::CoreBroker::allInitReady().
|
protected |
timeout for queries, if the query isn't answered within this time period respond with timeout error
|
protected |
thread for running the broker
|
protected |
specify that outgoing connection should use json serialization
Referenced by helics::NetworkBroker< COMMS, baseline, tcode >::brokerConnect(), and helics::CommonCore::connect().