17 #ifndef _SAG_CONNECTIVITY_PLUGINS_HPP_
18 #define _SAG_CONNECTIVITY_PLUGINS_HPP_
24 namespace softwareag {
25 namespace connectivity {
35 friend class CacheForThisThread;
56 class CacheForThisThread
60 CacheForThisThread(CacheOwner &owner);
62 ~CacheForThisThread();
86 Logger(
const std::string &category): category(
"AP_LOG_"+category), prefix(category) {}
94 template<level_t LEVEL,
typename... ARGS>
95 void log(
const char *format, ARGS... args)
const;
104 template<
typename... ARGS>
105 void log(level_t LEVEL,
const char *format, ARGS... args)
const;
113 template<level_t LEVEL,
typename... ARGS>
114 void log(
const std::string &format, ARGS... args)
const;
123 template<
typename... ARGS>
124 void log(level_t LEVEL,
const std::string &format, ARGS... args)
const;
152 template<
typename... ARGS>
void crit(
const char *format, ARGS... args)
const { log<SAG_LOG_CRIT>(format, args...); }
154 template<
typename... ARGS>
void fatal(
const char *format, ARGS... args)
const { log<SAG_LOG_FATAL>(format, args...); }
156 template<
typename... ARGS>
void error(
const char *format, ARGS... args)
const { log<SAG_LOG_ERROR>(format, args...); }
158 template<
typename... ARGS>
void warn(
const char *format, ARGS... args)
const { log<SAG_LOG_WARN>(format, args...); }
160 template<
typename... ARGS>
void info(
const char *format, ARGS... args)
const { log<SAG_LOG_INFO>(format, args...); }
162 template<
typename... ARGS>
void debug(
const char *format, ARGS... args)
const { log<SAG_LOG_DEBUG>(format, args...); }
164 template<
typename... ARGS>
void trace(
const char *format, ARGS... args)
const { log<SAG_LOG_TRACE>(format, args...); }
167 template<
typename... ARGS>
void crit(
const std::string &format, ARGS... args)
const { log<SAG_LOG_CRIT>(format, args...); }
169 template<
typename... ARGS>
void fatal(
const std::string &format, ARGS... args)
const { log<SAG_LOG_FATAL>(format, args...); }
171 template<
typename... ARGS>
void error(
const std::string &format, ARGS... args)
const { log<SAG_LOG_ERROR>(format, args...); }
173 template<
typename... ARGS>
void warn(
const std::string &format, ARGS... args)
const { log<SAG_LOG_WARN>(format, args...); }
175 template<
typename... ARGS>
void info(
const std::string &format, ARGS... args)
const { log<SAG_LOG_INFO>(format, args...); }
177 template<
typename... ARGS>
void debug(
const std::string &format, ARGS... args)
const { log<SAG_LOG_DEBUG>(format, args...); }
179 template<
typename... ARGS>
void trace(
const std::string &format, ARGS... args)
const { log<SAG_LOG_TRACE>(format, args...); }
183 std::string category;
225 : chainId(chainId), pluginName(pluginName), config(config.copy()), connectivityManager(connectivityManager), reserved(reserved)
230 std::string pluginName;
233 void* connectivityManager;
277 logger.
info(
"The %s connectivity plug-in in chain '%s' is using the legacy (std::string&,std::string&,map_t&) constructor which will be deprecated in a future release. We recommend changing to use the recommended (PluginConstructorParameters&) constructor instead.",
278 pluginName.c_str(), chainId.c_str());
361 typedef std::auto_ptr<HostSide>
ptr_t;
388 RemoteHostSide(sag_plugin_t other, sag_send_fn_t fn): other(other), fn(fn) {}
406 typedef std::auto_ptr<TransportSide>
ptr_t;
486 :
Plugin(pluginName, chainId, config)
577 :
Plugin(name, chainId, config)
662 for (
Message *it = start; it != end; ++it) {
664 if (it->getPayload().empty()) {
704 }
catch (
const std::exception &e) {
705 logger.
warn(
"Caught exception delivering message: %s", e.what());
707 logger.
warn(
"Caught unknown exception delivering message: %s");
771 for (
Message *it = start; it != end; ++it) {
774 if (it->getPayload().empty()) {
784 if (it != curr) it->swap(std::move(*curr));
798 for (
Message *it = start; it != end; ++it) {
802 if (it->getPayload().empty()) {
812 if (it != curr) it->swap(std::move(*curr));
868 }
catch (
const std::exception &e) {
869 logger.
warn(
"Caught exception transforming message: %s", e.what());
871 logger.
warn(
"Caught unknown exception transforming message");
880 #include <sag_internal/exception.hpp>
881 #include <sag_internal/remote_plugins.hpp>
882 #include <sag_internal/plugin_macros.hpp>
883 #include <sag_internal/logging.hpp>
894 #define SAG_DECLARE_CONNECTIVITY_TRANSPORT_CLASS(Class) _SAG_DECLARE_CONNECTIVITY_TRANSPORT_CLASS(Class)
907 #define SAG_DECLARE_CONNECTIVITY_TRANSPORT(Class) _SAG_DECLARE_CONNECTIVITY_TRANSPORT_LEGACY(Class)
918 #define SAG_DECLARE_CONNECTIVITY_CODEC_CLASS(Class) _SAG_DECLARE_CONNECTIVITY_CODEC_CLASS(Class)
930 #define SAG_DECLARE_CONNECTIVITY_CODEC(Class) _SAG_DECLARE_CONNECTIVITY_CODEC_LEGACY(Class)
932 #endif // _SAG_CONNECTIVITY_PLUGINS_HPP_
A container for parameters passed to the constructor of a codec plug-in.
Definition: sag_connectivity_plugins.hpp:251
Logger LOGGER
Legacy logging for writing to the host log file.
Definition: sag_connectivity_plugins.hpp:343
Base class that simplifies implementation of codec plug-ins that deal only with individual messages n...
Definition: sag_connectivity_plugins.hpp:730
AbstractTransport(const PluginConstructorParameters::TransportConstructorParameters ¶ms)
Constructor.
Definition: sag_connectivity_plugins.hpp:588
Base class that simplifies implementation of transport plug-ins that deal only with individual messag...
Definition: sag_connectivity_plugins.hpp:621
Wrap the next plugin in order as a TransportSide object.
Definition: sag_connectivity_plugins.hpp:430
HostSide::ptr_t hostSide
The next plug-in in the chain towards host.
Definition: sag_connectivity_plugins.hpp:517
An interface to the next component (plugin or host) towards the host.
Definition: sag_connectivity_plugins.hpp:355
virtual void sendBatchTowardsHost(Message *start, Message *end)=0
Abstract method that must be implemented to handle delivery of a batch of messages heading towards th...
bool isDebugEnabled() const
Returns true if DEBUG messages will be written to the log.
Definition: sag_connectivity_plugins.hpp:147
void debug(const std::string &format, ARGS...args) const
Log a message at DEBUG level.
Definition: sag_connectivity_plugins.hpp:177
map_t config
The configuration of this plug-in.
Definition: sag_connectivity_plugins.hpp:336
bool isInfoEnabled() const
Returns true if INFO messages will be written to the log.
Definition: sag_connectivity_plugins.hpp:145
Fatal errors.
Definition: sag_connectivity_c.h:78
void warn(const char *format, ARGS...args) const
Log a message at WARN level.
Definition: sag_connectivity_plugins.hpp:158
Class for writing to the host logger.
Definition: sag_connectivity_plugins.hpp:76
void error(const char *format, ARGS...args) const
Log a message at ERROR level.
Definition: sag_connectivity_plugins.hpp:156
Trace.
Definition: sag_connectivity_c.h:88
std::string name
The name used for this plug-in in the configuration file.
Definition: sag_connectivity_plugins.hpp:332
Contains the C++ implementation of the underlying datatypes used by connectivity plugins and their ac...
bool isTraceEnabled() const
Returns true if TRACE messages will be written to the log.
Definition: sag_connectivity_plugins.hpp:149
bool isErrorEnabled() const
Returns true if ERROR messages will be written to the log.
Definition: sag_connectivity_plugins.hpp:141
virtual void sendBatchTowardsTransport(Message *start, Message *end)
Implements batch sending, calling deliverMessageTowardsTransport(Message&) for each message individua...
Definition: sag_connectivity_plugins.hpp:660
Base of the inheritance tree for Connectivity plugins.
Definition: sag_connectivity_plugins.hpp:269
void warn(const std::string &format, ARGS...args) const
Log a message at WARN level.
Definition: sag_connectivity_plugins.hpp:173
sag_log_level_t level_t
The available log levels.
Definition: sag_connectivity_plugins.hpp:80
TransportSide::ptr_t transportSide
The next plug-in in the chain towards transport.
Definition: sag_connectivity_plugins.hpp:523
virtual void sendBatchTowardsTransport(Message *start, Message *end)=0
Abstract method that must be implemented to handle delivery of a batch of messages heading towards th...
void crit(const std::string &format, ARGS...args) const
Log a message at CRIT level.
Definition: sag_connectivity_plugins.hpp:167
Debug messages.
Definition: sag_connectivity_c.h:86
Critical log messages.
Definition: sag_connectivity_c.h:76
Definition: sag_connectivity_threading.h:178
std::auto_ptr< TransportSide > ptr_t
Pointers to TransportSides should always be this ptr_t type, which is a std::auto_ptr.
Definition: sag_connectivity_plugins.hpp:406
AbstractSimpleTransport(const PluginConstructorParameters::TransportConstructorParameters ¶ms)
Constructor.
Definition: sag_connectivity_plugins.hpp:651
Logger logger
Logging for writing to the host log file.
Definition: sag_connectivity_plugins.hpp:348
void info(const char *format, ARGS...args) const
Log a message at INFO level.
Definition: sag_connectivity_plugins.hpp:160
virtual bool transformNullPayloadTowardsTransport(Message &msg)
Transform a message with a null payload in a transport-wards direction.
Definition: sag_connectivity_plugins.hpp:838
virtual void start()
Called when an entire chain has been created and the plugin is allowed to start up (after all plugins...
Definition: sag_connectivity_plugins.hpp:301
sag_log_level_t
Log levels for logging to the system log.
Definition: sag_connectivity_c.h:73
Non-fatal errors.
Definition: sag_connectivity_c.h:80
void fatal(const char *format, ARGS...args) const
Log a message at FATAL level.
Definition: sag_connectivity_plugins.hpp:154
virtual ~TransportSide()
Ensure virtual destruction.
Definition: sag_connectivity_plugins.hpp:404
Base class for transport plug-ins.
Definition: sag_connectivity_plugins.hpp:557
void error(const std::string &format, ARGS...args) const
Log a message at ERROR level.
Definition: sag_connectivity_plugins.hpp:171
Logger(const std::string &category)
Construct a logger for the given category.
Definition: sag_connectivity_plugins.hpp:86
AbstractSimpleTransport(const std::string &name, const std::string &chainId, const map_t &config)
Legacy constructor.
Definition: sag_connectivity_plugins.hpp:639
Informational messages (default)
Definition: sag_connectivity_c.h:84
virtual void handleException(Message &m)
Handle an exception thrown while delivering a message towards the transport.
Definition: sag_connectivity_plugins.hpp:700
bool isCritEnabled() const
Returns true if CRIT messages will be written to the log.
Definition: sag_connectivity_plugins.hpp:137
Wrap the next plugin in order as a HostSide object.
Definition: sag_connectivity_plugins.hpp:385
virtual ~HostSide()
Ensure virtual destruction.
Definition: sag_connectivity_plugins.hpp:359
AbstractSimpleCodec(const PluginConstructorParameters::CodecConstructorParameters ¶ms)
Constructor.
Definition: sag_connectivity_plugins.hpp:759
virtual void hostReady()
Called some time after start(), when the host is ready to start receiving input (sends will be queued...
Definition: sag_connectivity_plugins.hpp:310
bool isEnabled(level_t LEVEL) const
Returns true if messages at the given level will be written to the log file.
Definition: sag_connectivity_plugins.hpp:128
Base class for codec plug-ins.
Definition: sag_connectivity_plugins.hpp:466
void trace(const char *format, ARGS...args) const
Log a message at TRACE level.
Definition: sag_connectivity_plugins.hpp:164
virtual bool transformMessageTowardsTransport(Message &msg)=0
Abstract method that must be implemented to handle transformation of an individual message in a trans...
void log(const char *format, ARGS...args) const
Log a message at a given level.
AbstractSimpleCodec(const std::string &name, const std::string &chainId, const map_t &config)
Legacy constructor.
Definition: sag_connectivity_plugins.hpp:747
virtual bool transformMessageTowardsHost(Message &msg)=0
Abstract method that must be implemented to handle transformation of an individual message...
A map class which implements many of the functions on std::map.
Definition: sag_connectivity_cpp.hpp:723
const std::string & getPluginName() const
Get the name used in the configuration file for this plug-in.
Definition: sag_connectivity_plugins.hpp:218
A container for an payload and associated metadata.
Definition: sag_connectivity_cpp.hpp:1545
virtual void shutdown()
Release any resources created by the connectivity plug-in, and terminate and join any background thre...
Definition: sag_connectivity_plugins.hpp:327
level_t getLevel() const
Returns the current log level.
void fatal(const std::string &format, ARGS...args) const
Log a message at FATAL level.
Definition: sag_connectivity_plugins.hpp:169
virtual void sendBatchTowardsHost(Message *start, Message *end)
Implements batch sending, calling transformMessageTowardsHost(Message &) for each message individuall...
Definition: sag_connectivity_plugins.hpp:768
An interface to the next component (plugin or host) towards the transport.
Definition: sag_connectivity_plugins.hpp:400
AbstractCodec(const PluginConstructorParameters::CodecConstructorParameters ¶ms)
Constructor.
Definition: sag_connectivity_plugins.hpp:497
virtual void deliverMessageTowardsTransport(Message &msg)=0
Abstract method that must be implemented to handle delivery of an individual message.
virtual void deliverNullPayloadTowardsTransport(Message &msg)
Deliver a message with a null payload.
Definition: sag_connectivity_plugins.hpp:677
void crit(const char *format, ARGS...args) const
Log a message at CRIT level.
Definition: sag_connectivity_plugins.hpp:152
void debug(const char *format, ARGS...args) const
Log a message at DEBUG level.
Definition: sag_connectivity_plugins.hpp:162
AbstractCodec(const std::string &pluginName, const std::string &chainId, const map_t &config)
Legacy constructor.
Definition: sag_connectivity_plugins.hpp:485
void info(const std::string &format, ARGS...args) const
Log a message at INFO level.
Definition: sag_connectivity_plugins.hpp:175
A container for parameters passed to the constructor of a transport plug-in.
Definition: sag_connectivity_plugins.hpp:239
bool isFatalEnabled() const
Returns true if FATAL messages will be written to the log.
Definition: sag_connectivity_plugins.hpp:139
map_t copy() const
Return a deep copy of this map.
Definition: sag_connectivity_cpp.hpp:874
AbstractTransport(const std::string &name, const std::string &chainId, const map_t &config)
Legacy constructor.
Definition: sag_connectivity_plugins.hpp:576
const std::string & getChainId() const
Get the identifier used for the chain this plug-in is part of.
Definition: sag_connectivity_plugins.hpp:213
A base interface for parameters passed to the constructor of transport or codec plug-ins.
Definition: sag_connectivity_plugins.hpp:198
virtual bool handleException(Message &m, bool towardsTransport)
Handle an exception thrown while delivering a message.
Definition: sag_connectivity_plugins.hpp:864
std::string chainId
The identifier used for the chain this plug-in is part of.
Definition: sag_connectivity_plugins.hpp:334
virtual void sendBatchTowardsHost(Message *start, Message *end)
Abstract method that must be implemented to handle delivery of a batch of messages heading towards th...
void trace(const std::string &format, ARGS...args) const
Log a message at TRACE level.
Definition: sag_connectivity_plugins.hpp:179
const map_t & getConfig() const
Get the configuration for this plug-in.
Definition: sag_connectivity_plugins.hpp:208
virtual void sendBatchTowardsTransport(Message *start, Message *end)
Implements batch sending, calling transformMessageTowardsTransport(Message &) for each message indivi...
Definition: sag_connectivity_plugins.hpp:795
bool isWarnEnabled() const
Returns true if WARN messages will be written to the log.
Definition: sag_connectivity_plugins.hpp:143
std::auto_ptr< HostSide > ptr_t
Pointers to HostSides should always be this ptr_t type, which is a std::auto_ptr. ...
Definition: sag_connectivity_plugins.hpp:361
virtual ~Plugin()
Virtual destructor to ensure that we can delete any part of the tree.
Definition: sag_connectivity_plugins.hpp:289
Warnings.
Definition: sag_connectivity_c.h:82
HostSide::ptr_t hostSide
The next plug-in in the chain towards host.
Definition: sag_connectivity_plugins.hpp:603
virtual void sendBatchTowardsTransport(Message *start, Message *end)
Abstract method that must be implemented to handle delivery of a batch of messages heading towards th...
const std::string & getName() const
Return the name of this plugin instance.
Definition: sag_connectivity_plugins.hpp:329
virtual bool transformNullPayloadTowardsHost(Message &msg)
Transform a message with a null payload in a host-wards direction.
Definition: sag_connectivity_plugins.hpp:830