neic-glass3  1.4.6
Public Member Functions | Protected Member Functions | List of all members
glass3::brokerOutput Class Reference

glass3 broker output class More...

#include <brokerOutput.h>

Inheritance diagram for glass3::brokerOutput:
Inheritance graph
Collaboration diagram for glass3::brokerOutput:
Collaboration graph

Public Member Functions

 brokerOutput ()
 brokerOutput constructor More...
 
 brokerOutput (const std::shared_ptr< json::Object > &config)
 brokerOutput advanced constructor More...
 
 ~brokerOutput ()
 brokerOutput destructor More...
 
bool setup (std::shared_ptr< const json::Object > config) override
 brokerOutput configuration function More...
 
void clear () override
 brokerOutput clear function More...
 
void setStationFileName (const std::string &filename)
 Sets the station file name. More...
 
const std::string getStationFileName ()
 Gets the station file name. More...
 
void logProducer (const std::string &message)
 the function for producer logging This function is used by the HazDevBroker producer to log messages with neic-glass3's logging system. More...
 
- Public Member Functions inherited from glass3::output::output
 output ()
 output constructor More...
 
 ~output ()
 output destructor More...
 
void sendToOutput (std::shared_ptr< json::Object > message) override
 output message sending function More...
 
bool start () override
 work thread start function More...
 
bool healthCheck () override
 output heath check function More...
 
void setSiteListRequestInterval (int delay)
 Function to set the interval for requesting the site list. More...
 
int getSiteListRequestInterval ()
 Function to retrieve the interval for requesting the site list. More...
 
void setReportInterval (int interval)
 Function to set the interval to generate informational reports. More...
 
int getReportInterval ()
 Function to retrieve the interval to generate informational reports. More...
 
void setAssociator (glass3::util::iAssociator *associator)
 Function to set the associator interface pointer. More...
 
glass3::util::iAssociatorgetAssociator ()
 Function to get the associator interface pointer. More...
 
void setPubOnExpiration (bool pub)
 Function to set the publish on expiration flag. More...
 
bool getPubOnExpiration ()
 Function to retrieve the publish on expiration flag. More...
 
void setImmediatePubThreshold (double threshold)
 Function to set the immediate publication threshold. More...
 
double getImmediatePubThreshold ()
 Function to retrieve the immediate publication threshold. More...
 
std::vector< int > getPubTimes ()
 Function to retrieve the publication times. More...
 
void addPubTime (int pubTime)
 Function to add a single publication time to the list. More...
 
void clearPubTimes ()
 Function to clear the publication times. More...
 
bool addTrackingData (std::shared_ptr< json::Object > data)
 add tracking information to the output tracking cache More...
 
std::shared_ptr< const json::Object > getTrackingData (std::string id)
 get tracking information from the output tracking cache by id More...
 
std::shared_ptr< const json::Object > getNextTrackingData ()
 get tracking information from the output tracking cache More...
 
bool haveTrackingData (std::shared_ptr< json::Object > data)
 check if tracking information is in output tracking cache More...
 
bool haveTrackingData (std::string ID)
 check if information is in output tracking cache by id More...
 
bool removeTrackingData (std::shared_ptr< const json::Object > data)
 remove tracking information from the output tracking cache More...
 
bool removeTrackingData (std::string ID)
 remove tracking information from the output tracking cache by id More...
 
void clearTrackingData ()
 clear output tracking cache More...
 
bool isDataReady (std::shared_ptr< const json::Object > data)
 check to see if tracking information is ready for output More...
 
bool isDataChanged (std::shared_ptr< const json::Object > data)
 check to see if detection data has changed More...
 
bool isDataPublished (std::shared_ptr< const json::Object > data, bool ignoreVersion=true)
 check to see if tracking information has been published More...
 
bool isDataFinished (std::shared_ptr< const json::Object > data)
 check to see if tracking information is finished More...
 
void writeOutput (std::shared_ptr< json::Object > data)
 output writing function More...
 
glass3::util::WorkState work () override
 output background work function More...
 
- Public Member Functions inherited from glass3::util::ThreadBaseClass
 ThreadBaseClass ()
 ThreadBaseClass constructor. More...
 
 ThreadBaseClass (std::string threadName, int sleepTimeMS=100, int numThreads=1, int checkInterval=300)
 An advanced constructor that sets up the ThreadBaseClass with a provided thread name, sleep between work time duration, number of threads, and statsus check interval. More...
 
 ~ThreadBaseClass ()
 ThreadBaseClass destructor. More...
 
virtual bool stop ()
 work thread stop function More...
 
int getNumThreads ()
 Retrieves the number of work threads. More...
 
void setNumThreads (int numThreads)
 Sets the number of work threads. More...
 
void setThreadHealth (bool health=true)
 Function to set thread health. More...
 
void setSleepTime (int sleepTimeMS)
 Sets the time to sleep between work() calls. More...
 
int getSleepTime ()
 Retrieves the time to sleep between work() calls. More...
 
glass3::util::ThreadState getWorkThreadsState ()
 Function to get the work threads state. More...
 
void setHealthCheckInterval (int interval)
 Function to set work threads health check interval. More...
 
int getHealthCheckInterval ()
 Function to retrieve the work threads health check interval. More...
 
bool getTerminate ()
 Function to retrieve whether the thread should terminate. More...
 
const std::string & getThreadName ()
 Function to retrieve the name of the work threads. More...
 
