Not allowed to set engine NULL !!
[anna.git] / example / diameter / launcher / Launcher.cpp
index edeaf88..5ee3466 100644 (file)
@@ -159,7 +159,6 @@ void Launcher::servicesFromXML(const anna::xml::Node* servicesNode, bool eventOp
   anna::diameter::comm::ApplicationMessageOamModule & appMsgOamModule = anna::diameter::comm::ApplicationMessageOamModule::instantiate();
   appMsgOamModule.enableCounters(); // this special module is disabled by default (the only)
   static int scope_id = 3;
-  bool id_0_registered = false;
   unsigned int id_value;
   std::string codecEngineName;
 
@@ -185,10 +184,7 @@ void Launcher::servicesFromXML(const anna::xml::Node* servicesNode, bool eventOp
         throw ex;
       }
 
-      if (id_value == 0) {
-        id_0_registered = true;
-        bpd = d;
-      }
+      bpd = d; // base protocol dictionary in case of monostack. If multistack, will be calculated later
 
       // Create codec engine and register it in the codec engine manager:
       codecEngineName = anna::functions::asString("CodecEngineForStackId_%llu", id_value);
@@ -236,14 +232,10 @@ void Launcher::servicesFromXML(const anna::xml::Node* servicesNode, bool eventOp
   // Basic checking for multistack:
   bool multistack = (stackEngine.stack_size() > 1);
   if (multistack) {
-    if(!id_0_registered)
+    bpd = stackEngine.getDictionary(0);
+    if(!bpd)
       throw anna::RuntimeException("In multistack applications is mandatory register a stack id = 0 using a dictionary which contains the needed elements to build base protocol messages (CER/A, DWR/A, DPR/A, STR/A, etc.)", ANNA_FILE_LOCATION);
   }
-  else { // monostack
-    if (!bpd)
-      bpd = ce->getDictionary(); // in mono-stack applications, we understand the existing stack as the used
-                                 // for base protocol, regardless if it is registered with stack id 0 or not
-  }
 
   // REALMS:
   for(anna::xml::Node::const_child_iterator it = servicesNode->child_begin(); it != servicesNode->child_end(); it++) {
@@ -988,6 +980,8 @@ 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 += "\n";
   result += "\n<visibility action>[|<address>:<port>][|socket id]";
   result += "\n";
@@ -1354,7 +1348,9 @@ std::string Launcher::help() const throw() {
   result += "\n";
   result += "\n   test|clear                    Clears all the programmed test cases and stop testing (if in progress).";
   result += "\n";
-  result += "\n   test|stat                     Global statistics.";
+  result += "\n   test|summary                  Test manager general report (number of test cases, counts by state, global configuration,";
+  result += "\n                                 forced in-progress limitation, reports visibility, etc.). Be careful when you have reports";
+  result += "\n                                 dumps enabled because all the programmed test cases will be dump and that could be heavy.";
   result += "\n";
   result += "\n";
   result += "\nUSING OPERATIONS INTERFACE";
@@ -1436,6 +1432,13 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
     return;
   }
 
+  // OAM & statistics:
+  if(operation == "oam-and-stats") {
+    anna::xml::Node root("root");
+    response_content = anna::xml::Compiler().apply(oamAndStatsAsXML(&root));
+    return;
+  }
+
   ///////////////////////////////////////////////////////////////////
   // Tokenize operation
   Tokenizer params;
@@ -1515,7 +1518,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
     }
     catch(anna::RuntimeException &ex) {
       ex.trace();
-      response_content = anna::functions::asString("Loaded services from file '%s' with some problems (ignored ones)", servicesFile.c_str());
+      response_content = anna::functions::asString("Loaded services from file '%s' with errors", servicesFile.c_str());
       return;
     }
     response_content = anna::functions::asString("Loaded services from file '%s'", servicesFile.c_str());
@@ -1747,6 +1750,8 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
     // test|interact|amount|id            Makes interactive a specific test case id. The amount is the margin of execution steps ...
     // test|reset|<soft/hard>[|id]        Reset the test case for id provided, all the tests when missing ...
     // test|clear                         Clears all the programmed test cases.
+    // test|summary                       Test manager general report (number of test cases, counts by state ...
+
 
     if(param1 == "ttps") {
       if (numParams > 2)
@@ -1916,6 +1921,10 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
         opt_response_content = "there are not programmed test cases to be removed";
       }
     }
+    else if(param1 == "summary") {
+      response_content = testManager.asXMLString();
+      return;
+    }
     else {
       int id = atoi(param1.c_str());
       if(id < 0)
@@ -2111,6 +2120,19 @@ throw() {
     it->second->asXML(result);
   }
 
+  // OAM & statistics:
+  oamAndStatsAsXML(result);
+
+  // Testing: could be heavy if test case reports are enabled
+  TestManager::instantiate().asXML(result);
+
+  return result;
+}
+
+anna::xml::Node* Launcher::oamAndStatsAsXML(anna::xml::Node* parent) const
+throw() {
+  anna::xml::Node* result = parent->createChild("OamAndStatistics");
+
   // OAM:
   anna::diameter::comm::OamModule::instantiate().asXML(result);
   anna::diameter::comm::ApplicationMessageOamModule::instantiate().asXML(result);
@@ -2118,8 +2140,6 @@ throw() {
   // Statistics:
   anna::statistics::Engine::instantiate().asXML(result);
 
-  // Testing: could be heavy if test case reports are enabled
-  //TestManager::instantiate().asXML(result);
-
   return result;
 }
+