$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
// Process
#include <Launcher.hpp>
-#include <RealmNode.hpp>
+#include <OriginHost.hpp>
#include <MyDiameterEngine.hpp>
#include <TestManager.hpp>
#include <TestCase.hpp>
-->\n\
\n\
<!ELEMENT node EMPTY>\n\
-<!ATTLIST node originRealm CDATA #REQUIRED applicationId CDATA #REQUIRED originHost CDATA #IMPLIED cer CDATA #IMPLIED dwr CDATA #IMPLIED allowedInactivityTime CDATA #IMPLIED tcpConnectDelay CDATA #IMPLIED answersTimeout CDATA #IMPLIED ceaTimeout CDATA #IMPLIED watchdogPeriod CDATA #IMPLIED entity CDATA #IMPLIED entityServerSessions CDATA #IMPLIED diameterServer CDATA #IMPLIED diameterServerSessions CDATA #IMPLIED balance (yes | no) #IMPLIED sessionBasedModelsClientSocketSelection (SessionIdLowPart | SessionIdHighPart | SessionIdOptionalPart | RoundRobin) #IMPLIED retries CDATA #IMPLIED log CDATA #IMPLIED splitLog (yes | no) #IMPLIED detailedLog (yes | no) #IMPLIED dumpLog (yes | no) #IMPLIED burstLog (yes | no) #IMPLIED>\n\
+<!ATTLIST node originHost CDATA #REQUIRED applicationId CDATA #REQUIRED originRealm CDATA #IMPLIED cer CDATA #IMPLIED dwr CDATA #IMPLIED allowedInactivityTime CDATA #IMPLIED tcpConnectDelay CDATA #IMPLIED answersTimeout CDATA #IMPLIED ceaTimeout CDATA #IMPLIED watchdogPeriod CDATA #IMPLIED entity CDATA #IMPLIED entityServerSessions CDATA #IMPLIED diameterServer CDATA #IMPLIED diameterServerSessions CDATA #IMPLIED balance (yes | no) #IMPLIED sessionBasedModelsClientSocketSelection (SessionIdLowPart | SessionIdHighPart | SessionIdOptionalPart | RoundRobin) #IMPLIED retries CDATA #IMPLIED log CDATA #IMPLIED splitLog (yes | no) #IMPLIED detailedLog (yes | no) #IMPLIED dumpLog (yes | no) #IMPLIED burstLog (yes | no) #IMPLIED>\n\
<!--\n\
Node record\n\
\n\
- originRealm: Node identifier (Origin-Realm name).\n\
+ originHost: Node identifier as diameter application host name.\n\
applicationId: The Application-Id provided must exists as a registered 'stack id'.\n\
- originHost: Diameter application host name (system name). If missing, process sets o.s. hostname.\n\
- Note that if you have two or more realms, the names must be different.\n\
+ originRealm: Origin-Realm (domain-name internally used by default).\n\
cer: User defined CER path file to be encoded to establish diameter connections.\n\
If missing, will be harcoded.\n\
dwr: User defined DWR path file to be encoded for diameter protocol keep alive.\n\
analysis behaviour providing 'SessionIdHighPart', 'SessionIdOptionalPart' (atoi applied;\n\
usually subscriber id data, i.e. MSISDN or IMSI) and 'RoundRobin' (also 'SessionIdLowPart').\n\
retries: Expired responses will cause a number of request retransmissions. Disabled by default (0 retries).\n\
- log: Process log file (operations result, traffic log, etc.). By default '<originRealm>.launcher.log'.\n\
+ log: Process log file (operations result, traffic log, etc.). By default '<originHost>.launcher.log'.\n\
Empty string or \"null\" name, to disable. Warning: there is no rotation for log files\n\
(use logrotate or whatever you consider).\n\
splitLog: Splits log file (appends to log filename, extensions with the type of event: see help on\n\
detailedLog: Insert detailed information at log files. Should be disabled on automatic tests. Useful on\n\
'balance' mode to know messages flow along the sockets. Default value 'no'.\n\
dumpLog: Write to disk every incoming/outcoming message named as:\n\
- '<originRealm>.<hop by hop>.<end to end>.<message code>.<request|answer>.<type of event>.xml'\n\
+ '<originHost>.<hop by hop>.<end to end>.<message code>.<request|answer>.<type of event>.xml'\n\
Default value 'no'.\n\
- burstLog: Burst operations log file. By default '<originRealm>.launcher.burst'. Empty string or \"null\" name, to disable.\n\
+ burstLog: Burst operations log file. By default '<originHost>.launcher.burst'. Empty string or \"null\" name, to disable.\n\
Warning: there is no rotation for log files (use logrotate or whatever). Output: dot (.) for each\n\
burst message sent/pushed, cross (x) for popped ones, and order number when multiple of 1% of burst\n\
list size, plus OTA requests when changed.\n\
//a_admlMinResolution = (anna::Millisecond)100;
a_counterRecorderClock = NULL;
- // a_nodes.clear();
+ // a_originHosts.clear();
a_workingNode = NULL;
a_httpServerSocket = NULL;
//<!ATTLIST stack id CDATA #REQUIRED dictionary CDATA #REQUIRED>
const anna::xml::Attribute *id, *dictionary;
- // <!ATTLIST node originRealm CDATA #REQUIRED applicationId CDATA #REQUIRED originHost CDATA #IMPLIED cer CDATA #IMPLIED dwr CDATA #IMPLIED allowedInactivityTime CDATA #IMPLIED tcpConnectDelay CDATA #IMPLIED answersTimeout CDATA #IMPLIED ceaTimeout CDATA #IMPLIED watchdogPeriod CDATA #IMPLIED entity CDATA #IMPLIED entityServerSessions CDATA #IMPLIED diameterServer CDATA #IMPLIED diameterServerSessions CDATA #IMPLIED balance (yes | no) #IMPLIED sessionBasedModelsClientSocketSelection (SessionIdLowPart | SessionIdHighPart | SessionIdOptionalPart | RoundRobin) #IMPLIED retries CDATA #IMPLIED log CDATA #IMPLIED splitLog (yes | no) #IMPLIED detailedLog (yes | no) #IMPLIED dumpLog (yes | no) #IMPLIED burstLog (yes | no) #IMPLIED>
- const anna::xml::Attribute *originRealm, *appId, *originHost, *cer, *dwr, *allowedInactivityTime, *tcpConnectDelay,
+ // <!ATTLIST node originHost CDATA #REQUIRED applicationId CDATA #REQUIRED cer CDATA #IMPLIED dwr CDATA #IMPLIED allowedInactivityTime CDATA #IMPLIED tcpConnectDelay CDATA #IMPLIED answersTimeout CDATA #IMPLIED ceaTimeout CDATA #IMPLIED watchdogPeriod CDATA #IMPLIED entity CDATA #IMPLIED entityServerSessions CDATA #IMPLIED diameterServer CDATA #IMPLIED diameterServerSessions CDATA #IMPLIED balance (yes | no) #IMPLIED sessionBasedModelsClientSocketSelection (SessionIdLowPart | SessionIdHighPart | SessionIdOptionalPart | RoundRobin) #IMPLIED retries CDATA #IMPLIED log CDATA #IMPLIED splitLog (yes | no) #IMPLIED detailedLog (yes | no) #IMPLIED dumpLog (yes | no) #IMPLIED burstLog (yes | no) #IMPLIED>
+ const anna::xml::Attribute *originHost, *appId, *originRealm, *cer, *dwr, *allowedInactivityTime, *tcpConnectDelay,
*answersTimeout, *ceaTimeout, *watchdogPeriod, *entity, *entityServerSessions,
*diameterServer, *diameterServerSessions, *balance, *sessionBasedModelsClientSocketSelection,
*retries, *log, *splitLog, *detailedLog, *dumpLog, *burstLog;
if(nodeName == "node") {
// Input data:
- originRealm = (*it)->getAttribute("originRealm");
+ originHost = (*it)->getAttribute("originHost");
appId = (*it)->getAttribute("applicationId");
- originHost = (*it)->getAttribute("originHost", false /* no exception */);
+ originRealm = (*it)->getAttribute("originRealm", false /* no exception */);
cer = (*it)->getAttribute("cer", false /* no exception */);
dwr = (*it)->getAttribute("dwr", false /* no exception */);
allowedInactivityTime = (*it)->getAttribute("allowedInactivityTime", false /* no exception */);
burstLog = (*it)->getAttribute("burstLog", false /* no exception */); // (yes | no)
// Basic checkings:
- realm_nodes_it nodeIt = a_nodes.find(originRealm->getValue());
- if (nodeIt != a_nodes.end()) {
- std::string msg = "Already registered node name (Origin-Realm): "; msg += originRealm->getValue();
+ origin_hosts_it nodeIt = a_originHosts.find(originHost->getValue());
+ if (nodeIt != a_originHosts.end()) {
+ std::string msg = "Already registered such Origin-Host: "; msg += originHost->getValue();
throw anna::RuntimeException(msg, ANNA_FILE_LOCATION);
}
}
// Create new Node instance /////////////////////////////////////////////////////////////////
- a_workingNode = new RealmNode(originRealm->getValue(), applicationId, bpd);
+ a_workingNode = new OriginHost(originHost->getValue(), applicationId, bpd);
MyDiameterEngine *commEngine = a_workingNode->getMyDiameterEngine();
/////////////////////////////////////////////////////////////////////////////////////////////
commEngine->setWatchdogPeriod(watchdogPeriodMs);
// Realm information:
- if (originHost) commEngine->setHost(originHost->getValue());
- commEngine->setRealm(originRealm->getValue());
+ commEngine->setOriginHost(originHost->getValue());
+ if (originRealm) commEngine->setOriginRealm(originRealm->getValue());
// Diameter entity:
if(entity) {
// Logs:
if (!allLogsDisabled) {
- std::string realm = commEngine->getRealm();
- std::string s_log = realm + ".launcher.log"; if (log) s_log = log->getValue();
+ std::string host = commEngine->getOriginHost();
+ std::string s_log = host + ".launcher.log"; if (log) s_log = log->getValue();
bool b_splitLog = (splitLog ? (splitLog->getValue() == "yes") : false);
bool b_detailedLog = (detailedLog ? (detailedLog->getValue() == "yes") : false);
bool b_dumpLog = (dumpLog ? (dumpLog->getValue() == "yes") : false);
- std::string s_burstLog = realm + ".launcher.burst"; if (burstLog) s_burstLog = burstLog->getValue();
+ std::string s_burstLog = host + ".launcher.burst"; if (burstLog) s_burstLog = burstLog->getValue();
a_workingNode->setLogs(s_log, b_splitLog, b_detailedLog, b_dumpLog, s_burstLog);
}
if (eventOperation) commEngine->lazyInitialize();
// Node and Codec Engine registration ///////////////////////////////////////////////////////
- a_nodes[originRealm->getValue()] = a_workingNode;
+ a_originHosts[originHost->getValue()] = a_workingNode;
/////////////////////////////////////////////////////////////////////////////////////////////
}
}
- if (!uniqueRealm())
+ if (!uniqueOriginHost())
a_workingNode = NULL; // by default, mode auto
// Diameter comm engines which are loaded after application start (via management operation 'services') are not really started,
bool Launcher::setWorkingNode(const std::string &name) throw() {
bool result = false;
- realm_nodes_it nodeIt = a_nodes.find(name);
- if (nodeIt == a_nodes.end()) {
+ origin_hosts_it nodeIt = a_originHosts.find(name);
+ if (nodeIt == a_originHosts.end()) {
LOGWARNING(
std::string msg = "Unknown node with name '"; msg += name; msg += "'. Ignoring ...";
anna::Logger::warning(msg, ANNA_FILE_LOCATION);
);
}
else {
- a_workingNode = const_cast<RealmNode*>(nodeIt->second);
+ a_workingNode = const_cast<OriginHost*>(nodeIt->second);
result = true;
}
return result;
}
-RealmNode *Launcher::getRealmNode(const std::string &realmName) const throw(anna::RuntimeException) {
- realm_nodes_it it = a_nodes.find(realmName);
- if (it != a_nodes.end()) return it->second;
- throw anna::RuntimeException(anna::functions::asString("There is no realm node registered as '%s' (set Origin-Realm avp correctly or force a specific realm with 'node' operation)", realmName.c_str()), ANNA_FILE_LOCATION);
+OriginHost *Launcher::getOriginHost(const std::string &oh) const throw(anna::RuntimeException) {
+ origin_hosts_it it = a_originHosts.find(oh);
+ if (it != a_originHosts.end()) return it->second;
+ throw anna::RuntimeException(anna::functions::asString("There is no origin host registered as '%s' (set Origin-Host avp correctly or force a specific host with 'node' operation)", oh.c_str()), ANNA_FILE_LOCATION);
}
-RealmNode *Launcher::getRealmNode(const anna::diameter::codec::Message &message) const throw(anna::RuntimeException) {
- std::string originRealm = message.getAvp(anna::diameter::helpers::base::AVPID__Origin_Realm)->getDiameterIdentity()->getValue();
- return (getRealmNode(originRealm));
+OriginHost *Launcher::getOriginHost(const anna::diameter::codec::Message &message) const throw(anna::RuntimeException) {
+ std::string originHost = message.getAvp(anna::diameter::helpers::base::AVPID__Origin_Host)->getDiameterIdentity()->getValue();
+ return (getOriginHost(originHost));
}
-void Launcher::updateOperatedRealmNodeWithMessage(const anna::diameter::codec::Message &message) throw(anna::RuntimeException) {
- if (!a_operatedRealm) // priority for working node by mean 'node' operation
- a_operatedRealm = getRealmNode(message);
+void Launcher::updateOperatedOriginHostWithMessage(const anna::diameter::codec::Message &message) throw(anna::RuntimeException) {
+ if (!a_operatedHost) // priority for working node by mean 'node' operation
+ a_operatedHost = getOriginHost(message);
}
-RealmNode *Launcher::getOperatedRealm() const throw(anna::RuntimeException) {
- if(!a_operatedRealm)
- throw anna::RuntimeException("Realm Node not identified (try to force a specific realm with 'node' operation)", ANNA_FILE_LOCATION);
+OriginHost *Launcher::getOperatedHost() const throw(anna::RuntimeException) {
+ if(!a_operatedHost)
+ throw anna::RuntimeException("Node not identified (try to force a specific Origin-Host with 'node' operation)", ANNA_FILE_LOCATION);
- return a_operatedRealm;
+ return a_operatedHost;
}
MyDiameterEntity *Launcher::getOperatedEntity() const throw(anna::RuntimeException) {
- MyDiameterEntity *result = getOperatedRealm()->getEntity();
+ MyDiameterEntity *result = getOperatedHost()->getEntity();
if (!result)
- throw anna::RuntimeException("No entity configured for the operated Realm Node", ANNA_FILE_LOCATION);
+ throw anna::RuntimeException("No entity configured for the operated node", ANNA_FILE_LOCATION);
return result;
}
MyLocalServer *Launcher::getOperatedServer() const throw(anna::RuntimeException) {
- MyLocalServer *result = getOperatedRealm()->getDiameterServer();
+ MyLocalServer *result = getOperatedHost()->getDiameterServer();
if (!result)
- throw anna::RuntimeException("No local server configured for the operated Realm Node", ANNA_FILE_LOCATION);
+ throw anna::RuntimeException("No local server configured for the operated node", ANNA_FILE_LOCATION);
return result;
}
MyDiameterEngine *Launcher::getOperatedEngine() const throw(anna::RuntimeException) {
- return getOperatedRealm()->getMyDiameterEngine(); // never will be NULL
+ return getOperatedHost()->getMyDiameterEngine(); // never will be NULL
}
void Launcher::initialize()
// Start client connections //////////////////////////////////////////////////////////////////////////////////
MyDiameterEntity *entity;
- 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++) {
entity = it->second->getEntity();
if (entity) entity->bind();
}
a_workingNode->getMyDiameterEngine()->resetStatistics();
}
else {
- 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->getMyDiameterEngine()->resetStatistics();
}
}
result += "\nOVERVIEW";
result += "\n--------";
result += "\n";
- result += "\nThe ADML (ANNA Diameter Multirealm Launcher) process is a multi-realm node with client and server";
+ result += "\nThe ADML (ANNA Diameter MultiHost Launcher) process is a multi-host node with client and server";
result += "\n capabilities as well as balancer (proxy) features. It could be used as diameter server (i.e. to";
result += "\n simulate PCRF nodes, OCS systems, etc.), as diameter client (GGSNs, DPIs, etc.), and balancer";
result += "\n systems to provide failover to external round-robin launchers. Also, auxiliary encoder/decoder/loader";
result += "\n establish as minimum), separate statistics analyzer per each resource, automatic CER/CEA and DWR/DWA";
result += "\n generation, expiration control and many more features.";
result += "\n";
- result += "\nThe ADML process can easily configure a many realm nodes as needed, which will have own endpoints.";
+ result += "\nThe ADML process can easily configure a many origin-host nodes as needed, which will have own endpoints.";
result += "\nYou should avoid loop configurations (client and server for that client) because automatic forwarding,";
result += "\n is implemented and this would get in a never ending cycle when a request is sent.";
result += "\n";
result += "\n <stack id=\"0\" dictionary=\"dictionary.xml\"/>";
result += "\n";
result += "\n <!-- Nodes -->";
- result += "\n <node originRealm=\"ADML-client\" applicationId=\"0\" entity=\"localhost:3868\"/>";
+ result += "\n <node originHost=\"ADML-client\" applicationId=\"0\" entity=\"localhost:3868\"/>";
result += "\n</services>";
result += "\n";
result += "\nServer configuration:";
result += "\n <stack id=\"0\" dictionary=\"dictionary.xml\"/>";
result += "\n";
result += "\n <!-- Nodes -->";
- result += "\n <node originRealm=\"ADML-server\" applicationId=\"0\" diameterServer=\"localhost:3868\"/>";
+ result += "\n <node originHost=\"ADML-server\" applicationId=\"0\" diameterServer=\"localhost:3868\"/>";
result += "\n</services>";
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";
result += "\n <stack id=\"0\" dictionary=\"dictionary_base.xml\"/>";
result += "\n";
result += "\n <!-- Nodes -->";
- result += "\n <node originRealm=\"ADML-Rx-client\" applicationId=\"16777236\" entity=\"localhost:3868\" cer=\"cer_Rx.xml\"/>";
- result += "\n <node originRealm=\"ADML-Gx-client\" applicationId=\"16777238\" entity=\"localhost:3868\" cer=\"cer_Gx.xml\"/>";
+ result += "\n <node originHost=\"ADML-Rx-client\" applicationId=\"16777236\" entity=\"localhost:3868\" cer=\"cer_Rx.xml\"/>";
+ result += "\n <node originHost=\"ADML-Gx-client\" applicationId=\"16777238\" entity=\"localhost:3868\" cer=\"cer_Gx.xml\"/>";
result += "\n</services>";
result += "\n";
result += "\n";
result += "\n";
result += "\n--------------------------------------------------------------------------------------- Node management";
result += "\n";
- result += "\nnode[|<name>] Selects a context working node by mean a registered name.";
+ result += "\nnode[|<name>] 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";
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";
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";
result += "\n performance measurement. Context data can be written at";
result += "\n '/var/tmp/anna.context.<pid>' by mean 'kill -10 <pid>'.";
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";
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|<action>[|parameter] Used for performance testing, we first program diameter requests";
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|<id>|<command>[|parameters]";
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).";
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";
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());
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") {
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());
// 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() : "<null client session>"; // 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|<source_file> loads the next diameter message into launcher burst.
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);
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 ";
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 ";
} 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 ";
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");
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 ";
} 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);
}
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)
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)
// 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() : "<null server session>"; // shouldn't happen
- getOperatedRealm()->writeLogFile(codecMsg, (success ? "sent2c" : "send2cError"), detail);
+ getOperatedHost()->writeLogFile(codecMsg, (success ? "sent2c" : "send2cError"), detail);
}
} else if(opType == "loadxml") {
codecMsg.loadXML(param1);
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())
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())
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);
}
}
class TestManager;
-class RealmNode;
+class OriginHost;
class MyDiameterEntity;
class MyLocalServer;
class MyDiameterEngine;
-// RealmNode resources
-class RealmNode;
-typedef std::map<std::string, RealmNode*> realm_nodes_t;
-typedef std::map<std::string, RealmNode*>::const_iterator realm_nodes_it;
-typedef std::map<std::string, RealmNode*>::iterator realm_nodes_nc_it;
+// OriginHost resources
+class OriginHost;
+typedef std::map<std::string, OriginHost*> origin_hosts_t;
+typedef std::map<std::string, OriginHost*>::const_iterator origin_hosts_it;
+typedef std::map<std::string, OriginHost*>::iterator origin_hosts_nc_it;
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
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);
#include <MyDiameterEntity.hpp>
#include <MyLocalServer.hpp>
#include <Launcher.hpp>
-#include <RealmNode.hpp>
+#include <OriginHost.hpp>
#include <TestManager.hpp>
// Performance stats:
Launcher& my_app = static_cast <Launcher&>(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
LOGMETHOD(anna::TraceMethod tm("launcher::MyDiameterEntity", "eventRequest", ANNA_FILE_LOCATION));
// Performance stats:
Launcher& my_app = static_cast <Launcher&>(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);
throw(anna::RuntimeException) {
LOGMETHOD(anna::TraceMethod tm("launcher::MyDiameterEntity", "eventResponse", ANNA_FILE_LOCATION));
Launcher& my_app = static_cast <Launcher&>(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<anna::diameter::comm::Message*>(response.getRequest());
LOGMETHOD(anna::TraceMethod tm("launcher::MyDiameterEntity", "eventUnknownResponse", ANNA_FILE_LOCATION));
// Performance stats:
Launcher& my_app = static_cast <Launcher&>(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
LOGMETHOD(anna::TraceMethod tm("launcher::MyDiameterEntity", "eventDPA", ANNA_FILE_LOCATION));
// Performance stats:
Launcher& my_app = static_cast <Launcher&>(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
#include <MyDiameterEngine.hpp>
#include <MyDiameterEntity.hpp>
#include <Launcher.hpp>
-#include <RealmNode.hpp>
+#include <OriginHost.hpp>
#include <TestManager.hpp>
LOGMETHOD(anna::TraceMethod tm("launcher::MyLocalServer", "eventRequest", ANNA_FILE_LOCATION));
// Performance stats:
Launcher& my_app = static_cast <Launcher&>(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:
// 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);
}
throw(anna::RuntimeException) {
LOGMETHOD(anna::TraceMethod tm("launcher::MyLocalServer", "eventResponse", ANNA_FILE_LOCATION));
Launcher& my_app = static_cast <Launcher&>(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<anna::diameter::comm::Message*>(response.getRequest());
LOGMETHOD(anna::TraceMethod tm("launcher::MyLocalServer", "eventUnknownResponse", ANNA_FILE_LOCATION));
// Performance stats:
Launcher& my_app = static_cast <Launcher&>(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
LOGMETHOD(anna::TraceMethod tm("launcher::MyLocalServer", "eventDPA", ANNA_FILE_LOCATION));
// Performance stats:
Launcher& my_app = static_cast <Launcher&>(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
--- /dev/null
+// 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 <string>
+
+// Project
+#include <anna/diameter.comm/Message.hpp>
+#include <anna/diameter/stack/Dictionary.hpp>
+#include <anna/diameter/codec/EngineManager.hpp>
+#include <anna/core/core.hpp>
+#include <anna/time/Date.hpp>
+#include <anna/xml/Compiler.hpp>
+
+// Process
+#include <OriginHost.hpp>
+#include <MyDiameterEngine.hpp>
+
+
+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<int, anna::diameter::comm::Message*>::const_iterator it;
+ std::map<int, anna::diameter::comm::Message*>::const_iterator it_min(a_burstMessages.begin());
+ std::map<int, anna::diameter::comm::Message*>::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() : "<null client session>"; // 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<int, anna::diameter::comm::Message*>::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<int, anna::diameter::comm::Message*>::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));
+}
--- /dev/null
+// 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 <string>
+#include <fstream>
+
+// Project
+#include <anna/core/util/Millisecond.hpp>
+#include <anna/core/util/Recycler.hpp>
+#include <anna/core/DataBlock.hpp>
+#include <anna/diameter/codec/Message.hpp>
+
+
+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<anna::diameter::comm::Message> 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<int, anna::diameter::comm::Message*>::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
+++ /dev/null
-// 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 <string>
-
-// Project
-#include <anna/diameter.comm/Message.hpp>
-#include <anna/diameter/stack/Dictionary.hpp>
-#include <anna/diameter/codec/EngineManager.hpp>
-#include <anna/core/core.hpp>
-#include <anna/time/Date.hpp>
-#include <anna/xml/Compiler.hpp>
-
-// Process
-#include <RealmNode.hpp>
-#include <MyDiameterEngine.hpp>
-
-
-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<int, anna::diameter::comm::Message*>::const_iterator it;
- std::map<int, anna::diameter::comm::Message*>::const_iterator it_min(a_burstMessages.begin());
- std::map<int, anna::diameter::comm::Message*>::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() : "<null client session>"; // 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<int, anna::diameter::comm::Message*>::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<int, anna::diameter::comm::Message*>::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));
-}
+++ /dev/null
-// 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 <string>
-#include <fstream>
-
-// Project
-#include <anna/core/util/Millisecond.hpp>
-#include <anna/core/util/Recycler.hpp>
-#include <anna/core/DataBlock.hpp>
-#include <anna/diameter/codec/Message.hpp>
-
-
-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<anna::diameter::comm::Message> 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<int, anna::diameter::comm::Message*>::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
<stack id="0" dictionary="dictionary.xml"/>
<!-- Nodes -->
- <node originRealm="ADML-advanced" applicationId="0" entity="_ENTITY_" entityServerSessions="_ENTITY_SERVER_SESSIONS_" diameterServer="_DIAMETER_SERVER_" diameterServerSessions="_DIAMETER_SERVER_SESSIONS_"/>
+ <node originHost="ADML-advanced" applicationId="0" entity="_ENTITY_" entityServerSessions="_ENTITY_SERVER_SESSIONS_" diameterServer="_DIAMETER_SERVER_" diameterServerSessions="_DIAMETER_SERVER_SESSIONS_"/>
</services>
<stack id="0" dictionary="dictionary.xml"/>
<!-- Nodes -->
- <node originRealm="ADML-ft-client" applicationId="0" entity="_ENTITY_" entityServerSessions="_ENTITY_SERVER_SESSIONS_" splitLog="yes"/>
+ <node originHost="ADML-ft-client" applicationId="0" entity="_ENTITY_" entityServerSessions="_ENTITY_SERVER_SESSIONS_" splitLog="yes"/>
</services>
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 #
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
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
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
dn_op=`dirname $op`
cd $dn_op
echo -n "Instance `basename $dn_op`: "
+ 0>launcher.trace
./operation.sh $@
cd - >/dev/null
done
+++ /dev/null
-
-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.
+++ /dev/null
-<message version="1" name="CER" application-id="0" hop-by-hop-id="722470" end-by-end-id="539510">
- <avp name="Origin-Host" data="ggsnNodeHostname.ggsnNodeHostRealm.com"/>
- <avp name="Origin-Realm" data="ggsnNodeHostRealm.com"/>
- <avp name="Auth-Application-Id" data="16777238"/>
- <avp name="Origin-State-Id" data="1"/>
- <avp name="Host-IP-Address" data="1|192.168.14.42"/>
- <avp name="Vendor-Id" data="193"/>
- <avp name="Product-Name" data="ggsnNode"/>
- <avp name="Firmware-Revision" data="1"/>
-</message>
+++ /dev/null
-<message version="1" name="CER" application-id="0" hop-by-hop-id="956775" end-by-end-id="968247">
- <avp name="Origin-Host" data="afNodeHostname.afNodeHostRealm.com"/>
- <avp name="Origin-Realm" data="afNodeHostRealm.com"/>
- <avp name="Auth-Application-Id" data="16777236"/>
- <avp name="Origin-State-Id" data="1"/>
- <avp name="Host-IP-Address" data="1|192.168.14.42"/>
- <avp name="Vendor-Id" data="193"/>
- <avp name="Product-Name" data="afNode"/>
- <avp name="Firmware-Revision" data="1"/>
-</message>
+++ /dev/null
-../../../resources/stack_examples/0.xml
\ No newline at end of file
+++ /dev/null
-../../../resources/stack_examples/16777238.xml
\ No newline at end of file
+++ /dev/null
-../../../resources/stack_examples/16777236.xml
\ No newline at end of file
+++ /dev/null
-<services>
- <!-- Stacks -->
- <stack id="16777238" dictionary="dictionaryGx.xml"/>
- <stack id="16777236" dictionary="dictionaryRx.xml"/>
- <stack id="0" dictionary="dictionaryBase.xml"/>
-
- <!-- Nodes -->
- <node originRealm="afNodeHostRealm.com" applicationId="16777236" entity="localhost:3868" cer="cerRx.xml" entityServerSessions="__CLIENT_CONNECTIONS__"/>
- <node originRealm="ggsnNodeHostRealm.com" applicationId="16777238" entity="localhost:3869" cer="cerGx.xml" entityServerSessions="__CLIENT_CONNECTIONS__"/>
-</services>
-
--- /dev/null
+
+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.
--- /dev/null
+<message version="1" name="CER" application-id="0" hop-by-hop-id="722470" end-by-end-id="539510">
+ <avp name="Origin-Host" data="ggsnNodeHostname.nodeHostRealm.com"/>
+ <avp name="Origin-Realm" data="nodeHostRealm.com"/>
+ <avp name="Auth-Application-Id" data="16777238"/>
+ <avp name="Origin-State-Id" data="1"/>
+ <avp name="Host-IP-Address" data="1|192.168.14.42"/>
+ <avp name="Vendor-Id" data="193"/>
+ <avp name="Product-Name" data="ggsnNode"/>
+ <avp name="Firmware-Revision" data="1"/>
+</message>
--- /dev/null
+<message version="1" name="CER" application-id="0" hop-by-hop-id="956775" end-by-end-id="968247">
+ <avp name="Origin-Host" data="afNodeHostname.nodeHostRealm.com"/>
+ <avp name="Origin-Realm" data="nodeHostRealm.com"/>
+ <avp name="Auth-Application-Id" data="16777236"/>
+ <avp name="Origin-State-Id" data="1"/>
+ <avp name="Host-IP-Address" data="1|192.168.14.42"/>
+ <avp name="Vendor-Id" data="193"/>
+ <avp name="Product-Name" data="afNode"/>
+ <avp name="Firmware-Revision" data="1"/>
+</message>
--- /dev/null
+../../../resources/stack_examples/0.xml
\ No newline at end of file
--- /dev/null
+../../../resources/stack_examples/16777238.xml
\ No newline at end of file
--- /dev/null
+../../../resources/stack_examples/16777236.xml
\ No newline at end of file
--- /dev/null
+<services>
+ <!-- Stacks -->
+ <stack id="16777238" dictionary="dictionaryGx.xml"/>
+ <stack id="16777236" dictionary="dictionaryRx.xml"/>
+ <stack id="0" dictionary="dictionaryBase.xml"/>
+
+ <!-- Nodes -->
+ <node originHost="afNodeHostname.nodeHostRealm.com" applicationId="16777236" entity="localhost:3868" cer="cerRx.xml" entityServerSessions="__CLIENT_CONNECTIONS__"/>
+ <node originHost="ggsnNodeHostname.nodeHostRealm.com" applicationId="16777238" entity="localhost:3869" cer="cerGx.xml" entityServerSessions="__CLIENT_CONNECTIONS__"/>
+</services>
+
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.<concept id>.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");
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
<stack id="0" dictionary="dictionary.xml"/>
<!-- Nodes -->
- <node originRealm="ADML-balancer" applicationId="0" entity="192.168.12.11:3868,192.168.12.21:3868" diameterServer="localhost:3868" balance="yes"/>
- <!-- <node originRealm="ADML-proxy" applicationId="0" entity="localhost:3868" diameterServer="localhost:3870"/> -->
+ <node originHost="ADML-balancer" applicationId="0" entity="192.168.12.11:3868,192.168.12.21:3868" diameterServer="localhost:3868" balance="yes"/>
+ <!-- <node originHost="ADML-proxy" applicationId="0" entity="localhost:3868" diameterServer="localhost:3870"/> -->
</services>
<stack id="0" dictionary="dictionary.xml"/>
<!-- Nodes -->
- <node originRealm="ADML-client" applicationId="0" entity="localhost:3868"/>
+ <node originHost="ADML-client" applicationId="0" entity="localhost:3868"/>
</services>
<stack id="0" dictionary="dictionary.xml"/>
<!-- Nodes -->
- <node originRealm="ADML-dummy" applicationId="0"/>
+ <node originHost="ADML-dummy" applicationId="0"/>
</services>
<stack id="0" dictionary="dictionaryBase.xml"/>
<!-- Nodes -->
- <node originRealm="afNode" applicationId="16777236" entity="192.168.12.11:3868,192.168.12.21:3868"/>
- <node originRealm="ggsnNode" applicationId="16777238" entity="192.168.12.11:3868,192.168.12.21:3868"/>
- <node originRealm="ggsn2Node" applicationId="16777238" entity="192.168.12.11:3868,192.168.12.21:3868"/>
- <node originRealm="ocsNode" applicationId="16777302" entity="192.168.12.11:3868,192.168.12.21:3868"/>
+ <node originHost="afNode" applicationId="16777236" entity="192.168.12.11:3868,192.168.12.21:3868"/>
+ <node originHost="ggsnNode" applicationId="16777238" entity="192.168.12.11:3868,192.168.12.21:3868"/>
+ <node originHost="ggsn2Node" applicationId="16777238" entity="192.168.12.11:3868,192.168.12.21:3868"/>
+ <node originHost="ocsNode" applicationId="16777302" entity="192.168.12.11:3868,192.168.12.21:3868"/>
</services>
<stack id="0" dictionary="dictionary.xml"/>
<!-- Nodes -->
- <node originRealm="ADML-server" applicationId="0" diameterServer="localhost:3868" diameterServerSessions="-1"/>
+ <node originHost="ADML-server" applicationId="0" diameterServer="localhost:3868" diameterServerSessions="-1"/>
</services>
-->
<!ELEMENT node EMPTY>
-<!ATTLIST node originRealm CDATA #REQUIRED applicationId CDATA #REQUIRED originHost CDATA #IMPLIED cer CDATA #IMPLIED dwr CDATA #IMPLIED allowedInactivityTime CDATA #IMPLIED tcpConnectDelay CDATA #IMPLIED answersTimeout CDATA #IMPLIED ceaTimeout CDATA #IMPLIED watchdogPeriod CDATA #IMPLIED entity CDATA #IMPLIED entityServerSessions CDATA #IMPLIED diameterServer CDATA #IMPLIED diameterServerSessions CDATA #IMPLIED balance (yes | no) #IMPLIED sessionBasedModelsClientSocketSelection (SessionIdLowPart | SessionIdHighPart | SessionIdOptionalPart | RoundRobin) #IMPLIED retries CDATA #IMPLIED log CDATA #IMPLIED splitLog (yes | no) #IMPLIED detailedLog (yes | no) #IMPLIED dumpLog (yes | no) #IMPLIED burstLog (yes | no) #IMPLIED>
+<!ATTLIST node originHost CDATA #REQUIRED applicationId CDATA #REQUIRED originRealm CDATA #IMPLIED cer CDATA #IMPLIED dwr CDATA #IMPLIED allowedInactivityTime CDATA #IMPLIED tcpConnectDelay CDATA #IMPLIED answersTimeout CDATA #IMPLIED ceaTimeout CDATA #IMPLIED watchdogPeriod CDATA #IMPLIED entity CDATA #IMPLIED entityServerSessions CDATA #IMPLIED diameterServer CDATA #IMPLIED diameterServerSessions CDATA #IMPLIED balance (yes | no) #IMPLIED sessionBasedModelsClientSocketSelection (SessionIdLowPart | SessionIdHighPart | SessionIdOptionalPart | RoundRobin) #IMPLIED retries CDATA #IMPLIED log CDATA #IMPLIED splitLog (yes | no) #IMPLIED detailedLog (yes | no) #IMPLIED dumpLog (yes | no) #IMPLIED burstLog (yes | no) #IMPLIED>
<!--
Node record
- originRealm: Node identifier (Origin-Realm name).
+ originHost: Node identifier as diameter application host name.
applicationId: The Application-Id provided must exists as a registered 'stack id'.
- originHost: Diameter application host name (system name). If missing, process sets o.s. hostname.
- Note that if you have two or more realms, the names must be different.
+ originRealm: Origin-Realm (domain-name internally used by default).
cer: User defined CER path file to be encoded to establish diameter connections.
If missing, will be harcoded.
dwr: User defined DWR path file to be encoded for diameter protocol keep alive.
analysis behaviour providing 'SessionIdHighPart', 'SessionIdOptionalPart' (atoi applied;
usually subscriber id data, i.e. MSISDN or IMSI) and 'RoundRobin' (also 'SessionIdLowPart')
retries: Expired responses will cause a number of request retransmissions. Disabled by default (0 retries).
- log: Process log file (operations result, traffic log, etc.). By default '<originRealm>.launcher.log'.
+ log: Process log file (operations result, traffic log, etc.). By default '<originHost>.launcher.log'.
Empty string or "null" name, to disable. Warning: there is no rotation for log files
(use logrotate or whatever you consider).
splitLog: Splits log file (appends to log filename, extensions with the type of event: see help on
detailedLog: Insert detailed information at log files. Should be disabled on automatic tests. Useful on
'balance' mode to know messages flow along the sockets. Default value 'no'.
dumpLog: Write to disk every incoming/outcoming message named as:
- '<originRealm>.<hop by hop>.<end to end>.<message code>.<request|answer>.<type of event>.xml'
+ '<originHost>.<hop by hop>.<end to end>.<message code>.<request|answer>.<type of event>.xml'
Default value 'no'.
- burstLog: Burst operations log file. By default '<originRealm>.launcher.burst'. Empty string or "null" name, to disable.
+ burstLog: Burst operations log file. By default '<originHost>.launcher.burst'. Empty string or "null" name, to disable.
Warning: there is no rotation for log files (use logrotate or whatever). Output: dot (.) for each
burst message sent/pushed, cross (x) for popped ones, and order number when multiple of 1% of burst
list size, plus OTA requests when changed.
test|1|delay|0
test|1|delay|0
test|1|sendxml2e|15.hex.as.xml
-test|1|waitfe|272|0|||tc_01_MMTel_DynamicQualification;ggsnNodeHostname.ggsnNodeHostRealm.com;2;|2001
+test|1|waitfe|272|0|||tc_01_MMTel_DynamicQualification;ggsnNodeHostname.nodeHostRealm.com;2;|2001
test|1|sendxml2e|20.hex.as.xml
-test|1|waitfe|265|0|||tc_01_MMTel_DynamicQualification;afNodeHostname.afNodeHostRealm.com;2;|2001
-test|1|waitfe|258|1|||tc_01_MMTel_DynamicQualification;ggsnNodeHostname.ggsnNodeHostRealm.com;2;
+test|1|waitfe|265|0|||tc_01_MMTel_DynamicQualification;afNodeHostname.nodeHostRealm.com;2;|2001
+test|1|waitfe|258|1|||tc_01_MMTel_DynamicQualification;ggsnNodeHostname.nodeHostRealm.com;2;
test|1|sendxml2e|28.hex.as.xml|8
test|1|sendxml2e|30.hex.as.xml
-test|1|waitfe|272|0|||tc_01_MMTel_DynamicQualification;ggsnNodeHostname.ggsnNodeHostRealm.com;2;|2001
+test|1|waitfe|272|0|||tc_01_MMTel_DynamicQualification;ggsnNodeHostname.nodeHostRealm.com;2;|2001
test|1|sendxml2e|35.hex.as.xml
-test|1|waitfe|275|0|||tc_01_MMTel_DynamicQualification;afNodeHostname.afNodeHostRealm.com;2;|2001
-test|1|waitfe|258|1|||tc_01_MMTel_DynamicQualification;ggsnNodeHostname.ggsnNodeHostRealm.com;2;
+test|1|waitfe|275|0|||tc_01_MMTel_DynamicQualification;afNodeHostname.nodeHostRealm.com;2;|2001
+test|1|waitfe|258|1|||tc_01_MMTel_DynamicQualification;ggsnNodeHostname.nodeHostRealm.com;2;
test|1|sendxml2e|39.hex.as.xml|14
test|1|sendxml2e|41.hex.as.xml
-test|1|waitfe|272|0|||tc_01_MMTel_DynamicQualification;ggsnNodeHostname.ggsnNodeHostRealm.com;2;|2001
+test|1|waitfe|272|0|||tc_01_MMTel_DynamicQualification;ggsnNodeHostname.nodeHostRealm.com;2;|2001
<message version="1" name="CC-Request" application-id="16777238" hop-by-hop-id="15" end-by-end-id="143351">
- <avp name="Session-Id" data="MMTel_DynamicQualification;ggsnNodeHostname.ggsnNodeHostRealm.com;2;1__SEQ8__"/>
+ <avp name="Session-Id" data="MMTel_DynamicQualification;ggsnNodeHostname.nodeHostRealm.com;2;1__SEQ8__"/>
<avp name="Destination-Host" data="ownHostId.operatorRealm.com"/>
<avp name="Destination-Realm" data="operatorRealm.com"/>
- <avp name="Origin-Host" data="ggsnNodeHostname.ggsnNodeHostRealm.com"/>
- <avp name="Origin-Realm" data="ggsnNodeHostRealm.com"/>
+ <avp name="Origin-Host" data="ggsnNodeHostname.nodeHostRealm.com"/>
+ <avp name="Origin-Realm" data="nodeHostRealm.com"/>
<avp name="Auth-Application-Id" data="16777238"/>
<avp name="Origin-State-Id" data="1"/>
<avp name="CC-Request-Number" data="0"/>
<message version="1" name="AA-Request" application-id="16777236" hop-by-hop-id="20" end-by-end-id="163097">
- <avp name="Session-Id" data="MMTel_DynamicQualification;afNodeHostname.afNodeHostRealm.com;2;1__SEQ8__"/>
+ <avp name="Session-Id" data="MMTel_DynamicQualification;afNodeHostname.nodeHostRealm.com;2;1__SEQ8__"/>
<avp name="Destination-Host" data="ownHostId.operatorRealm.com"/>
<avp name="Destination-Realm" data="operatorRealm.com"/>
- <avp name="Origin-Host" data="afNodeHostname.afNodeHostRealm.com"/>
- <avp name="Origin-Realm" data="afNodeHostRealm.com"/>
+ <avp name="Origin-Host" data="afNodeHostname.nodeHostRealm.com"/>
+ <avp name="Origin-Realm" data="nodeHostRealm.com"/>
<avp name="Auth-Application-Id" data="16777236"/>
<avp name="Origin-State-Id" data="1"/>
<avp name="Framed-IP-Address" hex-data="__IPV4HEX__"/>
<message version="1" name="RA-Answer" p-bit="yes" application-id="16777238" hop-by-hop-id="3244878460" end-by-end-id="3244878460">
- <avp name="Session-Id" data="MMTel_DynamicQualification;ggsnNodeHostname.ggsnNodeHostRealm.com;2;1__SEQ8__"/>
- <avp name="Origin-Host" data="ggsnNodeHostname.ggsnNodeHostRealm.com"/>
- <avp name="Origin-Realm" data="ggsnNodeHostRealm.com"/>
+ <avp name="Session-Id" data="MMTel_DynamicQualification;ggsnNodeHostname.nodeHostRealm.com;2;1__SEQ8__"/>
+ <avp name="Origin-Host" data="ggsnNodeHostname.nodeHostRealm.com"/>
+ <avp name="Origin-Realm" data="nodeHostRealm.com"/>
<avp name="Result-Code" data="2001" alias="DIAMETER_SUCCESS"/>
<avp name="Origin-State-Id" data="1"/>
</message>
<message version="1" name="CC-Request" application-id="16777238" hop-by-hop-id="30" end-by-end-id="3244878461">
- <avp name="Session-Id" data="MMTel_DynamicQualification;ggsnNodeHostname.ggsnNodeHostRealm.com;2;1__SEQ8__"/>
+ <avp name="Session-Id" data="MMTel_DynamicQualification;ggsnNodeHostname.nodeHostRealm.com;2;1__SEQ8__"/>
<avp name="Destination-Host" data="ownHostId.operatorRealm.com"/>
<avp name="Destination-Realm" data="operatorRealm.com"/>
- <avp name="Origin-Host" data="ggsnNodeHostname.ggsnNodeHostRealm.com"/>
- <avp name="Origin-Realm" data="ggsnNodeHostRealm.com"/>
+ <avp name="Origin-Host" data="ggsnNodeHostname.nodeHostRealm.com"/>
+ <avp name="Origin-Realm" data="nodeHostRealm.com"/>
<avp name="Auth-Application-Id" data="16777238"/>
<avp name="Origin-State-Id" data="1"/>
<avp name="CC-Request-Number" data="1"/>
<message version="1" name="ST-Request" application-id="16777236" hop-by-hop-id="35" end-by-end-id="163097">
- <avp name="Session-Id" data="MMTel_DynamicQualification;afNodeHostname.afNodeHostRealm.com;2;1__SEQ8__"/>
+ <avp name="Session-Id" data="MMTel_DynamicQualification;afNodeHostname.nodeHostRealm.com;2;1__SEQ8__"/>
<avp name="Destination-Host" data="ownHostId.operatorRealm.com"/>
<avp name="Destination-Realm" data="operatorRealm.com"/>
- <avp name="Origin-Host" data="afNodeHostname.afNodeHostRealm.com"/>
- <avp name="Origin-Realm" data="afNodeHostRealm.com"/>
+ <avp name="Origin-Host" data="afNodeHostname.nodeHostRealm.com"/>
+ <avp name="Origin-Realm" data="nodeHostRealm.com"/>
<avp name="Auth-Application-Id" data="16777236"/>
<avp name="Origin-State-Id" data="1"/>
<avp name="Termination-Cause" data="1" alias="LOGOUT"/>
<message version="1" name="RA-Answer" p-bit="yes" application-id="16777238" hop-by-hop-id="3244878461" end-by-end-id="3244878461">
- <avp name="Session-Id" data="MMTel_DynamicQualification;ggsnNodeHostname.ggsnNodeHostRealm.com;2;1__SEQ8__"/>
- <avp name="Origin-Host" data="ggsnNodeHostname.ggsnNodeHostRealm.com"/>
- <avp name="Origin-Realm" data="ggsnNodeHostRealm.com"/>
+ <avp name="Session-Id" data="MMTel_DynamicQualification;ggsnNodeHostname.nodeHostRealm.com;2;1__SEQ8__"/>
+ <avp name="Origin-Host" data="ggsnNodeHostname.nodeHostRealm.com"/>
+ <avp name="Origin-Realm" data="nodeHostRealm.com"/>
<avp name="Result-Code" data="2001" alias="DIAMETER_SUCCESS"/>
<avp name="Origin-State-Id" data="1"/>
</message>
<message version="1" name="CC-Request" application-id="16777238" hop-by-hop-id="41" end-by-end-id="3244878462">
- <avp name="Session-Id" data="MMTel_DynamicQualification;ggsnNodeHostname.ggsnNodeHostRealm.com;2;1__SEQ8__"/>
+ <avp name="Session-Id" data="MMTel_DynamicQualification;ggsnNodeHostname.nodeHostRealm.com;2;1__SEQ8__"/>
<avp name="Destination-Host" data="ownHostId.operatorRealm.com"/>
<avp name="Destination-Realm" data="operatorRealm.com"/>
- <avp name="Origin-Host" data="ggsnNodeHostname.ggsnNodeHostRealm.com"/>
- <avp name="Origin-Realm" data="ggsnNodeHostRealm.com"/>
+ <avp name="Origin-Host" data="ggsnNodeHostname.nodeHostRealm.com"/>
+ <avp name="Origin-Realm" data="nodeHostRealm.com"/>
<avp name="Auth-Application-Id" data="16777238"/>
<avp name="Origin-State-Id" data="1"/>
<avp name="CC-Request-Number" data="2"/>
test|__TESTID__|delay|0
test|__TESTID__|delay|0
test|__TESTID__|sendxml2e|15.hex.as.xml
-test|__TESTID__|waitfe|272|0|||MMTel_DynamicQualification;ggsnNodeHostname.ggsnNodeHostRealm.com;2;1__SEQ8__|2001
+test|__TESTID__|waitfe|272|0|||MMTel_DynamicQualification;ggsnNodeHostname.nodeHostRealm.com;2;1__SEQ8__|2001
test|__TESTID__|sendxml2e|20.hex.as.xml
-test|__TESTID__|waitfe|265|0|||MMTel_DynamicQualification;afNodeHostname.afNodeHostRealm.com;2;1__SEQ8__|2001
-test|__TESTID__|waitfe|258|1|||MMTel_DynamicQualification;ggsnNodeHostname.ggsnNodeHostRealm.com;2;1__SEQ8__
+test|__TESTID__|waitfe|265|0|||MMTel_DynamicQualification;afNodeHostname.nodeHostRealm.com;2;1__SEQ8__|2001
+test|__TESTID__|waitfe|258|1|||MMTel_DynamicQualification;ggsnNodeHostname.nodeHostRealm.com;2;1__SEQ8__
test|__TESTID__|sendxml2e|28.hex.as.xml|8
test|__TESTID__|sendxml2e|30.hex.as.xml
-test|__TESTID__|waitfe|272|0|||MMTel_DynamicQualification;ggsnNodeHostname.ggsnNodeHostRealm.com;2;1__SEQ8__|2001
+test|__TESTID__|waitfe|272|0|||MMTel_DynamicQualification;ggsnNodeHostname.nodeHostRealm.com;2;1__SEQ8__|2001
test|__TESTID__|sendxml2e|35.hex.as.xml
-test|__TESTID__|waitfe|275|0|||MMTel_DynamicQualification;afNodeHostname.afNodeHostRealm.com;2;1__SEQ8__|2001
-test|__TESTID__|waitfe|258|1|||MMTel_DynamicQualification;ggsnNodeHostname.ggsnNodeHostRealm.com;2;1__SEQ8__
+test|__TESTID__|waitfe|275|0|||MMTel_DynamicQualification;afNodeHostname.nodeHostRealm.com;2;1__SEQ8__|2001
+test|__TESTID__|waitfe|258|1|||MMTel_DynamicQualification;ggsnNodeHostname.nodeHostRealm.com;2;1__SEQ8__
test|__TESTID__|sendxml2e|39.hex.as.xml|14
test|__TESTID__|sendxml2e|41.hex.as.xml
-test|__TESTID__|waitfe|272|0|||MMTel_DynamicQualification;ggsnNodeHostname.ggsnNodeHostRealm.com;2;1__SEQ8__|2001
+test|__TESTID__|waitfe|272|0|||MMTel_DynamicQualification;ggsnNodeHostname.nodeHostRealm.com;2;1__SEQ8__|2001
<message version="1" name="AA-Answer" application-id="16777236" hop-by-hop-id="202475" end-by-end-id="509476">
<avp name="Auth-Application-Id" data="16777236"/>
- <avp name="Session-Id" data="test1;afNodeHostname.afNodeHostRealm.com;1;8033450"/>
- <avp name="Origin-Host" data="sapcOwnHostId.operatorRealm.com"/>
+ <avp name="Session-Id" data="test1;afNodeHostname.nodeHostRealm.com;1;8033450"/>
+ <avp name="Origin-Host" data="ownHostId.operatorRealm.com"/>
<avp name="Origin-State-Id" data="1428633668"/>
<avp name="Origin-Realm" data="operatorRealm.com"/>
<avp name="Experimental-Result">
addStep(step);
}
-void TestCase::addSendxml2e(const anna::DataBlock &db, RealmNode *realm, int stepNumber) throw(anna::RuntimeException) {
+void TestCase::addSendxml2e(const anna::DataBlock &db, OriginHost *host, int stepNumber) throw(anna::RuntimeException) {
assertInitialized();
assertMessage(db, true /* to entity */);
TestStepSendxml2e *step = new TestStepSendxml2e(this);
step->setMsgDataBlock(db);
- step->setRealmNode(realm);
+ step->setOriginHost(host);
step->setWaitForRequestStepNumber(stepNumber); // -1 means, no reference
addStep(step);
}
-void TestCase::addSendxml2c(const anna::DataBlock &db, RealmNode *realm, int stepNumber) throw(anna::RuntimeException) {
+void TestCase::addSendxml2c(const anna::DataBlock &db, OriginHost *host, int stepNumber) throw(anna::RuntimeException) {
assertInitialized();
assertMessage(db, false /* to client */);
TestStepSendxml2c *step = new TestStepSendxml2c(this);
step->setMsgDataBlock(db);
- step->setRealmNode(realm);
+ step->setOriginHost(host);
addStep(step);
}
}
}
-class RealmNode;
+class OriginHost;
class TestCase {
// Step type & information
void addTimeout(const anna::Millisecond &timeout) throw(anna::RuntimeException);
- void addSendxml2e(const anna::DataBlock &db, RealmNode *realm, int stepNumber) throw(anna::RuntimeException);
- void addSendxml2c(const anna::DataBlock &db, RealmNode *realm, int stepNumber) throw(anna::RuntimeException);
+ void addSendxml2e(const anna::DataBlock &db, OriginHost *host, int stepNumber) throw(anna::RuntimeException);
+ void addSendxml2c(const anna::DataBlock &db, OriginHost *host, int stepNumber) throw(anna::RuntimeException);
void addDelay(const anna::Millisecond &delay) throw(anna::RuntimeException);
void addWait(bool fromEntity,
const std::string &code, const std::string &bitR, const std::string &hopByHop, const std::string &applicationId,
#include <TestManager.hpp>
#include <TestClock.hpp>
#include <Launcher.hpp>
-#include <RealmNode.hpp>
+#include <OriginHost.hpp>
class TestTimer;
return NULL;
}
-void TestManager::receiveMessage(const anna::DataBlock &message, RealmNode *realm, const anna::diameter::comm::ClientSession *clientSession) throw(anna::RuntimeException) {
+void TestManager::receiveMessage(const anna::DataBlock &message, OriginHost *host, const anna::diameter::comm::ClientSession *clientSession) throw(anna::RuntimeException) {
// Testing disabled:
if (!tests()) return;
codecMsg.decode(message);
hint += "\n"; hint += codecMsg.asXMLString();
- // // Realm checking:
- // std::string messageOR = message.getAvp(anna::diameter::helpers::base::AVPID__Origin_Realm)->getDiameterIdentity()->getValue();
- // if (messageOR != realm->getName()) {
- // LOGWARNING(anna::Logger::warning(anna::functions::asString("Received message from realm '%s', with different Origin-Realm: %s", realm->getName().c_str(), messageOR.c_str()), ANNA_FILE_LOCATION));
+ // // Host checking:
+ // std::string messageOH = message.getAvp(anna::diameter::helpers::base::AVPID__Origin_Host)->getDiameterIdentity()->getValue();
+ // if (messageOH != host->getName()) {
+ // LOGWARNING(anna::Logger::warning(anna::functions::asString("Received message from host '%s', with different Origin-Host: %s", host->getName().c_str(), messageOH.c_str()), ANNA_FILE_LOCATION));
// }
}
catch (anna::RuntimeException &ex) {
}
}
-void TestManager::receiveMessage(const anna::DataBlock &message, RealmNode *realm, const anna::diameter::comm::ServerSession *serverSession) throw(anna::RuntimeException) {
+void TestManager::receiveMessage(const anna::DataBlock &message, OriginHost *host, const anna::diameter::comm::ServerSession *serverSession) throw(anna::RuntimeException) {
// Testing disabled:
if (!tests()) return;
codecMsg.decode(message);
hint += "\n"; hint += codecMsg.asXMLString();
- // // Realm checking:
- // std::string messageOR = message.getAvp(anna::diameter::helpers::base::AVPID__Origin_Realm)->getDiameterIdentity()->getValue();
- // if (messageOR != realm->getName()) {
- // LOGWARNING(anna::Logger::warning(anna::functions::asString("Received message from realm '%s', with different Origin-Realm: %s", realm->getName().c_str(), messageOR.c_str()), ANNA_FILE_LOCATION));
+ // // Host checking:
+ // std::string messageOH = message.getAvp(anna::diameter::helpers::base::AVPID__Origin_Host)->getDiameterIdentity()->getValue();
+ // if (messageOH != host->getName()) {
+ // LOGWARNING(anna::Logger::warning(anna::functions::asString("Received message from host '%s', with different Origin-Host: %s", host->getName().c_str(), messageOH.c_str()), ANNA_FILE_LOCATION));
// }
}
catch (anna::RuntimeException &ex) {
class TestClock;
class TestCase;
class TestCaseStep;
-class RealmNode;
+class OriginHost;
typedef std::map<unsigned int /* test case id */, TestCase*> test_pool_t;
// Main logic
TestCase *getTestCaseFromSessionId(const anna::DataBlock &message, std::string &sessionId) throw();
- void receiveMessage(const anna::DataBlock &message, RealmNode *realm, const anna::diameter::comm::ClientSession *clientSession) throw(anna::RuntimeException);
- void receiveMessage(const anna::DataBlock &message, RealmNode *realm, const anna::diameter::comm::ServerSession *serverSession) throw(anna::RuntimeException);
+ void receiveMessage(const anna::DataBlock &message, OriginHost *host, const anna::diameter::comm::ClientSession *clientSession) throw(anna::RuntimeException);
+ void receiveMessage(const anna::DataBlock &message, OriginHost *host, const anna::diameter::comm::ServerSession *serverSession) throw(anna::RuntimeException);
anna::xml::Node* asXML(anna::xml::Node* parent) const throw();
std::string asXMLString() const throw();
#include <anna/diameter/helpers/base/functions.hpp>
// Process
-#include <RealmNode.hpp>
+#include <OriginHost.hpp>
#include <MyDiameterEntity.hpp>
#include <MyLocalServer.hpp>
#include <TestStep.hpp>
bool TestStepSendxml::do_execute() throw() {
bool success = false;
std::string failReason, s_warn;
- MyDiameterEntity *entity = a_realmNode->getEntity(); // by default
- MyLocalServer *localServer = a_realmNode->getDiameterServer(); // by default
+ MyDiameterEntity *entity = a_originHost->getEntity(); // by default
+ MyLocalServer *localServer = a_originHost->getDiameterServer(); // by default
const TestStepWait *tsw = NULL;
// Create comm message:
- anna::diameter::comm::Message *msg = a_realmNode->createCommMessage();
+ anna::diameter::comm::Message *msg = a_originHost->createCommMessage();
//msg->clearBody();
msg->setBody(a_message);
} // else (normal sending)
// Detailed log:
- if(a_realmNode->logEnabled()) {
+ if(a_originHost->logEnabled()) {
if (decodeMessage()) {
std::string detail = usedClientSession ? usedClientSession->asString() : "<null client session>"; // shouldn't happen
- a_realmNode->writeLogFile(*a_messageCodec, (success ? "sent2e" : "send2eError"), detail);
+ a_originHost->writeLogFile(*a_messageCodec, (success ? "sent2e" : "send2eError"), detail);
}
}
}
} // else (normal sending)
// Detailed log:
- if(a_realmNode->logEnabled()) {
+ if(a_originHost->logEnabled()) {
if (decodeMessage()) {
std::string detail = usedServerSession ? usedServerSession->asString() : "<null server session>"; // shouldn't happen
- a_realmNode->writeLogFile(*a_messageCodec, (success ? "sent2c" : "send2cError"), detail);
+ a_originHost->writeLogFile(*a_messageCodec, (success ? "sent2c" : "send2cError"), detail);
}
}
}
}
// release msg
- a_realmNode->releaseCommMessage(msg);
+ a_originHost->releaseCommMessage(msg);
if (!success) {
a_testCase->addDebugSummaryHint(failReason); // before report (when set Failed state);
class TestCase;
class TestTimer;
-class RealmNode;
+class OriginHost;
class TestStep {
protected:
// possible end points:
- RealmNode *a_realmNode;
+ OriginHost *a_originHost;
// Step number reference ('wait for request' step)
int a_waitForRequestStepNumber;
public:
TestStepSendxml(TestCase *testCase) : TestStep(testCase),
a_expired(false),
- a_realmNode(NULL),
+ a_originHost(NULL),
a_waitForRequestStepNumber(-1) {;}
~TestStepSendxml() {;}
// setter & getters
- void setRealmNode(RealmNode *realm) throw() { a_realmNode = realm; }
- RealmNode *getRealmNode() const throw() { return a_realmNode; }
+ void setOriginHost(OriginHost *host) throw() { a_originHost = host; }
+ OriginHost *getOriginHost() const throw() { return a_originHost; }
void setWaitForRequestStepNumber(int stepNumber) throw() { a_waitForRequestStepNumber = stepNumber; }
int getWaitForRequestStepNumber() const throw() { return a_waitForRequestStepNumber; }
void setMsgDataBlock(const anna::DataBlock &db) throw() { a_message = db; }
public:
/**
- Diameter application node realm name (used to be the site domain name).
+ Diameter application node origin realm
- @param name Diameter application node realm name. Used in order to configure the Origin-Realm for outgoing messages.
+ @param originRealm Used to configure the Origin-Realm for outgoing messages.
If not configured or empty string provided, host domainname will be set.
*/
- void setRealm(const std::string & name) throw();
-
+ void setOriginRealm(const std::string & originRealm) throw();
/**
- Gets the configured diameter application node realm name.
+ Diameter application origin host
- @return Diameter application node realm name.
+ @param originHost Used to configure the Origin-Host for outgoing messages.
+ If not configured or empty string provided, hostname (system name) will be set.
*/
- const std::string & getRealm() const throw() { return a_realm; }
-
+ void setOriginHost(const std::string & originHost) throw();
/**
- Diameter application host name as solved by #anna::functions::getHostname()
+ Gets the configured diameter application node origin realm
- @param name Host name. Used in order to configure the Origin-Host for outgoing messages.
- If not configured or empty string provided, hostname (system name) will be set.
+ @return Diameter application node origin realm
*/
- void setHost(const std::string & name) throw();
-
+ const std::string & getOriginRealm() const throw() { return a_originRealm; }
/**
- Gets the configured diameter application host name.
+ Gets the configured diameter application origin host
- @return Diameter application host name.
+ @return Diameter application node origin host
*/
- const std::string & getHost() const throw() { return a_host; }
+ const std::string & getOriginHost() const throw() { return a_originHost; }
/**
// Internal use: tracing and readCEA/DPA/DWA
codec::Engine a_baseProtocolCodecEngine;
- std::string a_realm;
- std::string a_host;
+ std::string a_originRealm;
+ std::string a_originHost;
bool a_autoBind;
int a_numberOfClientSessionsPerServer;
a_baseProtocolCodecEngine((std::string("baseProtocolCodecEngine_for_") + std::string(className)).c_str(), baseProtocolDictionary)
{
anna::diameter::sccs::activate();
- a_realm = anna::functions::getDomainname();
- a_host = anna::functions::getHostname();
+ a_originRealm = anna::functions::getDomainname();
+ a_originHost = anna::functions::getHostname();
// Internal base protocol codec engine:
a_baseProtocolCodecEngine.setValidationMode(anna::diameter::codec::Engine::ValidationMode::Always); // default was: after decoding
// * [Acct-Application-Id] 259 Unsigned32
anna::diameter::codec::Message diameterCER(getBaseProtocolCodecEngine());
int applicationId = 0 /*anna::diameter::helpers::APPID__3GPP_Rx*/; // Unsigned32
- std::string OH = getHost();
- std::string OR = getRealm();
+ std::string OH = getOriginHost();
+ std::string OR = getOriginRealm();
std::string hostIP = anna::functions::getHostnameIP(); // Address
int vendorId = anna::diameter::helpers::VENDORID__tgpp; // Unsigned32
std::string productName = "ANNA Diameter Client"; // UTF8String
}
-void comm::Engine::setRealm(const std::string & name) throw() {
- a_realm = ((name != "") ? name : anna::functions::getDomainname());
+void comm::Engine::setOriginRealm(const std::string & originRealm) throw() {
+ a_originRealm = ((originRealm != "") ? originRealm : anna::functions::getDomainname());
}
-void comm::Engine::setHost(const std::string & name) throw() {
- a_host = ((name != "") ? name : anna::functions::getHostname());
+void comm::Engine::setOriginHost(const std::string & originHost) throw() {
+ a_originHost = ((originHost != "") ? originHost : anna::functions::getHostname());
}
void comm::Engine::availabilityLostForEntities() throw() {
a_availableForEntities = false;
LOGDEBUG(
- std::string msg = "diameter::comm::Engine { Realm: ";
- msg += getRealm();
+ std::string msg = "diameter::comm::Engine { Origin-Realm: ";
+ msg += getOriginRealm();
+ msg += " | Origin-Host: ";
+ msg += getOriginHost();
msg += " } has lost its availability for entities";
anna::Logger::debug(msg, ANNA_FILE_LOCATION);
);
void comm::Engine::availabilityRecoveredForEntities() throw() {
a_availableForEntities = true;
LOGDEBUG(
- std::string msg = "diameter::comm::Engine { Realm: ";
- msg += getRealm();
+ std::string msg = "diameter::comm::Engine { Origin-Realm: ";
+ msg += getOriginRealm();
+ msg += " | Origin-Host: ";
+ msg += getOriginHost();
msg += " } has recovered its availability for entities";
anna::Logger::debug(msg, ANNA_FILE_LOCATION);
);
void comm::Engine::availabilityLostForLocalServers() throw() {
a_availableForLocalServers = false;
LOGDEBUG(
- std::string msg = "diameter::comm::Engine { Realm: ";
- msg += getRealm();
+ std::string msg = "diameter::comm::Engine { Origin-Realm: ";
+ msg += getOriginRealm();
+ msg += " | Origin-Host: ";
+ msg += getOriginHost();
msg += " } has lost its availability for local servers";
anna::Logger::debug(msg, ANNA_FILE_LOCATION);
);
void comm::Engine::availabilityRecoveredForLocalServers() throw() {
a_availableForLocalServers = true;
LOGDEBUG(
- std::string msg = "diameter::comm::Engine { Realm: ";
- msg += getRealm();
+ std::string msg = "diameter::comm::Engine { Origin-Realm: ";
+ msg += getOriginRealm();
+ msg += " | Origin-Host: ";
+ msg += getOriginHost();
msg += " } has recovered its availability for local servers";
anna::Logger::debug(msg, ANNA_FILE_LOCATION);
);
// Origin-Host
avpOH.setId(anna::diameter::helpers::base::AVPID__Origin_Host);
avpOH.setMandatoryBit();
- avpOH.getDiameterIdentity()->fromPrintableString(a_host.c_str());
+ avpOH.getDiameterIdentity()->fromPrintableString(a_originHost.c_str());
// Origin-Realm
avpOR.setId(anna::diameter::helpers::base::AVPID__Origin_Realm);
avpOR.setMandatoryBit();
- avpOR.getDiameterIdentity()->fromPrintableString(a_realm.c_str());
+ avpOR.getDiameterIdentity()->fromPrintableString(a_originRealm.c_str());
diameterDPA.addAvp(&avpRC);
diameterDPA.addAvp(&avpOH);
diameterDPA.addAvp(&avpOR);
// Origin-Host
avpOH.setId(anna::diameter::helpers::base::AVPID__Origin_Host);
avpOH.setMandatoryBit();
- avpOH.getDiameterIdentity()->fromPrintableString(a_host.c_str());
+ avpOH.getDiameterIdentity()->fromPrintableString(a_originHost.c_str());
// Origin-Realm
avpOR.setId(anna::diameter::helpers::base::AVPID__Origin_Realm);
avpOR.setMandatoryBit();
- avpOR.getDiameterIdentity()->fromPrintableString(a_realm.c_str());
+ avpOR.getDiameterIdentity()->fromPrintableString(a_originRealm.c_str());
diameterCEA.addAvp(&avpRC);
diameterCEA.addAvp(&avpOH);
diameterCEA.addAvp(&avpOR);
// Origin-Host
avpOH.setId(anna::diameter::helpers::base::AVPID__Origin_Host);
avpOH.setMandatoryBit();
- avpOH.getDiameterIdentity()->fromPrintableString(a_host.c_str());
+ avpOH.getDiameterIdentity()->fromPrintableString(a_originHost.c_str());
// Origin-Realm
avpOR.setId(anna::diameter::helpers::base::AVPID__Origin_Realm);
avpOR.setMandatoryBit();
- avpOR.getDiameterIdentity()->fromPrintableString(a_realm.c_str());
+ avpOR.getDiameterIdentity()->fromPrintableString(a_originRealm.c_str());
diameterDWA.addAvp(&avpRC);
diameterDWA.addAvp(&avpOH);
diameterDWA.addAvp(&avpOR);
std::string Entity::asString() const throw() {
std::string result("diameter::comm::Entity { ");
- std::string realm = a_engine->getRealm();
+ std::string originRealm = a_engine->getOriginRealm();
+ std::string originHost = a_engine->getOriginHost();
- if(realm != "") {
- result += "Parent Engine (realm): ";
- result += realm;
- }
+ result += "Parent Engine Origin-Realm: ";
+ result += (originRealm != "") ? originRealm:"<not configured>";
+ result += " | Parent Engine Origin-Host: ";
+ result += (originHost != "") ? originHost:"<not configured>";
result += " | Category: ";
result += anna::functions::asString(a_category);
anna::xml::Node* Entity::asXML(anna::xml::Node* parent) const throw() {
anna::xml::Node* result = parent->createChild("diameter.Entity");
- std::string realm = a_engine->getRealm();
+ std::string originRealm = a_engine->getOriginRealm();
+ std::string originHost = a_engine->getOriginHost();
- if(realm != "") result->createAttribute("ParentEngineRealm", realm);
+ if(originRealm != "") result->createAttribute("ParentEngineOriginRealm", originRealm);
+ if(originHost != "") result->createAttribute("ParentEngineOriginHost", originHost);
result->createAttribute("Category", anna::functions::asString(a_category));
void LocalServer::initializeStatisticResources() throw() {
std::string accName = "local server '";
accName += anna::functions::socketLiteralAsString(a_key.first, a_key.second);
- accName += "' on realm '";
- accName += a_engine ? a_engine->getRealm() : "unknown"; // it should be known (createServer)
+ accName += "' on origin-realm '";
+ accName += a_engine ? a_engine->getOriginRealm() : "unknown"; // it should be known (createServer)
+ accName += "' and origin-host '";
+ accName += a_engine ? a_engine->getOriginHost() : "unknown"; // it should be known (createServer)
accName += "'";
a_statisticsAccumulator = anna::statistics::Engine::instantiate().createAccumulator(accName);
a_processing_time__StatisticConceptId = a_statisticsAccumulator->addConcept("Diameter requests processing time at clients connected to", "ms", true/* integer values */);
void Server::initializeStatisticResources() throw() {
std::string accName = "remote server '";
accName += anna::functions::socketLiteralAsString(a_socket.first, a_socket.second);
- accName += "' from realm '";
- accName += a_engine ? a_engine->getRealm() : "unknown"; // it should be known (createServer)
+ accName += "' from origin-realm '";
+ accName += a_engine ? a_engine->getOriginRealm() : "unknown"; // it should be known (createServer)
+ accName += "' and origin-host '";
+ accName += a_engine ? a_engine->getOriginHost() : "unknown"; // it should be known (createServer)
accName += "'";
a_statisticsAccumulator = anna::statistics::Engine::instantiate().createAccumulator(accName);
a_processing_time__StatisticConceptId = a_statisticsAccumulator->addConcept("Diameter requests processing time at", "ms", true/* integer values */);