hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
DataProcessorData.hpp
Go to the documentation of this file.
1 
17 #ifndef __HCE_DATA_PROCESSOR_DATA_INCLUDED__
18 #define __HCE_DATA_PROCESSOR_DATA_INCLUDED__
19 
20 #include <iostream>
21 #include <sstream>
22 #include <iterator>
23 
24 #include "Handler.hpp"
25 
26 //Node ini
27 #include <Poco/Util/IniFileConfiguration.h>
28 #include "Poco/String.h"
29 
30 //Sphinx FO
34 //DRCE FO
35 #include "DRCEDefaultJSON.hpp"
36 #include "DRCEInputJsonMessage.hpp"
38 #include "DRCEFunctionalObject.hpp"
39 //Reducer input object
41 #include <Poco/SharedPtr.h>
42 #include "Exceptions.hpp"
43 //Message cover object
44 #include "JsonMessageCover.hpp"
45 
46 //User home directory path
47 #include <unistd.h>
48 #include <sys/types.h>
49 #include <pwd.h>
50 
51 //Task state notification
52 #include <Poco/UUID.h>
53 
54 namespace HCE {
55  namespace handlers {
56 
58  public:
59  DataProcessorData(const std::string& nodeName, std::string name, zmq::context_t& ctx, int64_t startedAt, unsigned char logPriority, const std::string& iniFile);
61 
62  protected:
63  int initialize(void);
64  void deinitialize(void);
65  void* process(void);
66 
67  void handleInternalMessage(void);
68  std::string processDataRequest(const std::string& messageBody);
69  std::string processAdminCommands(std::string& command, std::string& parameters);
70  std::string processAdminCommandsSphinx(std::string& command);
71 
73  void setNodeName(const std::string& nodeName);
75  std::string getNodeName(void);
76 
78  std::string processDataRequestPlainText(const std::string& messageBody);
79 
81  std::string processDataRequestJson(const std::string& messageBody);
82 
84  std::string processDataRequestSphinx(const std::string& messageBody);
85 
87  void dataStorageInitSphinx(const std::string& iniFile);
88 
90  void nodeInit(const std::string& iniFile);
91 
93  void checkInit(void);
94 
96  void saveNodeProperties(void);
97 
99  void saveSphinxProperties(void);
100 
102  void saveDRCEProperties(void);
103 
105  void restoreNodeProperties(void);
106 
108  void restoreSphinxProperties(void);
109 
111  void restoreDRCEProperties(void);
112 
114  static std::string getUserHomeDir(void);
115 
117  std::string getDataStorageSphinxProperties(void);
118 
120  std::string getDataStorageDRCEProperties(void);
121 
123  std::string processDataRequestDRCE(const std::string& messageBody);
124 
126  void dataStorageInitDRCE(const std::string& iniFile);
127 
130 
132  std::string getPropertyInformation(void);
133 
137 
139  void setStatClientResponses(unsigned long long statClientResponses);
140  unsigned long long getStatClientResponses(void);
141 
142  void setStatSphinxRequestsSearch(unsigned long long statSphinxRequestsSearch);
143  unsigned long long getStatSphinxRequestsSearch(void);
144 
145  void setStatSphinxRequestsAdmin(unsigned long long statSphinxRequestsAdmin);
146  unsigned long long getStatSphinxRequestsAdmin(void);
147 
148  void setStatSphinxTimeTotalSearch(unsigned long long statSphinxTimeTotalSearch);
149  unsigned long long getStatSphinxTimeTotalSearch(void);
150 
151  void setStatSphinxTimeTotalAdmin(unsigned long long statSphinxTimeTotalAdmin);
152  unsigned long long getStatSphinxTimeTotalAdmin(void);
153 
154  void setStatDRCERequests(unsigned long long statDRCERequests);
155  unsigned long long getStatDRCERequests(void);
156 
157  void setStatDRCETimeTotal(unsigned long long statDRCETimeTotal);
158  unsigned long long getStatDRCETimeTotal(void);
159 
162 
165 
167  void setDataProcessingMode(unsigned int dataProcessingMode);
168  unsigned int getDataProcessingMode(void);
169 
170  void setDataProcessingFakeResults(unsigned int dataProcessingFakeResults);
171  unsigned int getDataProcessingFakeResults(void);
172 
173  void setDataProcessingFakeResultsMax(unsigned int dataProcessingFakeResultsMax);
174  unsigned int getDataProcessingFakeResultsMax(void);
175 
177  void setNodeNumber(unsigned int NodeNumber);
178  unsigned int getNodeNumber(void);
179 
181  void setStateNotificationHost(const std::string& stateNotificationHost);
182  std::string getStateNotificationHost(void);
183 
184  void setStateNotificationPort(const std::string& stateNotificationPort);
185  std::string getStateNotificationPort(void);
186 
188  public:
189  TasksStateNotificationFunctor(zmq::socket_t* _ssock):_msgId(Poco::UUID::x500().toString()),_updateConnectionSock( _ssock){
190  //std::cout << "\n\n***Constructor::TasksStateNotificationFunctor***\n\n";
191  //_updateConnectionSock = _ssock;
192  //_msgId = Poco::UUID::x500().toString();
193  }
194 
197  //std::cout << "\n\n***Destructor::TasksStateNotificationFunctor***\n\n";
198  }
199  }
200 
201  std::string operator()(const std::string& data){
202 // std::cout << "!!!TasksStateNotificationFunctor!!!" << std::endl;
203 // std::cout << data << std::endl;
204 // std::cout << "!!!TasksStateNotificationFunctor!!!" << std::endl;
205 
207  //Create new message with Id
208  zmsg msg(_msgId.c_str());
210  msg.append(data.c_str());
211 
213  msg.send(*_updateConnectionSock);
214  }
215 
216  return "";
217  }
218 
219  //Message Id
220  std::string _msgId;
223  };
224 
226  };
227 
228  }
229 }
230 
231 #endif /* __HCE_DATA_PROCESSOR_DATA_INCLUDED__ */