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