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/diameter.comm/Entity.hpp>
21 #include <anna/time/Date.hpp>
22 #include <anna/timex/Engine.hpp>
35 #include "MyCommunicator.hpp"
36 #include "MyCounterRecorder.hpp"
37 #include "MyDiameterEngine.hpp"
40 class Launcher : public anna::comm::Application {
42 MyCommunicator *a_communicator;
43 MyDiameterEngine *a_myDiameterEngine;
44 MyDiameterEntity *a_entity;
45 anna::diameter::codec::Engine *a_codecEngine;
46 std::string a_logFile, a_burstLogFile;
47 std::ofstream a_burstLogStream;
48 bool a_splitLog, a_detailedLog, a_dumpLog;
49 anna::time::Date a_start_time;
50 anna::timex::Engine* a_timeEngine;
51 MyCounterRecorder *a_counterRecorder;
52 MyCounterRecorderClock *a_counterRecorderClock;
53 std::string a_cerPathfile;
54 std::string a_dwrPathfile;
60 std::map < int /* dummy, p.e. used for order number */, anna::diameter::comm::Message* > a_burstMessages;
62 std::map<int, anna::diameter::comm::Message*>::const_iterator a_burstDeliveryIt;
64 int a_burstPopCounter;
66 // comm Messages factory:
67 anna::Recycler<anna::diameter::comm::Message> a_commMessages;
68 anna::Recycler<anna::diameter::codec::Message> a_codecMessages;
70 anna::comm::ServerSocket* a_httpServerSocket; // HTTP
71 MyLocalServer* a_diameterLocalServer; // DIAMETER
72 void checkTimeMeasure(const char * commandLineParameter, bool optional = true) throw(anna::RuntimeException);
73 void initialize() throw(anna::RuntimeException); // HTTP
74 void run() throw(anna::RuntimeException);
79 anna::diameter::codec::Engine *getCodecEngine() const throw() { return a_codecEngine; }
80 MyCommunicator *getCommunicator() throw() { return a_communicator; }
81 MyDiameterEngine* getMyDiameterEngine() const throw() { return (a_myDiameterEngine); }
82 void baseProtocolSetupAsClient(void) throw(anna::RuntimeException);
83 MyDiameterEntity *getEntity() throw() { return a_entity; }
84 MyLocalServer* getDiameterLocalServer() throw() { return a_diameterLocalServer; }
85 void eventOperation(const std::string &, std::string &) throw(anna::RuntimeException);
86 bool logEnabled() const throw() { return (((a_logFile == "") || (a_logFile == "null")) ? false : true); }
87 void writeLogFile(const anna::DataBlock & db, const std::string &logExtension, const std::string &detail) const throw();
88 void writeLogFile(const anna::diameter::codec::Message & decodedMessage, const std::string &logExtension, const std::string &detail) const throw();
89 void writeBurstLogFile(const std::string &buffer) throw();
90 bool burstLogEnabled() const throw() { return (((a_burstLogFile == "") || (a_burstLogFile == "null")) ? false : true); }
91 void startDiameterServer(int) throw(anna::RuntimeException);
92 void forceCountersRecord() throw(anna::RuntimeException) { if (a_counterRecorderClock) a_counterRecorderClock->tick(); }
94 anna::xml::Node* asXML(anna::xml::Node* parent) const throw();
95 void resetStatistics() throw() { a_myDiameterEngine->resetStatistics(); }
96 void resetCounters() throw();
97 void signalUSR2() throw(anna::RuntimeException);
98 std::string help() const throw();
101 anna::diameter::comm::Message *createCommMessage() throw(anna::RuntimeException);
102 void releaseCommMessage(anna::diameter::comm::Message*) throw();
103 anna::diameter::codec::Message *createCodecMessage() throw(anna::RuntimeException);
104 void releaseCodecMessage(anna::diameter::codec::Message*) throw();
107 bool getDataBlockFromHexFile(const std::string &pathfile, anna::DataBlock &db) const throw();
110 int clearBurst() throw(); // returns removed
111 int loadBurstMessage(const anna::DataBlock & db) throw(anna::RuntimeException);
112 void repeatBurst(bool repeat) throw() { a_burstRepeat = repeat; }
113 int startBurst(int initialLoad) throw(); // return processed on start, or -1 if burst list is empty, -2 if invalid initial load (0 or negative)
114 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)
115 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)
116 int popBurst(int releaseAmount) throw(); // returns popped (perhaps is less than provided because of OTA request), or -1 if burst stopped
117 int stopBurst() throw(); // returns remaining on cycle, or -1 if burst already stopped
118 bool burstActive() const throw() { return a_burstActive; }
119 bool sendBurstMessage(bool anyway = false) throw();
120 std::string lookBurst(int order) const throw();
121 std::string gotoBurst(int order) throw();