Separate oam and statistics in event operations
[anna.git] / example / diameter / launcher / Launcher.cpp
index 5ee3466..4ec6ea0 100644 (file)
@@ -132,7 +132,11 @@ Launcher::Launcher() : anna::comm::Application("launcher", "DiameterLauncher", "
 
 
 void Launcher::servicesFromXML(const anna::xml::Node* servicesNode, bool eventOperation) throw(anna::RuntimeException) {
-  //<!ATTLIST stack id CDATA #REQUIRED dictionary CDATA #REQUIRED>
+
+  CommandLine& cl(anna::CommandLine::instantiate());
+  bool allLogsDisabled = cl.exists("disableLogs");
+
+    //<!ATTLIST stack id CDATA #REQUIRED dictionary CDATA #REQUIRED>
   const anna::xml::Attribute *id, *dictionary;
 
   // <!ATTLIST node originRealm CDATA #REQUIRED applicationId CDATA #REQUIRED originHost CDATA #IMPLIED cer CDATA #IMPLIED dwr CDATA #IMPLIED allowedInactivityTime CDATA #IMPLIED tcpConnectDelay CDATA #IMPLIED answersTimeout CDATA #IMPLIED ceaTimeout CDATA #IMPLIED watchdogPeriod CDATA #IMPLIED entity CDATA #IMPLIED entityServerSessions CDATA #IMPLIED diameterServer CDATA #IMPLIED diameterServerSessions CDATA #IMPLIED balance (yes | no) #IMPLIED sessionBasedModelsClientSocketSelection (SessionIdLowPart | SessionIdHighPart | SessionIdOptionalPart | RoundRobin) #IMPLIED retries CDATA #IMPLIED log CDATA #IMPLIED splitLog (yes | no) #IMPLIED detailedLog (yes | no) #IMPLIED dumpLog (yes | no) #IMPLIED burstLog (yes | no) #IMPLIED>
@@ -140,7 +144,6 @@ void Launcher::servicesFromXML(const anna::xml::Node* servicesNode, bool eventOp
   *answersTimeout, *ceaTimeout, *watchdogPeriod, *entity, *entityServerSessions,
   *diameterServer, *diameterServerSessions, *balance, *sessionBasedModelsClientSocketSelection,
   *retries, *log, *splitLog, *detailedLog, *dumpLog, *burstLog;
-
   // Never clear services content from here (append new data from xml). At the moment no node removing is implemented in this process
 
   // Stacks
@@ -348,13 +351,15 @@ void Launcher::servicesFromXML(const anna::xml::Node* servicesNode, bool eventOp
       }
 
       // Logs:
-      std::string realm = commEngine->getRealm();
-      std::string s_log = realm + ".launcher.log"; if (log) s_log = log->getValue();
-      bool b_splitLog = (splitLog ? (splitLog->getValue() == "yes") : false);
-      bool b_detailedLog = (detailedLog ? (detailedLog->getValue() == "yes") : false);
-      bool b_dumpLog = (dumpLog ? (dumpLog->getValue() == "yes") : false);
-      std::string s_burstLog = realm + ".launcher.burst"; if (burstLog) s_burstLog = burstLog->getValue();
-      a_workingNode->setLogs(s_log, b_splitLog, b_detailedLog, b_dumpLog, s_burstLog);
+      if (!allLogsDisabled) {
+        std::string realm = commEngine->getRealm();
+        std::string s_log = realm + ".launcher.log"; if (log) s_log = log->getValue();
+        bool b_splitLog = (splitLog ? (splitLog->getValue() == "yes") : false);
+        bool b_detailedLog = (detailedLog ? (detailedLog->getValue() == "yes") : false);
+        bool b_dumpLog = (dumpLog ? (dumpLog->getValue() == "yes") : false);
+        std::string s_burstLog = realm + ".launcher.burst"; if (burstLog) s_burstLog = burstLog->getValue();
+        a_workingNode->setLogs(s_log, b_splitLog, b_detailedLog, b_dumpLog, s_burstLog);
+      }
 
 
       // Lazy initialization for comm engine:
@@ -967,6 +972,10 @@ std::string Launcher::help() const throw() {
   result += "\n                                      to load new nodes once the ADML is started, regardless if command";
   result += "\n                                      line '--services' parameter was used or not. Those services which";
   result += "\n                                      are not correctly loaded will be ignored to keep the process alive.";
+  result += "\n                                     If you need to load services as deltas, you must firstly load the";
+  result += "\n                                      diameter base dictionary with stack id 0, because all the realms";
+  result += "\n                                      will use this dictionary to encode/decode base protocol messages";
+  result += "\n                                      managed by the communication engine.";
   result += "\n";
   result += "\ndiameterServerSessions|<integer>     Updates the maximum number of accepted connections to diameter";
   result += "\n                                      server socket.";
@@ -980,8 +989,10 @@ std::string Launcher::help() const throw() {
   result += "\n                                     This operation applies over all the registered realm nodes";
   result += "\n                                      except if one specific working node has been set.";
   result += "\nforceCountersRecord                  Forces dump to file the current counters of the process.";
-  result += "\noam-and-stats                        Dumps current counters and statistics of the process. This is";
-  result += "\n                                      also done at process context dump.";
+  result += "\nshow-oam                             Dumps current counters of the process. This is also done at";
+  result += "\n                                      process context dump.";
+  result += "\nshow-stats                           Dumps statistics of the process. This is also done at process";
+  result += "\n                                      context dump.";
   result += "\n";
   result += "\n<visibility action>[|<address>:<port>][|socket id]";
   result += "\n";
@@ -1433,9 +1444,14 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
   }
 
   // OAM & statistics:
-  if(operation == "oam-and-stats") {
+  if(operation == "show-oam") {
+    anna::xml::Node root("root");
+    response_content = anna::xml::Compiler().apply(oamAsXML(&root));
+    return;
+  }
+  if(operation == "show-stats") {
     anna::xml::Node root("root");
-    response_content = anna::xml::Compiler().apply(oamAndStatsAsXML(&root));
+    response_content = anna::xml::Compiler().apply(statsAsXML(&root));
     return;
   }
 
@@ -2121,7 +2137,8 @@ throw() {
   }
 
   // OAM & statistics:
-  oamAndStatsAsXML(result);
+  oamAsXML(result);
+  statsAsXML(result);
 
   // Testing: could be heavy if test case reports are enabled
   TestManager::instantiate().asXML(result);
@@ -2129,17 +2146,24 @@ throw() {
   return result;
 }
 
-anna::xml::Node* Launcher::oamAndStatsAsXML(anna::xml::Node* parent) const
+anna::xml::Node* Launcher::oamAsXML(anna::xml::Node* parent) const
 throw() {
-  anna::xml::Node* result = parent->createChild("OamAndStatistics");
+  anna::xml::Node* result = parent->createChild("Oam");
 
   // OAM:
   anna::diameter::comm::OamModule::instantiate().asXML(result);
   anna::diameter::comm::ApplicationMessageOamModule::instantiate().asXML(result);
   anna::diameter::codec::OamModule::instantiate().asXML(result);
+
+  return result;
+}
+
+anna::xml::Node* Launcher::statsAsXML(anna::xml::Node* parent) const
+throw() {
+  anna::xml::Node* result = parent->createChild("Statistics");
+
   // Statistics:
   anna::statistics::Engine::instantiate().asXML(result);
 
   return result;
 }
-