Software.cpp 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2018 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #include "Software.hpp"
  14. #include "SWProcess.hpp"
  15. #include "SWDropZone.hpp"
  16. #include "SWThorCluster.hpp"
  17. #include "SWRoxieCluster.hpp"
  18. #include "SWEspProcess.hpp"
  19. #include "SWEspService.hpp"
  20. #include "SWDirectories.hpp"
  21. #include "SWDaliProcess.hpp"
  22. #include "SWBackupNode.hpp"
  23. #include "SWTopology.hpp"
  24. #include "deployutils.hpp"
  25. #include "ComponentBase.hpp"
  26. namespace ech
  27. {
  28. Software::Software(EnvHelper * envHelper):ComponentBase("software", envHelper)
  29. {
  30. }
  31. Software::~Software()
  32. {
  33. HashIterator swCompIter(m_swCompMap);
  34. ForEach(swCompIter)
  35. {
  36. IMapping &cur = swCompIter.query();
  37. IConfigComp* pSWComp = m_swCompMap.mapToValue(&cur);
  38. SWComponentBase *swcb = (SWComponentBase*) pSWComp;
  39. //swcb-Release();
  40. ::Release(swcb);
  41. }
  42. }
  43. void Software::create(IPropertyTree *params)
  44. {
  45. IPropertyTree * envTree = m_envHelper->getEnvTree();
  46. const IPropertyTree * buildSetTree = m_envHelper->getBuildSetTree();
  47. envTree->addPropTree(XML_TAG_SOFTWARE, createPTreeFromIPT(
  48. buildSetTree->queryPropTree("./" XML_TAG_SOFTWARE)));
  49. getSWComp("esp")->create(params);
  50. StringBuffer xpath;
  51. xpath.clear().appendf("./%s/%s/%s", XML_TAG_PROGRAMS, XML_TAG_BUILD, XML_TAG_BUILDSET);
  52. Owned<IPropertyTreeIterator> buildSetInsts = buildSetTree->getElements(xpath.str());
  53. const GenEnvRules& rules = m_envHelper->getGenEnvRules();
  54. ForEach(*buildSetInsts)
  55. {
  56. IPropertyTree* pBuildSet = &buildSetInsts->query();
  57. const char* buildSetName = pBuildSet->queryProp(XML_ATTR_NAME);
  58. if (stricmp(buildSetName, "esp") == 0) continue;
  59. if (rules.foundInProp("do_not_generate", buildSetName)) continue;
  60. getSWComp(buildSetName)->create(params);
  61. }
  62. }
  63. unsigned Software::add(IPropertyTree *params)
  64. {
  65. const char *comp = params->queryProp("@component");
  66. return getSWComp(comp)->add(params);
  67. }
  68. void Software::modify(IPropertyTree *params)
  69. {
  70. //IPropertyTree * envTree = m_envHelper->getEnvTree();
  71. const char *comp = params->queryProp("@component");
  72. getSWComp(comp)->modify(params);
  73. }
  74. void Software::remove(IPropertyTree *params)
  75. {
  76. const char *comp = params->queryProp("@component");
  77. getSWComp(comp)->remove(params);
  78. }
  79. void Software::getSWCompName(const char *inputName, StringBuffer& out)
  80. {
  81. const char * compNameLC = (StringBuffer(inputName).toLowerCase()).str();
  82. // Return xsd name in buildset.xml
  83. out.clear();
  84. if (!stricmp(compNameLC, "directories") || !stricmp(compNameLC, "dirs"))
  85. {
  86. out.append("directories");
  87. }
  88. else if (!stricmp(compNameLC, "dali") || !stricmp(compNameLC, "DaliServerProcess"))
  89. {
  90. out.append("dali");
  91. }
  92. else if (!stricmp(compNameLC, "dropzone"))
  93. {
  94. out.append("DropZone");
  95. }
  96. else if (!stricmp(compNameLC, "roxie") || !stricmp(compNameLC, "RoxieCluster"))
  97. {
  98. out.append("roxie");
  99. }
  100. else if (!stricmp(compNameLC, "thor") || !stricmp(compNameLC, "ThorCluster"))
  101. {
  102. out.append("thor");
  103. }
  104. else if (!stricmp(compNameLC, "esp") || !stricmp(compNameLC, "EspProcess"))
  105. {
  106. out.append("esp");
  107. }
  108. else if (!stricmp(compNameLC, "elcwatch") || !stricmp(compNameLC, "espsmc"))
  109. {
  110. out.append("espsmc");
  111. }
  112. else if (!stricmp(compNameLC, "esdl") || !stricmp(compNameLC, "DynamicESDL"))
  113. {
  114. out.append("DynamicESDL");
  115. }
  116. else if (!stricmp(compNameLC, "ws_sql") || !stricmp(compNameLC, "wssql"))
  117. {
  118. out.append("ws_sql");
  119. }
  120. else if (!stricmp(compNameLC, "ws_ecl") || !stricmp(compNameLC, "wsecl"))
  121. {
  122. out.append("ws_ecl");
  123. }
  124. else if (!stricmp(compNameLC, "wslogging"))
  125. {
  126. out.append("wslogging");
  127. }
  128. else if (!stricmp(compNameLC, "cassandra") || !stricmp(compNameLC, "CassandraLoggingAgent"))
  129. {
  130. out.append("cassandraloggingagent");
  131. }
  132. else if (!stricmp(compNameLC, "esplogging") || !stricmp(compNameLC, "EspLoggingAgent"))
  133. {
  134. out.append("esploggingagent");
  135. }
  136. else if (!stricmp(compNameLC, "loggingmgr") || !stricmp(compNameLC, "loggingmanager"))
  137. {
  138. out.append("loggingmanager");
  139. }
  140. else if (!stricmp(compNameLC, "backup") || !stricmp(compNameLC, "backupnode"))
  141. {
  142. out.append("backupnode");
  143. }
  144. else if (!stricmp(compNameLC, "agent") || !stricmp(compNameLC, "eclagent") ||
  145. !stricmp(compNameLC, "EclAgentiProcess"))
  146. {
  147. out.append("eclagent");
  148. }
  149. else if (!stricmp(compNameLC, "eclccsrv") || !stricmp(compNameLC, "eclccserver") ||
  150. !stricmp(compNameLC, "eclcc") || !stricmp(compNameLC, "EclCCServerProcess"))
  151. {
  152. out.append("eclccserver");
  153. }
  154. else if (!stricmp(compNameLC, "sch") || !stricmp(compNameLC, "eclsch") ||
  155. !stricmp(compNameLC, "scheduler") || !stricmp(compNameLC, "EclCCSchedulerProcess"))
  156. {
  157. out.append("eclscheduler");
  158. }
  159. else if (!stricmp(compNameLC, "dfu") || !stricmp(compNameLC, "dfusrv") ||
  160. !stricmp(compNameLC, "dfuserver") || !stricmp(compNameLC, "DfuServerProcess"))
  161. {
  162. out.append("dfuserver");
  163. }
  164. else if (!stricmp(compNameLC, "topo") || !stricmp(compNameLC, "Topology"))
  165. {
  166. out.append("topology");
  167. }
  168. else if (!stricmp(compNameLC, "fts") || !stricmp(compNameLC, "FTSlave") || !stricmp(compNameLC, "FTSlaveProcess"))
  169. {
  170. out.append("ftslave");
  171. }
  172. else
  173. {
  174. out.append(compNameLC);
  175. }
  176. }
  177. IConfigComp* Software::getSWComp(const char *compName)
  178. {
  179. //should call m_envHelper->getXMLTagName(compName)
  180. //const char *compNameLC = m_envHelper->getXMLTagName(compName);
  181. const char * compNameLC = (StringBuffer(compName).toLowerCase()).str();
  182. StringBuffer sbBuildSetName;
  183. getSWCompName(compNameLC, sbBuildSetName);
  184. const char* buildSetName = sbBuildSetName.str();
  185. IConfigComp * pComp = m_swCompMap.getValue(buildSetName);
  186. if (pComp) return pComp;
  187. if (!stricmp(buildSetName, "directories"))
  188. {
  189. pComp = (IConfigComp*) new SWDirectories(buildSetName, m_envHelper);
  190. }
  191. else if (!stricmp(buildSetName, "dali"))
  192. {
  193. pComp = (IConfigComp*) new SWDaliProcess(buildSetName, m_envHelper);
  194. }
  195. else if (!stricmp(buildSetName, "DropZone"))
  196. {
  197. pComp = (IConfigComp*) new SWDropZone(buildSetName, m_envHelper);
  198. }
  199. else if (!stricmp(buildSetName, "roxie"))
  200. {
  201. pComp = (IConfigComp*) new SWRoxieCluster(buildSetName, m_envHelper);
  202. }
  203. else if (!stricmp(buildSetName, "thor"))
  204. {
  205. pComp = (IConfigComp*) new SWThorCluster(buildSetName, m_envHelper);
  206. }
  207. else if (!stricmp(buildSetName, "esp"))
  208. {
  209. pComp = (IConfigComp*) new SWEspProcess(buildSetName, m_envHelper);
  210. }
  211. else if (!stricmp(buildSetName, "espsmc"))
  212. {
  213. pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
  214. }
  215. else if (!stricmp(buildSetName, "DynamicESDL"))
  216. {
  217. pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
  218. }
  219. else if (!stricmp(buildSetName, "ws_sql"))
  220. {
  221. pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
  222. }
  223. else if (!stricmp(buildSetName, "ws_ecl"))
  224. {
  225. pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
  226. }
  227. else if (!stricmp(buildSetName, "wslogging"))
  228. {
  229. pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
  230. }
  231. else if (!stricmp(buildSetName, "cassandraloggingagent"))
  232. {
  233. pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
  234. }
  235. else if (!stricmp(buildSetName, "esploggingagent"))
  236. {
  237. pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
  238. }
  239. else if (!stricmp(buildSetName, "loggingmanager"))
  240. {
  241. pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
  242. }
  243. else if (!stricmp(buildSetName, "eclagent"))
  244. {
  245. pComp = (IConfigComp*) new SWProcess(buildSetName, m_envHelper);
  246. }
  247. else if (!stricmp(buildSetName, "eclccserver"))
  248. {
  249. pComp = (IConfigComp*) new SWProcess(buildSetName, m_envHelper);
  250. }
  251. else if (!stricmp(buildSetName, "eclscheduler"))
  252. {
  253. pComp = (IConfigComp*) new SWProcess(buildSetName, m_envHelper);
  254. }
  255. else if (!stricmp(buildSetName, "dfuserver"))
  256. {
  257. pComp = (IConfigComp*) new SWProcess(buildSetName, m_envHelper);
  258. }
  259. else if (!stricmp(buildSetName, "topology"))
  260. {
  261. pComp = (IConfigComp*) new SWTopology(m_envHelper);
  262. }
  263. else if (!stricmp(buildSetName, "ftslave"))
  264. {
  265. pComp = (IConfigComp*) new SWProcess(buildSetName, m_envHelper);
  266. }
  267. else if (!stricmp(buildSetName, "backupnode"))
  268. {
  269. pComp = (IConfigComp*) new SWBackupNode(buildSetName, m_envHelper);
  270. }
  271. else
  272. {
  273. pComp = (IConfigComp*) new SWProcess(buildSetName, m_envHelper);
  274. }
  275. if (pComp != NULL)
  276. {
  277. m_swCompMap.setValue(buildSetName, pComp);
  278. }
  279. return pComp;
  280. }
  281. }