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";
const DPE_SKIP_DATA = "DPE-SKIP-DATA";
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 thread with no arguments
*/
*code thread_callback;
*string name;
};
class PipelineQueue {
public:
int id;
Mutex lck;
Counter cnt;
Condition cond();
int queue_waiting = 0;
int data_waiting = 0;
list<auto> queue;
int size;
int tid;
list<auto> elems();
DataProviderPipeline parent;
constructor(DataProviderPipeline parent, Mutex lck, Counter cnt, int id, int size);
int getId();
submit(auto record);
run(Counter run_cnt);
waitDone();
};
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 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:
};
};
DataProvider::DPE_SKIP_DATA
const DPE_SKIP_DATA
Skips processing a record.
Definition: DataProviderPipeline.qc.dox.h:53
DataProvider::PipelineQueue::lck
Mutex lck
Parent lock.
Definition: DataProviderPipeline.qc.dox.h:125
DataProvider::DataProviderPipeline::logError
logError(string fmt)
Logs to the error log, if set.
DataProvider::DataProviderPipeline::start_time
date start_time
run start time
Definition: DataProviderPipeline.qc.dox.h:214
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:114
DataProvider::PipelineOptionInfo::debug_log
*code debug_log
a closure or call reference for debug logging
Definition: DataProviderPipeline.qc.dox.h:96
DataProvider::DataProviderPipeline::pmap
hash< string, PipelineQueue > pmap
Hash of queues keyed by queue ID.
Definition: DataProviderPipeline.qc.dox.h:199
DataProvider::DataProviderPipeline::locked
bool locked
Locked flag.
Definition: DataProviderPipeline.qc.dox.h:205
DataProvider::DataProviderPipeline::name
string name
A descriptive name for logging purposes.
Definition: DataProviderPipeline.qc.dox.h:196
DataProvider::DataProviderPipeline::copyPipeline
PipelineQueue copyPipeline(PipelineQueue old_queue)
Called by the copy constructor to copy the queues.
DataProvider::DataProviderPipeline::append
append(int id, AbstractDataProcessor processor)
Appends a data processor to a pipeline.
DataProvider::DataProviderPipeline::submit
submit(auto _data)
Submits data for processing.
DataProvider::DataProviderPipeline::stop_flag
bool stop_flag
Stop flag.
Definition: DataProviderPipeline.qc.dox.h:240
DataProvider::PipelineQueue::submit
submit(auto record)
Submits data for processing.
DataProvider::DataProviderPipeline::reset
reset()
Resets the pipeline.
DataProvider::PipelineQueue::getId
int getId()
Returns the pipeline ID.
DataProvider::PipelineInfo
Pipeline info.
Definition: DataProviderPipeline.qc.dox.h:57
DataProvider::PipelineQueue::run
run(Counter run_cnt)
Processing thread.
DataProvider::PipelineQueue::data_waiting
int data_waiting
Number of threads waiting on data.
Definition: DataProviderPipeline.qc.dox.h:137
DataProvider::PipelineInfo::start_time
*date start_time
Start of processing.
Definition: DataProviderPipeline.qc.dox.h:62
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:226
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:229
DataProvider::PipelineInfo::status
string status
Pipeline status.
Definition: DataProviderPipeline.qc.dox.h:70
True
const True
DataProvider::DataProviderPipeline::append
append(AbstractDataProcessor processor)
Appends a data processor to the default pipeline.
DataProvider::DataProviderPipeline::getName
string getName()
Returns the pipeline name.
DataProvider::PipelineOptionInfo::error_log
*code error_log
a closure or call reference for error logging
Definition: DataProviderPipeline.qc.dox.h:101
DataProvider::PipelineQueue::cond
Condition cond()
Queue condition variable.
DataProvider::DataProviderPipeline::appendQueue
int appendQueue(int id)
Appends a new queue to an existing pipeline and returns the new queue ID.
DataProvider
Qore AbstractDataField class definition.
Definition: AbstractDataField.qc.dox.h:32
DataProvider::AbstractDataProcessor
Defines an abstract class for accepting data and outputting optionally transformed or filtered data.
Definition: AbstractDataProcessor.qc.dox.h:33
DataProvider::PS_RUNNING
const PS_RUNNING
Pipeline status: RUNNING.
Definition: DataProviderPipeline.qc.dox.h:40
DataProvider::DataProviderPipeline::isProcessing
bool isProcessing()
Returns True if the pipeline is processing data.
DataProvider::PipelineOptionInfo::thread_callback
*code thread_callback
a closure or call reference for setting thread-local data in new pipeline threads
Definition: DataProviderPipeline.qc.dox.h:111
DataProvider::DataProviderPipeline::do_bulk
bool do_bulk
Bulk flag.
Definition: DataProviderPipeline.qc.dox.h:202
DataProvider::PipelineInfo::record_count
int record_count
Number of input records submitted.
Definition: DataProviderPipeline.qc.dox.h:73
DataProvider::DataProviderPipeline::aborting
bool aborting()
Returns True if the object is aborting.
DataProvider::PipelineOptionInfo::info_log
*code info_log
a closure or call reference for info logging
Definition: DataProviderPipeline.qc.dox.h:106
DataProvider::PipelineQueue::constructor
constructor(DataProviderPipeline parent, Mutex lck, Counter cnt, int id, int size)
Creates the object.
DataProvider::PipelineInfo::num_queues
int num_queues
Number of pipeline queues.
Definition: DataProviderPipeline.qc.dox.h:76
DataProvider::DataProviderPipeline::submit
submit(AbstractDataProviderBulkRecordInterface i)
Submits data for processing.
DataProvider::PipelineQueue::parent
DataProviderPipeline parent
Parent object.
Definition: DataProviderPipeline.qc.dox.h:156
DataProvider::DataProviderPipeline::stop_time
date stop_time
run stop time (set in waitDone())
Definition: DataProviderPipeline.qc.dox.h:217
DataProvider::DataProviderPipeline::abort
abort(*bool ignore_exceptions)
Aborts execution of a pipeline in progress.
DataProvider::PipelineQueue::elems
list< auto > elems()
Pipeline elements.
DataProvider::AbstractDataProviderRecordIterator
Defines the abstract class for data provider iterators; the destructor releases the iterator.
Definition: AbstractDataProviderRecordIterator.qc.dox.h:33
DataProvider::DataProviderPipeline::abort_flag
bool abort_flag
Abort flag.
Definition: DataProviderPipeline.qc.dox.h:243
DataProvider::PipelineOptionInfo
Pipeline option info.
Definition: DataProviderPipeline.qc.dox.h:92
DataProvider::DataProviderPipeline::copy
copy()
Copy constructor; creates an empty pipeline with the same configuration as the original.
DataProvider::PipelineQueue
Pipeline element.
Definition: DataProviderPipeline.qc.dox.h:118
DataProvider::DataProviderPipeline::error_list
list< hash< ExceptionInfo > > error_list
list of exceptions in pipelines
Definition: DataProviderPipeline.qc.dox.h:211
DataProvider::DataProviderPipeline::destructor
destructor()
Destroys the object.
DataProvider::DataProviderPipeline::thread_callback
*code thread_callback
a closure or call reference for setting thread-local data in new pipeline threads
Definition: DataProviderPipeline.qc.dox.h:234
DataProvider::PipelineQueue::queue_waiting
int queue_waiting
Number of threads waiting data to be removed from the queue.
Definition: DataProviderPipeline.qc.dox.h:134
DataProvider::DataProviderPipeline::waitDone
waitDone()
Waits for all queues in all pipelines to have processed remaining data.
DataProvider::AbstractDataProviderBulkRecordInterface
Defines the abstract class for data provider iterators; the destructor releases the iterator.
Definition: AbstractDataProviderBulkRecordInterface.qc.dox.h:33
DataProvider::DataProviderPipeline::submitData
submitData(AbstractIterator i)
Submits data for processing.
DataProvider::DataProviderPipeline::submitIntern
submitIntern(auto _data)
Submits data for processing.
DataProvider::PipelineInfo::stop_time
*date stop_time
Stop time for processing.
Definition: DataProviderPipeline.qc.dox.h:65
DataProvider::PipelineQueue::waitDone
waitDone()
Wait for the queue to be empty, then wait for all terminating pipelines to be empty.
DataProvider::PS_IDLE
const PS_IDLE
Pipeline status: IDLE.
Definition: DataProviderPipeline.qc.dox.h:43
DataProvider::PipelineQueue::size
int size
Maximum queue size.
Definition: DataProviderPipeline.qc.dox.h:143
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:85
DataProvider::DataProviderPipeline::reportError
reportError(PipelineQueue queue, hash< ExceptionInfo > ex)
Called from a pipeline queue object to report a fatal error durring processing.
DataProvider::DataProviderPipeline::checkLockedIntern
checkLockedIntern()
Throws an exception if the pipeline is locked.
DataProvider::PipelineQueue::id
int id
Pipeline ID.
Definition: DataProviderPipeline.qc.dox.h:122
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:223
DataProvider::PipelineInfo::recs_per_sec
float recs_per_sec
Records processed per second end to end.
Definition: DataProviderPipeline.qc.dox.h:88
DataProvider::DataProviderPipeline::throwPipelineException
throwPipelineException()
Throws an exception if errors occured in background pipeline processing.
DataProvider::DataProviderPipeline::checkUpdatePipelineIntern
checkUpdatePipelineIntern(int id)
Check if the given queue exists.
False
const False
DataProvider::DataProviderPipeline::stopInternUnlocked
stopInternUnlocked()
Stops all background pipeline queues; lock must be held.
DataProvider::PipelineQueue::tid
int tid
TID of the background thread.
Definition: DataProviderPipeline.qc.dox.h:146
DataProvider::DataProviderPipeline::submit
submit(AbstractDataProviderRecordIterator i)
Submits data for processing.
DataProvider::DataProviderPipeline::logDebug
logDebug(string fmt)
Logs to the debug log, if set.
DataProvider::DataProviderPipeline::checkSubmitIntern
checkSubmitIntern()
Throws an exception if the pipeline cannot be used; locks the pipeline for changes otherwise.
DataProvider::DataProviderPipeline::record_count
int record_count
Record count.
Definition: DataProviderPipeline.qc.dox.h:220
DataProvider::DataProviderPipeline::logInfo
logInfo(string fmt)
Logs to the info log, if set.
DataProvider::DataProviderPipeline::constructor
constructor(*hash< PipelineOptionInfo > opts)
Creates the object with the given options.
DataProvider::DataProviderPipeline::hasQueue
bool hasQueue(int id)
Returns True if the given queue exists, False if not.
DataProvider::DataProviderPipeline::getInfo
hash< PipelineInfo > getInfo()
Returns pipeline info.
DataProvider::DataProviderPipeline::seq
Sequence seq(1)
Pipeline ID sequence generator.
DataProvider::PipelineQueue::queue
list< auto > queue
Data queue.
Definition: DataProviderPipeline.qc.dox.h:140
DataProvider::DataProviderPipeline::cnt
Counter cnt()
Thread counter.
DataProvider::PipelineInfo::duration
date duration
Total time processing end to end.
Definition: DataProviderPipeline.qc.dox.h:82
date
date date(date dt)
DataProvider::DataProviderPipeline::submitDataIntern
submitDataIntern(auto _data)
Submits a single record for processing.
DataProvider::DataProviderPipeline
Defines a class for passing data through record processors.
Definition: DataProviderPipeline.qc.dox.h:189
DataProvider::PipelineInfo::name
string name
The name of the pipeline.
Definition: DataProviderPipeline.qc.dox.h:59
DataProvider::DataProviderPipeline::submitBulkIntern
submitBulkIntern(AbstractDataProviderBulkRecordInterface i)
Submits bulk data for processing.
DataProvider::PipelineQueue::cnt
Counter cnt
Parent counter.
Definition: DataProviderPipeline.qc.dox.h:128
DataProvider::PS_ABORTED
const PS_ABORTED
Pipeline status: ABORTED.
Definition: DataProviderPipeline.qc.dox.h:37
DataProvider::DataProviderPipeline::lck
Mutex lck()
Atomic lock.
DataProvider::DataProviderPipeline::stopIntern
stopIntern()
Stops all background pipeline queues.
DataProvider::DataProviderPipeline::stopping
bool stopping()
Returns True if the object is stopping.
DataProvider::DataProviderPipeline::registerThread
registerThread(PipelineQueue queue)
Registers a new thread.
DataProvider::PipelineInfo::bulk
bool bulk
Flag that indicates if the pipeline is capable of bulk record processing.
Definition: DataProviderPipeline.qc.dox.h:79
DataProvider::DataProviderPipeline::resetIntern
resetIntern()
Resets the pipeline.