Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
dcdb
dcdb
Commits
6516c02f
Commit
6516c02f
authored
May 29, 2019
by
Alessio Netti
Browse files
Fixes after merge of master branch
- Changes mostly affect the REST API
parent
3b74a90b
Changes
7
Hide whitespace changes
Inline
Side-by-side
analytics/AnalyticsManager.cpp
View file @
6516c02f
...
@@ -343,7 +343,7 @@ void AnalyticsManager::GET_analytics_sensors(endpointArgs) {
...
@@ -343,7 +343,7 @@ void AnalyticsManager::GET_analytics_sensors(endpointArgs) {
for
(
const
auto
&
s
:
u
->
getBaseOutputs
())
{
for
(
const
auto
&
s
:
u
->
getBaseOutputs
())
{
// Explicitly adding nodes to the ptree as to prevent BOOST from performing
// Explicitly adding nodes to the ptree as to prevent BOOST from performing
// parsing on the node names
// parsing on the node names
group
.
push_back
(
boost
::
property_tree
::
ptree
::
value_type
(
s
->
getName
()
,
boost
::
property_tree
::
ptree
(
s
->
getMqtt
())));
group
.
push_back
(
boost
::
property_tree
::
ptree
::
value_type
(
""
,
boost
::
property_tree
::
ptree
(
s
->
getMqtt
())));
}
}
}
}
sensors
.
add_child
(
a
->
getName
(),
group
);
sensors
.
add_child
(
a
->
getName
(),
group
);
...
@@ -357,7 +357,7 @@ void AnalyticsManager::GET_analytics_sensors(endpointArgs) {
...
@@ -357,7 +357,7 @@ void AnalyticsManager::GET_analytics_sensors(endpointArgs) {
found
=
true
;
found
=
true
;
for
(
const
auto
&
u
:
a
->
getUnits
())
{
for
(
const
auto
&
u
:
a
->
getUnits
())
{
for
(
const
auto
&
s
:
u
->
getBaseOutputs
())
{
for
(
const
auto
&
s
:
u
->
getBaseOutputs
())
{
data
<<
a
->
getName
()
<<
"
."
<<
s
->
getName
()
<<
"
"
<<
s
->
getMqtt
()
<<
"
\n
"
;
data
<<
a
->
getName
()
<<
"
::
"
<<
s
->
getMqtt
()
<<
"
\n
"
;
}
}
}
}
}
}
...
@@ -400,7 +400,7 @@ void AnalyticsManager::GET_analytics_units(endpointArgs) {
...
@@ -400,7 +400,7 @@ void AnalyticsManager::GET_analytics_units(endpointArgs) {
found
=
true
;
found
=
true
;
boost
::
property_tree
::
ptree
group
;
boost
::
property_tree
::
ptree
group
;
for
(
const
auto
&
u
:
a
->
getUnits
())
{
for
(
const
auto
&
u
:
a
->
getUnits
())
{
group
.
push_back
(
boost
::
property_tree
::
ptree
::
value_type
(
u
->
getName
()
,
boost
::
property_tree
::
ptree
()));
group
.
push_back
(
boost
::
property_tree
::
ptree
::
value_type
(
""
,
boost
::
property_tree
::
ptree
(
u
->
getName
()
)));
}
}
units
.
add_child
(
a
->
getName
(),
group
);
units
.
add_child
(
a
->
getName
(),
group
);
}
}
...
@@ -411,7 +411,7 @@ void AnalyticsManager::GET_analytics_units(endpointArgs) {
...
@@ -411,7 +411,7 @@ void AnalyticsManager::GET_analytics_units(endpointArgs) {
if
(
a
->
getStreaming
()
&&
(
analyzer
==
""
||
analyzer
==
a
->
getName
()))
{
if
(
a
->
getStreaming
()
&&
(
analyzer
==
""
||
analyzer
==
a
->
getName
()))
{
found
=
true
;
found
=
true
;
for
(
const
auto
&
u
:
a
->
getUnits
())
{
for
(
const
auto
&
u
:
a
->
getUnits
())
{
data
<<
a
->
getName
()
<<
"
.
"
<<
u
->
getName
()
<<
"
\n
"
;
data
<<
a
->
getName
()
<<
"
::
"
<<
u
->
getName
()
<<
"
\n
"
;
}
}
}
}
}
}
...
@@ -535,7 +535,7 @@ void AnalyticsManager::PUT_analytics_compute(endpointArgs) {
...
@@ -535,7 +535,7 @@ void AnalyticsManager::PUT_analytics_compute(endpointArgs) {
const
std
::
string
plugin
=
getQuery
(
"plugin"
,
queries
);
const
std
::
string
plugin
=
getQuery
(
"plugin"
,
queries
);
const
std
::
string
analyzer
=
getQuery
(
"analyzer"
,
queries
);
const
std
::
string
analyzer
=
getQuery
(
"analyzer"
,
queries
);
std
::
string
unit
=
getQuery
(
"unit"
,
queries
);
std
::
string
unit
=
MQTTChecker
::
nameToTopic
(
getQuery
(
"unit"
,
queries
)
)
;
if
(
plugin
==
""
||
analyzer
==
""
)
{
if
(
plugin
==
""
||
analyzer
==
""
)
{
res
.
body
()
=
"Request malformed: plugin or analyzer query missing
\n
"
;
res
.
body
()
=
"Request malformed: plugin or analyzer query missing
\n
"
;
...
...
collectagent/CARestAPI.cpp
View file @
6516c02f
...
@@ -34,7 +34,7 @@ void CARestAPI::GET_help(endpointArgs) {
...
@@ -34,7 +34,7 @@ void CARestAPI::GET_help(endpointArgs) {
}
}
void
CARestAPI
::
GET_average
(
endpointArgs
)
{
void
CARestAPI
::
GET_average
(
endpointArgs
)
{
const
std
::
string
sensor
=
getQuery
(
"sensor"
,
queries
);
const
std
::
string
sensor
=
MQTTChecker
::
nameToTopic
(
getQuery
(
"sensor"
,
queries
)
)
;
const
std
::
string
interval
=
getQuery
(
"interval"
,
queries
);
const
std
::
string
interval
=
getQuery
(
"interval"
,
queries
);
if
(
sensor
==
""
)
{
if
(
sensor
==
""
)
{
...
@@ -58,7 +58,6 @@ void CARestAPI::GET_average(endpointArgs) {
...
@@ -58,7 +58,6 @@ void CARestAPI::GET_average(endpointArgs) {
//try getting the latest value
//try getting the latest value
try
{
try
{
//TODO: switch from SID input to sensor name input
int64_t
val
=
_sensorCache
->
getSensor
(
sensor
,
(
uint64_t
)
time
*
1000000000
);
int64_t
val
=
_sensorCache
->
getSensor
(
sensor
,
(
uint64_t
)
time
*
1000000000
);
res
.
body
()
=
"collectagent::"
+
sensor
+
" Average of last "
+
res
.
body
()
=
"collectagent::"
+
sensor
+
" Average of last "
+
...
...
collectagent/CARestAPI.h
View file @
6516c02f
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
#include "RESTHttpsServer.h"
#include "RESTHttpsServer.h"
#include "analyticscontroller.h"
#include "analyticscontroller.h"
#include "mqttchecker.h"
class
CARestAPI
:
public
RESTHttpsServer
{
class
CARestAPI
:
public
RESTHttpsServer
{
public:
public:
...
...
dcdbpusher/MQTTPusher.cpp
View file @
6516c02f
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#include <unistd.h>
#include <unistd.h>
#include "timestamp.h"
#include "timestamp.h"
MQTTPusher
::
MQTTPusher
(
int
brokerPort
,
const
std
::
string
&
brokerHost
,
const
std
::
string
&
sensorPattern
,
int
qosLevel
,
MQTTPusher
::
MQTTPusher
(
int
brokerPort
,
const
std
::
string
&
brokerHost
,
const
bool
autoPublish
,
int
qosLevel
,
pusherPluginStorage_t
&
plugins
,
an_pluginVector_t
&
aPlugins
,
int
maxNumberOfMessages
,
unsigned
int
maxInflightMsgNum
,
unsigned
int
maxQueuedMsgNum
)
:
pusherPluginStorage_t
&
plugins
,
an_pluginVector_t
&
aPlugins
,
int
maxNumberOfMessages
,
unsigned
int
maxInflightMsgNum
,
unsigned
int
maxQueuedMsgNum
)
:
_qosLevel
(
qosLevel
),
_qosLevel
(
qosLevel
),
_brokerPort
(
brokerPort
),
_brokerPort
(
brokerPort
),
...
...
dcdbpusher/MQTTPusher.h
View file @
6516c02f
...
@@ -24,7 +24,7 @@ enum msgCap_t {DISABLED = 1, ENABLED = 2, MINIMUM = 3};
...
@@ -24,7 +24,7 @@ enum msgCap_t {DISABLED = 1, ENABLED = 2, MINIMUM = 3};
*/
*/
class
MQTTPusher
{
class
MQTTPusher
{
public:
public:
MQTTPusher
(
int
brokerPort
,
const
std
::
string
&
brokerHost
,
const
std
::
string
&
sensorPattern
,
int
qosLevel
,
MQTTPusher
(
int
brokerPort
,
const
std
::
string
&
brokerHost
,
const
bool
autoPublish
,
int
qosLevel
,
pusherPluginStorage_t
&
plugins
,
an_pluginVector_t
&
aPlugins
,
int
maxNumberOfMessages
,
unsigned
int
maxInflightMsgNum
,
unsigned
int
maxQueuedMsgNum
);
pusherPluginStorage_t
&
plugins
,
an_pluginVector_t
&
aPlugins
,
int
maxNumberOfMessages
,
unsigned
int
maxInflightMsgNum
,
unsigned
int
maxQueuedMsgNum
);
virtual
~
MQTTPusher
();
virtual
~
MQTTPusher
();
...
@@ -88,7 +88,7 @@ private:
...
@@ -88,7 +88,7 @@ private:
int
_qosLevel
;
int
_qosLevel
;
int
_brokerPort
;
int
_brokerPort
;
std
::
string
_brokerHost
;
std
::
string
_brokerHost
;
std
::
string
_sensorPattern
;
bool
_autoPublish
;
pusherPluginStorage_t
&
_plugins
;
pusherPluginStorage_t
&
_plugins
;
an_pluginVector_t
&
_analyticsPlugins
;
an_pluginVector_t
&
_analyticsPlugins
;
struct
mosquitto
*
_mosq
;
struct
mosquitto
*
_mosq
;
...
...
dcdbpusher/RestAPI.cpp
View file @
6516c02f
...
@@ -84,7 +84,7 @@ void RestAPI::GET_sensors(endpointArgs) {
...
@@ -84,7 +84,7 @@ void RestAPI::GET_sensors(endpointArgs) {
for
(
const
auto
&
g
:
p
.
configurator
->
getSensorGroups
())
{
for
(
const
auto
&
g
:
p
.
configurator
->
getSensorGroups
())
{
boost
::
property_tree
::
ptree
group
;
boost
::
property_tree
::
ptree
group
;
for
(
const
auto
&
s
:
g
->
getSensors
())
{
for
(
const
auto
&
s
:
g
->
getSensors
())
{
group
.
pu
t
(
s
->
getName
(),
s
->
getMqtt
());
group
.
pu
sh_back
(
boost
::
property_tree
::
ptree
::
value_type
(
""
,
boost
::
property_tree
::
ptree
(
s
->
getMqtt
())
))
;
}
}
sensors
.
add_child
(
g
->
getGroupName
(),
group
);
sensors
.
add_child
(
g
->
getGroupName
(),
group
);
}
}
...
@@ -93,7 +93,7 @@ void RestAPI::GET_sensors(endpointArgs) {
...
@@ -93,7 +93,7 @@ void RestAPI::GET_sensors(endpointArgs) {
}
else
{
}
else
{
for
(
const
auto
&
g
:
p
.
configurator
->
getSensorGroups
())
{
for
(
const
auto
&
g
:
p
.
configurator
->
getSensorGroups
())
{
for
(
const
auto
&
s
:
g
->
getSensors
())
{
for
(
const
auto
&
s
:
g
->
getSensors
())
{
data
<<
g
->
getGroupName
()
<<
"
."
<<
s
->
getName
()
<<
"
"
<<
s
->
getMqtt
()
<<
"
\n
"
;
data
<<
g
->
getGroupName
()
<<
"
::
"
<<
s
->
getMqtt
()
<<
"
\n
"
;
}
}
}
}
}
}
...
@@ -106,7 +106,7 @@ void RestAPI::GET_sensors(endpointArgs) {
...
@@ -106,7 +106,7 @@ void RestAPI::GET_sensors(endpointArgs) {
void
RestAPI
::
GET_average
(
endpointArgs
)
{
void
RestAPI
::
GET_average
(
endpointArgs
)
{
const
std
::
string
plugin
=
getQuery
(
"plugin"
,
queries
);
const
std
::
string
plugin
=
getQuery
(
"plugin"
,
queries
);
const
std
::
string
sensor
=
getQuery
(
"sensor"
,
queries
);
const
std
::
string
sensor
=
MQTTChecker
::
nameToTopic
(
getQuery
(
"sensor"
,
queries
)
)
;
const
std
::
string
interval
=
getQuery
(
"interval"
,
queries
);
const
std
::
string
interval
=
getQuery
(
"interval"
,
queries
);
if
(
plugin
==
""
||
sensor
==
""
)
{
if
(
plugin
==
""
||
sensor
==
""
)
{
...
...
dcdbpusher/dcdbpusher.cpp
View file @
6516c02f
...
@@ -266,7 +266,7 @@ int main(int argc, char** argv) {
...
@@ -266,7 +266,7 @@ int main(int argc, char** argv) {
// Preparing the SensorNavigator
// Preparing the SensorNavigator
if
(
_analyticsManager
->
probe
(
argv
[
argc
-
1
],
"dcdbpusher.conf"
))
{
if
(
_analyticsManager
->
probe
(
argv
[
argc
-
1
],
"dcdbpusher.conf"
))
{
std
::
shared_ptr
<
SensorNavigator
>
navigator
=
std
::
make_shared
<
SensorNavigator
>
();
std
::
shared_ptr
<
SensorNavigator
>
navigator
=
std
::
make_shared
<
SensorNavigator
>
();
vector
<
std
::
string
>
names
,
topics
;
vector
<
std
::
string
>
topics
;
for
(
const
auto
&
p
:
_pluginManager
->
getPlugins
())
for
(
const
auto
&
p
:
_pluginManager
->
getPlugins
())
for
(
const
auto
&
g
:
p
.
configurator
->
getSensorGroups
())
for
(
const
auto
&
g
:
p
.
configurator
->
getSensorGroups
())
for
(
const
auto
&
s
:
g
->
getSensors
())
for
(
const
auto
&
s
:
g
->
getSensors
())
...
@@ -345,7 +345,7 @@ int main(int argc, char** argv) {
...
@@ -345,7 +345,7 @@ int main(int argc, char** argv) {
}
}
//MQTTPusher and Https server get their own threads
//MQTTPusher and Https server get their own threads
_mqttPusher
=
new
MQTTPusher
(
globalSettings
.
brokerPort
,
globalSettings
.
brokerHost
,
pluginSettings
.
sensorPattern
,
globalSettings
.
qosLevel
,
_mqttPusher
=
new
MQTTPusher
(
globalSettings
.
brokerPort
,
globalSettings
.
brokerHost
,
pluginSettings
.
autoPublish
,
globalSettings
.
qosLevel
,
_pluginManager
->
getPlugins
(),
_analyticsManager
->
getPlugins
(),
globalSettings
.
maxMsgNum
,
globalSettings
.
maxInflightMsgNum
,
globalSettings
.
maxQueuedMsgNum
);
_pluginManager
->
getPlugins
(),
_analyticsManager
->
getPlugins
(),
globalSettings
.
maxMsgNum
,
globalSettings
.
maxInflightMsgNum
,
globalSettings
.
maxQueuedMsgNum
);
_httpsServer
=
new
RestAPI
(
restAPISettings
,
_pluginManager
,
_mqttPusher
,
_analyticsManager
,
io
);
_httpsServer
=
new
RestAPI
(
restAPISettings
,
_pluginManager
,
_mqttPusher
,
_analyticsManager
,
io
);
_configuration
->
readRestAPIUsers
(
_httpsServer
);
_configuration
->
readRestAPIUsers
(
_httpsServer
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment