From: Eduardo Ramos Testillano Date: Wed, 22 Apr 2015 10:54:01 +0000 (+0200) Subject: Virtualize Dictionary::load, implements launcher management operation: forceCountersR... X-Git-Tag: REFACTORING_TESTING_LIBRARY~151 X-Git-Url: https://git.teslayout.com/public/public/public/?p=anna.git;a=commitdiff_plain;h=7ac94d8f360628b59b7fed8bfbc4509ad055712e Virtualize Dictionary::load, implements launcher management operation: forceCountersRecord --- diff --git a/example/diameter/launcher/main.cpp b/example/diameter/launcher/main.cpp index 92dd89b..44d2c06 100644 --- a/example/diameter/launcher/main.cpp +++ b/example/diameter/launcher/main.cpp @@ -436,6 +436,7 @@ public: void writeBurstLogFile(const std::string &buffer) throw(); bool burstLogEnabled() const throw() { return (((a_burstLogFile == "") || (a_burstLogFile == "null")) ? false : true); } void startDiameterServer(int) throw(anna::RuntimeException); + void forceCountersRecord() throw(anna::RuntimeException) { if (a_counterRecorderClock) a_counterRecorderClock->tick(); } anna::xml::Node* asXML(anna::xml::Node* parent) const throw(); void resetStatistics() throw() { a_myDiameterEngine->resetStatistics(); } @@ -846,6 +847,7 @@ std::string Launcher::help() const throw() { result += "\ncollect Reset statistics and counters to start a new test stage of"; result += "\n performance measurement. Context data is written at"; result += "\n '/var/tmp/anna.context.' by mean 'kill -10 '."; + result += "\nforceCountersRecord Forces dump to file the current counters of the process."; result += "\n"; result += "\n|[
:]|[socket id]"; result += "\n"; @@ -1835,6 +1837,13 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons return; } + // Counters dump on demand: + if(operation == "forceCountersRecord") { + forceCountersRecord(); + response_content = "Current counters have been dump to disk\n"; + return; + } + /////////////////////////////////////////////////////////////////// // Tokenize operation Tokenizer params; @@ -2228,14 +2237,14 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons response_content += "' loaded."; response_content += "\n"; } else if((opType == "answerxml") || (opType == "answerxml2c")) { - response_content += "Answer to client '"; + response_content += "'"; response_content += param1; - response_content += "' programmed."; + response_content += "' applied on server FIFO queue"; response_content += "\n"; } else if(opType == "answerxml2e") { - response_content += "Answer to entity '"; + response_content += "'"; response_content += param1; - response_content += "' programmed."; + response_content += "' applied on client FIFO queue"; response_content += "\n"; } else if(opType == "diameterServerSessions") { response_content += "Maximum server socket connections updated to '"; diff --git a/include/anna/diameter/stack/Dictionary.hpp b/include/anna/diameter/stack/Dictionary.hpp index bd4cd4d..e332fec 100644 --- a/include/anna/diameter/stack/Dictionary.hpp +++ b/include/anna/diameter/stack/Dictionary.hpp @@ -223,7 +223,7 @@ public: * and stack-specific commands in other set of xml files. Application only would have to load common part for all * the created dictionaries with this method and specific one for each final dictionary: * - * @param xmlPathFile Path file to the xml document which represents the diameter dictionary. + * @param pathFile Path file to the xml document which represents the diameter dictionary. * *
   * Dictionary *nokiaStack = stackEngine.createDictionary("/var/tmp/vendors_and_avps.xml", NOKIA_STACK_ID);
@@ -232,7 +232,7 @@ public:
   * huaweiStack->load("/var/tmp/huawei_commands.xml");
   * 
*/ - void load(const std::string & xmlPathFile) throw(anna::RuntimeException); + virtual void load(const std::string & pathFile) throw(anna::RuntimeException); /** * Clears dictionary content diff --git a/source/diameter/stack/Dictionary.cpp b/source/diameter/stack/Dictionary.cpp index 821659c..3fc79d5 100644 --- a/source/diameter/stack/Dictionary.cpp +++ b/source/diameter/stack/Dictionary.cpp @@ -839,13 +839,13 @@ void Dictionary::extractCommands(const anna::xml::Node *rootNode) throw(anna::Ru //------------------------------------------------------------------------------ //----------------------------------------------------------- Dictionary::load() //------------------------------------------------------------------------------ -void Dictionary::load(const std::string & xmlPathFile) throw(anna::RuntimeException) { - if(xmlPathFile == "") +void Dictionary::load(const std::string & pathFile) throw(anna::RuntimeException) { + if(pathFile == "") throw anna::RuntimeException("Empty xml path file provided", ANNA_FILE_LOCATION); LOGDEBUG( std::string trace = "Loading diameter dictionary from '"; - trace += xmlPathFile; + trace += pathFile; trace += "' ..."; anna::Logger::debug(trace, ANNA_FILE_LOCATION); ); @@ -853,7 +853,7 @@ void Dictionary::load(const std::string & xmlPathFile) throw(anna::RuntimeExcept try { anna::xml::DocumentFile xmlDocument; // has private copy constructor defined but not implemented to avoid inhenrit/copy (is very heavy) const anna::xml::Node *rootNode; - xmlDocument.initialize(xmlPathFile.c_str()); // fail here is i/o error + xmlDocument.initialize(pathFile.c_str()); // fail here is i/o error rootNode = xmlDocument.parse(*a_dtd); // Parsing: fail here if xml violates dtd a_name = rootNode->getAttribute("name")->getValue(); //checkUniqueIdentifiers(rootNode); // Check unique id within xml, for vendor, avp and command nodes: