PerSystSqlOperator.h 3.9 KB
Newer Older
1
//================================================================================
2
// Name        : PerSystSqlOperator.h
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Author      : Carla Guillen
// Contact     : info@dcdb.it
// Copyright   : Leibniz Supercomputing Centre
// Description : Template implementing features to use Units in Operators.
//================================================================================

//================================================================================
// This file is part of DCDB (DataCenter DataBase)
// Copyright (C) 2018-2019 Leibniz Supercomputing Centre
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
//================================================================================

28
29
#ifndef ANALYTICS_OPERATORS_PERSYSTSQL_PERSYSTSQLOPERATOR_H_
#define ANALYTICS_OPERATORS_PERSYSTSQL_PERSYSTSQLOPERATOR_H_
30
31
32
33
34
35
36

#include <vector>

#include "../../../common/include/cacheentry.h"
#include "../../includes/JobOperatorTemplate.h"
#include "../aggregator/AggregatorSensorBase.h"

37
class PerSystSqlOperator: public JobOperatorTemplate<AggregatorSensorBase>{
38
39
40
41
42
43
44
45
public:
	enum Formula {
		NOFORMULA = 0,
		FORMULA1 = 1,
		FORMULA2 = 2,
		FORMULA3 = 3,
		MEMORY_FORMULA = 4,
	};
46
public:
47
48
	PerSystSqlOperator(const std::string& name);
	virtual ~PerSystSqlOperator();
49
50
51
	void compute(U_Ptr unit, qeJobData& jobData) override;

	unsigned int getNumberOfEvenQuantiles() const {
52
		return _number_of_even_quantiles;
53
54
55
	}

	void setNumberOfEvenQuantiles(unsigned int numberOfEvenQuantiles) {
56
		_number_of_even_quantiles = numberOfEvenQuantiles;
57
58
	}

59
	void pushbackQuantileSensor(AggregatorSBPtr qSensor){
60
61
62
		_quantileSensors.push_back(qSensor);
	}

63
	void setSeverityExponent(double severityExponent) {
64
65
66
67
68
69
70
		_severity_exponent = severityExponent;
	}

	void setSeverityFormula(Formula severityFormula) {
		_severity_formula = severityFormula;
	}

71
	void setSeverityMaxMemory(double severityMaxMemory) {
72
73
74
		_severity_max_memory = severityMaxMemory;
	}

75
	void setSeverityThreshold(double severityThreshold) {
76
77
78
		_severity_threshold = severityThreshold;
	}

Carla Guillen's avatar
Carla Guillen committed
79
80
81
82
	void setGoBackInMs(int go_back_ms){
		_go_back_ns = go_back_ms * 1e6;
	}

83
84
85
private:
	std::vector<reading_t> _buffer;
	std::vector<AggregatorSBPtr> _quantileSensors;
86
87
	unsigned int _number_of_even_quantiles;
	Formula _severity_formula;
88
89
90
	double _severity_threshold;
	double _severity_exponent;
	double _severity_max_memory;
Carla Guillen's avatar
Carla Guillen committed
91
92
93
94
95
	std::vector<double> _severities;
	int _go_back_ns;

protected:
	virtual void compute(U_Ptr unit) override;
Carla Guillen's avatar
Carla Guillen committed
96
	void compute_internal(U_Ptr& unit, vector<reading_t>& buffer);
Carla Guillen's avatar
Carla Guillen committed
97
	double computeSeverityAverage(vector<double> & buffer);
98
99
};

100
101
102
103
104
105
106
107
108
109
double severity_formula1(double metric, double threshold, double exponent);
double severity_formula2(double metric, double threshold, double exponent);
double severity_formula3(double metric, double threshold, double exponent);
double severity_memory(double metric, double threshold, double max_memory);
constexpr double severity_noformula(){return 0.0;} //No severity
void punToDoubles(std::vector<reading_t> & buffer, std::vector<double> & outDoubleVec);
void computeEvenQuantiles(std::vector<double> &data, const unsigned int NUMBER_QUANTILES, std::vector<double> &quantiles);

double punLLToDouble(long long value);
long long punDoubleToLL(double value);
lu43jih's avatar
lu43jih committed
110

111
#endif /* ANALYTICS_OPERATORS_PERSYSTSQL_PERSYSTSQLOPERATOR_H_ */