X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=example%2Fdiameter%2Flauncher%2FLauncher.cpp;h=4ec6ea060eee4d47a761649f4dfe0416c026cf69;hb=56afb5fb4f4985e5529e7491b78a6214e455f95a;hp=e8ac212fbde8eedc554edafd0f1e608c8d64eb6c;hpb=13b6f0196c2091f9e88a0778155cdcb733cfdafd;p=anna.git diff --git a/example/diameter/launcher/Launcher.cpp b/example/diameter/launcher/Launcher.cpp index e8ac212..4ec6ea0 100644 --- a/example/diameter/launcher/Launcher.cpp +++ b/example/diameter/launcher/Launcher.cpp @@ -132,7 +132,11 @@ Launcher::Launcher() : anna::comm::Application("launcher", "DiameterLauncher", " void Launcher::servicesFromXML(const anna::xml::Node* servicesNode, bool eventOperation) throw(anna::RuntimeException) { - // + + CommandLine& cl(anna::CommandLine::instantiate()); + bool allLogsDisabled = cl.exists("disableLogs"); + + // const anna::xml::Attribute *id, *dictionary; // @@ -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 @@ -159,7 +162,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 +187,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 +235,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++) { @@ -356,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: @@ -975,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| Updates the maximum number of accepted connections to diameter"; result += "\n server socket."; @@ -988,6 +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 += "\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[|
:][|socket id]"; result += "\n"; @@ -1438,6 +1443,18 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons return; } + // OAM & statistics: + 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(statsAsXML(&root)); + return; + } + /////////////////////////////////////////////////////////////////// // Tokenize operation Tokenizer params; @@ -1517,7 +1534,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()); @@ -2119,15 +2136,34 @@ throw() { it->second->asXML(result); } + // OAM & statistics: + oamAsXML(result); + statsAsXML(result); + + // Testing: could be heavy if test case reports are enabled + TestManager::instantiate().asXML(result); + + return result; +} + +anna::xml::Node* Launcher::oamAsXML(anna::xml::Node* parent) const +throw() { + 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); - // Testing: could be heavy if test case reports are enabled - TestManager::instantiate().asXML(result); - return result; }