X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=example%2Fdiameter%2Flauncher%2FLauncher.cpp;h=f5fac98dee32ddc8650a748b8f1ee0628e914404;hb=431d322261ecfd6ef354abb392edbf8987e2407a;hp=59f5202beeed5c2e61c00268b44bb46a1e10a7d4;hpb=a8cde75abebb30020be4d9cb10d898f8986e124c;p=anna.git diff --git a/example/diameter/launcher/Launcher.cpp b/example/diameter/launcher/Launcher.cpp index 59f5202..f5fac98 100644 --- a/example/diameter/launcher/Launcher.cpp +++ b/example/diameter/launcher/Launcher.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include @@ -24,6 +23,41 @@ #define SIGUSR2_TASKS_OUTPUT_FILENAME "./sigusr2.tasks.output" #define DIAMETER_CODEC_ENGINE_NAME_PREFIX "MyCodecEngine" +const char *ServicesDTD = "\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +"; + + Launcher::Launcher() : anna::comm::Application("launcher", "DiameterLauncher", "1.1"), a_communicator(NULL) { a_myDiameterEngine = new MyDiameterEngine(); a_myDiameterEngine->setRealm("ADL.ericsson.com"); @@ -40,6 +74,8 @@ Launcher::Launcher() : anna::comm::Application("launcher", "DiameterLauncher", " a_diameterLocalServer = NULL; a_cerPathfile = "cer.xml"; a_dwrPathfile = "dwr.xml"; + a_workingStackId = 0; + // Burst a_burstCycle = 1; a_burstRepeat = false; @@ -341,36 +377,49 @@ throw(anna::RuntimeException) { // Stack: a_codecEngine = new anna::diameter::codec::Engine(DIAMETER_CODEC_ENGINE_NAME_PREFIX); anna::diameter::stack::Engine &stackEngine = anna::diameter::stack::Engine::instantiate(); - anna::diameter::stack::Dictionary * d = stackEngine.createDictionary(0 /* stack id; its value don't mind, is not used (ADL is monostack) */); - // Analyze comma-separated list: - anna::Tokenizer lst; - std::string dictionaryParameter = cl.getValue("dictionary"); - lst.apply(dictionaryParameter, ","); - - if(lst.size() >= 1) { // always true (at least one, because --dictionary is mandatory) - anna::Tokenizer::const_iterator tok_min(lst.begin()); - anna::Tokenizer::const_iterator tok_max(lst.end()); - anna::Tokenizer::const_iterator tok_iter; - std::string pathFile; - d->allowUpdates(); - - for(tok_iter = tok_min; tok_iter != tok_max; tok_iter++) { - pathFile = anna::Tokenizer::data(tok_iter); - d->load(pathFile); + std::string stacks = cl.getValue("stacks"); + bool multistack = false; + try { + anna::Tokenizer stacksTok; + stacksTok.apply(stacks, "#"); + anna::Tokenizer::const_iterator stacks_it, stack_it; + + for(stacks_it = stacksTok.begin(); stacks_it != stacksTok.end(); stacks_it++) { + std::string stack = anna::Tokenizer::data(stacks_it); + anna::Tokenizer stackTok; + stackTok.apply(stack, ","); + + if(stackTok.size() == 1) { + if(stacksTok.size() != 1) + throw anna::RuntimeException("Application Id value is mandatory when more than one stack is going to be configured", ANNA_FILE_LOCATION); + + anna::diameter::stack::Dictionary * d = stackEngine.createDictionary(0 /* no matter */, stack); // the stack is the dictionary + codecEngine->setDictionary(d); + break; + } + + if(stackTok.size() != 2) + throw anna::RuntimeException("Each stack must be in the form ','", ANNA_FILE_LOCATION); + + multistack = true; + stack_it = stackTok.begin(); + unsigned int stackId = atoll(anna::Tokenizer::data(stack_it)); + stack_it++; + std::string file = anna::Tokenizer::data(stack_it); + anna::diameter::stack::Dictionary * d = stackEngine.createDictionary(stackId, file); } - } - getCodecEngine()->setDictionary(d); // XXXX esto cambiara... - LOGDEBUG(anna::Logger::debug(getCodecEngine()->asString(), ANNA_FILE_LOCATION)); + // Auto stack selection based on Application-ID: + if (multistack) getCodecEngine()->selectStackWithApplicationId(true); - if(lst.size() > 1) { - std::string all_in_one = "./dictionary-all-in-one.xml"; - std::ofstream out(all_in_one.c_str(), std::ifstream::out); - std::string buffer = d->asXMLString(); - out.write(buffer.c_str(), buffer.size()); - out.close(); - std::cout << "Written accumulated '" << all_in_one << "' (provide it next time to be more comfortable)." << std::endl; + std::cout << "Stacks provided: " << std::endl; + std::cout << anna::functions::tab(stackEngine.asString(false /* light */)); + std::cout << std::endl; + } catch(anna::RuntimeException &ex) { + _exit(ex.asString()); } + //LOGDEBUG(anna::Logger::debug(codecEngine->asString(), ANNA_FILE_LOCATION)); + /////////////////////////////// // Diameter library COUNTERS // @@ -952,7 +1001,7 @@ std::string Launcher::help() const throw() { result += "\n vi /var/tmp/anna.context."; result += "\n"; result += "\nA complete xml report will show all the context information (counters, alarms, statistics,"; - result += "\n handlers, diameter dictionary, etc.), and a powerful log module could dump all the events"; + result += "\n handlers, diameter stacks, etc.), and a powerful log module could dump all the events"; result += "\n processed and flow information. Statistics could be analized at context dump and optionally"; result += "\n written to disk as sample files (useful for graphs and spreadsheet reports) with all the"; result += "\n measurements."; @@ -967,8 +1016,8 @@ std::string Launcher::help() const throw() { result += "\n posibilities, many of which could be modified on the air through the management interface"; result += "\n (we will talk later about this great feature). Some of the more common parameters are:"; result += "\n"; - result += "\nAs mandatory, the stack definition given through the xml dictionary:"; - result += "\n --dictionary "; + result += "\nAs mandatory, the stacks enabled given through the application-id and the xml dictionary:"; + result += "\n --stacks "; result += "\n"; result += "\nActing as a diameter server (accepting i.e. 10 connections), you would have:"; result += "\n --diameterServer localhost:3868 --diameterServerSessions 10 --entityServerSessions 0"; @@ -998,6 +1047,11 @@ std::string Launcher::help() const throw() { result += "\n"; result += "\nhelp This help. Startup information-level traces also dump this help."; result += "\n"; + result += "\n--------------------------------------------------------------------------------------- Stack selection"; + result += "\n"; + result += "\nstack| Select current working stack id (node selection). Many operations"; + result += " could use this value if proceed, in multistack configurations."; + result += "\n"; result += "\n------------------------------------------------------------------------------------ Parsing operations"; result += "\n"; result += "\ncode|| Encodes source file (pathfile) into target file (pathfile)."; @@ -1075,14 +1129,14 @@ std::string Launcher::help() const throw() { result += "\n to the peer which sent the request. If user wants to test a specific answer without changing it,"; result += "\n use sendxml/sendhex operations better than programming."; result += "\n"; - result += "\nBalance ('-balance' command line parameter) could be used to forward server socket receptions through"; + result += "\nBalance ('--balance' command line parameter) could be used to forward server socket receptions through"; result += "\n entity servers by mean a round-robin algorithm. Both diameter server socket and entity targets should"; result += "\n have been configured, that is to say: launcher acts as client and server. If no balance is used, an"; result += "\n standard delivery is performed: first primary entity server, secondary when fails, etc."; result += "\n"; result += "\n--------------------------------------------------------------------------- Processing types (log tags)"; result += "\n"; - result += "\nUsed as log file extensions (when '-splitLog' is provided on command line) and context preffixes on log"; + result += "\nUsed as log file extensions (when '--splitLog' is provided on command line) and context preffixes on log"; result += "\n details when unique log file is dumped:"; result += "\n"; result += "\n [sent2e/send2eError] Send to entity (success/error)"; @@ -1115,7 +1169,7 @@ std::string Launcher::help() const throw() { result += "\n burst|push| Sends specific non-aynchronous load."; result += "\n burst|pop| Skip send burst messages in order to reduce over-the-air requests."; result += "\n Popping all OTA requests implies burst stop because no more answer"; - result += "\n will arrive to the process. Burst output file (-burstLog command"; + result += "\n will arrive to the process. Burst output file (--burstLog command"; result += "\n line parameter) shows popped messages with crosses (x). Each cross"; result += "\n represents one received answer for which no new request is sent."; result += "\n burst|stop Stops the burst cycle. You can resume pushing 1 load amount."; @@ -1135,7 +1189,7 @@ std::string Launcher::help() const throw() { result += "\n------------------------------------------------------------------------- Operations via HTTP interface"; result += "\n"; result += "\nAll the operations described above can be used through the optional HTTP interface. You only have"; - result += "\n to define the http server at the command line with something like: '-httpServer localhost:9000'."; + result += "\n to define the http server at the command line with something like: '--httpServer localhost:9000'."; result += "\nTo send the task, we shall build the http request body with the operation string. Some examples"; result += "\n using curl client could be:"; result += "\n"; @@ -1685,3 +1739,4 @@ throw() { anna::statistics::Engine::instantiate().asXML(result); return result; } +