InfluxLogReader
class InfluxLogReader : public DataLogReader
Functions
| Name | Description |
|---|---|
| asyncDataCountForProperty | Triggers the retrieval of the number of data points for a given device property during a time interval. |
| onDataCountForProperty | Handles the retrieval of the number of data points for an ongoing GetPropertyHistory process. |
| asyncGetPropertyValues | Triggers the retrieval of the property values in an ongoing GetPropertyHistory process. |
| asyncGetPropertyValuesMean | Triggers the retrieval of the property values mean in an ongoing GetPropertyHistory process. |
| asyncGetPropertyValuesSamples | Triggers the retrieval of the property values samples in an ongoing GetPropertyHistory process. |
| onPropertyValues | Handles the retrieval of the values of a property in an ongoing GetPropertyHistory process. |
| onMeanPropertyValues | Handles the retrieval of the values of a property in an ongoing GetPropertyHistory process. |
| unescapeLoggedString | Unescapes a logged string. |
| preHandleHttpResponse | Performs an initial common handling of an HTTP response received by the Log Reader. |
| toEpoch | Convert a time point from influx to karabo Epochstamp |
| buildInfluxClientConfig | Builds and returns the configuration Hash for instantiating an InfluxDbClient to be used in the execution of one of the slots supported by the reader. |
Function Details
asyncDataCountForProperty
void asyncDataCountForProperty(const std::shared_ptr<PropertyHistoryContext>& context)
Triggers the retrieval of the number of data points for a given device property during a time interval.
context
:
asyncGetPropertyValues
void asyncGetPropertyValues(const std::shared_ptr<PropertyHistoryContext>& ctxt)
Triggers the retrieval of the property values in an ongoing GetPropertyHistory process.
context
:
asyncGetPropertyValuesMean
void asyncGetPropertyValuesMean(const std::shared_ptr<PropertyHistoryContext>& ctxt)
Triggers the retrieval of the property values mean in an ongoing GetPropertyHistory process. This is used when the number of available data points for the property is larger than the maximum requested by the slot caller and all values are scalar numbers. The UINT64 properties are included in this despite being reinterpreted as INT64 on the backend and possibly returning incorrect data.
context
:
asyncGetPropertyValuesSamples
void asyncGetPropertyValuesSamples(const std::shared_ptr<PropertyHistoryContext>& ctxt)
Triggers the retrieval of the property values samples in an ongoing GetPropertyHistory process. This is used when the number of available data points for the property is larger than the maximum requested by the slot caller.
context
:
buildInfluxClientConfig
karabo::data::Hash buildInfluxClientConfig(const std::string& dbUrlForSlot) const
Builds and returns the configuration Hash for instantiating an InfluxDbClient to be used in the execution of one of the slots supported by the reader.
dbUrlForSlot
: the URL to be used in the configuration - each slot can use a
different database URL.
Return : the configuration Hash for the InfluxDbClient.
onDataCountForProperty
void onDataCountForProperty(const karabo::net::HttpResponse& dataCountResp, const std::shared_ptr<PropertyHistoryContext>& ctxt)
Handles the retrieval of the number of data points for an ongoing GetPropertyHistory process. Responsible for invoking the appropriate async method for retrieving the property values depending on the number of data points received.
dataCountResponse
:
context
:
onMeanPropertyValues
void onMeanPropertyValues(const karabo::net::HttpResponse& valuesResp, const std::shared_ptr<PropertyHistoryContext>& ctxt)
Handles the retrieval of the values of a property in an ongoing GetPropertyHistory
process. Responsible for transforming the json formatted values received from
InfluxDbClient into a vector of hashes suitable to be returned to the slot caller.
This function extends the functionality of onPropertyValues while keeping the
property history protocol.
Also responsible for replying to the slot caller.
valuesResp
:
context
:
onPropertyValues
void onPropertyValues(const karabo::net::HttpResponse& valuesResp, const std::string& columnPrefixToRemove, const std::shared_ptr<PropertyHistoryContext>& ctxt)
Handles the retrieval of the values of a property in an ongoing GetPropertyHistory process. Responsible for transforming the json formatted values received from InfluxDbClient into a vector of hashes suitable to be returned to the slot caller. Also responsible for replying to the slot caller.
valuesResp
:
columnPrefixToRemove
:
context
:
preHandleHttpResponse
bool preHandleHttpResponse(const karabo::net::HttpResponse& httpResponse, const karabo::xms::SignalSlotable::AsyncReply& asyncReply)
Performs an initial common handling of an HTTP response received by the Log Reader.
In the InfluxDb client <-> server communication context, any response with a status code greater or equal to 300 is considered an error and will be completely handled by this method. A specific status code, 503, indicates that the InfluxDb server was not available and puts the Log Reader in ERROR state. Any other error puts the Log Reader in ON state.
The error handling consists of sending the appropriate error reply to the caller of the InfluxLogReader slot affected by the error and of optionally disconnecting the InfluxDbClient used by the slot.
httpResponse
: the response that potentially indicates an error.
asyncReply
: the reply to be sent to the caller of the slot where the error
happened.
Return : true if the preHandle method completely processed the HttpResponse and no further action from the Log Reader is needed. This is the case for responses with status codes indicating errors. false if the response should still be processed by the response handler that called preHandleHttpResponse.
toEpoch
karabo::data::Epochstamp toEpoch(unsigned long long timeFromInflux) const
Convert a time point from influx to karabo Epochstamp
unescapeLoggedString
std::string unescapeLoggedString(const std::string& loggedStr)
Unescapes a logged string. A logged string has its new lines mangled, then its double slashes escaped and then its double quotes escaped. This functions applies those transformations in the reverse order.
loggedStr
: The string as it has been escaped by the Influx Logger.
Return : The unescaped original string.