1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
9 #ifndef example_diameter_launcher_Launcher_hpp
10 #define example_diameter_launcher_Launcher_hpp
18 #include <anna/core/core.hpp>
19 #include <anna/comm/comm.hpp>
20 #include <anna/time/Date.hpp>
21 #include <anna/diameter/codec/Message.hpp>
24 #include <MyCommunicator.hpp>
25 #include <MyCounterRecorder.hpp>
26 #include <TestManager.hpp>
29 #define SH_COMMAND_TAG_FOR_REPLACE__CYCLE_ID "##cycleid##"
30 #define SH_COMMAND_TAG_FOR_REPLACE__TESTCASE_ID "##testcaseid##"
31 #define SH_COMMAND_TAG_FOR_REPLACE__TESTSTEP_ID "##teststepid##"
47 class MyDiameterEntity;
49 class MyDiameterEngine;
51 // RealmNode resources
53 typedef std::map<std::string, RealmNode*> realm_nodes_t;
54 typedef std::map<std::string, RealmNode*>::const_iterator realm_nodes_it;
55 typedef std::map<std::string, RealmNode*>::iterator realm_nodes_nc_it;
58 class Launcher : public anna::comm::Application {
61 anna::time::Date a_start_time;
64 MyCommunicator *a_communicator;
65 anna::timex::Engine* a_timeEngine;
66 MyCounterRecorder *a_counterRecorder;
67 anna::Millisecond a_admlMinResolution;
68 MyCounterRecorderClock *a_counterRecorderClock;
71 realm_nodes_t a_nodes;
72 RealmNode *a_workingNode;
73 RealmNode *a_operatedRealm; // auxiliary for eventOperation
76 anna::comm::ServerSocket* a_httpServerSocket; // HTTP
78 const anna::Millisecond &getADMLMinResolution() const throw() { return a_admlMinResolution; }
80 void servicesFromXML(const anna::xml::Node* servicesNode, bool eventOperation) throw(anna::RuntimeException);
81 anna::Millisecond checkTimeMeasure(const std::string ¶meter, const std::string &value) throw(anna::RuntimeException);
82 void initialize() throw(anna::RuntimeException); // HTTP
83 void run() throw(anna::RuntimeException);
89 void loadServices(const std::string & xmlPathFile, bool eventOperation = false) throw(anna::RuntimeException);
90 void startServices() throw(anna::RuntimeException);
92 bool setWorkingNode(const std::string &name) throw();
93 RealmNode *getRealmNode(const std::string &realmName) const throw(anna::RuntimeException);
94 RealmNode *getRealmNode(const anna::diameter::codec::Message &message) const throw(anna::RuntimeException);
95 bool uniqueRealm() const throw() { return (a_nodes.size() == 1); }
97 // Operated realm for communication resources smart assignment ////////////////////////////////////////////////////////////
98 void updateOperatedRealmNodeWithMessage(const anna::diameter::codec::Message &message) throw(anna::RuntimeException);
99 RealmNode *getOperatedRealm() const throw(anna::RuntimeException);
100 MyDiameterEntity *getOperatedEntity() const throw(anna::RuntimeException);
101 MyLocalServer *getOperatedServer() const throw(anna::RuntimeException);
102 MyDiameterEngine *getOperatedEngine() const throw(anna::RuntimeException);
103 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
106 MyCommunicator *getCommunicator() throw() { return a_communicator; }
107 void eventOperation(const std::string &, std::string &) throw(anna::RuntimeException);
108 void forceCountersRecord() throw(anna::RuntimeException) { if (a_counterRecorderClock) a_counterRecorderClock->tick(); }
110 anna::xml::Node* asXML(anna::xml::Node* parent) const throw();
111 void resetStatistics() throw();
112 void resetCounters() throw();
113 void signalUSR2() throw(anna::RuntimeException);
114 std::string help() const throw();
115 anna::xml::Node* oamAsXML(anna::xml::Node* parent) const throw();
116 anna::xml::Node* statsAsXML(anna::xml::Node* parent) const throw();
119 bool getDataBlockFromHexFile(const std::string &pathfile, anna::DataBlock &db) const throw();
121 friend class TestManager;