| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*************************************** | ||
| 2 | Auteur : Pierre Aubert | ||
| 3 | Mail : pierre.aubert@lapp.in2p3.fr | ||
| 4 | Licence : CeCILL-C | ||
| 5 | ****************************************/ | ||
| 6 | |||
| 7 | #ifndef __DAEMON_H_IMPL__ | ||
| 8 | #define __DAEMON_H_IMPL__ | ||
| 9 | |||
| 10 | #include "phoenix_assert.h" | ||
| 11 | #include "Daemon.h" | ||
| 12 | |||
| 13 | ///Default constructor of Daemon | ||
| 14 | template<class _TBackend> | ||
| 15 | 16 | Daemon<_TBackend>::Daemon() | |
| 16 |
2/2✓ Branch 0 (3→4) taken 16 times.
✓ Branch 2 (4→5) taken 16 times.
|
16 | :BaseDaemon() |
| 17 | { | ||
| 18 | 16 | initialisationDaemon(); | |
| 19 | 16 | } | |
| 20 | |||
| 21 | ///Destructor of Daemon | ||
| 22 | template<class _TBackend> | ||
| 23 | 16 | Daemon<_TBackend>::~Daemon(){ | |
| 24 | |||
| 25 | 16 | } | |
| 26 | |||
| 27 | ///Set the mode of the sockets of the SocketManager | ||
| 28 | /** @param mode : mode of the socket manager (NO_MOCK, MOCK, MOCK_RECORD) | ||
| 29 | */ | ||
| 30 | template<class _TBackend> | ||
| 31 | 18 | void Daemon<_TBackend>::setSocketMode(PSocketMode::PSocketMode mode){ | |
| 32 | 18 | p_backend.socketManager.setMode(mode); | |
| 33 |
3/3✓ Branch 0 (3→4) taken 16 times.
✓ Branch 1 (3→5) taken 1 times.
✓ Branch 2 (3→6) taken 1 times.
|
18 | switch(mode){ |
| 34 | 16 | case PSocketMode::MOCK: | |
| 35 | 16 | p_isFullMock = true; | |
| 36 | 16 | p_isFullMockRecord = false; | |
| 37 | 16 | break; | |
| 38 | 1 | case PSocketMode::MOCK_RECORD: | |
| 39 | 1 | p_isFullMock = false; | |
| 40 | 1 | p_isFullMockRecord = true; | |
| 41 | 1 | break; | |
| 42 | 1 | default: | |
| 43 | 1 | p_isFullMock = false; | |
| 44 | 1 | p_isFullMockRecord = false; | |
| 45 | 1 | break; | |
| 46 | } | ||
| 47 | 18 | } | |
| 48 | |||
| 49 | ///Set the mode of the clock | ||
| 50 | /** @param mode : mode of the clock (NO_MOCK, MOCK, MOCK_RECORD) | ||
| 51 | */ | ||
| 52 | template<class _TBackend> | ||
| 53 | 18 | void Daemon<_TBackend>::setClockMode(PClockMode::PClockMode mode){ | |
| 54 | 18 | p_backend.clock.setMode(mode); | |
| 55 |
3/3✓ Branch 0 (3→4) taken 16 times.
✓ Branch 1 (3→5) taken 1 times.
✓ Branch 2 (3→6) taken 1 times.
|
18 | switch(mode){ |
| 56 | 16 | case PClockMode::MOCK: | |
| 57 | 16 | p_isFullMock = true; | |
| 58 | 16 | p_isFullMockRecord = false; | |
| 59 | 16 | break; | |
| 60 | 1 | case PClockMode::MOCK_RECORD: | |
| 61 | 1 | p_isFullMock = false; | |
| 62 | 1 | p_isFullMockRecord = true; | |
| 63 | 1 | break; | |
| 64 | 1 | default: | |
| 65 | 1 | p_isFullMock = false; | |
| 66 | 1 | p_isFullMockRecord = false; | |
| 67 | 1 | break; | |
| 68 | } | ||
| 69 | 18 | } | |
| 70 | |||
| 71 | ///Check the status of recv sockets | ||
| 72 | /** @param recvStatus : status to be checked | ||
| 73 | */ | ||
| 74 | template<class _TBackend> | ||
| 75 | 323 | PRecvStatus::PRecvStatus Daemon<_TBackend>::checkRecvStatus(PRecvStatus::PRecvStatus recvStatus){ | |
| 76 |
1/2✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→6) taken 323 times.
|
323 | if(recvStatus == PRecvStatus::SOCKET_NOT_AVAILABLE){ |
| 77 | // p_log.errorAndThrow<Phoenix::SocketStatusException>("Daemon::checkRecvStatus : Socket not available", "Socket not available"); | ||
| 78 | ✗ | p_log.getLogWarning() << "Daemon::checkRecvStatus : Socket not available" << std::endl; | |
| 79 | } | ||
| 80 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→11) taken 323 times.
|
323 | if(recvStatus == PRecvStatus::SIGNAL_INTERRUPTION){ |
| 81 | ✗ | p_log.criticalAndThrow<Phoenix::SocketStatusException>("Daemon::checkRecvStatus : Socket Backend caught a signal, aborting", "Socket Backend caught a signal, aborting"); | |
| 82 | } | ||
| 83 |
1/2✗ Branch 0 (11→12) not taken.
✓ Branch 1 (11→16) taken 323 times.
|
323 | if(recvStatus == PRecvStatus::BROKEN_BACKEND){ |
| 84 | ✗ | p_log.criticalAndThrow<Phoenix::SocketStatusException>("Daemon::checkRecvStatus : Back-end is in invalid state", "Back-end is in invalid state"); | |
| 85 | } | ||
| 86 |
1/2✗ Branch 0 (16→17) not taken.
✓ Branch 1 (16→21) taken 323 times.
|
323 | if(recvStatus == PRecvStatus::BROKEN_SOCKET){ |
| 87 | ✗ | p_log.criticalAndThrow<Phoenix::SocketStatusException>("Daemon::checkRecvStatus : Socket is in invalid state", "Socket is in invalid state"); | |
| 88 | } | ||
| 89 |
1/2✗ Branch 0 (21→22) not taken.
✓ Branch 1 (21→26) taken 323 times.
|
323 | if(recvStatus == PRecvStatus::CANNOT_DESERIALIZE_DATA){ |
| 90 | ✗ | p_log.errorAndThrow<Phoenix::SocketStatusException>("Daemon::checkRecvStatus : Cannot deserialize data", "Cannot deserialize data"); | |
| 91 | } | ||
| 92 | 323 | return recvStatus; | |
| 93 | } | ||
| 94 | |||
| 95 | |||
| 96 | ///Check the status of recv sockets | ||
| 97 | /** @param sendStatus : status to be checked | ||
| 98 | */ | ||
| 99 | template<class _TBackend> | ||
| 100 | 20 | void Daemon<_TBackend>::checkSendStatus(PSendStatus::PSendStatus sendStatus){ | |
| 101 |
1/2✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→7) taken 20 times.
|
20 | if(sendStatus == PSendStatus::SOCKET_NOT_AVAILABLE){ |
| 102 | ✗ | p_log.errorAndThrow<Phoenix::SocketStatusException>("Daemon::checkSendStatus : Socket not available", "Socket not available"); | |
| 103 | } | ||
| 104 |
1/2✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→12) taken 20 times.
|
20 | if(sendStatus == PSendStatus::NO_ROUTE_TO_RECEIVER){ |
| 105 | ✗ | p_log.errorAndThrow<Phoenix::SocketStatusException>("Daemon::checkSendStatus : Receiver not reachable", "Receiver not reachable"); | |
| 106 | } | ||
| 107 |
1/2✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→17) taken 20 times.
|
20 | if(sendStatus == PSendStatus::SIGNAL_INTERRUPTION){ |
| 108 | ✗ | p_log.criticalAndThrow<Phoenix::SocketStatusException>("Daemon::checkSendStatus : Socket Backend caught a signal, aborting.", "Socket Backend caught a signal, aborting."); | |
| 109 | } | ||
| 110 |
1/2✗ Branch 0 (17→18) not taken.
✓ Branch 1 (17→22) taken 20 times.
|
20 | if(sendStatus == PSendStatus::BROKEN_BACKEND){ |
| 111 | ✗ | p_log.criticalAndThrow<Phoenix::SocketStatusException>("Daemon::checkSendStatus : Back-end is in invalid state", "Back-end is in invalid state"); | |
| 112 | } | ||
| 113 |
2/2✓ Branch 0 (22→23) taken 1 times.
✓ Branch 1 (22→27) taken 19 times.
|
20 | if(sendStatus == PSendStatus::BROKEN_SOCKET){ |
| 114 |
1/2✓ Branch 0 (23→24) taken 1 times.
✗ Branch 2 (24→25) not taken.
|
2 | p_log.criticalAndThrow<Phoenix::SocketStatusException>("Daemon::checkSendStatus : Socket is in invalid state", "Socket is in invalid state"); |
| 115 | } | ||
| 116 |
1/2✗ Branch 0 (27→28) not taken.
✓ Branch 1 (27→32) taken 19 times.
|
19 | if(sendStatus == PSendStatus::CANNOT_SERIALIZE_DATA){ |
| 117 | ✗ | p_log.errorAndThrow<Phoenix::SocketStatusException>("Daemon::checkSendStatus : Cannot serialize data", "Cannot serialize data"); | |
| 118 | } | ||
| 119 | 19 | } | |
| 120 | |||
| 121 | ///Run the Daemon | ||
| 122 | /** @return true if the run was a success, false otherwise | ||
| 123 | */ | ||
| 124 | template<class _TBackend> | ||
| 125 | 9 | bool Daemon<_TBackend>::run(){ | |
| 126 | 9 | p_isRun = true; | |
| 127 | //Let's initialise all connexions | ||
| 128 | 9 | initialisationDaemonSocket(); | |
| 129 | 9 | p_startTimestamp = p_backend.clock.now(); | |
| 130 | 9 | p_statTimer.setEllapsedTime(p_config.getStatTimerPeriodMs()); | |
| 131 | 9 | p_statTimer.setStartTime(p_startTimestamp); | |
| 132 |
2/2✓ Branch 0 (27→8) taken 299 times.
✓ Branch 1 (27→28) taken 8 times.
|
606 | while(p_isRun){ |
| 133 | //Let's get the last received message | ||
| 134 | //If there is not message, we treat the rest of the loop | ||
| 135 |
1/1✓ Branch 0 (8→9) taken 299 times.
|
299 | Message message; |
| 136 |
3/3✓ Branch 0 (9→10) taken 299 times.
✓ Branch 2 (10→11) taken 299 times.
✓ Branch 4 (11→12) taken 299 times.
|
299 | PRecvStatus::PRecvStatus recvStatus = checkRecvStatus(p_backend.socketManager.recvData("pull", message, p_mainConfig.recvFlag)); |
| 137 |
2/2✓ Branch 0 (13→14) taken 20 times.
✓ Branch 1 (13→15) taken 279 times.
|
299 | if(recvStatus == PRecvStatus::OK){ |
| 138 |
1/1✓ Branch 0 (14→15) taken 19 times.
|
20 | processInputMessage(message); |
| 139 | } | ||
| 140 |
1/1✓ Branch 0 (15→16) taken 298 times.
|
298 | extraLoopProcessing(); |
| 141 | |||
| 142 |
1/1✓ Branch 0 (16→17) taken 298 times.
|
298 | time_t currentTime = p_backend.clock.now(); |
| 143 |
1/1✓ Branch 0 (17→18) taken 298 times.
|
298 | checkMessageTimeout(currentTime); |
| 144 |
7/7✓ Branch 0 (18→19) taken 298 times.
✓ Branch 2 (19→20) taken 135 times.
✓ Branch 3 (19→21) taken 163 times.
✓ Branch 4 (20→21) taken 7 times.
✓ Branch 5 (20→22) taken 128 times.
✓ Branch 6 (23→24) taken 170 times.
✓ Branch 7 (23→25) taken 128 times.
|
298 | if(p_statTimer.isTime(currentTime) || !p_isRun){ |
| 145 |
1/1✓ Branch 0 (24→25) taken 170 times.
|
170 | sendStatToStatDaemon(currentTime); |
| 146 | } | ||
| 147 | } | ||
| 148 | //Let's execute a last command before stop | ||
| 149 | 8 | executeOnStop(); | |
| 150 | 8 | return true; | |
| 151 | } | ||
| 152 | |||
| 153 | ///Send message to other Daemon | ||
| 154 | /** @param message : message to be sent | ||
| 155 | * @return true on success, false otherwise (maybe received method does not exist) | ||
| 156 | */ | ||
| 157 | template<class _TBackend> | ||
| 158 | 10 | bool Daemon<_TBackend>::sendMessage(const Message & message){ | |
| 159 | 10 | bool b(true); | |
| 160 | 10 | const PVecString & vecDestination = message.getVecRecver(); | |
| 161 |
2/2✓ Branch 0 (17→4) taken 10 times.
✓ Branch 1 (17→18) taken 9 times.
|
38 | for(PVecString::const_iterator it(vecDestination.begin()); it != vecDestination.end(); ++it){ |
| 162 |
1/1✓ Branch 0 (6→7) taken 9 times.
|
10 | b &= sendMessage(*it, message); |
| 163 | } | ||
| 164 | 9 | return b; | |
| 165 | } | ||
| 166 | |||
| 167 | ///Send message to other Daemon | ||
| 168 | /** @param destinationName : name of the destination Daemon of the message | ||
| 169 | * @param message : message to be sent | ||
| 170 | * @return true on success, false otherwise (maybe received method does not exist) | ||
| 171 | */ | ||
| 172 | template<class _TBackend> | ||
| 173 | 20 | bool Daemon<_TBackend>::sendMessage(const PString & destinationName, const Message & message){ | |
| 174 |
2/2✓ Branch 0 (3→4) taken 10 times.
✓ Branch 1 (3→5) taken 10 times.
|
20 | if(message.getIsConfirmationNeeded()){ |
| 175 | 10 | addMessageToConfirm(message); | |
| 176 | } | ||
| 177 | 20 | checkSendStatus(p_backend.socketManager.sendData(destinationName, message, p_mainConfig.sendFlag)); | |
| 178 | 19 | return true; | |
| 179 | } | ||
| 180 | |||
| 181 | ///Send data to other Daemon (specialization for Data) | ||
| 182 | /** @param destinationName : name of the destination Daemon of the data | ||
| 183 | * @param data : data to be sent | ||
| 184 | * @param isConfirmationNeeded : true if a confirmation is needed | ||
| 185 | * @return true on success, false otherwise (maybe received method does not exist) | ||
| 186 | */ | ||
| 187 | template<class _TBackend> | ||
| 188 | 10 | bool Daemon<_TBackend>::sendData(const PString & destinationName, const Data & data, bool isConfirmationNeeded){ | |
| 189 |
1/1✓ Branch 0 (2→3) taken 10 times.
|
10 | Message message; |
| 190 |
2/2✓ Branch 0 (3→4) taken 10 times.
✓ Branch 2 (4→5) taken 10 times.
|
10 | message.setSendTime(p_backend.clock.now()); |
| 191 |
1/1✓ Branch 0 (5→6) taken 10 times.
|
10 | message.setData(data); |
| 192 |
2/2✓ Branch 0 (6→7) taken 10 times.
✓ Branch 2 (7→8) taken 10 times.
|
10 | message.setId(getMessageId()); |
| 193 |
1/1✓ Branch 0 (8→9) taken 10 times.
|
10 | message.setIsConfirmationNeeded(isConfirmationNeeded); |
| 194 |
1/1✓ Branch 0 (9→10) taken 10 times.
|
10 | message.setType(MessageType::RESULT_DATA); |
| 195 |
2/2✓ Branch 0 (10→11) taken 10 times.
✓ Branch 2 (11→12) taken 10 times.
|
10 | message.setSender(p_config.getName()); |
| 196 |
2/2✓ Branch 0 (12→13) taken 10 times.
✓ Branch 2 (13→14) taken 10 times.
|
10 | message.getVecRecver().push_back(destinationName); |
| 197 |
1/1✓ Branch 0 (14→15) taken 10 times.
|
20 | return sendMessage(destinationName, message); |
| 198 | 10 | } | |
| 199 | |||
| 200 | ///Computing Method for each event loop (when receiving message from other Daemon) | ||
| 201 | template<class _TBackend> | ||
| 202 | 10 | void Daemon<_TBackend>::extraLoopProcessing(){} | |
| 203 | |||
| 204 | ///Method which is called on stop of the Daemon | ||
| 205 | template<class _TBackend> | ||
| 206 | 6 | void Daemon<_TBackend>::executeOnStop(){} | |
| 207 | |||
| 208 | ///Initialisation function of the class Daemon | ||
| 209 | template<class _TBackend> | ||
| 210 | 16 | void Daemon<_TBackend>::initialisationDaemon(){ | |
| 211 | |||
| 212 | 16 | } | |
| 213 | |||
| 214 | ///Initialise the Daemon Sockets | ||
| 215 | template<class _TBackend> | ||
| 216 | 9 | void Daemon<_TBackend>::initialisationDaemonSocket(){ | |
| 217 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→10) taken 9 times.
|
9 | if(p_config.getName() == ""){ |
| 218 | ✗ | getLog().criticalAndThrow<Phoenix::ConfigException>("Daemon::initialisationDaemonSocket", "daemon has no name"); | |
| 219 | } | ||
| 220 |
1/2✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→13) taken 9 times.
|
9 | if(p_isFullMockRecord){ |
| 221 | ✗ | setSocketMode(PSocketMode::MOCK_RECORD); | |
| 222 | ✗ | setClockMode(PClockMode::MOCK_RECORD); | |
| 223 | }else{ | ||
| 224 |
2/2✓ Branch 0 (13→14) taken 6 times.
✓ Branch 1 (13→16) taken 3 times.
|
9 | if(p_isFullMock){ |
| 225 | 6 | setSocketMode(PSocketMode::MOCK); | |
| 226 | 6 | setClockMode(PClockMode::MOCK); | |
| 227 | } | ||
| 228 | } | ||
| 229 | //Let's send when we are a client and recv when we are a server | ||
| 230 | //By doing this way, we have one server per Daemon and as many clients as other Daemon | ||
| 231 | 9 | getLog().getLogInfo() << "Daemon<_TBackend>::initialisationDaemonSocket() : initialise pull socket for daemon '" << p_config.getName() << "'" << std::endl; | |
| 232 |
9/9✓ Branch 0 (25→26) taken 9 times.
✓ Branch 2 (28→29) taken 9 times.
✓ Branch 4 (31→32) taken 9 times.
✓ Branch 6 (32→33) taken 9 times.
✓ Branch 8 (33→34) taken 9 times.
✓ Branch 10 (34→35) taken 9 times.
✓ Branch 12 (35→36) taken 9 times.
✓ Branch 14 (39→40) taken 9 times.
✓ Branch 16 (40→41) taken 9 times.
|
63 | phoenix_assert(p_backend.socketManager.addServerSocket("pull", |
| 233 | PSocketParam{p_config.getHostName(), p_config.getReceivingPort(), p_mainConfig.recvTimeoutMs, p_mainConfig.sendTimeoutMs}, p_backend.extraServerParam, | ||
| 234 | "./" + p_config.getName() + "_", p_backend.extraMockServerParam)); | ||
| 235 | |||
| 236 | //Now let's initialise connexions to other | ||
| 237 |
2/2✓ Branch 0 (104→54) taken 10 times.
✓ Branch 1 (104→105) taken 9 times.
|
19 | for(MapDaemonConfig::iterator it(p_mapDaemon.begin()); it != p_mapDaemon.end(); ++it){ |
| 238 |
3/4✓ Branch 0 (54→55) taken 10 times.
✓ Branch 2 (56→57) taken 10 times.
✗ Branch 4 (58→59) not taken.
✓ Branch 5 (58→60) taken 10 times.
|
10 | if(it->second.getName() == p_config.getName()){continue;} |
| 239 |
7/7✓ Branch 0 (60→61) taken 10 times.
✓ Branch 2 (61→62) taken 10 times.
✓ Branch 4 (62→63) taken 10 times.
✓ Branch 6 (64→65) taken 10 times.
✓ Branch 8 (65→66) taken 10 times.
✓ Branch 10 (66→67) taken 10 times.
✓ Branch 12 (67→68) taken 10 times.
|
10 | getLog().getLogInfo() << "Daemon<_TBackend>::initialisationDaemonSocket() : initialise send socket for neighbour Daemon '"<<it->second.getName()<<"'" << std::endl; |
| 240 |
11/11✓ Branch 0 (70→71) taken 10 times.
✓ Branch 2 (73→74) taken 10 times.
✓ Branch 4 (76→77) taken 10 times.
✓ Branch 6 (77→78) taken 10 times.
✓ Branch 8 (78→79) taken 10 times.
✓ Branch 10 (79→80) taken 10 times.
✓ Branch 12 (81→82) taken 10 times.
✓ Branch 14 (84→85) taken 10 times.
✓ Branch 16 (86→87) taken 10 times.
✓ Branch 18 (87→88) taken 10 times.
✓ Branch 20 (88→89) taken 10 times.
|
90 | phoenix_assert(p_backend.socketManager.addClientSocket(it->second.getName(), |
| 241 | PSocketParam{it->second.getHostName(), it->second.getReceivingPort(), p_mainConfig.recvTimeoutMs, p_mainConfig.sendTimeoutMs}, p_backend.extraClientParam, | ||
| 242 | "./" + p_config.getName() + "_", p_backend.extraMockClientParam)); | ||
| 243 | // p_backend.socketManager.getSocket(it->second.getName())->waitUntilConnection(500000lu, 30lu); //0.5 s per check and 30 checks | ||
| 244 | } | ||
| 245 | 9 | getLog().getLogInfo() << "Daemon<_TBackend>::initialisationDaemonSocket() : all connection to neighbours Daemon initialised" << std::endl; | |
| 246 |
4/4✓ Branch 0 (109→110) taken 9 times.
✓ Branch 2 (110→111) taken 9 times.
✓ Branch 4 (111→112) taken 9 times.
✓ Branch 6 (112→113) taken 9 times.
|
9 | p_backend.clock.setMockPrefix("./" + p_config.getName() + "_"); |
| 247 | 57 | } | |
| 248 | |||
| 249 | ///Process an input message | ||
| 250 | /** @param[out] message : received Message to be processed | ||
| 251 | */ | ||
| 252 | template<class _TBackend> | ||
| 253 | 22 | void Daemon<_TBackend>::processInputMessage(Message & message){ | |
| 254 | //Check is the message needs a confirmation | ||
| 255 |
2/2✓ Branch 0 (3→4) taken 10 times.
✓ Branch 1 (3→18) taken 12 times.
|
22 | if(message.getIsConfirmationNeeded()){ |
| 256 |
1/1✓ Branch 0 (4→5) taken 10 times.
|
10 | Message confirmation; |
| 257 | //We do not need to change the time of the message because it has to be in the clock reference of the sender | ||
| 258 |
2/2✓ Branch 0 (5→6) taken 10 times.
✓ Branch 2 (6→7) taken 10 times.
|
10 | confirmation.setSendTime(message.getSendTime()); |
| 259 |
2/2✓ Branch 0 (7→8) taken 10 times.
✓ Branch 2 (8→9) taken 10 times.
|
10 | confirmation.setId(message.getId()); |
| 260 |
2/2✓ Branch 0 (9→10) taken 10 times.
✓ Branch 2 (10→11) taken 10 times.
|
10 | confirmation.setSender(p_config.getName()); |
| 261 |
1/1✓ Branch 0 (11→12) taken 10 times.
|
10 | confirmation.setType(MessageType::MESSAGE_CONFIRMATION); |
| 262 |
3/3✓ Branch 0 (12→13) taken 10 times.
✓ Branch 2 (13→14) taken 10 times.
✓ Branch 4 (14→15) taken 10 times.
|
10 | confirmation.getVecRecver().push_back(message.getSender()); |
| 263 |
1/1✓ Branch 0 (15→16) taken 9 times.
|
10 | sendMessage(confirmation); |
| 264 | 10 | } | |
| 265 | |||
| 266 | //Let's check is we receive a stop message | ||
| 267 |
2/2✓ Branch 0 (19→20) taken 5 times.
✓ Branch 1 (19→21) taken 16 times.
|
21 | if(message.getType() == MessageType::STOP){stop();} |
| 268 |
2/2✓ Branch 0 (22→23) taken 7 times.
✓ Branch 1 (22→26) taken 9 times.
|
16 | else if(message.getType() == MessageType::MESSAGE_CONFIRMATION){ |
| 269 | 7 | processConfirmedMessage(message.getId(), p_backend.clock.now()); | |
| 270 |
1/2✓ Branch 0 (27→28) taken 9 times.
✗ Branch 1 (27→80) not taken.
|
9 | }else if(message.getType() == MessageType::RESULT_DATA){ |
| 271 | 9 | AbstractDataFunction* function = getDataFunction(message.getData()); | |
| 272 |
1/2✗ Branch 0 (30→31) not taken.
✓ Branch 1 (30→32) taken 9 times.
|
9 | if(function == NULL){ |
| 273 | ✗ | return; | |
| 274 | } | ||
| 275 | 9 | time_t functionStartTime = p_backend.clock.now(); | |
| 276 |
1/2✗ Branch 0 (35→36) not taken.
✓ Branch 1 (35→48) taken 9 times.
|
9 | if(!function->call(p_log, message.getData())){ |
| 277 | ✗ | getLog().getLogError() << "Daemon<_TBackend>::processInputMessage : cannot process data of type '"<<message.getData().getType()<<"' from Daemon '"<<message.getSender()<<"'" << std::endl; | |
| 278 | ✗ | return; | |
| 279 | } | ||
| 280 | 9 | time_t functionEllapsedTime = p_backend.clock.now() - functionStartTime; | |
| 281 | 9 | getLog().getLogDebug() << "Daemon<_TBackend>::processInputMessage : function '"<<message.getData().getType()<<"' processed data from daemon '"<<message.getSender()<<"' in "<<functionEllapsedTime<<" nanoseconds" << std::endl; | |
| 282 |
6/6✓ Branch 0 (64→65) taken 7 times.
✓ Branch 1 (64→70) taken 2 times.
✓ Branch 2 (68→69) taken 5 times.
✓ Branch 3 (68→70) taken 2 times.
✓ Branch 4 (71→72) taken 5 times.
✓ Branch 5 (71→80) taken 4 times.
|
9 | if(p_config.getStatDaemonName() != "" && p_config.getStatDaemonName() != p_config.getName()){ |
| 283 |
6/6✓ Branch 0 (72→73) taken 5 times.
✓ Branch 2 (73→74) taken 5 times.
✓ Branch 4 (74→75) taken 5 times.
✓ Branch 6 (75→76) taken 5 times.
✓ Branch 8 (76→77) taken 5 times.
✓ Branch 10 (78→79) taken 5 times.
|
5 | updateStatAccumulator(p_config.getDaemonStatAccumulator().getMapStatComputing().find(message.getData().getType())->second, functionEllapsedTime); |
| 284 | } | ||
| 285 | } | ||
| 286 | } | ||
| 287 | |||
| 288 | ///Send the statistics of the Daemon to the Stat Daemon | ||
| 289 | /** @param[out] currentTime : current time to be used for the statistics | ||
| 290 | */ | ||
| 291 | template<class _TBackend> | ||
| 292 | 170 | void Daemon<_TBackend>::sendStatToStatDaemon(time_t currentTime){ | |
| 293 | //Let's fill the DaemonStat | ||
| 294 |
1/1✓ Branch 0 (2→3) taken 170 times.
|
170 | DaemonStat stat; |
| 295 |
1/1✓ Branch 0 (3→4) taken 170 times.
|
170 | fillDaemonStat(stat, p_startTimestamp, currentTime); |
| 296 |
2/2✓ Branch 0 (4→5) taken 170 times.
✓ Branch 2 (5→6) taken 170 times.
|
170 | stat.setName(p_config.getName()); |
| 297 | |||
| 298 | //Let's send it to the Stat Daemon | ||
| 299 |
10/10✓ Branch 0 (6→7) taken 170 times.
✓ Branch 2 (7→8) taken 170 times.
✓ Branch 4 (8→9) taken 165 times.
✓ Branch 5 (8→14) taken 5 times.
✓ Branch 6 (9→10) taken 165 times.
✓ Branch 8 (10→11) taken 165 times.
✓ Branch 10 (12→13) taken 2 times.
✓ Branch 11 (12→14) taken 163 times.
✓ Branch 12 (15→16) taken 2 times.
✓ Branch 13 (15→25) taken 168 times.
|
170 | if(p_config.getStatDaemonName() != "" && p_config.getStatDaemonName() != p_config.getName()){ |
| 300 |
7/7✓ Branch 0 (16→17) taken 2 times.
✓ Branch 2 (17→18) taken 2 times.
✓ Branch 4 (18→19) taken 2 times.
✓ Branch 6 (19→20) taken 2 times.
✓ Branch 8 (20→21) taken 2 times.
✓ Branch 10 (21→22) taken 2 times.
✓ Branch 12 (22→23) taken 2 times.
|
2 | getLog().getLogDebug() << "Daemon::sendStatToStatDaemon() : sending statistics to Stat Daemon '"<<p_config.getStatDaemonName()<<"'" << std::endl; |
| 301 |
2/2✓ Branch 0 (23→24) taken 2 times.
✓ Branch 2 (24→25) taken 2 times.
|
2 | sendValue(p_config.getStatDaemonName(), stat, true); |
| 302 | } | ||
| 303 | |||
| 304 |
1/1✓ Branch 0 (25→26) taken 170 times.
|
170 | clearStat(); |
| 305 | 170 | p_startTimestamp = currentTime; | |
| 306 | 170 | } | |
| 307 | |||
| 308 | #endif | ||
| 309 | |||
| 310 |