X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=example%2Fdiameter%2Flauncher%2FLauncher.hpp;h=c7181ee2eccd37bd005d85f235bb9c022d2df805;hb=5a6cba5fde2b2f538a7515f8293cc0a8d9589dfa;hp=9a61627a76c69c6abe90b51219b73a8e86dbcc69;hpb=752438861433c3789eb1b0d9f2c15e15037595e6;p=anna.git diff --git a/example/diameter/launcher/Launcher.hpp b/example/diameter/launcher/Launcher.hpp index 9a61627..c7181ee 100644 --- a/example/diameter/launcher/Launcher.hpp +++ b/example/diameter/launcher/Launcher.hpp @@ -10,102 +10,125 @@ #define example_diameter_launcher_Launcher_hpp // Standard +#include #include #include -#include // Project +#include #include -#include #include -#include +#include + +// Process +#include +#include +#include + namespace anna { + namespace timex { + class Engine; + } namespace diameter { + namespace codec { + class Engine; + } namespace comm { - //class Entity; - //class Response; - class LocalServer; + class OriginHost; } } } -// Process -#include "MyCommunicator.hpp" -#include "MyCounterRecorder.hpp" -#include "MyDiameterEngine.hpp" +class TestManager; +class MyDiameterEntity; +class MyLocalServer; +class MyDiameterEngine; + +// OriginHost resources +typedef std::map origin_hosts_t; +typedef std::map::const_iterator origin_hosts_it; +typedef std::map::iterator origin_hosts_nc_it; class Launcher : public anna::comm::Application { - MyCommunicator *a_communicator; - MyDiameterEngine *a_myDiameterEngine; - MyDiameterEntity *a_entity; - std::string a_logFile, a_burstLogFile; - std::ofstream a_burstLogStream; - bool a_splitLog, a_detailedLog, a_dumpLog; + // Start time: anna::time::Date a_start_time; + std::string a_initialWorkingDirectory; + + // Core engines: + MyCommunicator *a_communicator; anna::timex::Engine* a_timeEngine; MyCounterRecorder *a_counterRecorder; + anna::Millisecond a_admlMinResolution; MyCounterRecorderClock *a_counterRecorderClock; - std::string a_cerPathfile; - std::string a_dwrPathfile; - - // Burst feature - int a_burstCycle; - bool a_burstRepeat; - bool a_burstActive; - std::map < int /* dummy, p.e. used for order number */, anna::diameter::comm::Message* > a_burstMessages; - int a_burstLoadIndx; - std::map::const_iterator a_burstDeliveryIt; - int a_otaRequest; - int a_burstPopCounter; + // Nodes deployment: + anna::diameter::comm::OriginHost *a_workingNode; + anna::diameter::comm::OriginHost *a_operatedHost; // auxiliary for eventOperation + + // comm resources: anna::comm::ServerSocket* a_httpServerSocket; // HTTP - MyLocalServer* a_diameterLocalServer; // DIAMETER - void checkTimeMeasure(const char * commandLineParameter, bool optional = true) throw(anna::RuntimeException); - void initialize() throw(anna::RuntimeException); // HTTP - void run() throw(anna::RuntimeException); + + std::string getSignalUSR2InputFile() const ; + std::string getSignalUSR2OutputFile() const ; + + void servicesFromXML(const anna::xml::Node* servicesNode, bool bindResources) noexcept(false); + void initialize() noexcept(false); // HTTP + void run() noexcept(false); + + public: Launcher(); + //~Launcher(); TODO + + anna::Millisecond checkTimeMeasure(const std::string ¶meter, const std::string &value) noexcept(false); + + void loadServicesFromFile(const std::string & xmlPathFile, bool bindResources) noexcept(false); + void loadServicesFromXMLString(const std::string & xmlString, bool bindResources) noexcept(false); + void startServices() noexcept(false); + + bool setWorkingNode(const std::string &name) ; + void setNodeAuto() { a_workingNode = NULL; a_operatedHost = NULL; } + anna::diameter::comm::OriginHost *getOriginHost(const std::string &name) const noexcept(false); + anna::diameter::comm::OriginHost *getOriginHost(const anna::diameter::codec::Message &message) const noexcept(false); + anna::diameter::comm::OriginHost *getOriginHost(const anna::DataBlock &messageDataBlock) const noexcept(false); - MyCommunicator *getCommunicator() throw() { return a_communicator; } - MyDiameterEngine* getMyDiameterEngine() const throw() { return (a_myDiameterEngine); } - void baseProtocolSetupAsClient(void) throw(anna::RuntimeException); - MyDiameterEntity *getEntity() throw() { return a_entity; } - MyLocalServer* getDiameterLocalServer() throw() { return a_diameterLocalServer; } - void eventOperation(const std::string &, std::string &) throw(anna::RuntimeException); - 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); } - void startDiameterServer(int) throw(anna::RuntimeException); - void forceCountersRecord() throw(anna::RuntimeException) { if (a_counterRecorderClock) a_counterRecorderClock->tick(); } - - anna::xml::Node* asXML(anna::xml::Node* parent) const throw(); - void resetStatistics() throw() { a_myDiameterEngine->resetStatistics(); } - void resetCounters() throw(); - void signalUSR2() throw(anna::RuntimeException); - std::string help() const throw(); + bool uniqueOriginHost() const ; + + // Operated host for communication resources smart assignment //////////////////////////////////////////////////////////// + void updateOperatedOriginHostWithMessage(const anna::diameter::codec::Message &message) noexcept(false); + void updateOperatedOriginHostWithMessage(const anna::DataBlock &messageDataBlock) noexcept(false); + anna::diameter::comm::OriginHost *getWorkingNode() const noexcept(false); + anna::diameter::comm::OriginHost *getOperatedHost() const noexcept(false); + void setOperatedHost(anna::diameter::comm::OriginHost *); + MyDiameterEntity *getOperatedEntity() const noexcept(false); + MyLocalServer *getOperatedServer() const noexcept(false); + MyDiameterEngine *getOperatedEngine() const noexcept(false); + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + const std::string & getInitialWorkingDirectory() const { return a_initialWorkingDirectory; } + + MyCommunicator *getCommunicator() { return a_communicator; } + bool eventOperation(const std::string &, std::string &) noexcept(false); // returns success/failed + void forceCountersRecord() noexcept(false) { if (a_counterRecorderClock) a_counterRecorderClock->tick(); } + void logStatisticsSamples(const std::string &conceptsList) ; + + + anna::xml::Node* asXML(anna::xml::Node* parent) const ; + void resetStatistics() ; + void resetCounters() ; + void signalUSR2() noexcept(false); + void signalTerminate() noexcept(false); + anna::xml::Node* oamAsXML(anna::xml::Node* parent) const ; + anna::xml::Node* statsAsXML(anna::xml::Node* parent) const ; // helpers - bool getDataBlockFromHexFile(const std::string &pathfile, anna::DataBlock &db) const throw(); - - // Burst feature - 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) const throw(); - std::string gotoBurst(int order) throw(); + bool getDataBlockFromHexFile(const std::string &pathfile, anna::DataBlock &db) const noexcept(false); + + friend class TestManager; }; #endif