X-Git-Url: https://git.teslayout.com/public/public/public/?p=anna.git;a=blobdiff_plain;f=example%2Fdiameter%2Flauncher%2FLauncher.cpp;h=116c325e75285a49a5e0e2f3e7d6be04091e2256;hp=88e4c44b42d1a83ae2e4934763eb610a532eb2cf;hb=0c533bf948a63d134c8001e16b15194b197cb99a;hpb=3b2bc9873ddd3fa3418046fe6b1c320552d34b23 diff --git a/example/diameter/launcher/Launcher.cpp b/example/diameter/launcher/Launcher.cpp index 88e4c44..116c325 100644 --- a/example/diameter/launcher/Launcher.cpp +++ b/example/diameter/launcher/Launcher.cpp @@ -745,34 +745,11 @@ throw(anna::RuntimeException) { a_timeEngine->activate(a_counterRecorderClock); // start clock } - // Log statistics concepts - if(cl.exists("logStatisticSamples")) { - std::string list = cl.getValue("logStatisticSamples"); - anna::statistics::Engine &statEngine = anna::statistics::Engine::instantiate(); - - if(list == "all") { - if(statEngine.enableSampleLog(/* -1: all concepts */)) - LOGDEBUG(anna::Logger::debug("Sample log activation for all statistic concepts", ANNA_FILE_LOCATION)); - } else { - anna::Tokenizer lst; - lst.apply(cl.getValue("logStatisticSamples"), ","); - - if(lst.size() >= 1) { - anna::Tokenizer::const_iterator tok_min(lst.begin()); - anna::Tokenizer::const_iterator tok_max(lst.end()); - anna::Tokenizer::const_iterator tok_iter; - int conceptId; - - for(tok_iter = tok_min; tok_iter != tok_max; tok_iter++) { - conceptId = atoi(anna::Tokenizer::data(tok_iter)); - - if(statEngine.enableSampleLog(conceptId)) - LOGDEBUG(anna::Logger::debug(anna::functions::asString("Sample log activation for statistic concept id = %d", conceptId), ANNA_FILE_LOCATION)); - } - } - } - } - + ///////////////////////////// + // Log statistics concepts // + ///////////////////////////// + if(cl.exists("logStatisticSamples")) + logStatisticsSamples(cl.getValue("logStatisticSamples")); // Start client connections ////////////////////////////////////////////////////////////////////////////////// MyDiameterEntity *entity; @@ -1036,6 +1013,11 @@ std::string Launcher::help() const throw() { result += "\n This operation applies over all the registered host 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 += "\nlog-statistics-samples| Log statistics samples for the provided comma-separated concept id"; + result += "\n list, over './sample..csv' files. For example: \"1,2\""; + result += "\n will log concepts 1 and 2. Reserved words \"all\"/\"none\" activates/"; + result += "\n deactivates all registered statistics concept identifiers. That ids"; + result += "\n are shown at context dump."; result += "\nchange-dir[|directory] Changes the execution point which could be fine to ease some"; result += "\n file system interaction tasks. Be care about some requirements"; result += "\n (for example if you have a user defined counters directory as"; @@ -1476,6 +1458,38 @@ std::string Launcher::help() const throw() { return result; } + +void Launcher::logStatisticsSamples(const std::string &conceptsList) throw() { + anna::statistics::Engine &statEngine = anna::statistics::Engine::instantiate(); + + if(conceptsList == "all") { + if(statEngine.enableSampleLog(/* -1: all concepts */)) + LOGDEBUG(anna::Logger::debug("Sample log activation for all statistic concepts", ANNA_FILE_LOCATION)); + } + else if(conceptsList == "none") { + if(statEngine.disableSampleLog(/* -1: all concepts */)) + LOGDEBUG(anna::Logger::debug("Sample log deactivation for all statistic concepts", ANNA_FILE_LOCATION)); + } else { + anna::Tokenizer lst; + lst.apply(conceptsList, ","); + + if(lst.size() >= 1) { + anna::Tokenizer::const_iterator tok_min(lst.begin()); + anna::Tokenizer::const_iterator tok_max(lst.end()); + anna::Tokenizer::const_iterator tok_iter; + int conceptId; + + for(tok_iter = tok_min; tok_iter != tok_max; tok_iter++) { + conceptId = atoi(anna::Tokenizer::data(tok_iter)); + + if(statEngine.enableSampleLog(conceptId)) + LOGDEBUG(anna::Logger::debug(anna::functions::asString("Sample log activation for statistic concept id = %d", conceptId), ANNA_FILE_LOCATION)); + } + } + } +} + + void Launcher::eventOperation(const std::string &operation, std::string &response_content) throw(anna::RuntimeException) { LOGMETHOD(anna::TraceMethod tm("Launcher", "eventOperation", ANNA_FILE_LOCATION)); if (operation == "") return; // ignore @@ -1573,6 +1587,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons bool wrongBody = false; if((opType == "change-dir") && (numParams > 1)) wrongBody = true; + if((opType == "log-statistics-samples") && (numParams != 1)) wrongBody = true; if((opType == "node") && (numParams > 1)) wrongBody = true; if((opType == "node_auto") && (numParams > 0)) wrongBody = true; @@ -1603,6 +1618,12 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons return; } + if(opType == "log-statistics-samples") { + logStatisticsSamples(param1); + response_content = anna::functions::asString("Log statistics samples for '%s' concepts", param1.c_str()); + return; + } + // Change execution directory: if(opType == "change-dir") { if (param1 == "") param1 = a_initialWorkingDirectory;