| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*************************************** | ||
| 2 | Auteur : Thibaut Oprinsen | ||
| 3 | Mail : thibaut.oprinsen@lapp.in2p3.fr | ||
| 4 | Licence : CeCILL-C | ||
| 5 | ****************************************/ | ||
| 6 | #ifndef __Monitoring_IMPL_H__ | ||
| 7 | #define __Monitoring_IMPL_H__ | ||
| 8 | |||
| 9 | #include "StatSort.h" | ||
| 10 | #include "Monitoring.h" | ||
| 11 | |||
| 12 | using namespace Swarm; | ||
| 13 | |||
| 14 | ///Constructor of Monitoring | ||
| 15 | template<class _TBackend> | ||
| 16 | 2 | Monitoring<_TBackend>::Monitoring() | |
| 17 | 2 | :Daemon<_TBackend>() | |
| 18 | { | ||
| 19 | 2 | initializeMonitoring(); | |
| 20 | 2 | } | |
| 21 | |||
| 22 | ///Destructor of Monitoring | ||
| 23 | template<class _TBackend> | ||
| 24 | 2 | Monitoring<_TBackend>::~Monitoring(){ | |
| 25 | |||
| 26 | 2 | } | |
| 27 | |||
| 28 | ///Get the map of Stat | ||
| 29 | /** @return map of Stat | ||
| 30 | */ | ||
| 31 | template<class _TBackend> | ||
| 32 | 1 | const MapDaemonStat& Monitoring<_TBackend>::getMapDaemonStat() const { | |
| 33 | 1 | return p_mapDaemonStat; | |
| 34 | } | ||
| 35 | |||
| 36 | ///Check if stats have been received | ||
| 37 | /** @return true if the stats have been received, false otherwise | ||
| 38 | */ | ||
| 39 | template<class _TBackend> | ||
| 40 | bool Monitoring<_TBackend>::hasReceivedStats() const { | ||
| 41 | return !p_mapDaemonStat.empty(); | ||
| 42 | } | ||
| 43 | |||
| 44 | ///Get the count of stats received | ||
| 45 | /** @return number of stats received | ||
| 46 | */ | ||
| 47 | template<class _TBackend> | ||
| 48 | 232 | size_t Monitoring<_TBackend>::getStatsCount() const { | |
| 49 | 232 | return p_mapDaemonStat.size(); | |
| 50 | } | ||
| 51 | |||
| 52 | ///Get the buffer duration in seconds for the statistics accumulation period | ||
| 53 | /** @return buffer duration in seconds for the statistics accumulation period | ||
| 54 | */ | ||
| 55 | template<class _TBackend> | ||
| 56 | 2 | size_t Monitoring<_TBackend>::getStatBufferDurationSecond() const { | |
| 57 | 2 | return p_statBufferDuration; | |
| 58 | } | ||
| 59 | |||
| 60 | ///Get the duration of a bin in seconds for the histogram of the statistics | ||
| 61 | /** @return duration of a bin in seconds for the histogram of the statistics | ||
| 62 | */ | ||
| 63 | template<class _TBackend> | ||
| 64 | 2 | size_t Monitoring<_TBackend>::getStatBinDurationSecond() const { | |
| 65 | 2 | return p_binDuration; | |
| 66 | } | ||
| 67 | |||
| 68 | ///Fill the StatInfo of the Monitoring with the given Stat | ||
| 69 | /** @param stat : Stat to be filled | ||
| 70 | * @return true on success, false otherwise | ||
| 71 | */ | ||
| 72 | template<class _TBackend> | ||
| 73 | 2 | PUncastableBool Monitoring<_TBackend>::fillStatInfo(const Swarm::Stat & stat) { | |
| 74 | 2 | p_mapDaemonStat[stat.getName()] = stat; | |
| 75 | 2 | return UNCASTABLE_TRUE; | |
| 76 | } | ||
| 77 | |||
| 78 | /// Override for loading extra parameters for the Monitoring | ||
| 79 | /** @param config : ConfigNode with the extra parameters to be loaded | ||
| 80 | * @return true on success, false otherwise | ||
| 81 | */ | ||
| 82 | template<class _TBackend> | ||
| 83 | 2 | bool Monitoring<_TBackend>::extraLoad(const ConfigNode * config){ | |
| 84 |
1/2✓ Branch 0 (2→3) taken 2 times.
✗ Branch 1 (2→10) not taken.
|
2 | if(config != nullptr){ |
| 85 |
2/2✓ Branch 0 (3→4) taken 2 times.
✓ Branch 2 (4→5) taken 2 times.
|
2 | p_statBufferDuration = phoenix_get_value<size_t>(*config, "stat_buffer_duration_second", 30lu); |
| 86 |
2/2✓ Branch 0 (6→7) taken 2 times.
✓ Branch 2 (7→8) taken 2 times.
|
2 | p_binDuration = phoenix_get_value<size_t>(*config, "bin_duration_second", 5lu); |
| 87 | } | ||
| 88 | 2 | return true; | |
| 89 | } | ||
| 90 | |||
| 91 | ///Initialize the Monitoring | ||
| 92 | template<class _TBackend> | ||
| 93 | 2 | void Monitoring<_TBackend>::initializeMonitoring(){ | |
| 94 | ///Default values for the extra parameters of the Monitoring | ||
| 95 | 2 | p_statBufferDuration = 0lu; | |
| 96 | 2 | p_binDuration = 0lu; | |
| 97 | 2 | } | |
| 98 | |||
| 99 | ///Process event | ||
| 100 | /** @return true | ||
| 101 | */ | ||
| 102 | template<class _TBackend> | ||
| 103 | bool Monitoring<_TBackend>::processEvent(){ | ||
| 104 | // bool bResult = Daemon<_TBackend>::sendValue("SwarmTop", p_mapDaemonStat); | ||
| 105 | return true; | ||
| 106 | } | ||
| 107 | |||
| 108 | ///Method from BaseDaemon to add call methods | ||
| 109 | template<class _TBackend> | ||
| 110 | 2 | void Monitoring<_TBackend>::addCallMethod(){ | |
| 111 | 2 | DaemonConfig & daemonConfig = Daemon<_TBackend>::getConfig(); | |
| 112 | 2 | BaseDaemon::getLog().getLogInfo() << "Monitoring: Adding data callable method for stat sorting with nbBin=" << daemonConfig.getStatNbBin() << ", lowerBound=" << daemonConfig.getStatHistLowerBound() << ", upperBound=" << daemonConfig.getStatHistUpperBound() << std::endl; | |
| 113 | 2 | Daemon<_TBackend>::addDataCallableMethod(sortFillDaemonStat<_TBackend>, *this, daemonConfig.getStatNbBin(), daemonConfig.getStatHistLowerBound(), daemonConfig.getStatHistUpperBound()); | |
| 114 | 2 | } | |
| 115 | |||
| 116 | #endif | ||
| 117 |