C++ common classes
General purpose classes for use across projects (Apache license)
|
#include <CDBPublisher.h>
Public Member Functions | |
CDBPublisher () | |
virtual | ~CDBPublisher () |
void | StartPublishing (const char *pDatabase, const char *pCollection, VEC_DB_KEYS &vKeys, const char *pHost, const char *pUser, const char *pPassword) |
to ensure that the indices exist in the collection. Starts publishing thread. | |
void | StopPublishing () |
Stop publishing. Stops the publishing thread. | |
bool | Publish (CDBRecordsArray &cRecords) |
DBStats & | GetDBStats () |
void | SetUpsert (bool bOnOff) |
bool | GetUpsert () |
See if the upsert flag is set. | |
Public Attributes | |
time_t | tLastPublished |
Our last published timestamp. | |
Protected Member Functions | |
virtual unsigned | WorkerFunction (void *pParam) |
Called by CXPlatThread to start work in object context. | |
Protected Attributes | |
DBStats | cDBStats |
CXPlatCriticalSection | cPublishMutex |
CXPlatEvent | cStartEvent |
string | sHost |
string | sUser |
string | sPassword |
bool | bTerminate |
string | sDatabase |
VEC_DB_RECORDS | vDBRecords |
VEC_DB_KEYS | vKeys |
string | sCollection |
string | sDB_Collection |
Static Protected Attributes | |
static DBStats | cDBCopy |
CDBPublisher - publisher thread This class takes a set of records to be published to the MongoDB and writes them in bulk on a schedule
Definition at line 63 of file CDBPublisher.h.
Definition at line 26 of file CDBPublisher.cpp.
CDBPublisher::~CDBPublisher | ( | ) | [virtual] |
Definition at line 34 of file CDBPublisher.cpp.
Get and clear statistics. This returns a call to a static variable, which means the next call changes it.
Definition at line 215 of file CDBPublisher.cpp.
bool CDBPublisher::GetUpsert | ( | ) |
See if the upsert flag is set.
Definition at line 76 of file CDBPublisher.cpp.
bool CDBPublisher::Publish | ( | CDBRecordsArray & | cRecords | ) |
Publish records. This will copy the data from the passed in array, clear the array, and return immediately while connecting and writing in the background.
Definition at line 83 of file CDBPublisher.cpp.
void CDBPublisher::SetUpsert | ( | bool | bOnOff | ) |
Set upsert. Since Mongo doesn't have an "upsert" per se, this is a very expensive setting, performance wise. It will bulk delete all records before an insert is done.
Definition at line 70 of file CDBPublisher.cpp.
void CDBPublisher::StartPublishing | ( | const char * | pDatabase, |
const char * | pCollection, | ||
VEC_DB_KEYS & | vKeys, | ||
const char * | pHost, | ||
const char * | pUser, | ||
const char * | pPassword | ||
) |
to ensure that the indices exist in the collection. Starts publishing thread.
Set DB config. vKeys is an array of index strings (JSON, ex. "{'node': 1 }")
Definition at line 42 of file CDBPublisher.cpp.
Stop publishing. Stops the publishing thread.
Definition at line 60 of file CDBPublisher.cpp.
unsigned CDBPublisher::WorkerFunction | ( | void * | pParam | ) | [protected, virtual] |
Called by CXPlatThread to start work in object context.
Implements CXPlatThread.
Definition at line 113 of file CDBPublisher.cpp.
bool CDBPublisher::bTerminate [protected] |
Definition at line 102 of file CDBPublisher.h.
DBStats CDBPublisher::cDBCopy [static, protected] |
Definition at line 96 of file CDBPublisher.h.
DBStats CDBPublisher::cDBStats [protected] |
Definition at line 95 of file CDBPublisher.h.
CXPlatCriticalSection CDBPublisher::cPublishMutex [protected] |
Definition at line 97 of file CDBPublisher.h.
CXPlatEvent CDBPublisher::cStartEvent [protected] |
Definition at line 98 of file CDBPublisher.h.
string CDBPublisher::sCollection [protected] |
Definition at line 106 of file CDBPublisher.h.
string CDBPublisher::sDatabase [protected] |
Definition at line 103 of file CDBPublisher.h.
string CDBPublisher::sDB_Collection [protected] |
Definition at line 107 of file CDBPublisher.h.
string CDBPublisher::sHost [protected] |
Definition at line 99 of file CDBPublisher.h.
string CDBPublisher::sPassword [protected] |
Definition at line 101 of file CDBPublisher.h.
string CDBPublisher::sUser [protected] |
Definition at line 100 of file CDBPublisher.h.
time_t CDBPublisher::tLastPublished |
Our last published timestamp.
Definition at line 89 of file CDBPublisher.h.
VEC_DB_RECORDS CDBPublisher::vDBRecords [protected] |
Definition at line 104 of file CDBPublisher.h.
VEC_DB_KEYS CDBPublisher::vKeys [protected] |
Definition at line 105 of file CDBPublisher.h.