AggregatorAnalyzer.h 2.85 KB
Newer Older
1
2
3
//================================================================================
// Name        : AggregatorAnalyzer.h
// Author      : Alessio Netti
Micha Müller's avatar
Micha Müller committed
4
// Contact     : info@dcdb.it
5
6
7
8
9
10
11
12
13
14
15
16
// Copyright   : Leibniz Supercomputing Centre
// Description :
//================================================================================

//================================================================================
// This file is part of DCDB (DataCenter DataBase)
// Copyright (C) 2019-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.
Alessio Netti's avatar
Alessio Netti committed
17
//
18
19
20
21
// 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.
Alessio Netti's avatar
Alessio Netti committed
22
//
23
24
25
26
// 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.
//================================================================================
Alessio Netti's avatar
Alessio Netti committed
27
28
29
30
31

#ifndef PROJECT_AGGREGATORANALYZER_H
#define PROJECT_AGGREGATORANALYZER_H

#include "../../includes/AnalyzerTemplate.h"
32
33
34
#include "AggregatorSensorBase.h"
#include <math.h>
#include <algorithm>
Alessio Netti's avatar
Alessio Netti committed
35

36
37
38
39
40
/**
 * @brief Aggregator analyzer plugin.
 *
 * @ingroup aggregator
 */
41
class AggregatorAnalyzer : virtual public AnalyzerTemplate<AggregatorSensorBase> {
Alessio Netti's avatar
Alessio Netti committed
42
43

public:
44
    
Alessio Netti's avatar
Alessio Netti committed
45
    AggregatorAnalyzer(const std::string& name);
Alessio Netti's avatar
Alessio Netti committed
46
47
    AggregatorAnalyzer(const AggregatorAnalyzer& other);
    
Alessio Netti's avatar
Alessio Netti committed
48
49
    virtual ~AggregatorAnalyzer();

50
51
52
53
    void setWindow(unsigned long long w)        { _window = w; }
    
    unsigned long long getWindow()              { return _window; }
    
Alessio Netti's avatar
Alessio Netti committed
54
55
    void printConfig(LOG_LEVEL ll) override;

56
protected:
Alessio Netti's avatar
Alessio Netti committed
57

58
59
60
    virtual void compute(U_Ptr unit)	 override;
    // Internal method containing the actual logic of the analyzer
    void compute_internal(U_Ptr unit, vector<reading_t> *buffer);
Alessio Netti's avatar
Alessio Netti committed
61
62
    // A separate method for each operation implies code redundancy, but also better efficiency and less useless
    // variables used by specific operations lying around
63
    int64_t computeObs(vector<reading_t> *buffer);
64
65
66
67
68
69
    int64_t computeSum(vector<reading_t> *buffer);
    int64_t computeAvg(vector<reading_t> *buffer);
    int64_t computeMax(vector<reading_t> *buffer);
    int64_t computeMin(vector<reading_t> *buffer);
    int64_t computeStd(vector<reading_t> *buffer);
    vector<int64_t> computeQuantiles(vector<reading_t> *buffer);
Alessio Netti's avatar
Alessio Netti committed
70

71
    vector<reading_t> *_buffer;
72
    vector<AggregatorSBPtr> _quantileSensors;
Alessio Netti's avatar
Alessio Netti committed
73
    unsigned long long _window;
74
    
Alessio Netti's avatar
Alessio Netti committed
75
76
77
};

#endif //PROJECT_AGGREGATORANALYZER_H