nidas v1.2.3
|
Methods and memory for creating an Influx database, accumulating measurements, and posting them to the database. More...
Public Member Functions | |
InfluxDB (const std::string &url="", const std::string &dbname="") | |
bool | isOpen () |
void | open () |
Initialize for http database connections. | |
void | setURL (const std::string &url) |
void | setDatabase (const std::string &dbname) |
std::string | getDatabase () |
void | setUser (const std::string &username, const std::string &passwordfile) |
Set username to use for the http connection. | |
std::string | getAuth (const std::string &prefix="") |
void | setCount (unsigned int count) |
void | setEcho (bool echo) |
If echo is true, the data posted to the database is printed on stdout instead of being written to the database. | |
void | setAsync (bool enable) |
If enable is true, data will be posted to the database asynchronously. | |
~InfluxDB () | |
std::string | getHostURL () |
std::string | getWriteURL () |
std::string | getErrors () |
bool | addMeasurement (const std::string &data) |
Return false if there is an error adding this measurement. | |
bool | sendData () |
unsigned int | totalMeasurements () |
Return the total number of measurements written to the database so far. | |
void | flush () |
Send whatever is left in the current buffer and wait for it to finish. | |
void | createInfluxDB () |
void | handleResult (CURLcode res) |
Private Member Functions | |
InfluxDB (const InfluxDB &) | |
InfluxDB & | operator= (const InfluxDB &) |
Private Attributes | |
string | _url |
string | _dbname |
string | _username |
string | _password |
CharBuffer * | _data |
CharBuffer | _data1 |
CharBuffer | _data2 |
CharBuffer | _result |
string | _errs |
unsigned int | _nmeasurements |
unsigned int | _total_measurements |
unsigned int | _count |
bool | _echo |
bool | _async |
CURL * | _curl |
char | _curl_errors [CURL_ERROR_SIZE] |
std::future< CURLcode > | _post |
Methods and memory for creating an Influx database, accumulating measurements, and posting them to the database.
The host URL is something like "http://snoopy.eol.ucar.edu:8086"
The database URL is formed like "<url>/write?db=<dbname>&precision=u"
|
inline |
References _curl, and nidas::core::getSample().
Return false if there is an error adding this measurement.
If enough measurements have accumulated, then this will post the current buffer to the database. If there is an error, the description will be in getError().
References _count, _data, _nmeasurements, nidas::core::getSample(), CharBuffer::getSpace(), sendData(), and VLOG.
Referenced by SampleToDatabase::accumulate().
void InfluxDB::createInfluxDB | ( | ) |
References _curl, _dbname, _errs, getAuth(), getHostURL(), nidas::core::getSample(), handleResult(), ILOG, and open().
|
inline |
Send whatever is left in the current buffer and wait for it to finish.
References getErrors(), ILOG, and sendData().
|
inline |
References _password, _username, and nidas::core::getSample().
Referenced by createInfluxDB(), and getWriteURL().
|
inline |
References _dbname.
|
inline |
References _errs.
Referenced by SampleToDatabase::accumulate(), and flush().
|
inline |
References _url.
Referenced by createInfluxDB(), and getWriteURL().
|
inline |
References _dbname, getAuth(), getHostURL(), and nidas::core::getSample().
Referenced by sendData().
References _curl_errors, _errs, _result, CharBuffer::clear(), DLOG, CharBuffer::empty(), CharBuffer::get(), and nidas::core::getSample().
Referenced by createInfluxDB(), and sendData().
|
inline |
References _curl.
Referenced by open(), and sendData().
|
inline |
Initialize for http database connections.
No database actions can be performed before this initialization happens, but the initialization only happens once. This will be called implicitly by other methods which need http. Do not call it if the database will not actually be used, such as when echo is enabled.
References _curl, _curl_errors, _result, nidas::core::getSample(), isOpen(), and writeInfluxResult().
Referenced by createInfluxDB(), and sendData().
|
inline |
References _async, _curl, _data, _data1, _data2, _echo, _errs, _nmeasurements, _post, _total_measurements, CharBuffer::clear(), dataToInfluxDB(), DLOG, CharBuffer::empty(), CharBuffer::get(), nidas::core::getSample(), getWriteURL(), handleResult(), isOpen(), and open().
Referenced by addMeasurement(), and flush().
If enable
is true, data will be posted to the database asynchronously.
References _async.
References _dbname, and nidas::core::getSample().
If echo
is true, the data posted to the database is printed on stdout instead of being written to the database.
References _echo, and nidas::core::getSample().
References _url, and nidas::core::getSample().
Set username
to use for the http connection.
If passwordfile
is not empty, then open the file at the given path to read the password.
References _password, _username, nidas::core::getSample(), and ILOG.
Return the total number of measurements written to the database so far.
This does not include the measurements currently in the buffer and not yet written.
References _total_measurements.
|
private |
Referenced by sendData(), and setAsync().
Referenced by addMeasurement(), and setCount().
|
private |
Referenced by createInfluxDB(), isOpen(), open(), sendData(), and ~InfluxDB().
|
private |
Referenced by handleResult(), and open().
|
private |
Referenced by addMeasurement(), InfluxDB(), and sendData().
|
private |
Referenced by InfluxDB(), and sendData().
|
private |
Referenced by sendData().
|
private |
Referenced by createInfluxDB(), getDatabase(), getWriteURL(), and setDatabase().
|
private |
Referenced by sendData(), and setEcho().
|
private |
Referenced by createInfluxDB(), getErrors(), handleResult(), and sendData().
Referenced by addMeasurement(), and sendData().
|
private |
Referenced by sendData().
|
private |
Referenced by handleResult(), and open().
Referenced by sendData(), and totalMeasurements().
|
private |
Referenced by getHostURL(), and setURL().