32 : peer_(nullptr), module_(nullptr)
33 # ifndef SENF_PPI_NOTRACE
34 , traceState_(NO_TRACING)
37 namespace fty = console::factory;
39 #ifndef SENF_PPI_NOTRACE 62 "senf::ppi::connector::Connector::connect(): (source) " 63 "Missing route() or noroute()" );
68 <<
" in module: " <<
prettyName(
typeid(*module_))
69 <<
", source module: " <<
prettyName(
typeid(peerModule));
73 "senf::ppi::connector::Connector::connect(): (target) " 74 "Missing route() or noroute()" );
79 <<
" in module: " <<
prettyName(
typeid(*module_))
80 <<
", target module: " <<
prettyName(
typeid(targetPeerModule));
82 if (! (v_packetTypeId() ==
typeid(
void) ||
83 target.v_packetTypeId() ==
typeid(void) ||
84 v_packetTypeId() == target.v_packetTypeId()) ) {
88 <<
" [in module " <<
prettyName(
typeid(*module_)) <<
"] " 90 <<
" [in module " <<
prettyName(
typeid(targetModule)) <<
"]";
102 peer_->v_connected();
105 #ifndef SENF_PPI_NOTRACE 108 std::string senf::ppi::connector::Connector::traceFilter_;
116 if (! traceFilter_.empty()) {
117 std::stringstream ss;
119 std::string packetDump (ss.str());
120 if (! (boost::algorithm::ifind_first(type, traceFilter_) || boost::algorithm::ifind_first(packetDump, traceFilter_)))
126 log <<
"PPI packet trace: " << label <<
" 0x" << std::hex << p.
id() <<
" " 127 << type.substr(21, type.size()-22) <<
" on " << &
module() <<
" " 128 <<
prettyName(
typeid(mod)) <<
" connector 0x" <<
this <<
"\n";
141 log <<
"PPI throttling trace: " << label <<
" " << type <<
" on " << &
module()
142 <<
" " <<
prettyName(
typeid(mod)) <<
" connector 0x" <<
this <<
"\n";
146 namespace senf {
namespace ppi {
namespace connector {
156 struct ConsoleRegister
161 ConsoleRegister::ConsoleRegister()
163 #ifndef SENF_PPI_NOTRACE 168 .arg(
"state",
"new tracing state")
169 .doc(
"Log every packet sent or received by any module.\n" 170 "There are three different tracing levels:\n" 172 " NO_TRACING don't output any tracing information\n" 173 " TRACE_IDS trace packet id's but do not show packet contents\n" 174 " TRACE_CONTENTS trace complete packet contents\n" 176 "A log message is generated whenever the packet traverses a connector. The\n" 177 "TRACE_IDS log message has the following format:\n" 179 " PPI packet trace: <direction> <packet-id> <packet-type>\n" 180 " on <module-id> <module-type> connector <connector-id>\n" 181 " PPI throttling trace: <direction> <throttle-msg>\n" 182 " on <module-id> <module-type> connector <connector-id>\n" 186 " direction 'IN' for packets/throttle notifications entering the module,\n" 187 " 'OUT' for packets/throttle notifications leaving it\n" 188 " packet-id Numeric unique packet id. This value is unique for packets\n" 189 " alive at the same time, packets at different times may (and\n" 190 " will) share id's\n" 191 " packet-type The type of the packet header\n" 192 " module-id Unique module id\n" 193 " module-type Type of the module the packet is sent to/from\n" 194 " connector-id Unique connector id\n" 195 " throttle-msg Type of throttling event\n")
203 ConsoleRegister consoleRegister;
209 SENF_ASSERT( peer_,
"senf::ppi::connector::Connector::disconnect(): Not connected" );
224 prefix_ std::type_info
const & senf::ppi::connector::Connector::v_packetTypeId()
232 module_->unregisterConnector(*
this);
247 SENF_ASSERT(module_,
"Connector not registered: Missing route() or noroute()");
266 : peer_(nullptr), remoteThrottled_(false), nativeThrottled_(false)
268 namespace fty = console::factory;
293 prefix_ void senf::ppi::connector::PassiveConnector::v_init()
295 Routes::const_iterator i (routes_.begin());
296 Routes::const_iterator
const i_end (routes_.end());
297 for (; i != i_end; ++i)
298 if ((*i)->throttled())
301 remoteThrottled_ =
false;
310 routes_.push_back(&route);
315 Routes::iterator i (std::find(routes_.begin(), routes_.end(), &route));
316 if (i != routes_.end())
320 prefix_ void senf::ppi::connector::PassiveConnector::v_unthrottleEvent()
323 prefix_ void senf::ppi::connector::PassiveConnector::notifyUnthrottle()
325 if (std::find_if(routes_.begin(), routes_.end(),
327 remoteThrottled_ =
false;
328 if (!nativeThrottled_)
331 SENF_PPI_THROTTLE_TRACE(
"OUT",
"not forwarding unthrottle event");
359 prefix_ void senf::ppi::connector::ActiveConnector::v_init()
365 prefix_ void senf::ppi::connector::ActiveConnector::notifyThrottle()
367 SENF_PPI_THROTTLE_TRACE(
"IN ",
"throttle");
370 if (throttleCallback_)
372 NotifyRoutes::const_iterator i (notifyRoutes_.begin());
373 NotifyRoutes::const_iterator
const i_end (notifyRoutes_.end());
374 for (; i != i_end; ++i)
375 (*i)->notifyThrottle();
379 prefix_ void senf::ppi::connector::ActiveConnector::notifyUnthrottle()
381 SENF_PPI_THROTTLE_TRACE(
"IN ",
"unthrottle");
384 if (unthrottleCallback_)
385 unthrottleCallback_();
386 NotifyRoutes::const_iterator i (notifyRoutes_.begin());
387 NotifyRoutes::const_iterator
const i_end (notifyRoutes_.end());
388 for (; i != i_end; ++i)
389 (*i)->notifyUnthrottle();
395 notifyRoutes_.push_back(&route);
400 NotifyRoutes::iterator i (std::find(notifyRoutes_.begin(), notifyRoutes_.end(), &route));
401 if (i != notifyRoutes_.end())
402 notifyRoutes_.erase(i);
415 Packet const * p = fastPacket_;
416 fastPacket_ =
nullptr;
418 SENF_PPI_TRACE(*p,
"IN ");
421 if (! queue_.empty()) {
422 slowPacket_ = queue_.back();
425 SENF_PPI_TRACE(slowPacket_,
"IN ");
428 SENF_PPI_TRACE(nullPacket,
"IN ");
448 prefix_ void senf::ppi::connector::InputConnector::v_requestEvent()
451 prefix_ void senf::ppi::connector::InputConnector::v_enqueueEvent()
454 prefix_ void senf::ppi::connector::InputConnector::v_dequeueEvent()
478 prefix_ void senf::ppi::connector::GenericActiveInput::v_requestEvent()
503 prefix_ void senf::ppi::connector::GenericPassiveInput::v_enqueueEvent()
510 prefix_ void senf::ppi::connector::GenericPassiveInput::v_dequeueEvent()
518 throttlingDisc_.reset();
521 prefix_ void senf::ppi::connector::GenericPassiveInput::v_unthrottleEvent()
#define SENF_LOG_BLOCK(args)
virtual void v_disconnected()
virtual void v_disconnected()
Connectors public header.
#define SENF_FNP(ret, fn, args)
static ModuleManager & instance()
#define SENF_MEMFNP(ret, cls, fn, args)
Combination of PassiveConnector and OutputConnector.
virtual void v_connected()
Passive connector base-class.
std::type_info const & id() const
virtual void v_disconnected()
Active connector base-class.
bool initializationScheduled() const
virtual void v_connected()
ModuleManager public header.
Output connector base-class.
Incompatible connectors connected.
Combination of ActiveConnector and OutputConnector.
void unregisterConnector()
void throttleTrace(char const *label, char const *type)
NodeType & add(std::string const &name, boost::shared_ptr< NodeType > node)
virtual void v_connected()
static void tracingFilter(std::string const &traceFilter)
std::string prettyName(std::type_info const &type)
Connector & peer() const
Get peer connected to this connector.
console::DirectoryNode & consoleDir() const
bool throttled() const
Get accumulative throttling state.
virtual void v_connected()
void connect(Connector &target)
virtual void v_disconnected()
virtual void v_connected()
bool connected() const
true, if connector connected, false otherwise
void dump(std::ostream &os, DumpPacketAnnotations_t dumpAnnotationsSwitch=dumpAnnotations) const
#define SENF_ASSERT(x, comment)
Forwarding route base class.
bool throttled() const
true, if the route is throttled
virtual void v_connected()
void disconnect()
Disconnect connector from peer.
static void staticTracingState(TraceState state)
virtual void v_disconnected()
GenericNode::ptr remove(std::string const &name)
void enqueueInitializable()
TypeIdValue typeId() const
module::Module & module() const
Get this connectors containing module.
TraceState tracingState() const
console::DirectoryNode & consoleDir() const
void trace(Packet const &p, char const *label)
virtual void v_disconnected()
console::DirectoryNode & sysConsoleDir() const
SENF_CONSOLE_REGISTER_ENUM_MEMBER(Connector, TraceState,(NO_TRACING)(TRACE_IDS)(TRACE_CONTENTS))