Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 5c22da7a authored by Daniele Tafani's avatar Daniele Tafani
Browse files

Added column family "operations" in keyspace dcdb_config.

parent e274aa09
...@@ -71,6 +71,7 @@ public: ...@@ -71,6 +71,7 @@ public:
std::string v_sensorid; /**< For virtual sensors, this field holds a SensorID used for storing cached values in the database. (FIXME: Cache to be implemented) */ std::string v_sensorid; /**< For virtual sensors, this field holds a SensorID used for storing cached values in the database. (FIXME: Cache to be implemented) */
uint64_t t_zero; /**< For virtual sensors, this field holds the first point in time at which the sensor carries a value. */ uint64_t t_zero; /**< For virtual sensors, this field holds the first point in time at which the sensor carries a value. */
uint64_t frequency; /**< For virtual sensors, this field holds the interval at which the sensor evaluates (in nanoseconds). */ uint64_t frequency; /**< For virtual sensors, this field holds the interval at which the sensor evaluates (in nanoseconds). */
std::string operations; /**< Defines the operations on the sensor, e.g. avg, std deviation, etc. */
PublicSensor(); PublicSensor();
PublicSensor(const PublicSensor &copy); PublicSensor(const PublicSensor &copy);
...@@ -255,6 +256,15 @@ public: ...@@ -255,6 +256,15 @@ public:
*/ */
SCError setSensorMask(std::string publicName, uint64_t mask); SCError setSensorMask(std::string publicName, uint64_t mask);
/**
* @brief Set an operation for the sensor.
*
* @param publicName Name of the sensor.
* @param operstion New operation for the sensor.
* @return See SCError.
*/
SCError setOperations(std::string publicName, std::string operations);
/** /**
* @brief Set a new sensor expression for a virtual sensor. * @brief Set a new sensor expression for a virtual sensor.
* *
......
...@@ -78,6 +78,7 @@ public: ...@@ -78,6 +78,7 @@ public:
SCError setSensorScalingFactor(std::string publicName, double scalingFactor); SCError setSensorScalingFactor(std::string publicName, double scalingFactor);
SCError setSensorUnit(std::string publicName, std::string unit); SCError setSensorUnit(std::string publicName, std::string unit);
SCError setSensorMask(std::string publicName, uint64_t mask); SCError setSensorMask(std::string publicName, uint64_t mask);
SCError setOperations(std::string publicName, std::string operations);
SCError setVirtualSensorExpression(std::string publicName, std::string expression); SCError setVirtualSensorExpression(std::string publicName, std::string expression);
SCError setVirtualSensorTZero(std::string publicName, TimeStamp tZero); SCError setVirtualSensorTZero(std::string publicName, TimeStamp tZero);
......
...@@ -460,6 +460,7 @@ bool ConnectionImpl::initSchema() { ...@@ -460,6 +460,7 @@ bool ConnectionImpl::initSchema() {
"sensor_mask bigint, " /* Bit mask that specifies sensor properties. Currently defined ones are: "sensor_mask bigint, " /* Bit mask that specifies sensor properties. Currently defined ones are:
Integrable: indicates whether the sensor is integrable over time; Integrable: indicates whether the sensor is integrable over time;
Monotonic : indicates whether the collected sensor data is monotonic. */ Monotonic : indicates whether the collected sensor data is monotonic. */
"operations varchar, " /* Operations for the sensor (e.g., avg, stdev,...). */
"expression varchar, " /* For virtual sensors: arithmetic expression to derive the virtual sensor's value */ "expression varchar, " /* For virtual sensors: arithmetic expression to derive the virtual sensor's value */
"vsensorid varchar, " /* For virtual sensors: Unique sensorId for the sensor in the virtualsensors table */ "vsensorid varchar, " /* For virtual sensors: Unique sensorId for the sensor in the virtualsensors table */
"tzero bigint, " /* For virtual sensors: time of the first reading */ "tzero bigint, " /* For virtual sensors: time of the first reading */
......
...@@ -58,6 +58,7 @@ PublicSensor::PublicSensor() ...@@ -58,6 +58,7 @@ PublicSensor::PublicSensor()
v_sensorid = ""; v_sensorid = "";
t_zero = 0; t_zero = 0;
frequency = 0; frequency = 0;
operations = "";
} }
PublicSensor::PublicSensor (const PublicSensor &copy) PublicSensor::PublicSensor (const PublicSensor &copy)
...@@ -72,6 +73,7 @@ PublicSensor::PublicSensor (const PublicSensor &copy) ...@@ -72,6 +73,7 @@ PublicSensor::PublicSensor (const PublicSensor &copy)
v_sensorid = copy.v_sensorid; v_sensorid = copy.v_sensorid;
t_zero = copy.t_zero; t_zero = copy.t_zero;
frequency = copy.frequency; frequency = copy.frequency;
operations = copy.operations;
} }
...@@ -158,6 +160,11 @@ SCError SensorConfig::setSensorMask(std::string publicName, uint64_t mask) ...@@ -158,6 +160,11 @@ SCError SensorConfig::setSensorMask(std::string publicName, uint64_t mask)
return impl->setSensorMask(publicName, mask); return impl->setSensorMask(publicName, mask);
} }
SCError SensorConfig::setOperations(std::string publicName, std::string operations)
{
return impl->setOperations(publicName,operations);
}
SCError SensorConfig::setVirtualSensorExpression(std::string publicName, std::string expression) SCError SensorConfig::setVirtualSensorExpression(std::string publicName, std::string expression)
{ {
return impl->setVirtualSensorExpression(publicName, expression); return impl->setVirtualSensorExpression(publicName, expression);
...@@ -173,7 +180,6 @@ SCError SensorConfig::setVirtualSensorFrequency(std::string publicName, uint64_t ...@@ -173,7 +180,6 @@ SCError SensorConfig::setVirtualSensorFrequency(std::string publicName, uint64_t
return impl->setVirtualSensorFrequency(publicName, frequency); return impl->setVirtualSensorFrequency(publicName, frequency);
} }
SensorConfig::SensorConfig(Connection* conn) SensorConfig::SensorConfig(Connection* conn)
{ {
/* Allocate impl object */ /* Allocate impl object */
...@@ -561,6 +567,8 @@ SCError SensorConfigImpl::getPublicSensorsVerbose(std::list<PublicSensor>& publi ...@@ -561,6 +567,8 @@ SCError SensorConfigImpl::getPublicSensorsVerbose(std::list<PublicSensor>& publi
size_t vsensorid_len; size_t vsensorid_len;
int64_t tzero; int64_t tzero;
int64_t frequency; int64_t frequency;
const char* operations;
size_t operations_len;
PublicSensor sensor; PublicSensor sensor;
const CassRow* row = cass_iterator_get_row(iterator); const CassRow* row = cass_iterator_get_row(iterator);
...@@ -595,6 +603,9 @@ SCError SensorConfigImpl::getPublicSensorsVerbose(std::list<PublicSensor>& publi ...@@ -595,6 +603,9 @@ SCError SensorConfigImpl::getPublicSensorsVerbose(std::list<PublicSensor>& publi
if (cass_value_get_int64(cass_row_get_column_by_name(row, "frequency"), &frequency) != CASS_OK) { if (cass_value_get_int64(cass_row_get_column_by_name(row, "frequency"), &frequency) != CASS_OK) {
frequency = 0; frequency = 0;
} }
if (cass_value_get_string(cass_row_get_column_by_name(row, "operations"), &operations, &operations_len) != CASS_OK) {
operations = ""; operations_len = 0;
}
sensor.name = std::string(name, name_len); sensor.name = std::string(name, name_len);
sensor.is_virtual = is_virtual == cass_true ? true : false; sensor.is_virtual = is_virtual == cass_true ? true : false;
...@@ -606,6 +617,7 @@ SCError SensorConfigImpl::getPublicSensorsVerbose(std::list<PublicSensor>& publi ...@@ -606,6 +617,7 @@ SCError SensorConfigImpl::getPublicSensorsVerbose(std::list<PublicSensor>& publi
sensor.v_sensorid = std::string(vsensorid, vsensorid_len); sensor.v_sensorid = std::string(vsensorid, vsensorid_len);
sensor.t_zero = tzero; sensor.t_zero = tzero;
sensor.frequency = frequency; sensor.frequency = frequency;
sensor.operations = operations;
publicSensors.push_back(sensor); publicSensors.push_back(sensor);
} }
...@@ -685,6 +697,8 @@ SCError SensorConfigImpl::getPublicSensorByName(PublicSensor& sensor, const char ...@@ -685,6 +697,8 @@ SCError SensorConfigImpl::getPublicSensorByName(PublicSensor& sensor, const char
size_t vsensorid_len; size_t vsensorid_len;
int64_t tzero; int64_t tzero;
int64_t frequency; int64_t frequency;
const char* operations;
size_t operations_len;
const CassRow* row = cass_iterator_get_row(iterator); const CassRow* row = cass_iterator_get_row(iterator);
...@@ -718,6 +732,9 @@ SCError SensorConfigImpl::getPublicSensorByName(PublicSensor& sensor, const char ...@@ -718,6 +732,9 @@ SCError SensorConfigImpl::getPublicSensorByName(PublicSensor& sensor, const char
if (cass_value_get_int64(cass_row_get_column_by_name(row, "frequency"), &frequency) != CASS_OK) { if (cass_value_get_int64(cass_row_get_column_by_name(row, "frequency"), &frequency) != CASS_OK) {
frequency = 0; frequency = 0;
} }
if (cass_value_get_string(cass_row_get_column_by_name(row, "operations"), &operations, &operations_len) != CASS_OK) {
operations = ""; operations_len = 0;
}
sensor.name = std::string(name, name_len); sensor.name = std::string(name, name_len);
sensor.is_virtual = is_virtual == cass_true ? true : false; sensor.is_virtual = is_virtual == cass_true ? true : false;
...@@ -729,6 +746,7 @@ SCError SensorConfigImpl::getPublicSensorByName(PublicSensor& sensor, const char ...@@ -729,6 +746,7 @@ SCError SensorConfigImpl::getPublicSensorByName(PublicSensor& sensor, const char
sensor.v_sensorid = std::string(vsensorid, vsensorid_len); sensor.v_sensorid = std::string(vsensorid, vsensorid_len);
sensor.t_zero = tzero; sensor.t_zero = tzero;
sensor.frequency = frequency; sensor.frequency = frequency;
sensor.operations = operations;
/* Add to sensorPropertyCache for later use */ /* Add to sensorPropertyCache for later use */
sensorList.push_back(sensor); sensorList.push_back(sensor);
...@@ -1214,6 +1232,51 @@ SCError SensorConfigImpl::setSensorMask(std::string publicName, uint64_t mask) ...@@ -1214,6 +1232,51 @@ SCError SensorConfigImpl::setSensorMask(std::string publicName, uint64_t mask)
return error; return error;
} }
SCError SensorConfigImpl::setOperations(std::string publicName, std::string operations)
{
SCError error = SC_UNKNOWNERROR;
CassError rc = CASS_OK;
CassStatement* statement = nullptr;
CassFuture* future = nullptr;
const CassPrepared* prepared = nullptr;
const char* query = "UPDATE " CONFIG_KEYSPACE_NAME "." CF_PUBLISHEDSENSORS " SET operations = ? WHERE name = ? ;";
future = cass_session_prepare(session, query);
cass_future_wait(future);
rc = cass_future_error_code(future);
if (rc != CASS_OK) {
connection->printError(future);
return SC_UNKNOWNERROR;
}
prepared = cass_future_get_prepared(future);
cass_future_free(future);
statement = cass_prepared_bind(prepared);
cass_statement_bind_string(statement, 0, operations.c_str());
cass_statement_bind_string(statement, 1, publicName.c_str());
future = cass_session_execute(session, statement);
cass_future_wait(future);
rc = cass_future_error_code(future);
if (rc != CASS_OK) {
connection->printError(future);
error = SC_UNKNOWNERROR;
}
else {
error = SC_OK;
}
cass_statement_free(statement);
cass_prepared_free(prepared);
return error;
}
SCError SensorConfigImpl::setVirtualSensorExpression(std::string publicName, std::string expression) SCError SensorConfigImpl::setVirtualSensorExpression(std::string publicName, std::string expression)
{ {
/* Check if the session is valid */ /* Check if the session is valid */
......
...@@ -66,6 +66,8 @@ void SensorAction::printHelp(int argc, char* argv[]) ...@@ -66,6 +66,8 @@ void SensorAction::printHelp(int argc, char* argv[])
std::cout << " EXPRESSION <public name> <expr> - Change expression of virt sensor." << std::endl; std::cout << " EXPRESSION <public name> <expr> - Change expression of virt sensor." << std::endl;
std::cout << " TZERO <public name> <t0> - Change t0 of virt sensor." << std::endl; std::cout << " TZERO <public name> <t0> - Change t0 of virt sensor." << std::endl;
std::cout << " FREQUENCY <public name> <freq> - Change frequency of virt sensor." << std::endl; std::cout << " FREQUENCY <public name> <freq> - Change frequency of virt sensor." << std::endl;
std::cout << " OPERATIONS <public name> <operation>,<operation>,..." << std::endl;
std::cout << " - Set operations for the sensor (e.g., avg, stddev,...)." << std::endl;
std::cout << " UNPUBLISH <public name> - Unpublish a sensor." << std::endl; std::cout << " UNPUBLISH <public name> - Unpublish a sensor." << std::endl;
} }
...@@ -136,7 +138,7 @@ int SensorAction::executeCommand(int argc, char* argv[], int argvidx, const char ...@@ -136,7 +138,7 @@ int SensorAction::executeCommand(int argc, char* argv[], int argvidx, const char
doUnit(argv[argvidx+1], argv[argvidx+2]); doUnit(argv[argvidx+1], argv[argvidx+2]);
} }
else if (strcasecmp(argv[argvidx], "SENSORPROPERTY") == 0) { else if (strcasecmp(argv[argvidx], "SENSORPROPERTY") == 0) {
/* INTEGRABLE needs two more parameters */ /* SENSORPROPERTY needs two more parameters */
if (argvidx+2 >= argc) { if (argvidx+2 >= argc) {
std::cout << "SENSORPROPERTY needs two more parameters!" << std::endl; std::cout << "SENSORPROPERTY needs two more parameters!" << std::endl;
goto executeCommandError; goto executeCommandError;
...@@ -167,6 +169,14 @@ int SensorAction::executeCommand(int argc, char* argv[], int argvidx, const char ...@@ -167,6 +169,14 @@ int SensorAction::executeCommand(int argc, char* argv[], int argvidx, const char
} }
doFrequency(argv[argvidx+1], argv[argvidx+2]); doFrequency(argv[argvidx+1], argv[argvidx+2]);
} }
else if (strcasecmp(argv[argvidx], "OPERATIONS") == 0) {
/* OPERATIONS needs two more parameters */
if (argvidx+2 >= argc) {
std::cout << "OPERATIONS needs two more parameters!" << std::endl;
goto executeCommandError;
}
doOperations(argv[argvidx+1], argv[argvidx+2]);
}
else if (strcasecmp(argv[argvidx], "UNPUBLISH") == 0) { else if (strcasecmp(argv[argvidx], "UNPUBLISH") == 0) {
/* UNPUBLISH needs one more parameter */ /* UNPUBLISH needs one more parameter */
if (argvidx+1 >= argc) { if (argvidx+1 >= argc) {
...@@ -320,6 +330,7 @@ void SensorAction::doShow(const char* publicName) ...@@ -320,6 +330,7 @@ void SensorAction::doShow(const char* publicName)
} }
std::cout << "Unit: " << publicSensor.unit << std::endl; std::cout << "Unit: " << publicSensor.unit << std::endl;
std::cout << "Scaling factor: " << publicSensor.scaling_factor << std::endl; std::cout << "Scaling factor: " << publicSensor.scaling_factor << std::endl;
std::cout << "Operations: " << publicSensor.operations << std::endl;
std::cout << "Sensor Properties: "; std::cout << "Sensor Properties: ";
if((publicSensor.sensor_mask & INTEGRABLE) == INTEGRABLE) if((publicSensor.sensor_mask & INTEGRABLE) == INTEGRABLE)
std::cout << "Integrable "; std::cout << "Integrable ";
...@@ -514,6 +525,26 @@ void SensorAction::doFrequency(const char* publicName, const char *frequency) ...@@ -514,6 +525,26 @@ void SensorAction::doFrequency(const char* publicName, const char *frequency)
} }
} }
void SensorAction::doOperations(const char* publicName, const char *operations)
{
DCDB::SensorConfig sensorConfig(connection);
DCDB::SCError err = sensorConfig.setOperations(publicName, operations);
switch (err) {
case DCDB::SC_OK:
break;
case DCDB::SC_UNKNOWNSENSOR:
std::cout << "Unknown sensor name: " << publicName << std::endl;
break;
case DCDB::SC_INVALIDSESSION:
std::cout << "Invalid session!" << std::endl;
break;
default:
std::cout << "Internal error." << std::endl;
}
}
/* /*
* Unpublish a sensor * Unpublish a sensor
*/ */
......
...@@ -56,6 +56,7 @@ protected: ...@@ -56,6 +56,7 @@ protected:
void doExpression(const char* publicName, const char* expression); void doExpression(const char* publicName, const char* expression);
void doTZero(const char* publicName, const char* tZero); void doTZero(const char* publicName, const char* tZero);
void doFrequency(const char* publicName, const char *frequency); void doFrequency(const char* publicName, const char *frequency);
void doOperations(const char* publicName, const char *operations);
void doUnPublishSensor(const char* publicName); void doUnPublishSensor(const char* publicName);
}; };
......
Markdown is supported
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