Remove operation help.
[anna.git] / example / diameter / launcher / Launcher.hpp
index f5f1eb9..8a68888 100644 (file)
 #define example_diameter_launcher_Launcher_hpp
 
 // Standard
+#include <fstream>
 #include <string>
 #include <map>
-#include <fstream>
 
 // Project
 #include <anna/core/core.hpp>
 #include <anna/comm/comm.hpp>
-#include <anna/diameter.comm/Entity.hpp>
 #include <anna/time/Date.hpp>
-#include <anna/timex/Engine.hpp>
+#include <anna/diameter/codec/Message.hpp>
+
+// Process
+#include <MyCommunicator.hpp>
+#include <MyCounterRecorder.hpp>
+#include <anna/testing/TestManager.hpp>
+
 
 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<std::string, anna::diameter::comm::OriginHost*> origin_hosts_t;
+typedef std::map<std::string, anna::diameter::comm::OriginHost*>::const_iterator origin_hosts_it;
+typedef std::map<std::string, anna::diameter::comm::OriginHost*>::iterator origin_hosts_nc_it;
 
 
 class Launcher : public anna::comm::Application {
 
-  MyCommunicator *a_communicator;
-  MyDiameterEngine *a_myDiameterEngine;
-  MyDiameterEntity *a_entity;
-  anna::diameter::codec::Engine *a_codecEngine;
-  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; // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-  std::string a_dwrPathfile; // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-  std::string a_workingNode; // this is the node name (usually equals to the Origin-Realm value
-
-  // 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; // XXXXXXXXXXXXXXXXXXXXX
-  int a_burstLoadIndx;
-  std::map<int, anna::diameter::comm::Message*>::const_iterator a_burstDeliveryIt;
-  int a_otaRequest;
-  int a_burstPopCounter;
-
-  // comm Messages factory:
-  anna::Recycler<anna::diameter::comm::Message> a_commMessages;
 
+  // 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  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-  void checkTimeMeasure(const char * commandLineParameter, bool optional = true) throw(anna::RuntimeException);
+
+  std::string getSignalUSR2InputFile() const throw();
+  std::string getSignalUSR2OutputFile() const throw();
+
+  void servicesFromXML(const anna::xml::Node* servicesNode, bool eventOperation) throw(anna::RuntimeException);
+  anna::Millisecond checkTimeMeasure(const std::string &parameter, const std::string &value) throw(anna::RuntimeException);
   void initialize() throw(anna::RuntimeException); // HTTP
   void run() throw(anna::RuntimeException);
 
+
+
 public:
   Launcher();
+  //~Launcher(); TODO
+
+  void loadServices(const std::string & xmlPathFile, bool eventOperation = false) throw(anna::RuntimeException);
+  void startServices() throw(anna::RuntimeException);
+
+  bool setWorkingNode(const std::string &name) throw();
+  anna::diameter::comm::OriginHost *getOriginHost(const std::string &name) const throw(anna::RuntimeException);
+  anna::diameter::comm::OriginHost *getOriginHost(const anna::diameter::codec::Message &message) const throw(anna::RuntimeException);
+  bool uniqueOriginHost() const throw();
+
+  // Operated host for communication resources smart assignment ////////////////////////////////////////////////////////////
+  void updateOperatedOriginHostWithMessage(const anna::diameter::codec::Message &message) throw(anna::RuntimeException);
+  anna::diameter::comm::OriginHost *getWorkingNode() const throw(anna::RuntimeException);
+  anna::diameter::comm::OriginHost *getOperatedHost() const throw(anna::RuntimeException);
+  MyDiameterEntity *getOperatedEntity() const throw(anna::RuntimeException);
+  MyLocalServer *getOperatedServer() const throw(anna::RuntimeException);
+  MyDiameterEngine *getOperatedEngine() const throw(anna::RuntimeException);
+  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 
-  anna::diameter::codec::Engine *getCodecEngine() const throw() { return a_codecEngine; }
-  std::string getWorkingNode() const throw() { return a_workingNode; }
-  void setWorkingNode(const std::string &node) throw() { a_workingNode = node; }
   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; } // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-  MyLocalServer* getDiameterLocalServer() throw() { return a_diameterLocalServer; } // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-  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(); // XXXXXXXXXXXXXXXXXXXXX
-  void writeLogFile(const anna::diameter::codec::Message & decodedMessage, const std::string &logExtension, const std::string &detail) const throw(); // XXXXXXXXXXXXXXXXXX
-  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); // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+  bool eventOperation(const std::string &, std::string &) throw(anna::RuntimeException); // returns success/failed
   void forceCountersRecord() throw(anna::RuntimeException) { if (a_counterRecorderClock) a_counterRecorderClock->tick(); }
+  void logStatisticsSamples(const std::string &conceptsList) throw();
 
-  anna::xml::Node* asXML(anna::xml::Node* parent) const throw(); // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-  void resetStatistics() throw() { a_myDiameterEngine->resetStatistics(); }
+
+  anna::xml::Node* asXML(anna::xml::Node* parent) const throw();
+  void resetStatistics() throw();
   void resetCounters() throw();
   void signalUSR2() throw(anna::RuntimeException);
-  std::string help() const throw();
-
-  // Messages factory:
-  anna::diameter::comm::Message *createCommMessage() throw(anna::RuntimeException);
-  void releaseCommMessage(anna::diameter::comm::Message*) throw();
+  void signalTerminate() throw(anna::RuntimeException);
+  anna::xml::Node* oamAsXML(anna::xml::Node* parent) const throw();
+  anna::xml::Node* statsAsXML(anna::xml::Node* parent) const throw();
 
   // 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 throw(anna::RuntimeException);
+  bool getContentFromFile(const std::string &pathfile, std::string &content) const throw(anna::RuntimeException);
+
+  friend class TestManager;
 };
 
 #endif