hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
DRCEFunctionalObject.hpp
Go to the documentation of this file.
1 
14 #ifndef DRCE_FUNCTIONAL_OBJECT_HPP
15 #define DRCE_FUNCTIONAL_OBJECT_HPP
16 
17 #include <iostream>
18 #include <vector>
19 
20 #include "DRCEError.hpp"
21 #include "DRCEInputJsonMessage.hpp"
24 #include "DRCENodeOptions.hpp"
25 #include "DRCEResultData.hpp"
26 #include "CustomMessage.hpp"
27 #include "DRCEAsyncTasksQueue.hpp"
28 #include "DRCEResourceMonitor.hpp"
29 
30 namespace HCE
31 {
32 namespace drce
33 {
34 class DRCENotificationExecutor;
35 //-----------------------------------------------------------------------------
37 {
38 public:
39  DRCEFunctionalObject(const std::string& nodeName_, const std::string& homeDir_,
40  const std::string& tasksDataDir_, const std::string& tasksStatusDir_,
41  const std::string& nodeHost_="", const std::string& nodePort_="");
42  virtual ~DRCEFunctionalObject(void);
43 
44  std::string Process(const std::string& json);
46 
47  void setNotificationFunctor(std::function<std::string(const std::string&)> notificationFunctor_);
48  bool setHomeDir(const std::string& homeDir_);
49  void resetError(void);
50 
51  void setMaxThreadCount(unsigned int threadCount);
52  unsigned int getMaxThreadCount(void) const;
53  void saveTaskQueue(void);
54  void loadTaskQueue(void);
55 
56  void setTasksQueueDumpPeriod(unsigned int periodMs); // period in msec
57  unsigned int getTasksQueueDumpPeriod(void);
58 
59  void setResourceMonitorTimePeriod(unsigned int timePeriod_);
60  unsigned int getResourceMonitorTimePeriod(void);
61 
62  void setResetErrorCodeStateNotification(bool resetErrorCodeStateNotification_);
64 
66 
67  typedef std::map<std::string, Poco::Dynamic::Var> Dictionary;
70  void restoreResourceMonitor(const Dictionary& dictionary);
71 
72  size_t getAsyncTasksCount(void);
73  bool hasTask(unsigned int taskId);
74 
75  size_t getRequestTime(void) const {return requestTime;}
76  std::string getCurrentTasksQueue(void);
77  std::string getListInfoAllTasks(void);
78  std::string getHostResourceUsage(void);
79 
80  void setResourceExtractorMaxThreadsCount(size_t maxThreadsCount_);
81  size_t getResourceExtractorMaxThreadsCount(void) const;
82 
83  void setResourceExtractorMaxProcessesCount(size_t maxProcessesCount_);
84  size_t getResourceExtractorMaxProcessesCount(void) const;
85 
86  void setResourceExtractorMaxDiskSize(size_t maxDiskSize_);
87  size_t getResourceExtractorMaxDiskSize(void) const;
88 
89  void setResourceExtractorMaxVramSize(size_t maxVramSize_);
90  size_t getResourceExtractorMaxVramSize(void) const;
91 
92  void setResourceExtractorMaxRramSize(size_t maxRramSize_);
93  size_t getResourceExtractorMaxRramSize(void) const;
94 
95  static std::string makeErrorMessage(const std::string& inputMessage, unsigned int state,
96  unsigned int errorCode, const std::string& errorMessage);
97 private:
98  std::string getDefaultJSON(const std::string& jsonErrorMessage="", unsigned int jsonErrorCode=NO_ERROR);
99  bool process(DRCEInputJsonMessage& inputJsonMessage, DRCEResultDataItem& resultDataItem);
100 private:
101  MessagesCollection messagesCollection;
102  CustomMessage message;
103  DRCENotificationExecutor notificationExecutor;
104  DRCEAsyncTasksQueue asyncTaskQueue;
105  DRCEResourceMonitor resourceMonitor;
106 
107  size_t requestTime;
108 };
109 //-----------------------------------------------------------------------------
110 //-----------------------------------------------------------------------------
111 } // namespace drce
112 } // namespace HCE
113 
114 #endif // DRCE_FUNCTIONAL_OBJECT_HPP