Message statistics
[anna.git] / include / anna / diameter.comm / LocalServer.hpp
index 9d733d4..e0ce97c 100644 (file)
 // STL
 #include <string>
 #include <vector>
+#include <map>
 
+// Project
 #include <anna/config/defines.hpp>
-#include <anna/statistics/Accumulator.hpp>
 #include <anna/diameter.comm/ServerSession.hpp>
+#include <anna/diameter/defines.hpp>
+#include <anna/diameter.comm/MessageStatistics.hpp>
 
 
 namespace anna {
@@ -65,10 +68,8 @@ class LocalServer {
   Engine *a_engine;
 
   // Statistics
-  int a_processing_time__StatisticConceptId; // request from local server (dpr's, etc.)
-  int a_received_message_size__StatisticConceptId;
-  anna::statistics::Accumulator a_statisticsAccumulator;
-  void initializeStatisticConcepts() throw();
+  MessageStatistics a_messageStatistics;
+  void initializeStatisticResources() throw();
   void resetStatistics() throw();
 
 //   void eraseServerSession(const anna::comm::ClientSocket& clientSocket) throw();
@@ -143,6 +144,14 @@ public:
   */
   void setDescription(const std::string description) throw() { a_description = description; }
 
+  /**
+     Set timeout to consider failed a request.
+     \param v Requests class code.
+     \param millisecond Milliseconds wait before considering the requests failed.
+
+     Timers are internally managed and automatically activated.
+  */
+  void setClassCodeTimeout(const ClassCode::_v v, const anna::Millisecond & millisecond) throw();
 
   /**
      Sets the server socket optional category
@@ -175,14 +184,14 @@ public:
   */
   void setEngine(Engine *e) throw() { a_engine = e; }
 
-//  /**
-//  * Gets the diameter::comm::Engine
-//  * @return Diameter::comm::Engine
-//  */
-//  Engine *getEngine() const throw() { return a_engine; }
-
   // getters
 
+  /**
+  * Gets the diameter::comm::Engine
+  * @return Diameter::comm::Engine
+  */
+  Engine *getEngine() const throw() { return a_engine; }
+
   /**
   * Gets the local server key
   * @return LocalServer key
@@ -343,10 +352,10 @@ public:
   anna::xml::Node* asXML(anna::xml::Node* parent) const throw();
 
   // Statistics
-  void updateProcessingTimeStatisticConcept(const double &value) throw();
-  void updateReceivedMessageSizeStatisticConcept(const double &value) throw();
-  int getProcessingTimeStatisticConcept() const throw() { return a_processing_time__StatisticConceptId; }
-  int getReceivedMessageSizeStatisticConcept() const throw() { return a_received_message_size__StatisticConceptId; }
+  void updateProcessingTimeStatisticConcept(const double &value, const anna::diameter::CommandId &cid) throw();
+  void updateReceivedMessageSizeStatisticConcept(const double &value, const anna::diameter::CommandId &cid) throw();
+//  int getProcessingTimeStatisticConcept() const throw() { return a_processing_time__StatisticConceptId; }
+//  int getReceivedMessageSizeStatisticConcept() const throw() { return a_received_message_size__StatisticConceptId; }
 
 protected:
 
@@ -412,4 +421,3 @@ protected:
 }
 
 #endif
-