std::time_t getAllLastHealthy (size_t *pThreadId)
 Function to retrieve the oldest time any of the work threads last updated their health status as healthy. More...
 
- Public Member Functions inherited from glass3::util::BaseClass
 BaseClass ()
 BaseClass constructor. More...
 
virtual ~BaseClass ()
 BaseClass destructor. More...
 
const std::shared_ptr< const json::Object > getConfig ()
 
bool getSetup ()
 Retrieves the class member boolean flag indicating whether the class has been setup, set to true if setup was successful. More...
 
const std::string & getDefaultAgencyId ()
 Function to retrieve the name of the default agency id. More...
 
void setDefaultAgencyId (const std::string &id)
 Function to set the name of the default agency id. More...
 
const std::string & getDefaultAuthor ()
 Function to retrieve the name of the default author. More...
 
void setDefaultAuthor (const std::string &author)
 Function to set the name of the default author. More...
 

Protected Member Functions

void sendOutput (const std::string &type, const std::string &id, const std::string &message) override
 output sending function More...
 
void sendToOutputTopics (const std::string &message)
 Sends the provided message to each of the output topics. More...
 
void sendHeartbeat () override
 Send heartbeats. More...
 
- Protected Member Functions inherited from glass3::output::output
void checkEventsLoop ()
 output tracking data background work function More...
 
- Protected Member Functions inherited from glass3::util::ThreadBaseClass
void setWorkThreadsState (glass3::util::ThreadState state)
 Function to set threads state. More...
 
void workLoop ()
 ThreadBaseClass work loop function. More...
 
void setLastHealthy (std::time_t now)
 Function to set the last time the work thread was healthy. More...
 

Additional Inherited Members

- Static Public Attributes inherited from glass3::output::output
static constexpr int k_iMinimumPublicationTime = 10
 The minimum time in seconds to publish an event. More...
 
- Protected Attributes inherited from glass3::util::ThreadBaseClass
std::vector< std::thread > m_WorkThreads
 the std::vector that contains the work std::thread objects More...
 
std::map< std::thread::id, std::atomic< int > > m_ThreadHealthMap
 A std::map containing the epoch times as std::atomic<double>> that each work thread was last marked as healthy, identified by the thread id. More...
 
- Protected Attributes inherited from glass3::util::BaseClass
std::shared_ptr< const json::Object > m_Config
 A shared pointer to the json::Object that holds the configuration. More...
 
std::atomic< bool > m_bIsSetup
 the boolean flag indicating whether the class has been setup, set to true if setup was successful. More...
 
std::string m_DefaultAgencyID
 A std::string containing the default agency id to use in parsing if one is not provided. More...
 
std::string m_DefaultAuthor
 A std::string containing the default author to use in parsing if one is not provided. More...
 

Detailed Description

glass3 broker output class

The glass3 broker output class is a class encapsulating the broker output logic. The output class handles setting up a hazdevbroker producer, configuring output topic(s) and sending messages from glasscore, to kafka via the hazdevbroker producer

brokerOutput inherits from the glass3::output::output class.

Constructor & Destructor Documentation

glass3::brokerOutput::brokerOutput ( )

brokerOutput constructor

The constructor for the brokerOutput class. Initializes members to default values.

glass3::brokerOutput::brokerOutput ( const std::shared_ptr< json::Object > &  config)
explicit

brokerOutput advanced constructor

The advanced constructor for the brokerOutput class. Initializes members to default values. Calls setup to configure the class Starts the work thread

Parameters
config- A json::Object pointer to the configuration to use
glass3::brokerOutput::~brokerOutput ( )

brokerOutput destructor

The destructor for the brokerOutput class. Stops the work thread

Member Function Documentation

void glass3::brokerOutput::clear ( )
overridevirtual

brokerOutput clear function

The clear function for the brokerOutput class. Clears all configuration

Reimplemented from glass3::output::output.

const std::string glass3::brokerOutput::getStationFileName ( )

Gets the station file name.

Returns
Returns A string containing the file name
void glass3::brokerOutput::logProducer ( const std::string &  message)

the function for producer logging This function is used by the HazDevBroker producer to log messages with neic-glass3's logging system.

Parameters
message- A string containing the logging message
void glass3::brokerOutput::sendHeartbeat ( )
overrideprotectedvirtual

Send heartbeats.

This function is used to optionally send heartbeat messages to kafka via the hazdev-broker producer.

Reimplemented from glass3::output::output.

void glass3::brokerOutput::sendOutput ( const std::string &  type,
const std::string &  id,
const std::string &  message 
)
overrideprotectedvirtual

output sending function

The function used output detection data

Parameters
type- A std::string containing the type of the data message
id- A std::string containing the id of the data message
message- A std::string containing the data message

Implements glass3::output::output.

void glass3::brokerOutput::sendToOutputTopics ( const std::string &  message)
protected

Sends the provided message to each of the output topics.

Parameters
message- A string containing the message
void glass3::brokerOutput::setStationFileName ( const std::string &  filename)

Sets the station file name.

Parameters
filename- A string containing the file name
bool glass3::brokerOutput::setup ( std::shared_ptr< const json::Object >  config)
overridevirtual

brokerOutput configuration function

This function configures the brokerOutput class.

Parameters
config- A pointer to a json::Object containing to the configuration to use
Returns
returns true if successful.

Reimplemented from glass3::output::output.


The documentation for this class was generated from the following files: