From 2921c651c9945cefec0715167201596aaa079e8d Mon Sep 17 00:00:00 2001 From: Eduardo Ramos Testillano Date: Tue, 8 Sep 2015 02:19:21 +0200 Subject: [PATCH] Fixes and improvs. Basic DRA feature. --- example/diameter/launcher/Launcher.cpp | 271 +++++++++------- example/diameter/launcher/Launcher.hpp | 2 + .../diameter/launcher/MyDiameterEngine.hpp | 10 +- example/diameter/launcher/RealmNode.cpp | 18 +- example/diameter/launcher/RealmNode.hpp | 8 +- .../resources/scripts/operation_signal.sh | 6 +- .../resources/services_examples/balancer.xml | 4 +- .../resources/services_examples/client.xml | 2 +- .../resources/services_examples/dummy.xml | 2 +- .../services_examples/multi-client.xml | 9 +- .../resources/services_examples/server.xml | 2 +- .../resources/services_examples/services.dtd | 5 +- .../diameter/launcher/testing/TestCase.cpp | 1 + .../diameter/launcher/testing/TestManager.cpp | 19 +- .../diameter/launcher/testing/TestManager.hpp | 2 +- .../diameter/launcher/testing/TestStep.cpp | 92 +++--- .../diameter/launcher/testing/TestStep.hpp | 2 +- include/anna/diameter.comm/Engine.hpp | 88 +++--- include/anna/diameter/codec/EngineImpl.hpp | 3 +- include/anna/diameter/codec/Message.hpp | 2 +- source/diameter.comm/Engine.cpp | 293 ++++++++++++++---- source/diameter.comm/LocalServer.cpp | 4 + source/diameter.comm/ServerSession.cpp | 6 +- 23 files changed, 544 insertions(+), 307 deletions(-) diff --git a/example/diameter/launcher/Launcher.cpp b/example/diameter/launcher/Launcher.cpp index eb4dfe7..a6c5bee 100644 --- a/example/diameter/launcher/Launcher.cpp +++ b/example/diameter/launcher/Launcher.cpp @@ -31,8 +31,8 @@ #include -#define SIGUSR2_TASKS_INPUT_FILENAME "./sigusr2.tasks.input" -#define SIGUSR2_TASKS_OUTPUT_FILENAME "./sigusr2.tasks.output" +#define SIGUSR2_TASKS_INPUT_FILENAME "./sigusr2.in" +#define SIGUSR2_TASKS_OUTPUT_FILENAME "./sigusr2.out" @@ -47,19 +47,18 @@ const char *ServicesDTD = "\ \n\ \n\ \n\ -\n\ +\n\ "; + result += "\n "; result += "\n"; - result += "\nAs mandatory, the stacks enabled given through the applicationId and the xml dictionary:"; - result += "\n --stacks "; + result += "\n "; + result += "\n "; + result += "\n"; 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"; + result += "\nServer configuration:"; result += "\n"; - result += "\nActing as a diameter client (launching i.e. 10 connections to each entity server), you would have:"; - result += "\n --entity 192.168.12.11:3868,192.168.12.21:3868 --entityServerSessions 10 --diameterServerSessions 0"; + result += "\n"; + result += "\n "; + result += "\n "; + result += "\n"; + result += "\n "; + result += "\n "; + result += "\n"; result += "\n"; result += "\nIf you act as a proxy or a translation agent, you need to combine both former setups, and probably"; result += "\n will need to program the answers to be replied through the operations interface. To balance the"; result += "\n traffic at your client side you shall use '--balance' and '--sessionBasedModelsClientSocketSelection'"; - result += "\n arguments in order to define the balancing behaviour."; + result += "\n arguments in order to define the balancing behaviour. To make hybrid setups you only must mix the realms:"; result += "\n"; - result += "\nThe process builds automatically CER and DWR messages as a client, but you could specify your own"; - result += "\n customized ones using '--cer ' and '--dwr '."; - result += "\nThe process builds automatically CEA and DWA messages as a server, but you could program your own"; - result += "\n customized ones using operations interface."; + result += "\nClient and server configuration:"; + result += "\n"; + result += "\n"; + result += "\n "; + result += "\n "; + result += "\n "; + result += "\n "; result += "\n"; + result += "\n "; + result += "\n "; + result += "\n "; + result += "\n"; + result += "\n"; + result += "\n"; + result += "\nThe process builds automatically CER and DWR messages as a client, but you could specify your own"; + result += "\n as shown in the hybrid former example. Note that the base protocol stack must be registered because"; + result += "\n the configuration corresponds to a multistack process which change the stack using the application-id"; + result += "\n processed (0 in the case of base protocol messages: CER, CEA, DWR, DWA, DPR, DPA)."; result += "\n"; result += "\nDYNAMIC OPERATIONS"; result += "\n------------------"; @@ -837,13 +873,13 @@ std::string Launcher::help() const throw() { result += "\n"; result += "\n--------------------------------------------------------------------------------------- General purpose"; result += "\n"; - result += "\nhelp This help. Startup information-level traces also dump this help."; + result += "\nhelp This help."; result += "\n"; result += "\n---------------------------------------------------------------------------------------- Node selection"; result += "\n"; result += "\nnode[|] Select current working node by mean the registered name."; result += "\n All the subsequent operations will be referred to this node."; - result += "\n Without argument, the current node is dumped on stdout."; + result += "\n Without argument, the current node information is retrieved."; result += "\n"; result += "\n------------------------------------------------------------------------------------ Parsing operations"; result += "\n"; @@ -1241,11 +1277,14 @@ std::string Launcher::help() const throw() { result += "\n interface."; result += "\n"; result += "\n"; + return result; } 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 + CommandLine& cl(anna::CommandLine::instantiate()); TestManager &testManager = TestManager::instantiate(); LOGDEBUG(anna::Logger::debug(operation, ANNA_FILE_LOCATION)); @@ -1253,21 +1292,17 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons // Default response: response_content = "Operation processed with exception (see traces): "; response_content += operation; - response_content += "\n"; - std::string result_msg = ""; - anna::DataBlock db_aux(true); + std::string opt_response_content = ""; // aditional response content + anna::DataBlock db_aux(true); /////////////////////////////////////////////////////////////////// // Simple operations without arguments: // Help: if(operation == "help") { - std::string s_help = help(); - std::cout << s_help << std::endl; - LOGINFORMATION(anna::Logger::information(s_help, ANNA_FILE_LOCATION)); - response_content = "Help dumped on stdout and information-level traces\n"; + response_content = help(); return; } @@ -1275,14 +1310,14 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if(operation == "collect") { resetCounters(); resetStatistics(); - response_content = "All process counters & statistic information have been reset\n"; + response_content = "All process counters & statistic information have been reset"; return; } // Counters dump on demand: if(operation == "forceCountersRecord") { forceCountersRecord(); - response_content = "Current counters have been dump to disk\n"; + response_content = "Current counters have been dump to disk"; return; } @@ -1351,7 +1386,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if(opType == "context") { std::string contextFile = ((numParams == 1) ? param1 : anna::functions::asString("/var/tmp/anna.context.%05d", getPid())); writeContext(contextFile); - response_content = anna::functions::asString("Context dumped on file '%s'\n", contextFile.c_str()); + response_content = anna::functions::asString("Context dumped on file '%s'", contextFile.c_str()); return; } @@ -1362,20 +1397,20 @@ 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)\n", servicesFile.c_str()); + response_content = anna::functions::asString("Loaded services from file '%s' with some problems (ignored ones)", servicesFile.c_str()); return; } - response_content = anna::functions::asString("Loaded services from file '%s'\n", servicesFile.c_str()); + response_content = anna::functions::asString("Loaded services from file '%s'", servicesFile.c_str()); return; } // Realm switch: if(opType == "node") { if (param1 != "") { - if (setWorkingNode(param1)) response_content = anna::functions::asString("Current node is now '%s'\n", param1.c_str()); + if (setWorkingNode(param1)) response_content = anna::functions::asString("Current node is now '%s'", param1.c_str()); } else { - std::cout << getWorkingNode()->asXMLString() << std::endl; + response_content = getWorkingNode()->asXMLString(); } return; } @@ -1420,9 +1455,9 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if(opType == "show") commEngine->findClientSession(key)->show(); - if(opType == "hidden") result_msg = commEngine->findClientSession(key)->hidden() ? "true" : "false"; + if(opType == "hidden") opt_response_content = commEngine->findClientSession(key)->hidden() ? "true" : "false"; - if(opType == "shown") result_msg = commEngine->findClientSession(key)->shown() ? "true" : "false"; + if(opType == "shown") opt_response_content = commEngine->findClientSession(key)->shown() ? "true" : "false"; } else { std::string address; int port; @@ -1432,18 +1467,18 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if(opType == "show") commEngine->findServer(address, port)->show(); - if(opType == "hidden") result_msg = commEngine->findServer(address, port)->hidden() ? "true" : "false"; + if(opType == "hidden") opt_response_content = commEngine->findServer(address, port)->hidden() ? "true" : "false"; - if(opType == "shown") result_msg = commEngine->findServer(address, port)->shown() ? "true" : "false"; + if(opType == "shown") opt_response_content = commEngine->findServer(address, port)->shown() ? "true" : "false"; } } else { if(opType == "hide") entity->hide(); if(opType == "show") entity->show(); - if(opType == "hidden") result_msg = entity->hidden() ? "true" : "false"; + if(opType == "hidden") opt_response_content = entity->hidden() ? "true" : "false"; - if(opType == "shown") result_msg = entity->shown() ? "true" : "false"; + if(opType == "shown") opt_response_content = entity->shown() ? "true" : "false"; } } else if((opType == "sendxml") || (opType == "sendxml2e") || (opType == "sendhex") || (opType == "sendhex2e")) { if(!entity) throw anna::RuntimeException("No entity configured to send the message", ANNA_FILE_LOCATION); @@ -1490,9 +1525,9 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons // burst|look| Show programmed burst message for order provided, current when missing. if(param1 == "clear") { - result_msg = "removed "; - result_msg += anna::functions::asString(getWorkingNode()->clearBurst()); - result_msg += " elements"; + opt_response_content = "removed "; + opt_response_content += anna::functions::asString(getWorkingNode()->clearBurst()); + opt_response_content += " elements"; } else if(param1 == "load") { if(param2 == "") throw anna::RuntimeException("Missing xml path file for burst load operation", ANNA_FILE_LOCATION); @@ -1502,10 +1537,10 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons try { codecMsg.valid(); } catch(anna::RuntimeException &ex) { ex.trace(); } // at least we need to see validation errors although it will continue loading (see validation mode configured in launcher) int position = getWorkingNode()->loadBurstMessage(codecMsg.code()); - result_msg = "loaded '"; - result_msg += param2; - result_msg += "' file into burst list position "; - result_msg += anna::functions::asString(position); + opt_response_content = "loaded '"; + opt_response_content += param2; + opt_response_content += "' file into burst list position "; + opt_response_content += anna::functions::asString(position); } else if(param1 == "start") { if(param2 == "") throw anna::RuntimeException("Missing initial load for burst start operation", ANNA_FILE_LOCATION); @@ -1513,8 +1548,8 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons int processed = getWorkingNode()->startBurst(initialLoad); if(processed > 0) { - result_msg = "initial load completed for "; - result_msg += anna::functions::entriesAsString(processed, "message"); + opt_response_content = "initial load completed for "; + opt_response_content += anna::functions::entriesAsString(processed, "message"); } } else if(param1 == "push") { if(param2 == "") throw anna::RuntimeException("Missing load amount for burst push operation", ANNA_FILE_LOCATION); @@ -1522,8 +1557,8 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons int pushed = getWorkingNode()->pushBurst(atoi(param2.c_str())); if(pushed > 0) { - result_msg = "pushed "; - result_msg += anna::functions::entriesAsString(pushed, "message"); + opt_response_content = "pushed "; + opt_response_content += anna::functions::entriesAsString(pushed, "message"); } } else if(param1 == "pop") { if(param2 == "") throw anna::RuntimeException("Missing amount for burst pop operation", ANNA_FILE_LOCATION); @@ -1532,39 +1567,39 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons int popped = getWorkingNode()->popBurst(releaseLoad); if(popped > 0) { - result_msg = "burst popped for "; - result_msg += anna::functions::entriesAsString(popped, "message"); + opt_response_content = "burst popped for "; + opt_response_content += anna::functions::entriesAsString(popped, "message"); } } else if(param1 == "stop") { int left = getWorkingNode()->stopBurst(); if(left != -1) { - result_msg += anna::functions::entriesAsString(left, "message"); - result_msg += " left to the end of the cycle"; + opt_response_content += anna::functions::entriesAsString(left, "message"); + opt_response_content += " left to the end of the cycle"; } } else if(param1 == "repeat") { if(param2 == "") param2 = "yes"; bool repeat = (param2 == "yes"); getWorkingNode()->repeatBurst(repeat); - result_msg += (repeat ? "repeat enabled" : "repeat disabled"); + opt_response_content += (repeat ? "repeat enabled" : "repeat disabled"); } else if(param1 == "send") { if(param2 == "") throw anna::RuntimeException("Missing amount for burst send operation", ANNA_FILE_LOCATION); int sent = getWorkingNode()->sendBurst(atoi(param2.c_str())); if(sent > 0) { - result_msg = "sent "; - result_msg += anna::functions::entriesAsString(sent, "message"); + opt_response_content = "sent "; + opt_response_content += anna::functions::entriesAsString(sent, "message"); } } else if(param1 == "goto") { if(param2 == "") throw anna::RuntimeException("Missing order position for burst goto operation", ANNA_FILE_LOCATION); - result_msg = getWorkingNode()->gotoBurst(atoi(param2.c_str())); + opt_response_content = getWorkingNode()->gotoBurst(atoi(param2.c_str())); } else if(param1 == "look") { int order = ((param2 != "") ? atoi(param2.c_str()) : -1); - result_msg = "\n\n"; - result_msg += getWorkingNode()->lookBurst(order); + opt_response_content = "\n\n"; + opt_response_content += getWorkingNode()->lookBurst(order); } else { throw anna::RuntimeException("Wrong body content format on HTTP Request for 'burst' operation (unexpected action parameter). See help", ANNA_FILE_LOCATION); } @@ -1586,12 +1621,12 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons bool success = ((param2 != "") ? testManager.configureTTPS(atoi(param2.c_str())) : false); if (success) { - result_msg = "assigned new test launch rate to "; - result_msg += anna::functions::asString(atoi(param2.c_str())); - result_msg += " events per second"; + opt_response_content = "assigned new test launch rate to "; + opt_response_content += anna::functions::asString(atoi(param2.c_str())); + opt_response_content += " events per second"; } else { - result_msg += "unable to configure the test rate provided"; + opt_response_content += "unable to configure the test rate provided"; } } else if(param1 == "ip-limit") { @@ -1602,16 +1637,16 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if (param2 != "") { limit = atoi(param2.c_str()); testManager.setInProgressLimit(limit); - result_msg = "new in-progress limit: "; - result_msg += (limit != UINT_MAX) ? anna::functions::asString(limit) : ""; + opt_response_content = "new in-progress limit: "; + opt_response_content += (limit != UINT_MAX) ? anna::functions::asString(limit) : ""; } else { - result_msg = "in-progress limit amount: "; + opt_response_content = "in-progress limit amount: "; limit = testManager.getInProgressLimit(); - result_msg += (limit != UINT_MAX) ? anna::functions::asString(limit) : ""; - result_msg += "; currently there are "; - result_msg += anna::functions::asString(testManager.getInProgressCount()); - result_msg += " test cases running"; + opt_response_content += (limit != UINT_MAX) ? anna::functions::asString(limit) : ""; + opt_response_content += "; currently there are "; + opt_response_content += anna::functions::asString(testManager.getInProgressCount()); + opt_response_content += " test cases running"; } } else if(param1 == "repeat") { @@ -1620,7 +1655,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if(param2 == "") param2 = "yes"; testManager.setPoolRepeat((param2 == "yes")); - result_msg += (testManager.getPoolRepeat() ? "repeat enabled" : "repeat disabled"); + opt_response_content += (testManager.getPoolRepeat() ? "repeat enabled" : "repeat disabled"); } else if(param1 == "report") { if (numParams > 2) @@ -1628,7 +1663,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if(param2 == "") param2 = "yes"; testManager.setDumpReports((param2 == "yes")); - result_msg += (testManager.getDumpReports() ? "report enabled" : "report disabled"); + opt_response_content += (testManager.getDumpReports() ? "report enabled" : "report disabled"); } else if(param1 == "goto") { if (numParams > 2) @@ -1637,13 +1672,13 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if(param2 == "") throw anna::RuntimeException("Missing id for test goto operation", ANNA_FILE_LOCATION); int id = atoi(param2.c_str()); if (testManager.gotoTestCase(id)) { - result_msg = "position updated for id provided ("; + opt_response_content = "position updated for id provided ("; } else { - result_msg = "cannot found test id ("; + opt_response_content = "cannot found test id ("; } - result_msg += anna::functions::asString(id); - result_msg += ")"; + opt_response_content += anna::functions::asString(id); + opt_response_content += ")"; } else if(param1 == "look") { if (numParams > 2) @@ -1653,17 +1688,17 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons TestCase *testCase = testManager.findTestCase(id); if (testCase) { - result_msg = "\n\n"; - result_msg += testCase->asXMLString(); + response_content = testCase->asXMLString(); + return; } else { if (id == -1) { - result_msg = "no current test case detected (testing started ?)"; + opt_response_content = "no current test case detected (testing started ?)"; } else { - result_msg = "cannot found test id ("; - result_msg += anna::functions::asString(id); - result_msg += ")"; + opt_response_content = "cannot found test id ("; + opt_response_content += anna::functions::asString(id); + opt_response_content += ")"; } } } @@ -1679,21 +1714,21 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if (testCase) { bool done = testCase->reset((param2 == "hard") ? true:false); - result_msg = "test "; - result_msg += param2; - result_msg += " reset for id "; - result_msg += anna::functions::asString(id); - result_msg += done ? ": done": ": not done"; + opt_response_content = "test "; + opt_response_content += param2; + opt_response_content += " reset for id "; + opt_response_content += anna::functions::asString(id); + opt_response_content += done ? ": done": ": not done"; } else { if (id == -1) { bool anyReset = testManager.resetPool((param2 == "hard") ? true:false); - result_msg = "reset have been sent to all programmed tests: "; result_msg += anyReset ? "some/all was actually reset" : "nothing was reset"; + opt_response_content = "reset have been sent to all programmed tests: "; opt_response_content += anyReset ? "some/all was actually reset" : "nothing was reset"; } else { - result_msg = "cannot found test id ("; - result_msg += anna::functions::asString(id); - result_msg += ")"; + opt_response_content = "cannot found test id ("; + opt_response_content += anna::functions::asString(id); + opt_response_content += ")"; } } } @@ -1702,10 +1737,10 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION); if (testManager.clearPool()) { - result_msg = "all the programmed test cases have been dropped"; + opt_response_content = "all the programmed test cases have been dropped"; } else { - result_msg = "there are not programmed test cases to be removed"; + opt_response_content = "there are not programmed test cases to be removed"; } } else { @@ -1787,9 +1822,6 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons else { throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION); } - - result_msg = "new step added to test id "; - result_msg += anna::functions::asString(id); } } else if((opType == "sendxml2c") || (opType == "sendhex2c")) { @@ -1821,8 +1853,8 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons } } else if(opType == "loadxml") { codecMsg.loadXML(param1); - std::string xmlString = codecMsg.asXMLString(); - std::cout << xmlString << std::endl; + response_content = codecMsg.asXMLString(); + return; } else if(opType == "diameterServerSessions") { int diameterServerSessions = atoi(param1.c_str()); @@ -1836,8 +1868,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons throw anna::RuntimeException("Operation not applicable (no own diameter server has been configured)", ANNA_FILE_LOCATION); if(param1 == "") { // programmed answers FIFO's to stdout - std::cout << localServer->getReactingAnswers()->asString("ANSWERS TO CLIENT") << std::endl; - response_content = "Programmed answers dumped on stdout\n"; + response_content = localServer->getReactingAnswers()->asString("ANSWERS TO CLIENT"); return; } else if (param1 == "rotate") { localServer->getReactingAnswers()->rotate(true); @@ -1866,8 +1897,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons throw anna::RuntimeException("Operation not applicable (no diameter entity has been configured)", ANNA_FILE_LOCATION); if(param1 == "") { // programmed answers FIFO's to stdout - std::cout << entity->getReactingAnswers()->asString("ANSWERS TO ENTITY") << std::endl; - response_content = "Programmed answers dumped on stdout\n"; + response_content = entity->getReactingAnswers()->asString("ANSWERS TO ENTITY"); return; } else if (param1 == "rotate") { entity->getReactingAnswers()->rotate(true); @@ -1896,8 +1926,11 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons } // HTTP response - response_content = "Operation correctly processed: "; response_content += operation; response_content += " => "; - response_content += result_msg; + response_content = "Operation correctly processed: "; response_content += operation; + if (opt_response_content != "") { + response_content += " => "; + response_content += opt_response_content; + } } anna::xml::Node* Launcher::asXML(anna::xml::Node* parent) const diff --git a/example/diameter/launcher/Launcher.hpp b/example/diameter/launcher/Launcher.hpp index 21c3d25..204459a 100644 --- a/example/diameter/launcher/Launcher.hpp +++ b/example/diameter/launcher/Launcher.hpp @@ -53,6 +53,7 @@ class Launcher : public anna::comm::Application { // Core engines: MyCommunicator *a_communicator; anna::diameter::codec::Engine *a_codecEngine; + anna::diameter::stack::Dictionary *a_baseProtocolDictionary; anna::timex::Engine* a_timeEngine; MyCounterRecorder *a_counterRecorder; anna::Millisecond a_admlMinResolution; @@ -79,6 +80,7 @@ public: void startServices() throw(anna::RuntimeException); anna::diameter::codec::Engine *getCodecEngine() const throw() { return a_codecEngine; } + //anna::diameter::stack::Dictionary *getBaseProtocolDictionary() const throw() { return a_baseProtocolDictionary; } RealmNode *getWorkingNode() const throw(anna::RuntimeException); // management operations working node bool setWorkingNode(const std::string &name) throw(); // we could update ignoreFlagsOnValidation/integrationAndDebugging over the global codec engine // but finally, that configuration issues will be global to the process. diff --git a/example/diameter/launcher/MyDiameterEngine.hpp b/example/diameter/launcher/MyDiameterEngine.hpp index 29b3c1b..d7c9b07 100644 --- a/example/diameter/launcher/MyDiameterEngine.hpp +++ b/example/diameter/launcher/MyDiameterEngine.hpp @@ -17,10 +17,18 @@ #include +namespace anna { + namespace diameter { + namespace stack { + class Dictionary; + } + } +} + class MyDiameterEngine : public anna::diameter::comm::Engine { public: - MyDiameterEngine(const char *className = "MyDiameterEngine") : Engine(className, NULL /* we will assign the base protocol codec engine later*/) {;} + MyDiameterEngine(const char *className, const anna::diameter::stack::Dictionary *baseProtocolDictionary) : Engine(className, baseProtocolDictionary) {;} // Default implementation is enough // void readDPA(anna::DataBlock &dpa, const anna::DataBlock & dpr) throw() {;} // DPA is not replied diff --git a/example/diameter/launcher/RealmNode.cpp b/example/diameter/launcher/RealmNode.cpp index 630ab8f..d3a2b89 100644 --- a/example/diameter/launcher/RealmNode.cpp +++ b/example/diameter/launcher/RealmNode.cpp @@ -19,15 +19,20 @@ #include #include +namespace anna { + namespace diameter { + namespace stack { + class Dictionary; + } + } +} - -RealmNode::RealmNode(const std::string &originRealm, unsigned int applicationId, anna::diameter::codec::Engine *codecEngine) : - a_originRealm(originRealm), a_applicationId(applicationId), a_codecEngine(codecEngine) { +RealmNode::RealmNode(const std::string &originRealm, anna::diameter::codec::Engine *codecEngine, const anna::diameter::stack::Dictionary *baseProtocolDictionary) : + a_originRealm(originRealm), a_codecEngine(codecEngine) { std::string commEngineName = a_originRealm + "_DiameterCommEngine"; - a_commEngine = new MyDiameterEngine(commEngineName.c_str()); + a_commEngine = new MyDiameterEngine(commEngineName.c_str(), baseProtocolDictionary); a_commEngine->setAutoBind(false); // allow to create client-sessions without binding them, in order to set timeouts. - a_commEngine->setBaseProtocolCodecEngine(getCodecEngine()); a_logFile = ""; a_burstLogFile = ""; @@ -56,7 +61,7 @@ RealmNode::RealmNode(const std::string &originRealm, unsigned int applicationId, } -void RealmNode::createEntity(const std::string &entityRepresentation, const anna::Millisecond &bindTimeout, const anna::Millisecond &applicationTimeout) throw() { +void RealmNode::createEntity(const std::string &entityRepresentation, const anna::Millisecond &bindTimeout, const anna::Millisecond &applicationTimeout) throw(anna::RuntimeException) { anna::socket_v servers = anna::functions::getSocketVectorFromString(entityRepresentation); std::string entityDescription = "Launcher diameter entity for "; entityDescription += a_originRealm; @@ -402,7 +407,6 @@ throw() { anna::xml::Node* result = parent->createChild("RealmNode"); result->createAttribute("OriginRealm", a_originRealm); - result->createAttribute("ApplicationId", a_applicationId); result->createAttribute("LogFile", a_logFile); result->createAttribute("SplitLog", a_splitLog ? "yes" : "no"); result->createAttribute("DetailedLog", a_detailedLog ? "yes" : "no"); diff --git a/example/diameter/launcher/RealmNode.hpp b/example/diameter/launcher/RealmNode.hpp index a8a49fd..774e858 100644 --- a/example/diameter/launcher/RealmNode.hpp +++ b/example/diameter/launcher/RealmNode.hpp @@ -25,6 +25,9 @@ namespace anna { namespace codec { class Engine; } + namespace stack { + class Dictionary; + } namespace comm { class Message; } @@ -50,7 +53,6 @@ class RealmNode { // main std::string a_originRealm; - unsigned int a_applicationId; // Timming anna::Millisecond a_allowedInactivityTime; @@ -74,13 +76,13 @@ class RealmNode { int a_burstPopCounter; public: - RealmNode(const std::string &originRealm, unsigned int applicationId, anna::diameter::codec::Engine *codecEngine); + RealmNode(const std::string &originRealm, anna::diameter::codec::Engine *codecEngine, const anna::diameter::stack::Dictionary *baseProtocolDictionary); ~RealmNode() {;} // Core resources: MyDiameterEngine* getMyDiameterEngine() const throw() { return a_commEngine; } anna::diameter::codec::Engine *getCodecEngine() const throw() { return a_codecEngine; } - void createEntity(const std::string &entityRepresentation, const anna::Millisecond &bindTimeout, const anna::Millisecond &applicationTimeout) throw(); + void createEntity(const std::string &entityRepresentation, const anna::Millisecond &bindTimeout, const anna::Millisecond &applicationTimeout) throw(anna::RuntimeException); MyDiameterEntity *getEntity() const throw() { return a_entity; } void startDiameterServer(const std::string &serverRepresentation, int sessions, const anna::Millisecond &inactivityTimeout) throw(anna::RuntimeException); MyLocalServer* getDiameterServer() throw() { return a_diameterServer; } diff --git a/example/diameter/launcher/resources/scripts/operation_signal.sh b/example/diameter/launcher/resources/scripts/operation_signal.sh index 8c9ce85..d312981 100755 --- a/example/diameter/launcher/resources/scripts/operation_signal.sh +++ b/example/diameter/launcher/resources/scripts/operation_signal.sh @@ -18,10 +18,10 @@ PID=`cat .pid` # Send operation: [ "$1" = "" ] && _exit "Usage: $0 ; i.e.: $0 help" -echo $1 > sigusr2.tasks.input +echo $1 > sigusr2.in kill -s SIGUSR2 $PID -#echo "You could see results on '`pwd`/sigusr2.tasks.output' file." -cat `pwd`/sigusr2.tasks.output 2>/dev/null +#echo "You could see results on '`pwd`/sigusr2.out' file." +cat `pwd`/sigusr2.out 2>/dev/null echo diff --git a/example/diameter/launcher/resources/services_examples/balancer.xml b/example/diameter/launcher/resources/services_examples/balancer.xml index d7bfbc6..a7d3f30 100644 --- a/example/diameter/launcher/resources/services_examples/balancer.xml +++ b/example/diameter/launcher/resources/services_examples/balancer.xml @@ -3,7 +3,7 @@ - - + + diff --git a/example/diameter/launcher/resources/services_examples/client.xml b/example/diameter/launcher/resources/services_examples/client.xml index dfbb943..4c5e019 100644 --- a/example/diameter/launcher/resources/services_examples/client.xml +++ b/example/diameter/launcher/resources/services_examples/client.xml @@ -3,6 +3,6 @@ - + diff --git a/example/diameter/launcher/resources/services_examples/dummy.xml b/example/diameter/launcher/resources/services_examples/dummy.xml index f1602be..c09c529 100644 --- a/example/diameter/launcher/resources/services_examples/dummy.xml +++ b/example/diameter/launcher/resources/services_examples/dummy.xml @@ -3,6 +3,6 @@ - + diff --git a/example/diameter/launcher/resources/services_examples/multi-client.xml b/example/diameter/launcher/resources/services_examples/multi-client.xml index 795143f..a47db65 100644 --- a/example/diameter/launcher/resources/services_examples/multi-client.xml +++ b/example/diameter/launcher/resources/services_examples/multi-client.xml @@ -3,11 +3,12 @@ + - - - - + + + + diff --git a/example/diameter/launcher/resources/services_examples/server.xml b/example/diameter/launcher/resources/services_examples/server.xml index c257afc..e615c4a 100644 --- a/example/diameter/launcher/resources/services_examples/server.xml +++ b/example/diameter/launcher/resources/services_examples/server.xml @@ -3,6 +3,6 @@ - + diff --git a/example/diameter/launcher/resources/services_examples/services.dtd b/example/diameter/launcher/resources/services_examples/services.dtd index 05edb86..6dd31ed 100755 --- a/example/diameter/launcher/resources/services_examples/services.dtd +++ b/example/diameter/launcher/resources/services_examples/services.dtd @@ -8,19 +8,18 @@ - +