X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=example%2Fdiameter%2Flauncher%2FLauncher.cpp;h=4219399813e82a6fe06745cf1463b0bdabc9de64;hb=ec48516a195faabbb514298ad743520b3fdb7ee4;hp=f7921e72d37aeb3e5ddd60adde0c0a85214be081;hpb=e80e62a5cf9aacad1a9551c68c432147ef98cd29;p=anna.git diff --git a/example/diameter/launcher/Launcher.cpp b/example/diameter/launcher/Launcher.cpp index f7921e7..4219399 100644 --- a/example/diameter/launcher/Launcher.cpp +++ b/example/diameter/launcher/Launcher.cpp @@ -65,50 +65,51 @@ const char *ServicesDTD = "\ \n\ originRealm: Node identifier (Origin-Realm name).\n\ applicationId: The Application-Id provided must exists as a registered 'stack id'.\n\ - originHost: Diameter application host name (system name). If missing, process sets o.s. hostname\n\ + originHost: Diameter application host name (system name). If missing, process sets o.s. hostname.\n\ Note that if you have two or more realms, the names must be different.\n\ cer: User defined CER path file to be encoded to establish diameter connections.\n\ - If missing, will be harcoded\n\ + If missing, will be harcoded.\n\ dwr: User defined DWR path file to be encoded for diameter protocol keep alive.\n\ - If missing, will be harcoded\n\ + If missing, will be harcoded.\n\ allowedInactivityTime: Milliseconds for the maximum allowed inactivity time on server sessions born over the\n\ - local server before being reset. If missing, default value of 90000 will be assigned\n\ + local server before being reset. If missing, default value of 90000 will be assigned.\n\ tcpConnectDelay: Milliseconds to wait TCP connect to any server. If missing, default value of 200 will\n\ be assigned\n\ answersTimeout: Milliseconds to wait pending application answers from diameter peers. If missing,\n\ - default value of 10000 will be assigned\n\ + default value of 10000 will be assigned.\n\ ceaTimeout: Milliseconds to wait CEA from diameter server. If missing, default value of 'answersTimeout'\n\ - will be assigned\n\ + will be assigned.\n\ watchdogPeriod: Milliseconds for watchdog timer (Tw) for diameter keep-alive procedure. If missing, default\n\ - value of 30000 will be assigned\n\ + value of 30000 will be assigned.\n\ entity: Target diameter entity (comma-separated '
:' format).\n\ - For example: 10.20.30.40:3868,10.20.30.41:3868. If missing, no entity will be enabled\n\ - entityServerSessions: Diameter entity server sessions (0: diameter entity disabled). Default value of 1\n\ + For example: 10.20.30.40:3868,10.20.30.41:3868. If missing, no entity will be enabled.\n\ + entityServerSessions: Diameter entity server sessions (0: diameter entity disabled). Default value of 1.\n\ diameterServer: Diameter own server address in '
:' format. For example: 10.20.30.40:3868.\n\ - If missing, no local server will be enabled\n\ - diameterServerSessions: Diameter own server available connections (0: diameter server disabled). Default value of 1\n\ + If missing, no local server will be enabled.\n\ + diameterServerSessions: Diameter own server available connections (0: diameter server disabled). Default value of 1.\n\ + Negative value implies no limit accepting incoming connections.\n\ balance: Balance over entity servers instead of doing standard behaviour (first primary, secondary\n\ - if fails, etc.). Default value 'no'\n\ + if fails, etc.). Default value 'no'.\n\ sessionBasedModelsClientSocketSelection: By default, round-robin will be applied for IEC model (SMS/MMS), and Session-Id Low Part\n\ will be analyzed for ECUR/SCUR model (data, voice and content). You could change ECUR/SCUR\n\ analysis behaviour providing 'SessionIdHighPart', 'SessionIdOptionalPart' (atoi applied;\n\ - usually subscriber id data, i.e. MSISDN or IMSI) and 'RoundRobin' (also 'SessionIdLowPart')\n\ - retries: Expired responses will cause a number of request retransmissions. Disabled by default (0 retries)\n\ + usually subscriber id data, i.e. MSISDN or IMSI) and 'RoundRobin' (also 'SessionIdLowPart').\n\ + retries: Expired responses will cause a number of request retransmissions. Disabled by default (0 retries).\n\ log: Process log file (operations result, traffic log, etc.). By default '.launcher.log'.\n\ Empty string or \"null\" name, to disable. Warning: there is no rotation for log files\n\ - (use logrotate or whatever you consider)\n\ + (use logrotate or whatever you consider).\n\ splitLog: Splits log file (appends to log filename, extensions with the type of event: see help on\n\ startup information-level traces). No log files for code/decode and load operations are created.\n\ - Default value 'no'\n\ + Default value 'no'.\n\ detailedLog: Insert detailed information at log files. Should be disabled on automatic tests. Useful on\n\ - 'balance' mode to know messages flow along the sockets. Default value 'no'\n\ + 'balance' mode to know messages flow along the sockets. Default value 'no'.\n\ dumpLog: Write to disk every incoming/outcoming message named as:\n\ '......xml'\n\ - Default value 'no'\n\ + Default value 'no'.\n\ burstLog: Burst operations log file. By default '.launcher.burst'. Empty string or \"null\" name, to disable.\n\ Warning: there is no rotation for log files (use logrotate or whatever). Output: dot (.) for each\n\ burst message sent/pushed, cross (x) for popped ones, and order number when multiple of 1% of burst\n\ - list size, plus OTA requests when changed\n\ + list size, plus OTA requests when changed.\n\ \n\ -->\n\ \n\ @@ -132,7 +133,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 +145,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 +163,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; @@ -172,6 +175,11 @@ void Launcher::servicesFromXML(const anna::xml::Node* servicesNode, bool eventOp dictionary = (*it)->getAttribute("dictionary"); id_value = id->getIntegerValue(); + if (stackEngine.getDictionary(id_value)) { // Ignore (but don't fail) dictionary load with same stack id already registered + LOGWARNING(anna::Logger::warning(anna::functions::asString("Ignore dictionary load for stack id already registered: %llu", id_value), ANNA_FILE_LOCATION)); + continue; + } + try { d = stackEngine.createDictionary(id_value, dictionary->getValue()); LOGDEBUG(anna::Logger::debug(anna::functions::asString("Created dictionary (%p) for stack id %llu", d, id_value), ANNA_FILE_LOCATION)); @@ -185,10 +193,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 +241,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 +357,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: @@ -800,7 +803,7 @@ void Launcher::resetCounters() throw() { void Launcher::signalUSR2() throw(anna::RuntimeException) { LOGNOTICE( - std::string msg = "Captured signal SIGUSR2. Reading tasks at '"; + std::string msg = "Captured signal SIGUSR2. Reading tasks at '"; msg += SIGUSR2_TASKS_INPUT_FILENAME; msg += "' (results will be written at '"; msg += SIGUSR2_TASKS_OUTPUT_FILENAME; @@ -815,7 +818,6 @@ void Launcher::signalUSR2() throw(anna::RuntimeException) { std::ofstream out_file(SIGUSR2_TASKS_OUTPUT_FILENAME); if(!in_file.is_open()) throw RuntimeException("Unable to read tasks", ANNA_FILE_LOCATION); - if(!out_file.is_open()) throw RuntimeException("Unable to write tasks", ANNA_FILE_LOCATION); while(getline(in_file, line)) { @@ -835,6 +837,7 @@ void Launcher::signalUSR2() throw(anna::RuntimeException) { } in_file.close(); + out_file << "EOF\n"; out_file.close(); } @@ -971,12 +974,14 @@ std::string Launcher::help() const throw() { result += "\n------------------------------------------------------------------------------------------- Hot changes"; result += "\n"; result += "\nservices[|source file] Adds and starts the services specified in the xml file provided."; - result += "\n (if missing, the file 'services.xml' will be used)."; - result += "\n The last loaded realm node will be automatically the new current"; - result += "\n working node. This is used to load new nodes once the ADML is"; - result += "\n started, regardless if '--services' command line parameter was"; - result += "\n used or not. Those services which are not correctly loaded, will"; - result += "\n be ignored, keeping the process alive."; + result += "\n (if missing, the file 'services.xml' will be used). This is used"; + 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."; @@ -990,6 +995,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"; @@ -1155,34 +1164,34 @@ std::string Launcher::help() const throw() { result += "\n"; result += "\n delay| Blocking step until the time lapse expires. Useful to give "; result += "\n some cadence control and time schedule for a specific case."; + result += "\n A value of 0 could be used as a dummy step."; result += "\n wait| Blocking step until condition is fulfilled. The message could"; result += "\n received from entity (waitfe) or from client (waitfc)."; result += "\n"; result += "\n wait-regexp|"; - result += "\n Wait condition, from entity (waitfe-regexp) or client (waitfc-regexp)"; + result += "\n Wait condition, from entity (waitfe-regexp) or client (waitfc-regexp)"; result += "\n to match the serialized xml content for received messages. CPU cost"; result += "\n is bigger than the former ones because the whole message must be"; result += "\n decoded and converted to xml instead of doing a direct hexadecimal"; result += "\n buffer search. The main advantage is the great flexibility to identify"; result += "\n any content with a regular expression."; result += "\n"; - result += "\n sh-command|