From: Eduardo Ramos Testillano Date: Tue, 24 Nov 2015 17:17:26 +0000 (+0100) Subject: Make Origin-Host the node identifier instead of origin-realm X-Git-Tag: REFACTORING_TESTING_LIBRARY~76 X-Git-Url: https://git.teslayout.com/public/public/public/?p=anna.git;a=commitdiff_plain;h=5bf5055ab79aaf464e2491cfbab173ba37ba3419 Make Origin-Host the node identifier instead of origin-realm --- diff --git a/example/diameter/launcher/DEPLOY_setups.sh b/example/diameter/launcher/DEPLOY_setups.sh index ff55549..fe89053 100755 --- a/example/diameter/launcher/DEPLOY_setups.sh +++ b/example/diameter/launcher/DEPLOY_setups.sh @@ -81,7 +81,7 @@ case $type in $DEPLOY_SCR b $DIR/ADML-serverRx echo "Configuring ..." cd $DIR/ADML-st-client - ln -s realms_example realms + ln -s services_example services mv run.sh .run-one.sh mv run_all.sh run.sh mv operation.sh .operation-one.sh diff --git a/example/diameter/launcher/Launcher.cpp b/example/diameter/launcher/Launcher.cpp index 4219399..67343ff 100644 --- a/example/diameter/launcher/Launcher.cpp +++ b/example/diameter/launcher/Launcher.cpp @@ -27,7 +27,7 @@ // Process #include -#include +#include #include #include #include @@ -59,14 +59,13 @@ const char *ServicesDTD = "\ -->\n\ \n\ \n\ -\n\ +\n\ "; - result += "\n "; + result += "\n "; result += "\n"; result += "\n"; result += "\nServer configuration:"; @@ -908,13 +907,13 @@ std::string Launcher::help() const throw() { 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. To make hybrid setups you only must mix the realms:"; + result += "\n arguments in order to define the balancing behaviour. To make hybrid setups you only must mix the nodes:"; result += "\n"; result += "\nClient and server configuration:"; result += "\n"; @@ -925,8 +924,8 @@ std::string Launcher::help() const throw() { result += "\n "; result += "\n"; result += "\n "; - result += "\n "; - result += "\n "; + result += "\n "; + result += "\n "; result += "\n"; result += "\n"; result += "\n"; @@ -948,7 +947,7 @@ std::string Launcher::help() const throw() { result += "\n"; result += "\n--------------------------------------------------------------------------------------- Node management"; result += "\n"; - result += "\nnode[|] Selects a context working node by mean a registered name."; + result += "\nnode[|] Selects a context working node by mean a registered name (origin-host)."; result += "\n All the subsequent operations will be forced to work with"; result += "\n this node, which makes possible some rare scenarios like"; result += "\n sending unexpected messages on remote peers. This is also"; @@ -958,12 +957,12 @@ std::string Launcher::help() const throw() { result += "\n"; result += "\nnode_auto Returns to the default behaviour (smart node selection)."; result += "\n Depending on the operation, this could imply a global"; - result += "\n action scope, affecting to all the registered realms."; + result += "\n action scope, affecting to all the registered hosts."; result += "\n This should be the normal configuration. Take into"; result += "\n account that if you fix the working node, this could"; result += "\n affect to things like test programming: communication"; result += "\n resources will override those which would be inferred"; - result += "\n from programmed messages Origin-Realm avps."; + result += "\n from programmed messages Origin-Host avps."; result += "\n"; result += "\n------------------------------------------------------------------------------------ Parsing operations"; result += "\n"; @@ -979,7 +978,7 @@ std::string Launcher::help() const throw() { 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 diameter base dictionary with stack id 0, because all the nodes"; result += "\n will use this dictionary to encode/decode base protocol messages"; result += "\n managed by the communication engine."; result += "\n"; @@ -992,7 +991,7 @@ std::string Launcher::help() const throw() { result += "\n performance measurement. Context data can be written at"; result += "\n '/var/tmp/anna.context.' by mean 'kill -10 '."; result += "\n or sending operation 'context|[target file]'."; - result += "\n This operation applies over all the registered realm nodes"; + 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 += "\nshow-oam Dumps current counters of the process. This is also done at"; @@ -1081,10 +1080,10 @@ std::string Launcher::help() const throw() { result += "\n"; result += "\n------------------------------------------------------------------------------------------- Burst tests"; result += "\n"; - result += "\nIn order to simplify user experience, burst category operations are only allowed in single realm node"; - result += "\n configuration. Indeed, you could send messages with incorrect Origin-Realm, and no warning is shown."; - result += "\nAll the operations are performed through the unique realm: if you need to use more interfaces, you may"; - result += "\n launch different ADML instances. Is nonsense to allow burst in a multi-realm configured ADML, because"; + result += "\nIn order to simplify user experience, burst category operations are only allowed in single host node"; + result += "\n configuration. Indeed, you could send messages with unmatched Origin-Host, and no warning is shown."; + result += "\nAll the operations are performed through the unique host: if you need to use more interfaces, you may"; + result += "\n launch different ADML instances. Is nonsense to allow burst in a multi-host configured ADML, because"; result += "\n this feature is not able to coordinate the messages."; result += "\n"; result += "\nburst|[|parameter] Used for performance testing, we first program diameter requests"; @@ -1117,7 +1116,7 @@ std::string Launcher::help() const throw() { result += "\n-------------------------------------------------------------------------------------- Advanced testing"; result += "\n"; result += "\n Burst mode only allows single interface interaction. For multiple interface"; - result += "\n (realm) coordination, you could use the advanced test cases programming:"; + result += "\n (origin-host) coordination, you could use the advanced test cases programming:"; result += "\n"; result += "\n"; result += "\n test||[|parameters]"; @@ -1215,7 +1214,7 @@ std::string Launcher::help() const throw() { result += "\n which fulfills that condition. This message is useful together with the peer"; result += "\n connection source in a further send step configured with the corresponding"; result += "\n response. You could also insert a delay between wait and send steps to be"; - result += "\n more realistic (processing time simulation in a specific ADML realm node)."; + result += "\n more realistic (processing time simulation in a specific ADML host node)."; result += "\n Always, a response send step will get the needed information from the most"; result += "\n recent wait step finding in reverse order (note that some race conditions"; result += "\n could happen if your condition is not specific enough)."; @@ -1253,7 +1252,7 @@ std::string Launcher::help() const throw() { result += "\n RFC says that a hop by hop must be unique for a specific connection, something that"; result += "\n could be difficult to manage if we have multiple available connections from client"; result += "\n side endpoint (entity or local server), even if we would have only one connection but"; - result += "\n several realm interfaces. It is enough to configure different hop-by-hop values within"; + result += "\n several host interfaces. It is enough to configure different hop-by-hop values within"; result += "\n each test case, because on reception, the Session-Id is used to identify that test case."; result += "\n"; result += "\n"; @@ -1563,7 +1562,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons return; } - // Realm switch: + // Host switch: if(opType == "node") { if (param1 != "") { if (setWorkingNode(param1)) response_content = anna::functions::asString("Forced node is now '%s'", param1.c_str()); @@ -1585,12 +1584,12 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons return; } - // Operated realm from possible forced-working node: - a_operatedRealm = a_workingNode ? a_workingNode /* priority */: NULL /* auto */; + // Operated host from possible forced-working node: + a_operatedHost = a_workingNode ? a_workingNode /* priority */: NULL /* auto */; // Use later: - // If any message is managed: updateOperatedRealmNodeWithMessage(codecMessage) + // If any message is managed: updateOperatedOriginHostWithMessage(codecMessage) // To operate, use the exception-protected methods which never will return NULL: - // getOperatedRealm(), getOperatedEntity(), getOperatedServer(), getOperatedEngine() + // getOperatedHost(), getOperatedEntity(), getOperatedServer(), getOperatedEngine() if(opType == "code") { @@ -1655,8 +1654,8 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if(opType == "sendxml2e") { codecMsg.loadXML(param1); - updateOperatedRealmNodeWithMessage(codecMsg); - msg = getOperatedRealm()->createCommMessage(); + updateOperatedOriginHostWithMessage(codecMsg); + msg = getOperatedHost()->createCommMessage(); msg->clearBody(); try { codecMsg.valid(); } catch(anna::RuntimeException &ex) { ex.trace(); } // at least we need to see validation errors although it will continue sending (see validation mode configured in launcher) msg->setBody(codecMsg.code()); @@ -1664,25 +1663,25 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons // Get DataBlock from file with hex content: if(!getDataBlockFromHexFile(param1, db_aux)) throw anna::RuntimeException("Error reading hex file provided", ANNA_FILE_LOCATION); - msg = getOperatedRealm()->createCommMessage(); + msg = getOperatedHost()->createCommMessage(); msg->setBody(db_aux); - try { if(getOperatedRealm()->logEnabled()) codecMsg.decode(db_aux); } catch(anna::RuntimeException &ex) { ex.trace(); } + try { if(getOperatedHost()->logEnabled()) codecMsg.decode(db_aux); } catch(anna::RuntimeException &ex) { ex.trace(); } } bool success = getOperatedEntity()->send(msg, cl.exists("balance")); - getOperatedRealm()->releaseCommMessage(msg); + getOperatedHost()->releaseCommMessage(msg); // Detailed log: - if(getOperatedRealm()->logEnabled()) { + if(getOperatedHost()->logEnabled()) { anna::diameter::comm::Server *usedServer = getOperatedEntity()->getLastUsedResource(); anna::diameter::comm::ClientSession *usedClientSession = usedServer ? usedServer->getLastUsedResource() : NULL; std::string detail = usedClientSession ? usedClientSession->asString() : ""; // shouldn't happen - getOperatedRealm()->writeLogFile(codecMsg, (success ? "sent2e" : "send2eError"), detail); + getOperatedHost()->writeLogFile(codecMsg, (success ? "sent2e" : "send2eError"), detail); } } else if((opType == "burst")) { - if (!uniqueRealm()) - throw anna::RuntimeException("Burst category operations are only allowed in single realm node configuration. This is only to simplify user experience.", ANNA_FILE_LOCATION); + if (!uniqueOriginHost()) + throw anna::RuntimeException("Burst category operations are only allowed in single host node configuration. This is only to simplify user experience.", ANNA_FILE_LOCATION); // burst|clear clears all loaded burst messages. // burst|load| loads the next diameter message into launcher burst. @@ -1699,7 +1698,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if(param1 == "clear") { opt_response_content = "removed "; - opt_response_content += anna::functions::asString(getOperatedRealm()->clearBurst()); + opt_response_content += anna::functions::asString(getOperatedHost()->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); @@ -1708,7 +1707,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if(codecMsg.isAnswer()) throw anna::RuntimeException("Cannot load diameter answers for burst feature", ANNA_FILE_LOCATION); 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 = getOperatedRealm()->loadBurstMessage(codecMsg.code()); + int position = getOperatedHost()->loadBurstMessage(codecMsg.code()); opt_response_content = "loaded '"; opt_response_content += param2; opt_response_content += "' file into burst list position "; @@ -1717,7 +1716,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if(param2 == "") throw anna::RuntimeException("Missing initial load for burst start operation", ANNA_FILE_LOCATION); int initialLoad = atoi(param2.c_str()); - int processed = getOperatedRealm()->startBurst(initialLoad); + int processed = getOperatedHost()->startBurst(initialLoad); if(processed > 0) { opt_response_content = "initial load completed for "; @@ -1726,7 +1725,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons } else if(param1 == "push") { if(param2 == "") throw anna::RuntimeException("Missing load amount for burst push operation", ANNA_FILE_LOCATION); - int pushed = getOperatedRealm()->pushBurst(atoi(param2.c_str())); + int pushed = getOperatedHost()->pushBurst(atoi(param2.c_str())); if(pushed > 0) { opt_response_content = "pushed "; @@ -1736,14 +1735,14 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if(param2 == "") throw anna::RuntimeException("Missing amount for burst pop operation", ANNA_FILE_LOCATION); int releaseLoad = atoi(param2.c_str()); - int popped = getOperatedRealm()->popBurst(releaseLoad); + int popped = getOperatedHost()->popBurst(releaseLoad); if(popped > 0) { opt_response_content = "burst popped for "; opt_response_content += anna::functions::entriesAsString(popped, "message"); } } else if(param1 == "stop") { - int left = getOperatedRealm()->stopBurst(); + int left = getOperatedHost()->stopBurst(); if(left != -1) { opt_response_content += anna::functions::entriesAsString(left, "message"); @@ -1753,12 +1752,12 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if(param2 == "") param2 = "yes"; bool repeat = (param2 == "yes"); - getOperatedRealm()->repeatBurst(repeat); + getOperatedHost()->repeatBurst(repeat); 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 = getOperatedRealm()->sendBurst(atoi(param2.c_str())); + int sent = getOperatedHost()->sendBurst(atoi(param2.c_str())); if(sent > 0) { opt_response_content = "sent "; @@ -1767,11 +1766,11 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons } else if(param1 == "goto") { if(param2 == "") throw anna::RuntimeException("Missing order position for burst goto operation", ANNA_FILE_LOCATION); - opt_response_content = getOperatedRealm()->gotoBurst(atoi(param2.c_str())); + opt_response_content = getOperatedHost()->gotoBurst(atoi(param2.c_str())); } else if(param1 == "look") { int order = ((param2 != "") ? atoi(param2.c_str()) : -1); opt_response_content = "\n\n"; - opt_response_content += getOperatedRealm()->lookBurst(order); + opt_response_content += getOperatedHost()->lookBurst(order); } else { throw anna::RuntimeException("Wrong body content format on HTTP Request for 'burst' operation (unexpected action parameter). See help", ANNA_FILE_LOCATION); } @@ -2035,13 +2034,13 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons else { if (param4 == "") LOGWARNING(anna::Logger::warning("Step number has not been provided. Take into account that this answer message will be sent 'as is' and sequence information could be wrong at the remote peer", ANNA_FILE_LOCATION)); } - updateOperatedRealmNodeWithMessage(codecMsg); + updateOperatedOriginHostWithMessage(codecMsg); int stepNumber = ((param4 != "") ? atoi(param4.c_str()):-1); if (param2 == "sendxml2e") - testManager.getTestCase(id)->addSendxml2e(codecMsg.code(), getOperatedRealm(), stepNumber); // creates / reuses + testManager.getTestCase(id)->addSendxml2e(codecMsg.code(), getOperatedHost(), stepNumber); // creates / reuses else - testManager.getTestCase(id)->addSendxml2c(codecMsg.code(), getOperatedRealm(), stepNumber); // creates / reuses + testManager.getTestCase(id)->addSendxml2c(codecMsg.code(), getOperatedHost(), stepNumber); // creates / reuses } else if (param2 == "delay") { if (numParams > 3) @@ -2088,8 +2087,8 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if(opType == "sendxml2c") { codecMsg.loadXML(param1); - updateOperatedRealmNodeWithMessage(codecMsg); - msg = getOperatedRealm()->createCommMessage(); + updateOperatedOriginHostWithMessage(codecMsg); + msg = getOperatedHost()->createCommMessage(); msg->clearBody(); try { codecMsg.valid(); } catch(anna::RuntimeException &ex) { ex.trace(); } // at least we need to see validation errors although it will continue sending (see validation mode configured in launcher) @@ -2098,18 +2097,18 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons // Get DataBlock from file with hex content: if(!getDataBlockFromHexFile(param1, db_aux)) throw anna::RuntimeException("Error reading hex file provided", ANNA_FILE_LOCATION); - msg = getOperatedRealm()->createCommMessage(); + msg = getOperatedHost()->createCommMessage(); msg->setBody(db_aux); } bool success = getOperatedServer()->send(msg); - getOperatedRealm()->releaseCommMessage(msg); + getOperatedHost()->releaseCommMessage(msg); // Detailed log: - if(getOperatedRealm()->logEnabled()) { + if(getOperatedHost()->logEnabled()) { anna::diameter::comm::ServerSession *usedServerSession = getOperatedServer()->getLastUsedResource(); std::string detail = usedServerSession ? usedServerSession->asString() : ""; // shouldn't happen - getOperatedRealm()->writeLogFile(codecMsg, (success ? "sent2c" : "send2cError"), detail); + getOperatedHost()->writeLogFile(codecMsg, (success ? "sent2c" : "send2cError"), detail); } } else if(opType == "loadxml") { codecMsg.loadXML(param1); @@ -2133,8 +2132,8 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons getOperatedServer()->getReactingAnswers()->dump(); } else { codecMsg.loadXML(param1); - updateOperatedRealmNodeWithMessage(codecMsg); - anna::diameter::codec::Message *message = getOperatedRealm()->getCodecEngine()->createMessage(param1); // loads xml again, lesser of two evils + updateOperatedOriginHostWithMessage(codecMsg); + anna::diameter::codec::Message *message = getOperatedHost()->getCodecEngine()->createMessage(param1); // loads xml again, lesser of two evils LOGDEBUG(anna::Logger::debug(message->asXMLString(), ANNA_FILE_LOCATION)); if(message->isRequest()) @@ -2159,8 +2158,8 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons getOperatedEntity()->getReactingAnswers()->dump(); } else { codecMsg.loadXML(param1); - updateOperatedRealmNodeWithMessage(codecMsg); - anna::diameter::codec::Message *message = getOperatedRealm()->getCodecEngine()->createMessage(param1); // loads xml again, lesser of two evils + updateOperatedOriginHostWithMessage(codecMsg); + anna::diameter::codec::Message *message = getOperatedHost()->getCodecEngine()->createMessage(param1); // loads xml again, lesser of two evils LOGDEBUG(anna::Logger::debug(message->asXMLString(), ANNA_FILE_LOCATION)); if(message->isRequest()) @@ -2190,7 +2189,7 @@ throw() { result->createAttribute("StartTime", a_start_time.asString()); result->createAttribute("SecondsLifeTime", anna::time::functions::lapsedMilliseconds() / 1000); // Diameter: - for (realm_nodes_it it = a_nodes.begin(); it != a_nodes.end(); it++) { + for (origin_hosts_it it = a_originHosts.begin(); it != a_originHosts.end(); it++) { it->second->asXML(result); } diff --git a/example/diameter/launcher/Launcher.hpp b/example/diameter/launcher/Launcher.hpp index 2101948..af8a07a 100644 --- a/example/diameter/launcher/Launcher.hpp +++ b/example/diameter/launcher/Launcher.hpp @@ -43,16 +43,16 @@ namespace anna { } class TestManager; -class RealmNode; +class OriginHost; class MyDiameterEntity; class MyLocalServer; class MyDiameterEngine; -// RealmNode resources -class RealmNode; -typedef std::map realm_nodes_t; -typedef std::map::const_iterator realm_nodes_it; -typedef std::map::iterator realm_nodes_nc_it; +// OriginHost resources +class OriginHost; +typedef std::map origin_hosts_t; +typedef std::map::const_iterator origin_hosts_it; +typedef std::map::iterator origin_hosts_nc_it; class Launcher : public anna::comm::Application { @@ -68,9 +68,9 @@ class Launcher : public anna::comm::Application { MyCounterRecorderClock *a_counterRecorderClock; // Nodes deployment: - realm_nodes_t a_nodes; - RealmNode *a_workingNode; - RealmNode *a_operatedRealm; // auxiliary for eventOperation + origin_hosts_t a_originHosts; + OriginHost *a_workingNode; + OriginHost *a_operatedHost; // auxiliary for eventOperation // comm resources: anna::comm::ServerSocket* a_httpServerSocket; // HTTP @@ -90,13 +90,13 @@ public: void startServices() throw(anna::RuntimeException); bool setWorkingNode(const std::string &name) throw(); - RealmNode *getRealmNode(const std::string &realmName) const throw(anna::RuntimeException); - RealmNode *getRealmNode(const anna::diameter::codec::Message &message) const throw(anna::RuntimeException); - bool uniqueRealm() const throw() { return (a_nodes.size() == 1); } + OriginHost *getOriginHost(const std::string &oh) const throw(anna::RuntimeException); + OriginHost *getOriginHost(const anna::diameter::codec::Message &message) const throw(anna::RuntimeException); + bool uniqueOriginHost() const throw() { return (a_originHosts.size() == 1); } - // Operated realm for communication resources smart assignment //////////////////////////////////////////////////////////// - void updateOperatedRealmNodeWithMessage(const anna::diameter::codec::Message &message) throw(anna::RuntimeException); - RealmNode *getOperatedRealm() const throw(anna::RuntimeException); + // Operated host for communication resources smart assignment //////////////////////////////////////////////////////////// + void updateOperatedOriginHostWithMessage(const anna::diameter::codec::Message &message) throw(anna::RuntimeException); + OriginHost *getOperatedHost() const throw(anna::RuntimeException); MyDiameterEntity *getOperatedEntity() const throw(anna::RuntimeException); MyLocalServer *getOperatedServer() const throw(anna::RuntimeException); MyDiameterEngine *getOperatedEngine() const throw(anna::RuntimeException); diff --git a/example/diameter/launcher/MyDiameterEntity.cpp b/example/diameter/launcher/MyDiameterEntity.cpp index 6dcf797..5e78ab3 100644 --- a/example/diameter/launcher/MyDiameterEntity.cpp +++ b/example/diameter/launcher/MyDiameterEntity.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include @@ -33,7 +33,7 @@ void MyDiameterEntity::eventRequestRetransmission(const anna::diameter::comm::Cl // Performance stats: Launcher& my_app = static_cast (anna::app::functions::getApp()); - RealmNode * my_node = my_app.getRealmNode(getEngine()->getRealm()); + OriginHost * my_node = my_app.getOriginHost(getEngine()->getOriginHost()); // CommandId: anna::diameter::CommandId cid = anna::diameter::codec::functions::getCommandId(request->getBody()); LOGDEBUG @@ -99,7 +99,7 @@ throw(anna::RuntimeException) { LOGMETHOD(anna::TraceMethod tm("launcher::MyDiameterEntity", "eventRequest", ANNA_FILE_LOCATION)); // Performance stats: Launcher& my_app = static_cast (anna::app::functions::getApp()); - RealmNode * my_node = my_app.getRealmNode(getEngine()->getRealm()); + OriginHost * my_node = my_app.getOriginHost(getEngine()->getOriginHost()); // CommandId: anna::diameter::CommandId cid = anna::diameter::codec::functions::getCommandId(message); @@ -183,7 +183,7 @@ void MyDiameterEntity::eventResponse(const anna::diameter::comm::Response &respo throw(anna::RuntimeException) { LOGMETHOD(anna::TraceMethod tm("launcher::MyDiameterEntity", "eventResponse", ANNA_FILE_LOCATION)); Launcher& my_app = static_cast (anna::app::functions::getApp()); - RealmNode * my_node = my_app.getRealmNode(getEngine()->getRealm()); + OriginHost * my_node = my_app.getOriginHost(getEngine()->getOriginHost()); anna::diameter::comm::ClassCode::_v code = response.getClassCode(); anna::diameter::comm::Response::ResultCode::_v result = response.getResultCode(); anna::diameter::comm::Message* request = const_cast(response.getRequest()); @@ -279,7 +279,7 @@ throw(anna::RuntimeException) { LOGMETHOD(anna::TraceMethod tm("launcher::MyDiameterEntity", "eventUnknownResponse", ANNA_FILE_LOCATION)); // Performance stats: Launcher& my_app = static_cast (anna::app::functions::getApp()); - RealmNode * my_node = my_app.getRealmNode(getEngine()->getRealm()); + OriginHost * my_node = my_app.getOriginHost(getEngine()->getOriginHost()); // CommandId: anna::diameter::CommandId cid = anna::diameter::codec::functions::getCommandId(message); LOGDEBUG @@ -302,7 +302,7 @@ throw(anna::RuntimeException) { LOGMETHOD(anna::TraceMethod tm("launcher::MyDiameterEntity", "eventDPA", ANNA_FILE_LOCATION)); // Performance stats: Launcher& my_app = static_cast (anna::app::functions::getApp()); - RealmNode * my_node = my_app.getRealmNode(getEngine()->getRealm()); + OriginHost * my_node = my_app.getOriginHost(getEngine()->getOriginHost()); // CommandId: anna::diameter::CommandId cid = anna::diameter::codec::functions::getCommandId(message); LOGDEBUG diff --git a/example/diameter/launcher/MyLocalServer.cpp b/example/diameter/launcher/MyLocalServer.cpp index 513cdb4..7d34b46 100644 --- a/example/diameter/launcher/MyLocalServer.cpp +++ b/example/diameter/launcher/MyLocalServer.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include @@ -29,7 +29,7 @@ throw(anna::RuntimeException) { LOGMETHOD(anna::TraceMethod tm("launcher::MyLocalServer", "eventRequest", ANNA_FILE_LOCATION)); // Performance stats: Launcher& my_app = static_cast (anna::app::functions::getApp()); - RealmNode * my_node = my_app.getRealmNode(getEngine()->getRealm()); + OriginHost * my_node = my_app.getOriginHost(getEngine()->getOriginHost()); anna::diameter::codec::Engine *codecEngine = my_node->getCodecEngine(); // CommandId: @@ -90,7 +90,7 @@ throw(anna::RuntimeException) { // Decode try { codecMsg.decode(message, answer_message); } catch(anna::RuntimeException &ex) { ex.trace(); } - answer_message->setStandardToAnswer(codecMsg, my_node->getMyDiameterEngine()->getHost(), my_node->getMyDiameterEngine()->getRealm()); + answer_message->setStandardToAnswer(codecMsg, my_node->getMyDiameterEngine()->getOriginHost(), my_node->getMyDiameterEngine()->getOriginRealm()); analysisOK = (answer_message->getResultCode() == anna::diameter::helpers::base::AVPVALUES__Result_Code::DIAMETER_SUCCESS); } @@ -143,7 +143,7 @@ void MyLocalServer::eventResponse(const anna::diameter::comm::Response &response throw(anna::RuntimeException) { LOGMETHOD(anna::TraceMethod tm("launcher::MyLocalServer", "eventResponse", ANNA_FILE_LOCATION)); Launcher& my_app = static_cast (anna::app::functions::getApp()); - RealmNode * my_node = my_app.getRealmNode(getEngine()->getRealm()); + OriginHost * my_node = my_app.getOriginHost(getEngine()->getOriginHost()); anna::diameter::comm::ClassCode::_v code = response.getClassCode(); anna::diameter::comm::Response::ResultCode::_v result = response.getResultCode(); anna::diameter::comm::Message* request = const_cast(response.getRequest()); @@ -237,7 +237,7 @@ throw(anna::RuntimeException) { LOGMETHOD(anna::TraceMethod tm("launcher::MyLocalServer", "eventUnknownResponse", ANNA_FILE_LOCATION)); // Performance stats: Launcher& my_app = static_cast (anna::app::functions::getApp()); - RealmNode * my_node = my_app.getRealmNode(getEngine()->getRealm()); + OriginHost * my_node = my_app.getOriginHost(getEngine()->getOriginHost()); // CommandId: anna::diameter::CommandId cid = anna::diameter::codec::functions::getCommandId(message); LOGDEBUG @@ -259,7 +259,7 @@ throw(anna::RuntimeException) { LOGMETHOD(anna::TraceMethod tm("launcher::MyLocalServer", "eventDPA", ANNA_FILE_LOCATION)); // Performance stats: Launcher& my_app = static_cast (anna::app::functions::getApp()); - RealmNode * my_node = my_app.getRealmNode(getEngine()->getRealm()); + OriginHost * my_node = my_app.getOriginHost(getEngine()->getOriginHost()); // CommandId: anna::diameter::CommandId cid = anna::diameter::codec::functions::getCommandId(message); LOGDEBUG diff --git a/example/diameter/launcher/OriginHost.cpp b/example/diameter/launcher/OriginHost.cpp new file mode 100644 index 0000000..32044b9 --- /dev/null +++ b/example/diameter/launcher/OriginHost.cpp @@ -0,0 +1,421 @@ +// ANNA - Anna is Not Nothingness Anymore // +// // +// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo // +// // +// See project site at http://redmine.teslayout.com/projects/anna-suite // +// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE // + + +// Standard +#include + +// Project +#include +#include +#include +#include +#include +#include + +// Process +#include +#include + + +namespace anna { + namespace diameter { + namespace stack { + class Dictionary; + } + } +} + +OriginHost::OriginHost(const std::string &originHost, unsigned int applicationId, const anna::diameter::stack::Dictionary *baseProtocolDictionary) : + a_originHost(originHost), a_applicationId(applicationId) { + + std::string commEngineName = a_originHost + "_DiameterCommEngine"; + 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_codecEngine = anna::diameter::codec::EngineManager::instantiate().getCodecEngine(applicationId); + + a_logFile = ""; + a_burstLogFile = ""; + a_splitLog = false; + a_detailedLog = false; + a_dumpLog = false; + a_entity = NULL; + a_diameterServer = NULL; + + // Comm resources: + a_allowedInactivityTime = (anna::Millisecond)90000; + a_tcpConnectDelay = (anna::Millisecond)200; + a_answersTimeout = (anna::Millisecond)10000; + a_ceaTimeout = (anna::Millisecond)10000; + a_watchdogPeriod = (anna::Millisecond)30000; + a_requestRetransmissions = 0; + + // Burst + a_burstCycle = 1; + a_burstRepeat = false; + a_burstActive = false; + a_burstLoadIndx = 0; + a_burstDeliveryIt = a_burstMessages.begin(); + a_otaRequest = 0; + a_burstPopCounter = 0; +} + + +void OriginHost::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_originHost; + a_entity = (MyDiameterEntity*)(a_commEngine->createEntity(servers, entityDescription)); + a_entity->setClassCodeTimeout(anna::diameter::comm::ClassCode::Bind, bindTimeout); + a_entity->setClassCodeTimeout(anna::diameter::comm::ClassCode::ApplicationMessage, applicationTimeout); +} + +void OriginHost::startDiameterServer(const std::string &serverRepresentation, int sessions, const anna::Millisecond &inactivityTimeout) throw(anna::RuntimeException) { + + //if(sessions <= 0) return; negative implies no limit for accepted connections + + std::string address; int port; + anna::functions::getAddressAndPortFromSocketLiteral(serverRepresentation, address, port); + std::string serverDescription = "Launcher diameter local server for "; serverDescription += a_originHost; + a_diameterServer = (MyLocalServer*)(a_commEngine->createLocalServer(address, port, sessions)); + // we could set sessions = 0, and after application run(), use setMaxConnections(real sessions) + // over the local server in order to start it. + + a_diameterServer->setDescription(serverDescription); + a_diameterServer->setAllowedInactivityTime(inactivityTimeout); +} + +anna::diameter::comm::Message *OriginHost::createCommMessage() throw(anna::RuntimeException) { + anna::diameter::comm::Message *result = a_commMessages.create(); + result->setRetries(a_requestRetransmissions); + if (a_requestRetransmissions > 0) result->setOnExpiry(anna::diameter::comm::Message::OnExpiry::Retransmit); + return result; +} + + +void OriginHost::releaseCommMessage(anna::diameter::comm::Message *msg) throw() { + a_commMessages.release(msg); +} + + +void OriginHost::writeLogFile(const anna::DataBlock & db, const std::string &logExtension, const std::string &detail) const throw() { + anna::diameter::codec::Message codecMsg; + try { codecMsg.decode(db); } catch(anna::RuntimeException &ex) { ex.trace(); } + writeLogFile(codecMsg, logExtension, detail); +} + +// Already decoded: +void OriginHost::writeLogFile(const anna::diameter::codec::Message &decodedMessage, const std::string &logExtension, const std::string &detail) const throw() { + // Open target file: + std::string targetFile = a_logFile; + + if(a_splitLog) { + targetFile += "."; + targetFile += logExtension; + } + + std::ofstream out(targetFile.c_str(), std::ifstream::out | std::ifstream::app); + // Set text to dump: + std::string title = "["; + title += logExtension; + title += "]"; + // Build complete log: + std::string log = "\n"; + std::string xml = decodedMessage.asXMLString(); + + + if(a_detailedLog) { + anna::time::Date now; + now.setNow(); + title += " "; + title += now.asString(); + log += anna::functions::highlight(title, anna::functions::TextHighlightMode::OverAndUnderline); + log += xml; + log += "\n"; + log += anna::functions::highlight("Used resource"); + log += detail; + log += "\n"; + } else { + log += title; + log += "\n"; + log += xml; + log += "\n"; + } + + if(a_dumpLog) { + std::string name = getMyDiameterEngine()->getOriginHost(); + name += "."; + name += anna::functions::asString(decodedMessage.getHopByHop()); + name += "."; + name += anna::functions::asString(decodedMessage.getEndToEnd()); + name += "."; + name += anna::functions::asString(decodedMessage.getId().first); + name += "."; + name += ((decodedMessage.getId().second) ? "request.":"answer."); + name += logExtension; + name += ".xml"; + std::ofstream outMsg(name.c_str(), std::ifstream::out | std::ifstream::app); + outMsg.write(xml.c_str(), xml.size()); + outMsg.close(); + } + + // Write and close + out.write(log.c_str(), log.size()); + out.close(); +} + +void OriginHost::writeBurstLogFile(const std::string &buffer) throw() { + std::ofstream out(a_burstLogFile.c_str(), std::ifstream::out | std::ifstream::app); + out.write(buffer.c_str(), buffer.size()); + out.close(); // close() will be called when the object is destructed (i.e., when it goes out of scope). + // you'd call close() only if you indeed for some reason wanted to close the filestream + // earlier than it goes out of scope. +} + +int OriginHost::clearBurst() throw() { + int size = a_burstMessages.size(); + + if(size) { + std::map::const_iterator it; + std::map::const_iterator it_min(a_burstMessages.begin()); + std::map::const_iterator it_max(a_burstMessages.end()); + + for(it = it_min; it != it_max; it++) releaseCommMessage((*it).second); + + a_burstMessages.clear(); + } else { + std::string msg = "Burst list already empty. Nothing done"; + std::cout << msg << std::endl; + LOGWARNING(anna::Logger::warning(msg, ANNA_FILE_LOCATION)); + } + + a_burstActive = false; + a_burstLoadIndx = 0; + a_burstDeliveryIt = a_burstMessages.begin(); + return size; +} + +int OriginHost::loadBurstMessage(const anna::DataBlock & db) throw(anna::RuntimeException) { + anna::diameter::comm::Message *msg = createCommMessage(); + msg->setBody(db); + a_burstMessages[a_burstLoadIndx++] = msg; + return (a_burstLoadIndx - 1); +} + +int OriginHost::stopBurst() throw() { + if(!a_burstActive) { + std::string msg = "Burst launch is already stopped. Nothing done"; + std::cout << msg << std::endl; + LOGWARNING(anna::Logger::warning(msg, ANNA_FILE_LOCATION)); + return -1; + } + + a_burstActive = false; + // Remaining on cycle: + return (a_burstMessages.size() - (*a_burstDeliveryIt).first); +} + +int OriginHost::popBurst(int releaseAmount) throw() { + if(!a_burstActive) { + std::string msg = "Burst launch is stopped. Nothing done"; + std::cout << msg << std::endl; + LOGWARNING(anna::Logger::warning(msg, ANNA_FILE_LOCATION)); + return -1; + } + + if(releaseAmount < 1) { + std::string msg = "No valid release amount is specified. Ignoring burst pop"; + std::cout << msg << std::endl; + LOGWARNING(anna::Logger::warning(msg, ANNA_FILE_LOCATION)); + return -2; + } + + int currentOTArequests = a_entity->getOTARequests(); + a_burstPopCounter = (releaseAmount > currentOTArequests) ? currentOTArequests : releaseAmount; + return a_burstPopCounter; +} + +int OriginHost::pushBurst(int loadAmount) throw() { + if(a_burstMessages.size() == 0) { + std::string msg = "Burst data not found (empty list). Ignoring burst launch"; + std::cout << msg << std::endl; + LOGWARNING(anna::Logger::warning(msg, ANNA_FILE_LOCATION)); + return -1; + } + + if(loadAmount < 1) { + std::string msg = "No valid load amount is specified. Ignoring burst push"; + std::cout << msg << std::endl; + LOGWARNING(anna::Logger::warning(msg, ANNA_FILE_LOCATION)); + return -2; + } + + a_burstActive = true; + int count; + + for(count = 0; count < loadAmount; count++) + if(!sendBurstMessage()) break; + + return count; +} + +int OriginHost::sendBurst(int loadAmount) throw() { + if(a_burstMessages.size() == 0) { + std::string msg = "Burst data not found (empty list). Ignoring burst launch"; + std::cout << msg << std::endl; + LOGWARNING(anna::Logger::warning(msg, ANNA_FILE_LOCATION)); + return -1; + } + + if(loadAmount < 1) { + std::string msg = "No valid load amount is specified. Ignoring burst send"; + std::cout << msg << std::endl; + LOGWARNING(anna::Logger::warning(msg, ANNA_FILE_LOCATION)); + return -2; + } + + int count; + + for(count = 0; count < loadAmount; count++) + if(!sendBurstMessage(true /* anyway */)) break; + + return count; +} + +int OriginHost::startBurst(int initialLoad) throw() { + if(initialLoad < 1) { + std::string msg = "No initial load is specified. Ignoring burst start"; + std::cout << msg << std::endl; + LOGWARNING(anna::Logger::warning(msg, ANNA_FILE_LOCATION)); + return -2; + } + + a_burstActive = true; + a_burstCycle = 1; + a_burstDeliveryIt = a_burstMessages.begin(); + return (pushBurst(initialLoad)); +} + +bool OriginHost::sendBurstMessage(bool anyway) throw() { + if(!anyway && !burstActive()) return false; + + if(a_burstPopCounter > 0) { + if(burstLogEnabled()) writeBurstLogFile("x"); + + a_burstPopCounter--; + return false; + } + + if(a_burstDeliveryIt == a_burstMessages.end()) { + a_burstDeliveryIt = a_burstMessages.begin(); + + if(!anyway) { + if(a_burstRepeat) { + a_burstCycle++; + + if(burstLogEnabled()) writeBurstLogFile(anna::functions::asString("\nCompleted burst cycle. Starting again (repeat mode) on cycle %d.\n", a_burstCycle)); + } else { + if(burstLogEnabled()) writeBurstLogFile("\nCompleted burst cycle. Burst finished (repeat mode disabled).\n"); + + stopBurst(); + return false; + } + } + } + + anna::diameter::comm::Message *msg = (*a_burstDeliveryIt).second; + int order = (*a_burstDeliveryIt).first + 1; + a_burstDeliveryIt++; + bool dot = true; + // sending + bool result = a_entity->send(msg, anna::CommandLine::instantiate().exists("balance")); + + if(burstLogEnabled()) { + if(a_burstMessages.size() >= 100) + dot = (order % (a_burstMessages.size() / 100)); + + if(dot) { + writeBurstLogFile("."); + } else { + writeBurstLogFile(anna::functions::asString(" %d", order)); + int otaReqs = a_entity->getOTARequests(); + + if(result && (otaReqs != a_otaRequest)) { + // false if was a sending after an answer received (no OTA change in this case) + // true after push and pop operations + a_otaRequest = otaReqs; + writeBurstLogFile(anna::functions::asString("[OTA %d]", a_otaRequest)); + } + } + } + + // Detailed log: + if(logEnabled()) { + anna::diameter::comm::Server *usedServer = a_entity->getLastUsedResource(); + anna::diameter::comm::ClientSession *usedClientSession = usedServer ? usedServer->getLastUsedResource() : NULL; + std::string detail = usedClientSession ? usedClientSession->asString() : ""; // esto no deberia ocurrir + writeLogFile(msg->getBody(), (result ? "sent2e" : "send2eError"), detail); // el del nodo de trabajo + } + + return result; +} + +std::string OriginHost::lookBurst(int order) const throw() { + + if (order == -1) order = a_burstDeliveryIt->first; + + std::string result = "No message found for order provided ("; + result += anna::functions::asString(order); + result += ")"; + std::map::const_iterator it = a_burstMessages.find(order - 1); + + if(it != a_burstMessages.end()) { + anna::diameter::codec::Message codecMsg; + try { codecMsg.decode((*it).second->getBody()); result = codecMsg.asXMLString(); } catch(anna::RuntimeException &ex) { ex.trace(); } + } + + return result; +} + +std::string OriginHost::gotoBurst(int order) throw() { + std::string result = "Position not found for order provided ("; + std::map::iterator it = a_burstMessages.find(order - 1); + + if(it != a_burstMessages.end()) { + a_burstDeliveryIt = it; + result = "Position updated for order provided ("; + } + + result += anna::functions::asString(order); + result += ")"; + return result; +} + +anna::xml::Node* OriginHost::asXML(anna::xml::Node* parent) const +throw() { + anna::xml::Node* result = parent->createChild("OriginHost"); + + result->createAttribute("originHost", a_originHost); + result->createAttribute("ApplicationId", a_applicationId); + result->createAttribute("originRealm", a_commEngine->getOriginRealm()); + result->createAttribute("LogFile", a_logFile); + result->createAttribute("SplitLog", a_splitLog ? "yes" : "no"); + result->createAttribute("DetailedLog", a_detailedLog ? "yes" : "no"); + result->createAttribute("DumpLog", a_dumpLog ? "yes" : "no"); + result->createAttribute("BurstLogFile", a_burstLogFile); + result->createAttribute("RequestRetransmissions", a_requestRetransmissions); + + anna::xml::Node* commEngine = result->createChild("CommEngine"); + a_commEngine->asXML(commEngine); + + return result; +} + +std::string OriginHost::asXMLString() const throw() { + anna::xml::Node root("root"); + return anna::xml::Compiler().apply(asXML(&root)); +} diff --git a/example/diameter/launcher/OriginHost.hpp b/example/diameter/launcher/OriginHost.hpp new file mode 100644 index 0000000..6f27f95 --- /dev/null +++ b/example/diameter/launcher/OriginHost.hpp @@ -0,0 +1,131 @@ +// ANNA - Anna is Not Nothingness Anymore // +// // +// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo // +// // +// See project site at http://redmine.teslayout.com/projects/anna-suite // +// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE // + + +#ifndef example_diameter_launcher_OriginHost_hpp +#define example_diameter_launcher_OriginHost_hpp + +// Standard +#include +#include + +// Project +#include +#include +#include +#include + + +namespace anna { + namespace diameter { + namespace codec { + class Engine; + } + namespace stack { + class Dictionary; + } + namespace comm { + class Message; + } + } +} + + +class MyDiameterEntity; +class MyDiameterEngine; +class MyLocalServer; + + +class OriginHost { + + MyDiameterEngine *a_commEngine; + MyDiameterEntity *a_entity; // we could get it finding the unique instante within comm engine, but it is more comfortable assign here. + MyLocalServer* a_diameterServer; // idem + anna::diameter::codec::Engine *a_codecEngine; + + // resources + int a_requestRetransmissions; + anna::Recycler a_commMessages; + + // main + std::string a_originHost; + unsigned int a_applicationId; + + // Timming + anna::Millisecond a_allowedInactivityTime; + anna::Millisecond a_tcpConnectDelay; + anna::Millisecond a_answersTimeout; + anna::Millisecond a_ceaTimeout; + anna::Millisecond a_watchdogPeriod; + + // Logs & burst + std::string a_logFile; + bool a_splitLog, a_detailedLog, a_dumpLog; + std::string a_burstLogFile; + std::ofstream a_burstLogStream; + int a_burstCycle; + bool a_burstRepeat; + bool a_burstActive; + std::map < int /* dummy, p.e. used for order number */, anna::diameter::comm::Message* > a_burstMessages; + int a_burstLoadIndx; + std::map::const_iterator a_burstDeliveryIt; + int a_otaRequest; + int a_burstPopCounter; + +public: + OriginHost(const std::string &originHost, unsigned int applicationId, const anna::diameter::stack::Dictionary *baseProtocolDictionary); + ~OriginHost() {;} + + const std::string &getName() const throw() { return a_originHost; } + + // Core resources: + MyDiameterEngine* getMyDiameterEngine() const throw() { return a_commEngine; } + unsigned int getApplicationId() const throw() { return a_applicationId; } + 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(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; } + void setRequestRetransmissions(int r) throw() { if (r >= 0) a_requestRetransmissions = r; } + + // Messages factory: + anna::diameter::comm::Message *createCommMessage() throw(anna::RuntimeException); + void releaseCommMessage(anna::diameter::comm::Message*) throw(); + + // Traffic logs & burst: + void setLogs(const std::string &log, bool splitLog, bool detailedLog, bool dumpLog, const std::string &burstLog) throw() { + a_logFile = log; + a_splitLog = splitLog; + a_detailedLog = detailedLog; + a_dumpLog = dumpLog; + a_burstLogFile = burstLog; + } + + bool logEnabled() const throw() { return (((a_logFile == "") || (a_logFile == "null")) ? false : true); } + void writeLogFile(const anna::DataBlock & db, const std::string &logExtension, const std::string &detail) const throw(); + void writeLogFile(const anna::diameter::codec::Message & decodedMessage, const std::string &logExtension, const std::string &detail) const throw(); + void writeBurstLogFile(const std::string &buffer) throw(); + bool burstLogEnabled() const throw() { return (((a_burstLogFile == "") || (a_burstLogFile == "null")) ? false : true); } + int clearBurst() throw(); // returns removed + int loadBurstMessage(const anna::DataBlock & db) throw(anna::RuntimeException); + void repeatBurst(bool repeat) throw() { a_burstRepeat = repeat; } + int startBurst(int initialLoad) throw(); // return processed on start, or -1 if burst list is empty, -2 if invalid initial load (0 or negative) + int pushBurst(int loadAmount) throw(); // returns pushed (perhaps is less than provided because of no repeat mode and burst list exhausted), or -1 if burst list is empty, -2 if invalid load (0 or negative) + int sendBurst(int loadAmount) throw(); // returns sent (burst always cycled using send), returns -1 if burst list is empty, -2 if invalid load (0 or negative) + int popBurst(int releaseAmount) throw(); // returns popped (perhaps is less than provided because of OTA request), or -1 if burst stopped + int stopBurst() throw(); // returns remaining on cycle, or -1 if burst already stopped + bool burstActive() const throw() { return a_burstActive; } + bool sendBurstMessage(bool anyway = false) throw(); + std::string lookBurst(int order = -1) const throw(); + std::string gotoBurst(int order) throw(); + + anna::xml::Node* asXML(anna::xml::Node* parent) const throw(); + std::string asXMLString() const throw(); +}; + +#endif diff --git a/example/diameter/launcher/RealmNode.cpp b/example/diameter/launcher/RealmNode.cpp deleted file mode 100644 index ca6cfce..0000000 --- a/example/diameter/launcher/RealmNode.cpp +++ /dev/null @@ -1,420 +0,0 @@ -// ANNA - Anna is Not Nothingness Anymore // -// // -// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo // -// // -// See project site at http://redmine.teslayout.com/projects/anna-suite // -// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE // - - -// Standard -#include - -// Project -#include -#include -#include -#include -#include -#include - -// Process -#include -#include - - -namespace anna { - namespace diameter { - namespace stack { - class Dictionary; - } - } -} - -RealmNode::RealmNode(const std::string &originRealm, unsigned int applicationId, const anna::diameter::stack::Dictionary *baseProtocolDictionary) : - a_originRealm(originRealm), a_applicationId(applicationId) { - - std::string commEngineName = a_originRealm + "_DiameterCommEngine"; - 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_codecEngine = anna::diameter::codec::EngineManager::instantiate().getCodecEngine(applicationId); - - a_logFile = ""; - a_burstLogFile = ""; - a_splitLog = false; - a_detailedLog = false; - a_dumpLog = false; - a_entity = NULL; - a_diameterServer = NULL; - - // Comm resources: - a_allowedInactivityTime = (anna::Millisecond)90000; - a_tcpConnectDelay = (anna::Millisecond)200; - a_answersTimeout = (anna::Millisecond)10000; - a_ceaTimeout = (anna::Millisecond)10000; - a_watchdogPeriod = (anna::Millisecond)30000; - a_requestRetransmissions = 0; - - // Burst - a_burstCycle = 1; - a_burstRepeat = false; - a_burstActive = false; - a_burstLoadIndx = 0; - a_burstDeliveryIt = a_burstMessages.begin(); - a_otaRequest = 0; - a_burstPopCounter = 0; -} - - -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; - a_entity = (MyDiameterEntity*)(a_commEngine->createEntity(servers, entityDescription)); - a_entity->setClassCodeTimeout(anna::diameter::comm::ClassCode::Bind, bindTimeout); - a_entity->setClassCodeTimeout(anna::diameter::comm::ClassCode::ApplicationMessage, applicationTimeout); -} - -void RealmNode::startDiameterServer(const std::string &serverRepresentation, int sessions, const anna::Millisecond &inactivityTimeout) throw(anna::RuntimeException) { - - //if(sessions <= 0) return; negative implies no limit for accepted connections - - std::string address; int port; - anna::functions::getAddressAndPortFromSocketLiteral(serverRepresentation, address, port); - std::string serverDescription = "Launcher diameter local server for "; serverDescription += a_originRealm; - a_diameterServer = (MyLocalServer*)(a_commEngine->createLocalServer(address, port, sessions)); - // we could set sessions = 0, and after application run(), use setMaxConnections(real sessions) - // over the local server in order to start it. - - a_diameterServer->setDescription(serverDescription); - a_diameterServer->setAllowedInactivityTime(inactivityTimeout); -} - -anna::diameter::comm::Message *RealmNode::createCommMessage() throw(anna::RuntimeException) { - anna::diameter::comm::Message *result = a_commMessages.create(); - result->setRetries(a_requestRetransmissions); - if (a_requestRetransmissions > 0) result->setOnExpiry(anna::diameter::comm::Message::OnExpiry::Retransmit); - return result; -} - - -void RealmNode::releaseCommMessage(anna::diameter::comm::Message *msg) throw() { - a_commMessages.release(msg); -} - - -void RealmNode::writeLogFile(const anna::DataBlock & db, const std::string &logExtension, const std::string &detail) const throw() { - anna::diameter::codec::Message codecMsg; - try { codecMsg.decode(db); } catch(anna::RuntimeException &ex) { ex.trace(); } - writeLogFile(codecMsg, logExtension, detail); -} - -// Already decoded: -void RealmNode::writeLogFile(const anna::diameter::codec::Message &decodedMessage, const std::string &logExtension, const std::string &detail) const throw() { - // Open target file: - std::string targetFile = a_logFile; - - if(a_splitLog) { - targetFile += "."; - targetFile += logExtension; - } - - std::ofstream out(targetFile.c_str(), std::ifstream::out | std::ifstream::app); - // Set text to dump: - std::string title = "["; - title += logExtension; - title += "]"; - // Build complete log: - std::string log = "\n"; - std::string xml = decodedMessage.asXMLString(); - - - if(a_detailedLog) { - anna::time::Date now; - now.setNow(); - title += " "; - title += now.asString(); - log += anna::functions::highlight(title, anna::functions::TextHighlightMode::OverAndUnderline); - log += xml; - log += "\n"; - log += anna::functions::highlight("Used resource"); - log += detail; - log += "\n"; - } else { - log += title; - log += "\n"; - log += xml; - log += "\n"; - } - - if(a_dumpLog) { - std::string name = getMyDiameterEngine()->getRealm(); - name += "."; - name += anna::functions::asString(decodedMessage.getHopByHop()); - name += "."; - name += anna::functions::asString(decodedMessage.getEndToEnd()); - name += "."; - name += anna::functions::asString(decodedMessage.getId().first); - name += "."; - name += ((decodedMessage.getId().second) ? "request.":"answer."); - name += logExtension; - name += ".xml"; - std::ofstream outMsg(name.c_str(), std::ifstream::out | std::ifstream::app); - outMsg.write(xml.c_str(), xml.size()); - outMsg.close(); - } - - // Write and close - out.write(log.c_str(), log.size()); - out.close(); -} - -void RealmNode::writeBurstLogFile(const std::string &buffer) throw() { - std::ofstream out(a_burstLogFile.c_str(), std::ifstream::out | std::ifstream::app); - out.write(buffer.c_str(), buffer.size()); - out.close(); // close() will be called when the object is destructed (i.e., when it goes out of scope). - // you'd call close() only if you indeed for some reason wanted to close the filestream - // earlier than it goes out of scope. -} - -int RealmNode::clearBurst() throw() { - int size = a_burstMessages.size(); - - if(size) { - std::map::const_iterator it; - std::map::const_iterator it_min(a_burstMessages.begin()); - std::map::const_iterator it_max(a_burstMessages.end()); - - for(it = it_min; it != it_max; it++) releaseCommMessage((*it).second); - - a_burstMessages.clear(); - } else { - std::string msg = "Burst list already empty. Nothing done"; - std::cout << msg << std::endl; - LOGWARNING(anna::Logger::warning(msg, ANNA_FILE_LOCATION)); - } - - a_burstActive = false; - a_burstLoadIndx = 0; - a_burstDeliveryIt = a_burstMessages.begin(); - return size; -} - -int RealmNode::loadBurstMessage(const anna::DataBlock & db) throw(anna::RuntimeException) { - anna::diameter::comm::Message *msg = createCommMessage(); - msg->setBody(db); - a_burstMessages[a_burstLoadIndx++] = msg; - return (a_burstLoadIndx - 1); -} - -int RealmNode::stopBurst() throw() { - if(!a_burstActive) { - std::string msg = "Burst launch is already stopped. Nothing done"; - std::cout << msg << std::endl; - LOGWARNING(anna::Logger::warning(msg, ANNA_FILE_LOCATION)); - return -1; - } - - a_burstActive = false; - // Remaining on cycle: - return (a_burstMessages.size() - (*a_burstDeliveryIt).first); -} - -int RealmNode::popBurst(int releaseAmount) throw() { - if(!a_burstActive) { - std::string msg = "Burst launch is stopped. Nothing done"; - std::cout << msg << std::endl; - LOGWARNING(anna::Logger::warning(msg, ANNA_FILE_LOCATION)); - return -1; - } - - if(releaseAmount < 1) { - std::string msg = "No valid release amount is specified. Ignoring burst pop"; - std::cout << msg << std::endl; - LOGWARNING(anna::Logger::warning(msg, ANNA_FILE_LOCATION)); - return -2; - } - - int currentOTArequests = a_entity->getOTARequests(); - a_burstPopCounter = (releaseAmount > currentOTArequests) ? currentOTArequests : releaseAmount; - return a_burstPopCounter; -} - -int RealmNode::pushBurst(int loadAmount) throw() { - if(a_burstMessages.size() == 0) { - std::string msg = "Burst data not found (empty list). Ignoring burst launch"; - std::cout << msg << std::endl; - LOGWARNING(anna::Logger::warning(msg, ANNA_FILE_LOCATION)); - return -1; - } - - if(loadAmount < 1) { - std::string msg = "No valid load amount is specified. Ignoring burst push"; - std::cout << msg << std::endl; - LOGWARNING(anna::Logger::warning(msg, ANNA_FILE_LOCATION)); - return -2; - } - - a_burstActive = true; - int count; - - for(count = 0; count < loadAmount; count++) - if(!sendBurstMessage()) break; - - return count; -} - -int RealmNode::sendBurst(int loadAmount) throw() { - if(a_burstMessages.size() == 0) { - std::string msg = "Burst data not found (empty list). Ignoring burst launch"; - std::cout << msg << std::endl; - LOGWARNING(anna::Logger::warning(msg, ANNA_FILE_LOCATION)); - return -1; - } - - if(loadAmount < 1) { - std::string msg = "No valid load amount is specified. Ignoring burst send"; - std::cout << msg << std::endl; - LOGWARNING(anna::Logger::warning(msg, ANNA_FILE_LOCATION)); - return -2; - } - - int count; - - for(count = 0; count < loadAmount; count++) - if(!sendBurstMessage(true /* anyway */)) break; - - return count; -} - -int RealmNode::startBurst(int initialLoad) throw() { - if(initialLoad < 1) { - std::string msg = "No initial load is specified. Ignoring burst start"; - std::cout << msg << std::endl; - LOGWARNING(anna::Logger::warning(msg, ANNA_FILE_LOCATION)); - return -2; - } - - a_burstActive = true; - a_burstCycle = 1; - a_burstDeliveryIt = a_burstMessages.begin(); - return (pushBurst(initialLoad)); -} - -bool RealmNode::sendBurstMessage(bool anyway) throw() { - if(!anyway && !burstActive()) return false; - - if(a_burstPopCounter > 0) { - if(burstLogEnabled()) writeBurstLogFile("x"); - - a_burstPopCounter--; - return false; - } - - if(a_burstDeliveryIt == a_burstMessages.end()) { - a_burstDeliveryIt = a_burstMessages.begin(); - - if(!anyway) { - if(a_burstRepeat) { - a_burstCycle++; - - if(burstLogEnabled()) writeBurstLogFile(anna::functions::asString("\nCompleted burst cycle. Starting again (repeat mode) on cycle %d.\n", a_burstCycle)); - } else { - if(burstLogEnabled()) writeBurstLogFile("\nCompleted burst cycle. Burst finished (repeat mode disabled).\n"); - - stopBurst(); - return false; - } - } - } - - anna::diameter::comm::Message *msg = (*a_burstDeliveryIt).second; - int order = (*a_burstDeliveryIt).first + 1; - a_burstDeliveryIt++; - bool dot = true; - // sending - bool result = a_entity->send(msg, anna::CommandLine::instantiate().exists("balance")); - - if(burstLogEnabled()) { - if(a_burstMessages.size() >= 100) - dot = (order % (a_burstMessages.size() / 100)); - - if(dot) { - writeBurstLogFile("."); - } else { - writeBurstLogFile(anna::functions::asString(" %d", order)); - int otaReqs = a_entity->getOTARequests(); - - if(result && (otaReqs != a_otaRequest)) { - // false if was a sending after an answer received (no OTA change in this case) - // true after push and pop operations - a_otaRequest = otaReqs; - writeBurstLogFile(anna::functions::asString("[OTA %d]", a_otaRequest)); - } - } - } - - // Detailed log: - if(logEnabled()) { - anna::diameter::comm::Server *usedServer = a_entity->getLastUsedResource(); - anna::diameter::comm::ClientSession *usedClientSession = usedServer ? usedServer->getLastUsedResource() : NULL; - std::string detail = usedClientSession ? usedClientSession->asString() : ""; // esto no deberia ocurrir - writeLogFile(msg->getBody(), (result ? "sent2e" : "send2eError"), detail); // el del nodo de trabajo - } - - return result; -} - -std::string RealmNode::lookBurst(int order) const throw() { - - if (order == -1) order = a_burstDeliveryIt->first; - - std::string result = "No message found for order provided ("; - result += anna::functions::asString(order); - result += ")"; - std::map::const_iterator it = a_burstMessages.find(order - 1); - - if(it != a_burstMessages.end()) { - anna::diameter::codec::Message codecMsg; - try { codecMsg.decode((*it).second->getBody()); result = codecMsg.asXMLString(); } catch(anna::RuntimeException &ex) { ex.trace(); } - } - - return result; -} - -std::string RealmNode::gotoBurst(int order) throw() { - std::string result = "Position not found for order provided ("; - std::map::iterator it = a_burstMessages.find(order - 1); - - if(it != a_burstMessages.end()) { - a_burstDeliveryIt = it; - result = "Position updated for order provided ("; - } - - result += anna::functions::asString(order); - result += ")"; - return result; -} - -anna::xml::Node* RealmNode::asXML(anna::xml::Node* parent) const -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"); - result->createAttribute("DumpLog", a_dumpLog ? "yes" : "no"); - result->createAttribute("BurstLogFile", a_burstLogFile); - result->createAttribute("RequestRetransmissions", a_requestRetransmissions); - - anna::xml::Node* commEngine = result->createChild("CommEngine"); - a_commEngine->asXML(commEngine); - - return result; -} - -std::string RealmNode::asXMLString() const throw() { - anna::xml::Node root("root"); - return anna::xml::Compiler().apply(asXML(&root)); -} diff --git a/example/diameter/launcher/RealmNode.hpp b/example/diameter/launcher/RealmNode.hpp deleted file mode 100644 index 7f239ca..0000000 --- a/example/diameter/launcher/RealmNode.hpp +++ /dev/null @@ -1,131 +0,0 @@ -// ANNA - Anna is Not Nothingness Anymore // -// // -// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo // -// // -// See project site at http://redmine.teslayout.com/projects/anna-suite // -// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE // - - -#ifndef example_diameter_launcher_RealmNode_hpp -#define example_diameter_launcher_RealmNode_hpp - -// Standard -#include -#include - -// Project -#include -#include -#include -#include - - -namespace anna { - namespace diameter { - namespace codec { - class Engine; - } - namespace stack { - class Dictionary; - } - namespace comm { - class Message; - } - } -} - - -class MyDiameterEntity; -class MyDiameterEngine; -class MyLocalServer; - - -class RealmNode { - - MyDiameterEngine *a_commEngine; - MyDiameterEntity *a_entity; // we could get it finding the unique instante within comm engine, but it is more comfortable assign here. - MyLocalServer* a_diameterServer; // idem - anna::diameter::codec::Engine *a_codecEngine; - - // resources - int a_requestRetransmissions; - anna::Recycler a_commMessages; - - // main - std::string a_originRealm; - unsigned int a_applicationId; - - // Timming - anna::Millisecond a_allowedInactivityTime; - anna::Millisecond a_tcpConnectDelay; - anna::Millisecond a_answersTimeout; - anna::Millisecond a_ceaTimeout; - anna::Millisecond a_watchdogPeriod; - - // Logs & burst - std::string a_logFile; - bool a_splitLog, a_detailedLog, a_dumpLog; - std::string a_burstLogFile; - std::ofstream a_burstLogStream; - int a_burstCycle; - bool a_burstRepeat; - bool a_burstActive; - std::map < int /* dummy, p.e. used for order number */, anna::diameter::comm::Message* > a_burstMessages; - int a_burstLoadIndx; - std::map::const_iterator a_burstDeliveryIt; - int a_otaRequest; - int a_burstPopCounter; - -public: - RealmNode(const std::string &originRealm, unsigned int applicationId, const anna::diameter::stack::Dictionary *baseProtocolDictionary); - ~RealmNode() {;} - - const std::string &getName() const throw() { return a_originRealm; } - - // Core resources: - MyDiameterEngine* getMyDiameterEngine() const throw() { return a_commEngine; } - unsigned int getApplicationId() const throw() { return a_applicationId; } - 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(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; } - void setRequestRetransmissions(int r) throw() { if (r >= 0) a_requestRetransmissions = r; } - - // Messages factory: - anna::diameter::comm::Message *createCommMessage() throw(anna::RuntimeException); - void releaseCommMessage(anna::diameter::comm::Message*) throw(); - - // Traffic logs & burst: - void setLogs(const std::string &log, bool splitLog, bool detailedLog, bool dumpLog, const std::string &burstLog) throw() { - a_logFile = log; - a_splitLog = splitLog; - a_detailedLog = detailedLog; - a_dumpLog = dumpLog; - a_burstLogFile = burstLog; - } - - bool logEnabled() const throw() { return (((a_logFile == "") || (a_logFile == "null")) ? false : true); } - void writeLogFile(const anna::DataBlock & db, const std::string &logExtension, const std::string &detail) const throw(); - void writeLogFile(const anna::diameter::codec::Message & decodedMessage, const std::string &logExtension, const std::string &detail) const throw(); - void writeBurstLogFile(const std::string &buffer) throw(); - bool burstLogEnabled() const throw() { return (((a_burstLogFile == "") || (a_burstLogFile == "null")) ? false : true); } - int clearBurst() throw(); // returns removed - int loadBurstMessage(const anna::DataBlock & db) throw(anna::RuntimeException); - void repeatBurst(bool repeat) throw() { a_burstRepeat = repeat; } - int startBurst(int initialLoad) throw(); // return processed on start, or -1 if burst list is empty, -2 if invalid initial load (0 or negative) - int pushBurst(int loadAmount) throw(); // returns pushed (perhaps is less than provided because of no repeat mode and burst list exhausted), or -1 if burst list is empty, -2 if invalid load (0 or negative) - int sendBurst(int loadAmount) throw(); // returns sent (burst always cycled using send), returns -1 if burst list is empty, -2 if invalid load (0 or negative) - int popBurst(int releaseAmount) throw(); // returns popped (perhaps is less than provided because of OTA request), or -1 if burst stopped - int stopBurst() throw(); // returns remaining on cycle, or -1 if burst already stopped - bool burstActive() const throw() { return a_burstActive; } - bool sendBurstMessage(bool anyway = false) throw(); - std::string lookBurst(int order = -1) const throw(); - std::string gotoBurst(int order) throw(); - - anna::xml::Node* asXML(anna::xml::Node* parent) const throw(); - std::string asXMLString() const throw(); -}; - -#endif diff --git a/example/diameter/launcher/deployments/advanced/services.msk b/example/diameter/launcher/deployments/advanced/services.msk index 67cc434..315bcd4 100644 --- a/example/diameter/launcher/deployments/advanced/services.msk +++ b/example/diameter/launcher/deployments/advanced/services.msk @@ -3,6 +3,6 @@ - + diff --git a/example/diameter/launcher/deployments/ft-client/services.msk b/example/diameter/launcher/deployments/ft-client/services.msk index cf6d7e3..86af47d 100644 --- a/example/diameter/launcher/deployments/ft-client/services.msk +++ b/example/diameter/launcher/deployments/ft-client/services.msk @@ -3,6 +3,6 @@ - + diff --git a/example/diameter/launcher/deployments/ft-client/tests/go.sh b/example/diameter/launcher/deployments/ft-client/tests/go.sh index 0bf18a2..f4137aa 100755 --- a/example/diameter/launcher/deployments/ft-client/tests/go.sh +++ b/example/diameter/launcher/deployments/ft-client/tests/go.sh @@ -8,8 +8,8 @@ tmpdir=$(mktemp -d) SCR_BN=`basename $0` OPER_SCR=../operation.sh RESULT_LOG=result.log -realm=`cat ../services.xml | grep originRealm | awk -F'originRealm=' '{ print $2 }' | cut -d\" -f2` -RECV_LOG=../${realm}.launcher.log.recvfe +host=`cat ../services.xml | grep originHost | awk -F'originHost=' '{ print $2 }' | cut -d\" -f2` +RECV_LOG=../${host}.launcher.log.recvfe ############# # FUNCTIONS # diff --git a/example/diameter/launcher/deployments/st-client/configure.sh b/example/diameter/launcher/deployments/st-client/configure.sh index 622ec79..d174de6 100755 --- a/example/diameter/launcher/deployments/st-client/configure.sh +++ b/example/diameter/launcher/deployments/st-client/configure.sh @@ -103,7 +103,7 @@ echo "ADML SYSTEM TEST CONFIGURATION WIZARD" echo "=====================================" echo [ -d ADMLS ] && _exit "ADMLS directory still exists. Please remove it to continue (perhaps you have to 'pkill ADML' before) !" -[ ! -d realms ] && _exit "Missing realms configuration (expecting '$PWD/realms' directory) !" +[ ! -d services ] && _exit "Missing services configuration (expecting '$PWD/services' directory) !" calculate_deployment_layout @@ -179,7 +179,7 @@ echo "Ready to clone/start the ADML instances: press ENTER to continue, CTRL+C t read dummy # Update services.xml regarding the number of client connections: -cd realms +cd services cp services.msk services.xml sed -i 's/__CLIENT_CONNECTIONS__/'$G_ADML_CONNECTIONS'/g' services.xml cd - >/dev/null @@ -196,7 +196,7 @@ do cp ../../.run-one.sh run.sh sed -i 's/^EXE=.*/EXE=ADML-'$instance'/' run.sh ln -s ../../ADML-launcher ADML-$instance - for xml in `ls ../../realms/*xml`; do ln -s $xml; done + for xml in `ls ../../services/*xml`; do ln -s $xml; done cd - >/dev/null done diff --git a/example/diameter/launcher/deployments/st-client/operation_all.sh b/example/diameter/launcher/deployments/st-client/operation_all.sh index 7d9eeb0..8811381 100755 --- a/example/diameter/launcher/deployments/st-client/operation_all.sh +++ b/example/diameter/launcher/deployments/st-client/operation_all.sh @@ -13,6 +13,7 @@ do dn_op=`dirname $op` cd $dn_op echo -n "Instance `basename $dn_op`: " + 0>launcher.trace ./operation.sh $@ cd - >/dev/null done diff --git a/example/diameter/launcher/deployments/st-client/realms_example/README b/example/diameter/launcher/deployments/st-client/realms_example/README deleted file mode 100644 index 1ddd49b..0000000 --- a/example/diameter/launcher/deployments/st-client/realms_example/README +++ /dev/null @@ -1,13 +0,0 @@ - -Content -======= - -README: this file. -services.msk: services with some possible parseable variables: - __CLIENT_CONNECTIONS__: Number of client conections from a specific realm to the - corresponding diameter entity. -cerGx.xml: CER file for Gx referenced in the services specification. -cerRx.xml: CER file for Rx referenced in the services specification. -dictionaryBase.xml: Diameter base dictionary used in the services specification. -dictionaryGx.xml: Gx dictionary used in the services specification. -dictionaryRx.xml: Rx dictionary used in the services specification. diff --git a/example/diameter/launcher/deployments/st-client/realms_example/cerGx.xml b/example/diameter/launcher/deployments/st-client/realms_example/cerGx.xml deleted file mode 100644 index b5caf20..0000000 --- a/example/diameter/launcher/deployments/st-client/realms_example/cerGx.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/example/diameter/launcher/deployments/st-client/realms_example/cerRx.xml b/example/diameter/launcher/deployments/st-client/realms_example/cerRx.xml deleted file mode 100644 index e79ce98..0000000 --- a/example/diameter/launcher/deployments/st-client/realms_example/cerRx.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/example/diameter/launcher/deployments/st-client/realms_example/dictionaryBase.xml b/example/diameter/launcher/deployments/st-client/realms_example/dictionaryBase.xml deleted file mode 120000 index 3b80f68..0000000 --- a/example/diameter/launcher/deployments/st-client/realms_example/dictionaryBase.xml +++ /dev/null @@ -1 +0,0 @@ -../../../resources/stack_examples/0.xml \ No newline at end of file diff --git a/example/diameter/launcher/deployments/st-client/realms_example/dictionaryGx.xml b/example/diameter/launcher/deployments/st-client/realms_example/dictionaryGx.xml deleted file mode 120000 index 4221ca3..0000000 --- a/example/diameter/launcher/deployments/st-client/realms_example/dictionaryGx.xml +++ /dev/null @@ -1 +0,0 @@ -../../../resources/stack_examples/16777238.xml \ No newline at end of file diff --git a/example/diameter/launcher/deployments/st-client/realms_example/dictionaryRx.xml b/example/diameter/launcher/deployments/st-client/realms_example/dictionaryRx.xml deleted file mode 120000 index 0706e2b..0000000 --- a/example/diameter/launcher/deployments/st-client/realms_example/dictionaryRx.xml +++ /dev/null @@ -1 +0,0 @@ -../../../resources/stack_examples/16777236.xml \ No newline at end of file diff --git a/example/diameter/launcher/deployments/st-client/realms_example/services.msk b/example/diameter/launcher/deployments/st-client/realms_example/services.msk deleted file mode 100644 index dc06824..0000000 --- a/example/diameter/launcher/deployments/st-client/realms_example/services.msk +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/example/diameter/launcher/deployments/st-client/services_example/README b/example/diameter/launcher/deployments/st-client/services_example/README new file mode 100644 index 0000000..abb8743 --- /dev/null +++ b/example/diameter/launcher/deployments/st-client/services_example/README @@ -0,0 +1,13 @@ + +Content +======= + +README: this file. +services.msk: services with some possible parseable variables: + __CLIENT_CONNECTIONS__: Number of client conections from a specific host to the + corresponding diameter entity. +cerGx.xml: CER file for Gx referenced in the services specification. +cerRx.xml: CER file for Rx referenced in the services specification. +dictionaryBase.xml: Diameter base dictionary used in the services specification. +dictionaryGx.xml: Gx dictionary used in the services specification. +dictionaryRx.xml: Rx dictionary used in the services specification. diff --git a/example/diameter/launcher/deployments/st-client/services_example/cerGx.xml b/example/diameter/launcher/deployments/st-client/services_example/cerGx.xml new file mode 100644 index 0000000..29b0fbe --- /dev/null +++ b/example/diameter/launcher/deployments/st-client/services_example/cerGx.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/example/diameter/launcher/deployments/st-client/services_example/cerRx.xml b/example/diameter/launcher/deployments/st-client/services_example/cerRx.xml new file mode 100644 index 0000000..e16b236 --- /dev/null +++ b/example/diameter/launcher/deployments/st-client/services_example/cerRx.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/example/diameter/launcher/deployments/st-client/services_example/dictionaryBase.xml b/example/diameter/launcher/deployments/st-client/services_example/dictionaryBase.xml new file mode 120000 index 0000000..3b80f68 --- /dev/null +++ b/example/diameter/launcher/deployments/st-client/services_example/dictionaryBase.xml @@ -0,0 +1 @@ +../../../resources/stack_examples/0.xml \ No newline at end of file diff --git a/example/diameter/launcher/deployments/st-client/services_example/dictionaryGx.xml b/example/diameter/launcher/deployments/st-client/services_example/dictionaryGx.xml new file mode 120000 index 0000000..4221ca3 --- /dev/null +++ b/example/diameter/launcher/deployments/st-client/services_example/dictionaryGx.xml @@ -0,0 +1 @@ +../../../resources/stack_examples/16777238.xml \ No newline at end of file diff --git a/example/diameter/launcher/deployments/st-client/services_example/dictionaryRx.xml b/example/diameter/launcher/deployments/st-client/services_example/dictionaryRx.xml new file mode 120000 index 0000000..0706e2b --- /dev/null +++ b/example/diameter/launcher/deployments/st-client/services_example/dictionaryRx.xml @@ -0,0 +1 @@ +../../../resources/stack_examples/16777236.xml \ No newline at end of file diff --git a/example/diameter/launcher/deployments/st-client/services_example/services.msk b/example/diameter/launcher/deployments/st-client/services_example/services.msk new file mode 100644 index 0000000..51b50f3 --- /dev/null +++ b/example/diameter/launcher/deployments/st-client/services_example/services.msk @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/example/diameter/launcher/main.cpp b/example/diameter/launcher/main.cpp index 2d44b3a..b603dee 100644 --- a/example/diameter/launcher/main.cpp +++ b/example/diameter/launcher/main.cpp @@ -35,7 +35,7 @@ int main(int argc, const char** argv) { commandLine.add("tmDir", anna::CommandLine::Argument::Optional, "Test manager directory. By default is the current execution directory. Warning: report files could be dump during system testing (see help for management operation 'test|report|result'); take care about the possible accumulation of files"); commandLine.add("cntRecordPeriod", anna::CommandLine::Argument::Optional, "Counters record procedure period in milliseconds. If missing, default value of 300000 (5 minutes) will be assigned. Value of 0 disables the record procedure."); commandLine.add("logStatisticSamples", anna::CommandLine::Argument::Optional, "Log statistics samples for the provided concept id list, over './sample..csv' files. For example: \"1,2\" will log concepts 1 and 2. Reserved word \"all\" activates all registered statistics concept identifiers. That ids are shown at context dump (see help to get it)."); - commandLine.add("disableLogs", anna::CommandLine::Argument::Optional, "Overrides every realm configuration regarding traffic log in order to disable it and ease production or system test startup.", false); + commandLine.add("disableLogs", anna::CommandLine::Argument::Optional, "Overrides every node configuration regarding traffic log in order to disable it and ease production or system test startup.", false); // Communications commandLine.add("reconnectionPeriod", anna::CommandLine::Argument::Optional, "Milliseconds to recover diameter client-session when server connection has been broken. If missing, default value of 10000 will be assigned"); diff --git a/example/diameter/launcher/resources/scripts/clone.sh b/example/diameter/launcher/resources/scripts/clone.sh index d392097..c9b7a66 100755 --- a/example/diameter/launcher/resources/scripts/clone.sh +++ b/example/diameter/launcher/resources/scripts/clone.sh @@ -216,12 +216,18 @@ do echo -n . r_file=`readlink -f $file` dn_r_file=`dirname $r_file` - #bn_dn_r_file=`basename $dn_r_file` - #echo "Programming group $bn_dn_r_file ..." - $OPERATION -f $r_file >/dev/null + #$OPERATION -f $r_file >/dev/null + $OPERATION -f $r_file > $dn_r_file/result.txt res=$? - #$OPERATION -f $r_file > $dn_r_file/result.txt - [ $res -ne 0 ] && _exit "Exception detected programming a testcase:\n\n`cat $r_file`" + if [ $res -ne 0 ] + then + bn_dn_r_file=`basename $dn_r_file` + exception_dir=$ADML_DIR/exception_stuff_${bn_dn_r_file} + rm -rf $exception_dir + cp -r $dn_r_file $exception_dir + cp $ADML_DIR/launcher.trace $exception_dir + _exit "Exception detected programming a testcase. Check for '$exception_dir'" + fi rm -rf $dn_r_file & done diff --git a/example/diameter/launcher/resources/services_examples/balancer.xml b/example/diameter/launcher/resources/services_examples/balancer.xml index d7bfbc6..b7c6a9e 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..908c1b7 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..e64626c 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 aa884eb..c677e93 100644 --- a/example/diameter/launcher/resources/services_examples/multi-client.xml +++ b/example/diameter/launcher/resources/services_examples/multi-client.xml @@ -6,9 +6,9 @@ - - - - + + + + diff --git a/example/diameter/launcher/resources/services_examples/server.xml b/example/diameter/launcher/resources/services_examples/server.xml index b58ec6a..9c4000f 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 dee3f1e..c1bc9da 100755 --- a/example/diameter/launcher/resources/services_examples/services.dtd +++ b/example/diameter/launcher/resources/services_examples/services.dtd @@ -19,14 +19,13 @@ --> - +