Commit 8b50c2b6 authored by Daniele Tafani's avatar Daniele Tafani
Browse files

Fixed typos and config

parent a42ae915
...@@ -214,7 +214,6 @@ int main(int argc, char *argv[]) ...@@ -214,7 +214,6 @@ int main(int argc, char *argv[])
} }
_httpsServer = new RestAPI(restAPISettings, hierarchySettings, _cassandraConnection); _httpsServer = new RestAPI(restAPISettings, hierarchySettings, _cassandraConnection);
//_httpsServer = new RestAPI(restAPISettings, hierarchySettings);
_configuration->readRestAPIUsers(_httpsServer); _configuration->readRestAPIUsers(_httpsServer);
if (globalSettings.daemonize) { if (globalSettings.daemonize) {
...@@ -260,11 +259,12 @@ int main(int argc, char *argv[]) ...@@ -260,11 +259,12 @@ int main(int argc, char *argv[])
LOG(trace) << "Running..."; LOG(trace) << "Running...";
//Run until Strg+C //Run until Strg+C
// threads.join_all(); threads.join_all();
//will only continue if interrupted by SIGINT and threads were stopped //will only continue if interrupted by SIGINT and threads were stopped
LOG(info) << "Tearing down objects..."; LOG(info) << "Tearing down objects...";
delete _cassandraConnection;
delete _httpsServer; delete _httpsServer;
LOG(info) << "Exiting...Goodbye!"; LOG(info) << "Exiting...Goodbye!";
......
...@@ -36,11 +36,11 @@ ...@@ -36,11 +36,11 @@
std::placeholders::_2, \ std::placeholders::_2, \
std::placeholders::_3) std::placeholders::_3)
DCDB::Connection* conn;
RestAPI::RestAPI(serverSettings_t settings, RestAPI::RestAPI(serverSettings_t settings,
hierarchySettings_t hierarchySettings) : hierarchySettings_t hierarchySettings,
RESTHttpsServer(settings) { DCDB::Connection* cassandraConnection) :
RESTHttpsServer(settings),
_connection(cassandraConnection) {
//Configuring endpoints //Configuring endpoints
addEndpoint("/", {http::verb::get, stdBind(GET_datasource)}); addEndpoint("/", {http::verb::get, stdBind(GET_datasource)});
...@@ -48,43 +48,26 @@ RestAPI::RestAPI(serverSettings_t settings, ...@@ -48,43 +48,26 @@ RestAPI::RestAPI(serverSettings_t settings,
addEndpoint("/search", {http::verb::post, stdBind(POST_search)}); addEndpoint("/search", {http::verb::post, stdBind(POST_search)});
addEndpoint("/query", {http::verb::post, stdBind(POST_query)}); addEndpoint("/query", {http::verb::post, stdBind(POST_query)});
//_connection = cassandraConnection; LOG(info) << "Retrieving published sensor names and topics...";
std::cout << "Trying connecting..." << std::endl;
conn = new DCDB::Connection(); //Get the list of all public sensors and topics.
conn->setHostname("127.0.0.1"); std::list<DCDB::PublicSensor> publicSensors;
conn->setPort(atoi("9042")); _sensorConfig = new DCDB::SensorConfig(_connection);
_sensorConfig->getPublicSensorsVerbose(publicSensors);
// if (!conn->connect()) { std::vector<std::string> sensors;
// LOG(fatal) << "Failed to connect to the Cassandra database!"; std::vector<std::string> topics;
// }
LOG(info) << "Retrieving published sensor names and topics..."; for(auto& s : publicSensors) {
sensors.push_back(s.name);
topics.push_back(s.pattern);
}
//Get the list of all public sensors and topics. //Build the tree navigator
// std::list<DCDB::PublicSensor> publicSensors; LOG(info) << "Building the sensor navigator...";
// DCDB::SensorConfig sensorConfig(conn);
//sensorConfig.getPublicSensorsVerbose(publicSensors);
//_sensorConfig = new DCDB::SensorConfig(cassandraConnection); _navigator = new SensorNavigator();
//_sensorConfig->getPublicSensorsVerbose(publicSensors); _navigator->buildTree(hierarchySettings.regex, &sensors, &topics, hierarchySettings.separator);
//
// std::vector<std::string> sensors;
// std::vector<std::string> topics;
//
// for(auto& s : publicSensors) {
// sensors.push_back(s.name);
// topics.push_back(s.pattern);
// }
//
// //Build the tree navigator
// LOG(info) << "Building the sensor navigator...";
//
// _navigator = new SensorNavigator();
// std::cout << "Ok" << std::endl;
// _navigator->buildTree(hierarchySettings.regex, &sensors, &topics, hierarchySettings.separator);
// std::cout << "Ok" << std::endl;
} }
//Dummy GET request to create a datasource. All necessary checks that could be peformed here are //Dummy GET request to create a datasource. All necessary checks that could be peformed here are
...@@ -220,12 +203,8 @@ void::RestAPI::POST_query(endpointArgs) { ...@@ -220,12 +203,8 @@ void::RestAPI::POST_query(endpointArgs) {
for(auto& sensorName : sensors) { for(auto& sensorName : sensors) {
// DCDB::SensorConfig sc(_connection); DCDB::Sensor sensor(_connection, sensorName);
// DCDB::Sensor sensor(_connection, sensorName); _sensorConfig->getPublicSensorByName(ps,sensorName.c_str());
DCDB::SensorConfig sc(conn);
DCDB::Sensor sensor(conn, sensorName);
//_sensorConfig->getPublicSensorByName(ps,sensorName.c_str());
sc.getPublicSensorByName(ps,sensorName.c_str());
//Shoot the query for this sensor. //Shoot the query for this sensor.
std::list<DCDB::SensorDataStoreReading> results; std::list<DCDB::SensorDataStoreReading> results;
...@@ -238,9 +217,7 @@ void::RestAPI::POST_query(endpointArgs) { ...@@ -238,9 +217,7 @@ void::RestAPI::POST_query(endpointArgs) {
datapoints += "[" + std::to_string(r.value * ps.scaling_factor) + "," datapoints += "[" + std::to_string(r.value * ps.scaling_factor) + ","
+ std::to_string(r.timeStamp.getRaw()/1000000) + "],"; + std::to_string(r.timeStamp.getRaw()/1000000) + "],";
if(datapoints.back() == ',')
datapoints.pop_back(); datapoints.pop_back();
datapoints += "]"; datapoints += "]";
res.body() += "{\"target\":\"" + sensorName + "\",\"datapoints\":" + datapoints + "},"; res.body() += "{\"target\":\"" + sensorName + "\",\"datapoints\":" + datapoints + "},";
} }
......
...@@ -10,18 +10,14 @@ cassandra { ...@@ -10,18 +10,14 @@ cassandra {
} }
hierarchy { hierarchy {
separator ,
; regex mpp3.,r\\d{2}.,c\\d{2}.,s\\d{2}.,cpu\\d+
regex /mpp2,/r\\d{2},/c\\d{2},/s\\d{2}
} }
restAPI { restAPI {
address 127.0.0.1:8081 address 0.0.0.0:8081
certificate /Users/di34bap/Projects/dcdb-grafana/deps/openssl-1.1.1c/test/certs/ca-cert.pem certificate ../../deps/openssl-1.1.1c/test/certs/ca-cert.pem
privateKey /Users/di34bap/Projects/dcdb-grafana/deps/openssl-1.1.1c/test/certs/ca-key.pem privateKey ../../deps/openssl-1.1.1c/test/certs/ca-key.pem
dhFile /Users/di34bap/Projects/dcdb-grafana/deps/openssl-1.1.1c/crypto/dh/dh2048.pem dhFile ../../deps/openssl-1.1.1c/crypto/dh/dh2048.pem
user user1 { user user1 {
...@@ -36,7 +32,7 @@ restAPI { ...@@ -36,7 +32,7 @@ restAPI {
POST POST
} }
user user3 { user user3 {
password pass3 password pass3
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment