App counters including message name and result code if proceed
[anna.git] / source / diameter.comm / ClientSession.cpp
index 5a7ca94..aea2851 100644 (file)
 #include <stdlib.h> // rand()
 #include <time.h>
 
-// XXXXXXXXXX
-#include <iostream>
-
-
-
 
 using namespace std;
 using namespace anna::diameter;
@@ -86,7 +81,7 @@ int ClientSession::getPort() const throw() {
 void ClientSession::setState(State::_v state) throw() {
   Session::setState(state);
   // Inform father server (availability changes):
-  bool changes = a_parent->refreshAvailability();
+  a_parent->refreshAvailability();
 }
 
 void ClientSession::bind() throw(anna::RuntimeException) {
@@ -453,6 +448,12 @@ void ClientSession::eventPeerShutdown() throw() {
 }
 
 void ClientSession::eventRequestRetransmission(Message *request) throw() {
+
+  // OAM
+  OamModule &oamModule = OamModule::instantiate();
+  oamModule.count(OamModule::Counter::RequestRetransmitted);
+  oamModule.count(OamModule::Counter::RequestRetransmittedOnClientSession);
+
   // Inform father server:
   a_parent->eventRequestRetransmission(this, request);
 }
@@ -509,12 +510,13 @@ throw(anna::RuntimeException) {
       }
     }
 );
+
   // Main counters:
   OamModule &oamModule = OamModule::instantiate();
   oamModule.count(isRequest ? OamModule::Counter::RequestReceived : OamModule::Counter::AnswerReceived);
   oamModule.count(isRequest ? OamModule::Counter::RequestReceivedOnClientSession : OamModule::Counter::AnswerReceivedOnClientSession);
   // Statistic (size)
