DataProviderPipeline.qc.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
// assume local scope for variables, do not use "$" signs
// require type definitions everywhere
// enable all warnings
// allow weak references
namespace DataProvider {
const PS_ABORTED = "ABORTED";
const PS_RUNNING = "RUNNING";
const PS_IDLE = "IDLE";
public struct PipelineInfo {
string name;
*date start_time;
*date stop_time;
string status;
int record_count;
int num_queues;
bool bulk;
date duration;
float duration_secs;
float recs_per_sec;
};
public struct PipelineOptionInfo {
*code debug_log;
*code error_log;
*code info_log;
/* it is called in the new pipeline queue thread with no arguments
*/
*code thread_callback;
*string name;
};
class PipelineQueue {
public:
int id;
Mutex lck;
Counter cnt;
Condition cond();
Condition flush_cond();
int queue_waiting = 0;
int data_waiting = 0;
int flush_waiting = 0;
list<auto> queue;
int size;
int tid;
list<auto> elems();
bool do_flush;
bool data_flushed;
DataProviderPipeline parent;
constructor(DataProviderPipeline parent, Mutex lck, Counter cnt, int id, int size);
int getId();
submit(auto qdata);
run(Counter run_cnt);
waitDone();
protected:
runIntern();
public:
protected:
flushIntern();
public:
};
class DataProviderPipeline {
public:
protected:
string name;
hash<string, PipelineQueue> pmap;
bool do_bulk = True;
bool locked = False;
Sequence seq(1);
list<hash<ExceptionInfo>> error_list;
date start_time;
date stop_time;
int record_count = 0;
*code info_log;
*code error_log;
*code debug_log;
/* it is called in the new pipeline queue thread with no arguments
*/
*code thread_callback;
Mutex lck();
bool stop_flag;
bool abort_flag;
Counter cnt();
public:
constructor(*hash<PipelineOptionInfo> opts);
copy();
destructor();
string getName();
bool hasQueue(int id);
bool stopping();
bool aborting();
registerThread(PipelineQueue queue);
append(AbstractDataProcessor processor);
append(int id, AbstractDataProcessor processor);
int appendQueue(int id);
bool isProcessing();
submit(auto _data);
submitData(AbstractIterator i);
submit(AbstractDataProviderRecordIterator i);
submit(AbstractDataProviderBulkRecordInterface i);
reset();
waitDone();
abort(*bool ignore_exceptions);
hash<PipelineInfo> getInfo();
reportError(PipelineQueue queue, hash<ExceptionInfo> ex);
logInfo(string fmt);
logError(string fmt);
logDebug(string fmt);
private:
PipelineQueue copyPipeline(PipelineQueue old_queue);
public:
private:
submitIntern(auto _data);
public:
private:
submitDataIntern(auto _data);
public:
private:
submitBulkIntern(AbstractDataProviderBulkRecordInterface i);
public:
private:
resetIntern();
public:
private:
checkSubmitIntern();
public:
private:
checkLockedIntern();
public:
private:
throwPipelineException();
public:
private:
checkUpdatePipelineIntern(int id);
public:
private:
stopIntern();
public:
private:
stopInternUnlocked();
public:
};
};
*list get_stack();
DataProvider::AbstractDataProcessor
Defines an abstract class for accepting data and outputting optionally transformed or filtered data.
Definition: AbstractDataProcessor.qc.dox.h:33
DataProvider::AbstractDataProviderBulkRecordInterface
Defines the abstract class for data provider iterators; the destructor releases the iterator.
Definition: AbstractDataProviderBulkRecordInterface.qc.dox.h:33
DataProvider::AbstractDataProviderRecordIterator
Defines the abstract class for data provider iterators; the destructor releases the iterator.
Definition: AbstractDataProviderRecordIterator.qc.dox.h:33
DataProvider::DataProviderPipeline
Defines a class for passing data through record processors.
Definition: DataProviderPipeline.qc.dox.h:207
DataProvider::DataProviderPipeline::getName
string getName()
Returns the pipeline name.
DataProvider::DataProviderPipeline::error_log
*code error_log
Error log closure; takes a single format string and then arguments for format placeholders.
Definition: DataProviderPipeline.qc.dox.h:246
DataProvider::DataProviderPipeline::cnt
Counter cnt()
Thread counter.
DataProvider::DataProviderPipeline::thread_callback
*code thread_callback
a closure or call reference for setting thread-local data in new pipeline queue threads
Definition: DataProviderPipeline.qc.dox.h:254
DataProvider::DataProviderPipeline::record_count
int record_count
Record count.
Definition: DataProviderPipeline.qc.dox.h:240
DataProvider::DataProviderPipeline::hasQueue
bool hasQueue(int id)
Returns True if the given queue exists, False if not.
DataProvider::DataProviderPipeline::stop_flag
bool stop_flag
Stop flag.
Definition: DataProviderPipeline.qc.dox.h:260
DataProvider::DataProviderPipeline::pmap
hash< string, PipelineQueue > pmap
Hash of queues keyed by queue ID.
Definition: DataProviderPipeline.qc.dox.h:217
DataProvider::DataProviderPipeline::getInfo
hash< PipelineInfo > getInfo()
Returns pipeline info.
DataProvider::DataProviderPipeline::abort
abort(*bool ignore_exceptions)
Aborts execution of a pipeline in progress.
DataProvider::DataProviderPipeline::seq
Sequence seq(1)
Pipeline ID sequence generator.
DataProvider::DataProviderPipeline::submitBulkIntern
submitBulkIntern(AbstractDataProviderBulkRecordInterface i)
Submits bulk data for processing.
DataProvider::DataProviderPipeline::logError
logError(string fmt)
Logs to the error log, if set.
DataProvider::DataProviderPipeline::copy
copy()
Copy constructor; creates an empty pipeline with the same configuration as the original.
DataProvider::DataProviderPipeline::stopping
bool stopping()
Returns True if the object is stopping.
DataProvider::DataProviderPipeline::registerThread
registerThread(PipelineQueue queue)
Registers a new thread.
DataProvider::DataProviderPipeline::throwPipelineException
throwPipelineException()
Throws an exception if errors occured in background pipeline processing.
DataProvider::DataProviderPipeline::resetIntern
resetIntern()
Resets the pipeline.
DataProvider::DataProviderPipeline::submitIntern
submitIntern(auto _data)
Submits data for processing.
DataProvider::DataProviderPipeline::error_list
list< hash< ExceptionInfo > > error_list
list of exceptions in pipelines
Definition: DataProviderPipeline.qc.dox.h:231
DataProvider::DataProviderPipeline::aborting
bool aborting()
Returns True if the object is aborting.
DataProvider::DataProviderPipeline::isProcessing
bool isProcessing()
Returns True if the pipeline is processing data.
DataProvider::DataProviderPipeline::copyPipeline
PipelineQueue copyPipeline(PipelineQueue old_queue)
Called by the copy constructor to copy the queues.
DataProvider::DataProviderPipeline::appendQueue
int appendQueue(int id)
Appends a new queue to an existing pipeline and returns the new queue ID.
DataProvider::DataProviderPipeline::debug_log
*code debug_log
Debug log closure; takes a single format string and then arguments for format placeholders.
Definition: DataProviderPipeline.qc.dox.h:249
DataProvider::DataProviderPipeline::reportError
reportError(PipelineQueue queue, hash< ExceptionInfo > ex)
Called from a pipeline queue object to report a fatal error durring processing.
DataProvider::DataProviderPipeline::info_log
*code info_log
Info log closure; takes a single format string and then arguments for format placeholders.
Definition: DataProviderPipeline.qc.dox.h:243
DataProvider::DataProviderPipeline::name
string name
A descriptive name for logging purposes.
Definition: DataProviderPipeline.qc.dox.h:214
DataProvider::DataProviderPipeline::append
append(int id, AbstractDataProcessor processor)
Appends a data processor to a queue.
DataProvider::DataProviderPipeline::stop_time
date stop_time
run stop time (set in waitDone())
Definition: DataProviderPipeline.qc.dox.h:237
DataProvider::DataProviderPipeline::lck
Mutex lck()
Atomic lock.
DataProvider::DataProviderPipeline::submit
submit(auto _data)
Submits data for processing.
DataProvider::DataProviderPipeline::logInfo
logInfo(string fmt)
Logs to the info log, if set.
DataProvider::DataProviderPipeline::submit
submit(AbstractDataProviderBulkRecordInterface i)
Submits data for processing.
DataProvider::DataProviderPipeline::waitDone
waitDone()
Waits for all queues to have processed remaining data.
DataProvider::DataProviderPipeline::start_time
date start_time
run start time
Definition: DataProviderPipeline.qc.dox.h:234
DataProvider::DataProviderPipeline::locked
bool locked
Locked flag.
Definition: DataProviderPipeline.qc.dox.h:225
DataProvider::DataProviderPipeline::logDebug
logDebug(string fmt)
Logs to the debug log, if set.
DataProvider::DataProviderPipeline::submit
submit(AbstractDataProviderRecordIterator i)
Submits data for processing.
DataProvider::DataProviderPipeline::destructor
destructor()
Destroys the object.
DataProvider::DataProviderPipeline::submitData
submitData(AbstractIterator i)
Submits data for processing.
DataProvider::DataProviderPipeline::abort_flag
bool abort_flag
Abort flag.
Definition: DataProviderPipeline.qc.dox.h:263
DataProvider::DataProviderPipeline::checkUpdatePipelineIntern
checkUpdatePipelineIntern(int id)
Check if the given queue exists.
DataProvider::DataProviderPipeline::stopInternUnlocked
stopInternUnlocked()
Stops all background pipeline queues; lock must be held.
DataProvider::DataProviderPipeline::checkSubmitIntern
checkSubmitIntern()
Throws an exception if the pipeline cannot be used; locks the pipeline for changes otherwise.
DataProvider::DataProviderPipeline::do_bulk
bool do_bulk
Bulk flag.
Definition: DataProviderPipeline.qc.dox.h:222
DataProvider::DataProviderPipeline::checkLockedIntern
checkLockedIntern()
Throws an exception if the pipeline is locked.
DataProvider::DataProviderPipeline::append
append(AbstractDataProcessor processor)
Appends a data processor to the default queue.
DataProvider::DataProviderPipeline::reset
reset()
Resets the pipeline.
DataProvider::DataProviderPipeline::submitDataIntern
submitDataIntern(auto _data)
Submits a single record for processing.
DataProvider::DataProviderPipeline::constructor
constructor(*hash< PipelineOptionInfo > opts)
Creates the object with the given options.
DataProvider::DataProviderPipeline::stopIntern
stopIntern()
Stops all background pipeline queues.
DataProvider::PipelineQueue
Pipeline element.
Definition: DataProviderPipeline.qc.dox.h:110
DataProvider::PipelineQueue::do_flush
bool do_flush
Flush pipeline flag.
Definition: DataProviderPipeline.qc.dox.h:154
DataProvider::PipelineQueue::lck
Mutex lck
Parent lock.
Definition: DataProviderPipeline.qc.dox.h:117
DataProvider::PipelineQueue::queue
list< auto > queue
Data queue.
Definition: DataProviderPipeline.qc.dox.h:138
DataProvider::PipelineQueue::getId
int getId()
Returns the pipeline ID.
DataProvider::PipelineQueue::waitDone
waitDone()
Wait for the queue to be empty, then wait for all terminating pipelines to be empty.
DataProvider::PipelineQueue::data_waiting
int data_waiting
Number of threads waiting on data.
Definition: DataProviderPipeline.qc.dox.h:132
DataProvider::PipelineQueue::elems
list< auto > elems()
Pipeline elements.
DataProvider::PipelineQueue::id
int id
Queue ID.
Definition: DataProviderPipeline.qc.dox.h:114
DataProvider::PipelineQueue::cond
Condition cond()
Queue condition variable.
DataProvider::PipelineQueue::submit
submit(auto qdata)
Submits data for processing.
DataProvider::PipelineQueue::flush_cond
Condition flush_cond()
Flush condition variable.
DataProvider::PipelineQueue::tid
int tid
TID of the background thread.
Definition: DataProviderPipeline.qc.dox.h:144
DataProvider::PipelineQueue::constructor
constructor(DataProviderPipeline parent, Mutex lck, Counter cnt, int id, int size)
Creates the object.
DataProvider::PipelineQueue::data_flushed
bool data_flushed
Data flushed confirmation.
Definition: DataProviderPipeline.qc.dox.h:157
DataProvider::PipelineQueue::runIntern
runIntern()
DataProvider::PipelineQueue::size
int size
Maximum queue size.
Definition: DataProviderPipeline.qc.dox.h:141
DataProvider::PipelineQueue::queue_waiting
int queue_waiting
Number of threads waiting data to be removed from the queue.
Definition: DataProviderPipeline.qc.dox.h:129
DataProvider::PipelineQueue::run
run(Counter run_cnt)
Processing thread.
DataProvider::PipelineQueue::cnt
Counter cnt
Parent counter.
Definition: DataProviderPipeline.qc.dox.h:120
DataProvider::PipelineQueue::flush_waiting
int flush_waiting
Number of threads waiting on the flush cond.
Definition: DataProviderPipeline.qc.dox.h:135
DataProvider::PipelineQueue::parent
DataProviderPipeline parent
Parent object.
Definition: DataProviderPipeline.qc.dox.h:160
True
const True
False
const False
date
date date(date dt)
list
list< auto > list(...)
DataProvider
Qore AbstractDataField class definition.
Definition: AbstractDataField.qc.dox.h:27
DataProvider::PS_IDLE
const PS_IDLE
Pipeline status: IDLE.
Definition: DataProviderPipeline.qc.dox.h:43
DataProvider::PS_RUNNING
const PS_RUNNING
Pipeline status: RUNNING.
Definition: DataProviderPipeline.qc.dox.h:40
DataProvider::PS_ABORTED
const PS_ABORTED
Pipeline status: ABORTED.
Definition: DataProviderPipeline.qc.dox.h:37
DataProvider::PipelineInfo
Pipeline info.
Definition: DataProviderPipeline.qc.dox.h:47
DataProvider::PipelineInfo::duration
date duration
Total time processing end to end.
Definition: DataProviderPipeline.qc.dox.h:74
DataProvider::PipelineInfo::stop_time
*date stop_time
Stop time for processing.
Definition: DataProviderPipeline.qc.dox.h:55
DataProvider::PipelineInfo::recs_per_sec
float recs_per_sec
Records processed per second end to end.
Definition: DataProviderPipeline.qc.dox.h:80
DataProvider::PipelineInfo::start_time
*date start_time
Start of processing.
Definition: DataProviderPipeline.qc.dox.h:52
DataProvider::PipelineInfo::bulk
bool bulk
Flag that indicates if the pipeline is capable of bulk record processing.
Definition: DataProviderPipeline.qc.dox.h:71
DataProvider::PipelineInfo::num_queues
int num_queues
Number of pipeline queues.
Definition: DataProviderPipeline.qc.dox.h:66
DataProvider::PipelineInfo::record_count
int record_count
Number of input records submitted.
Definition: DataProviderPipeline.qc.dox.h:63
DataProvider::PipelineInfo::status
string status
Pipeline status.
Definition: DataProviderPipeline.qc.dox.h:60
DataProvider::PipelineInfo::duration_secs
float duration_secs
Total time processing end to end as a floating-point value in durationSecondsFloat.
Definition: DataProviderPipeline.qc.dox.h:77
DataProvider::PipelineInfo::name
string name
The name of the pipeline.
Definition: DataProviderPipeline.qc.dox.h:49
DataProvider::PipelineOptionInfo
Pipeline option info.
Definition: DataProviderPipeline.qc.dox.h:84
DataProvider::PipelineOptionInfo::name
*string name
the name of the pipeline for logging purposes; if this key is not included, a generic name will be ge...
Definition: DataProviderPipeline.qc.dox.h:106
DataProvider::PipelineOptionInfo::info_log
*code info_log
a closure or call reference for info logging
Definition: DataProviderPipeline.qc.dox.h:98
DataProvider::PipelineOptionInfo::error_log
*code error_log
a closure or call reference for error logging
Definition: DataProviderPipeline.qc.dox.h:93
DataProvider::PipelineOptionInfo::thread_callback
*code thread_callback
a closure or call reference for setting thread-local data in new pipeline queue threads
Definition: DataProviderPipeline.qc.dox.h:103
DataProvider::PipelineOptionInfo::debug_log
*code debug_log
a closure or call reference for debug logging
Definition: DataProviderPipeline.qc.dox.h:88