neic-glass3  1.4.6
Public Member Functions | Protected Member Functions | List of all members
glass3::input::Input Class Referenceabstract

neic-glass3 Input class More...

#include <input.h>

Inheritance diagram for glass3::input::Input:
Inheritance graph
Collaboration diagram for glass3::input::Input:
Collaboration graph

Public Member Functions

 Input ()
 Input default constructor. More...
 
 Input (std::shared_ptr< const json::Object > config)
 Input advanced constructor. More...
 
 ~Input ()
 Input destructor. More...
 
bool setup (std::shared_ptr< const json::Object > config) override
 Input configuration function. More...
 
void clear () override
 Input clear function. More...
 
std::shared_ptr< json::Object > getInputData () override
 Input data getting function. More...
 
int getInputDataCount () override
 Input data count function. More...
 
void setInputDataMaxSize (int size)
 Function to set the maximum queue size. More...
 
int getInputDataMaxSize ()
 Function to retrieve the maximum queue size. 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 start ()
 work thread start function 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...
 
virtual bool healthCheck ()
 work threads check function 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

glass3::util::WorkState work () override
 Input work function. More...
 
virtual std::shared_ptr< json::Object > parse (std::string inputType, std::string inputMessage)
 parse line function More...
 
virtual std::string fetchRawData (std::string *pOutType)=0
 get Input data string and type 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

- 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

neic-glass3 Input class

The neic-glass3 Input class is a thread class encapsulating the data Input logic for neic-glass3. The Input class handles reading Input data, parsing it, validating it, and queuing it for later use byglasscore via the Associator class. If the internal queue isfull, the class will pause reading Input data until space is available.

The input class generates detection format json messages as defined in https://github.com/usgs/earthquake-detection-formats/tree/master/format-docs that are then passed to the associator/glasscore via a queue.

The Input class is intended to be inherited from to define application specific input mechanisms (i.e. input from disk files).

Input inherits from the glass3::util::ThreadBaseClass class. Input implements the glass3::util::iInput interface.

Constructor & Destructor Documentation

glass3::input::Input::Input ( )

Input default constructor.

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

glass3::input::Input::Input ( std::shared_ptr< const json::Object >  config)
explicit

Input advanced constructor.

The advanced constructor for the Input class. This function calls setup to configure the class, initializing members to the configured values, and starts the work thread

Parameters
config- A json::Object shared_ptr to the configuration to use
glass3::input::Input::~Input ( )

Input destructor.

The destructor for the Input class. Stops the work thread

Member Function Documentation

void glass3::input::Input::clear ( )
overridevirtual

Input clear function.

The clear function for the Input class. Clears all configuration, clears and reallocates the message queue and cache

Reimplemented from glass3::util::BaseClass.

Reimplemented in glass3::fileInput, and glass3::brokerInput.

virtual std::string glass3::input::Input::fetchRawData ( std::string *  pOutType)
protectedpure virtual

get Input data string and type

A pure virtual function that retrieves the next data message and type from an Input source

Parameters
pOutType- A pointer to a std::string used to pass out the type of the data
Returns
returns a std::string containing the Input data message

Implemented in glass3::fileInput, and glass3::brokerInput.

std::shared_ptr< json::Object > glass3::input::Input::getInputData ( )
overridevirtual

Input data getting function.

The function (from iinput) used to get Input data from the data queue.

Returns
Returns a pointer to a json::Object containing the data, or NULL if the Input queue is empty

Implements glass3::util::iInput.

int glass3::input::Input::getInputDataCount ( )
overridevirtual

Input data count function.

The function (from iInput) used to get the count of how much data is in the data queue.

Returns
Returns a postitve integer containing the count of data currently in the Input queue

Implements glass3::util::iInput.

int glass3::input::Input::getInputDataMaxSize ( )

Function to retrieve the maximum queue size.

This function retrieves the maximum allowable size of the Input data queue

Returns
Returns an integer value containing the maximum queue size
std::shared_ptr< json::Object > glass3::input::Input::parse ( std::string  inputType,
std::string  inputMessage 
)
protectedvirtual

parse line function

The function that parses an Input line, based on the given extension

Parameters
inputType- A std::string containing the type of data to parse
Returns
returns a shared pointer to a json::Object containing the parsed
Parameters
inputMessage- A std::string containing the input message line to parse
void glass3::input::Input::setInputDataMaxSize ( int  size)

Function to set the maximum queue size.

This function sets the maximum allowable size of the Input data queue. Setting this value to -1 indicates that there is no maximum size to the Input queue

Parameters
size= An integer value containing the maximum queue size
bool glass3::input::Input::setup ( std::shared_ptr< const json::Object >  config)
overridevirtual

Input configuration function.

The this function configures the Input class, The setup() function can be called multiple times, in order to reload or update configuration information.

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

Reimplemented from glass3::util::BaseClass.

Reimplemented in glass3::fileInput, and glass3::brokerInput.

glass3::util::WorkState glass3::input::Input::work ( )
overrideprotectedvirtual

Input work function.

The function (from threadclassbase) used to do work.

Returns
returns true if work was successful, false otherwise.

Implements glass3::util::ThreadBaseClass.


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