-  a_parent->updateReceivedMessageSizeStatisticConcept(message.getSize()); // only on reception (application could manage sent sizes)
+  a_parent->updateReceivedMessageSizeStatisticConcept(message.getSize(), cid); // only on reception (application could manage sent sizes)
 
   if(isRequest) {
     /////////////////////////////
@@ -552,7 +554,7 @@ throw(anna::RuntimeException) {
 
     try {
       // application message counters
-      ApplicationMessageOamModule::instantiate().count(cid.first, anna::diameter::codec::functions::getApplicationId(db), ApplicationMessageOamModule::Counter::Request_Received_AsClient);
+      ApplicationMessageOamModule::instantiate().count(cid.first, -1 /* no result code */, anna::diameter::codec::functions::getApplicationId(db), ApplicationMessageOamModule::Counter::Request_Received_AsClient);
 
       eventRequest(db);
     } catch(anna::RuntimeException& ex) {
@@ -598,7 +600,7 @@ throw(anna::RuntimeException) {
       setState(State::Bound);
       //activateTimer(); // Ya se invoca al inicio de este metodo ::receive
       // Inform father server (availability changes):
-      bool changes = a_parent->refreshAvailability();
+      a_parent->refreshAvailability();
       //startClock();
     }
   }
@@ -656,7 +658,7 @@ throw(anna::RuntimeException) {
     oamModule.activateAlarm(OamModule::Alarm::AnswerReceivedOnClientSessionUnknown);
 
     // application message counters
-    ApplicationMessageOamModule::instantiate().count(cid.first, anna::diameter::codec::functions::getApplicationId(db), ApplicationMessageOamModule::Counter::Answer_UnknownReceived_AsClient);
+    ApplicationMessageOamModule::instantiate().count(cid.first, resultCode, anna::diameter::codec::functions::getApplicationId(db), ApplicationMessageOamModule::Counter::Answer_UnknownReceived_AsClient);
 
     eventUnknownResponse(db);
     string msg(asString());
@@ -677,14 +679,14 @@ throw(anna::RuntimeException) {
   anna::Millisecond current = (anna::Millisecond)anna::functions::millisecond();
   anna::Millisecond request = response->getRequest()->getRequestTimestampMs();
   anna::Millisecond timeToAnswerMs = current - request;
-  a_parent->updateProcessingTimeStatisticConcept(timeToAnswerMs);
-  LOGDEBUG
-  (
-    std::string msg = "This diameter request context lasted ";
-    msg += anna::functions::asString(timeToAnswerMs);
-    msg += " milliseconds at diameter server (included network time)";
-    anna::Logger::debug(msg, ANNA_FILE_LOCATION);
-  );
+  a_parent->updateProcessingTimeStatisticConcept(timeToAnswerMs, cid);
+  //LOGDEBUG
+  //(
+  //  std::string msg = "This diameter request context lasted ";
+  //  msg += anna::functions::asString(timeToAnswerMs);
+  //  msg += " milliseconds at diameter server (included network time)";
+  //  anna::Logger::debug(msg, ANNA_FILE_LOCATION);
+  //);
   // Progress origin for tracking purposes on asyncronous boxes with both diameter interfaces (entities and clients)
   Message * requestMessage = const_cast<Message*>(response->getRequest());
   requestMessage->setRequestServerSessionKey(response->getRequest()->getRequestServerSessionKey()); // -1 means unkown/unset
@@ -706,7 +708,7 @@ throw(anna::RuntimeException) {
 
       // application message counters
       if(cid != helpers::base::COMMANDID__Capabilities_Exchange_Answer)
-        ApplicationMessageOamModule::instantiate().count(cid.first, anna::diameter::codec::functions::getApplicationId(db), ApplicationMessageOamModule::Counter::Answer_Received_AsClient);
+        ApplicationMessageOamModule::instantiate().count(cid.first, resultCode, anna::diameter::codec::functions::getApplicationId(db), ApplicationMessageOamModule::Counter::Answer_Received_AsClient);
 
       eventResponse(*response);
     } catch(anna::RuntimeException& ex) {
@@ -729,10 +731,8 @@ throw(anna::RuntimeException) {
 void ClientSession::finalize() throw() {
   LOGMETHOD(anna::TraceMethod traceMethod(a_className, "finalize", ANNA_FILE_LOCATION));
   Session::finalize();
-  // Check deprecated entity:
-  const Entity *entity = getParent() /* server */ ->getParent() /* entity */;
   // Inform father server (availability changes):
-  bool changes = a_parent->refreshAvailability();
+  a_parent->refreshAvailability();
   // OAM
   const Server *server = getParent();
   bool multipleConnections = (server->getMaxClientSessions() > 1);
@@ -763,7 +763,7 @@ void ClientSession::recover() throw() {
   }
 
   // Inform father server (availability changes):
-  bool changes = a_parent->refreshAvailability();
+  a_parent->refreshAvailability();
   // OAM
   const Server *server = getParent();
   bool multipleConnections = (server->getMaxClientSessions() > 1);
@@ -979,7 +979,7 @@ void ClientSession::countSendings(const diameter::CommandId & cid, unsigned int
     else if(cid == helpers::base::COMMANDID__Disconnect_Peer_Answer) oamModule.count(OamModule::Counter::DPASentOK);
     // Application messages:
     else {
-      appMsgOamModule.count(cid.first, aid, isRequest ? ApplicationMessageOamModule::Counter::Request_SentOK_AsClient : ApplicationMessageOamModule::Counter::Answer_SentOK_AsClient);
+      appMsgOamModule.count(cid.first, -1 /* no result code */, aid, isRequest ? ApplicationMessageOamModule::Counter::Request_SentOK_AsClient : ApplicationMessageOamModule::Counter::Answer_SentOK_AsClient);
     }
   } else {
     // Main counters:
@@ -993,7 +993,7 @@ void ClientSession::countSendings(const diameter::CommandId & cid, unsigned int
     else if(cid == helpers::base::COMMANDID__Disconnect_Peer_Answer) oamModule.count(OamModule::Counter::DPASentNOK);
     // Application messages:
     else {
-      appMsgOamModule.count(cid.first, aid, isRequest ? ApplicationMessageOamModule::Counter::Request_SentNOK_AsClient : ApplicationMessageOamModule::Counter::Answer_SentNOK_AsClient);
+      appMsgOamModule.count(cid.first, -1 /* no result code */, aid, isRequest ? ApplicationMessageOamModule::Counter::Request_SentNOK_AsClient : ApplicationMessageOamModule::Counter::Answer_SentNOK_AsClient);
     }
   }
 }