Software.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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. #include "SWLdapProcess.hpp"
  27. namespace ech
  28. {
  29. Software::Software(EnvHelper * envHelper):ComponentBase("software", envHelper)
  30. {
  31. }
  32. Software::~Software()
  33. {
  34. HashIterator swCompIter(m_swCompMap);
  35. ForEach(swCompIter)
  36. {
  37. IMapping &cur = swCompIter.query();
  38. IConfigComp* pSWComp = m_swCompMap.mapToValue(&cur);
  39. SWComponentBase *swcb = (SWComponentBase*) pSWComp;
  40. //swcb-Release();
  41. ::Release(swcb);
  42. }
  43. }
  44. void Software::create(IPropertyTree *params)
  45. {
  46. IPropertyTree * envTree = m_envHelper->getEnvTree();
  47. const IPropertyTree * buildSetTree = m_envHelper->getBuildSetTree();
  48. envTree->addPropTree(XML_TAG_SOFTWARE, createPTreeFromIPT(
  49. buildSetTree->queryPropTree("./" XML_TAG_SOFTWARE)));
  50. getSWComp("esp")->create(params);
  51. StringBuffer xpath;
  52. xpath.clear().appendf("./%s/%s/%s", XML_TAG_PROGRAMS, XML_TAG_BUILD, XML_TAG_BUILDSET);
  53. Owned<IPropertyTreeIterator> buildSetInsts = buildSetTree->getElements(xpath.str());
  54. const GenEnvRules& rules = m_envHelper->getGenEnvRules();
  55. ForEach(*buildSetInsts)
  56. {
  57. IPropertyTree* pBuildSet = &buildSetInsts->query();
  58. const char* buildSetName = pBuildSet->queryProp(XML_ATTR_NAME);
  59. if (stricmp(buildSetName, "esp") == 0) continue;
  60. if (rules.foundInProp("do_not_generate", buildSetName)) continue;
  61. getSWComp(buildSetName)->create(params);
  62. }
  63. }
  64. unsigned Software::add(IPropertyTree *params)
  65. {
  66. const char *comp = params->queryProp("@component");
  67. return getSWComp(comp)->add(params);
  68. }
  69. void Software::modify(IPropertyTree *params)
  70. {
  71. //IPropertyTree * envTree = m_envHelper->getEnvTree();
  72. const char *comp = params->queryProp("@component");
  73. getSWComp(comp)->modify(params);
  74. }
  75. void Software::remove(IPropertyTree *params)
  76. {
  77. const char *comp = params->queryProp("@component");
  78. getSWComp(comp)->remove(params);
  79. }
  80. void Software::getSWCompName(const char *inputName, StringBuffer& out)
  81. {
  82. const char * compNameLC = (StringBuffer(inputName).toLowerCase()).str();
  83. // Return xsd name in buildset.xml
  84. out.clear();
  85. if (!stricmp(compNameLC, "directories") || !stricmp(compNameLC, "dirs"))
  86. {
  87. out.append("directories");
  88. }
  89. else if (!stricmp(compNameLC, "dali") || !stricmp(compNameLC, "DaliServerProcess"))
  90. {
  91. out.append("dali");
  92. }
  93. else if (!stricmp(compNameLC, "dropzone"))
  94. {
  95. out.append("DropZone");
  96. }
  97. else if (!stricmp(compNameLC, "roxie") || !stricmp(compNameLC, "RoxieCluster"))
  98. {
  99. out.append("roxie");
  100. }
  101. else if (!stricmp(compNameLC, "thor") || !stricmp(compNameLC, "ThorCluster"))
  102. {
  103. out.append("thor");
  104. }
  105. else if (!stricmp(compNameLC, "esp") || !stricmp(compNameLC, "EspProcess"))
  106. {
  107. out.append("esp");
  108. }
  109. else if (!stricmp(compNameLC, "elcwatch") || !stricmp(compNameLC, "espsmc"))
  110. {
  111. out.append("espsmc");
  112. }
  113. else if (!stricmp(compNameLC, "esdl") || !stricmp(compNameLC, "DynamicESDL") ||
  114. !stricmp(compNameLC, "DESDLBindingTemplate"))
  115. {
  116. out.append("DynamicESDL");
  117. }
  118. else if (!stricmp(compNameLC, "ws_sql") || !stricmp(compNameLC, "wssql"))
  119. {
  120. out.append("ws_sql");
  121. }
  122. else if (!stricmp(compNameLC, "ws_ecl") || !stricmp(compNameLC, "wsecl"))
  123. {
  124. out.append("ws_ecl");
  125. }
  126. else if (!stricmp(compNameLC, "wslogging"))
  127. {
  128. out.append("wslogging");
  129. }
  130. else if (!stricmp(compNameLC, "cassandra") || !stricmp(compNameLC, "CassandraLoggingAgent"))
  131. {
  132. out.append("cassandraloggingagent");
  133. }
  134. else if (!stricmp(compNameLC, "esplogging") || !stricmp(compNameLC, "EspLoggingAgent"))
  135. {
  136. out.append("esploggingagent");
  137. }
  138. else if (!stricmp(compNameLC, "loggingmgr") || !stricmp(compNameLC, "loggingmanager"))
  139. {
  140. out.append("loggingmanager");
  141. }
  142. else if (!stricmp(compNameLC, "backup") || !stricmp(compNameLC, "backupnode"))
  143. {
  144. out.append("backupnode");
  145. }
  146. else if (!stricmp(compNameLC, "agent") || !stricmp(compNameLC, "eclagent") ||
  147. !stricmp(compNameLC, "EclAgentiProcess"))
  148. {
  149. out.append("eclagent");
  150. }
  151. else if (!stricmp(compNameLC, "eclccsrv") || !stricmp(compNameLC, "eclccserver") ||
  152. !stricmp(compNameLC, "eclcc") || !stricmp(compNameLC, "EclCCServerProcess"))
  153. {
  154. out.append("eclccserver");
  155. }
  156. else if (!stricmp(compNameLC, "eclplus") || !stricmp(compNameLC, "eclplusserver") ||
  157. !stricmp(compNameLC, "EclPlusProcess"))
  158. {
  159. out.append("eclplus");
  160. }
  161. else if (!stricmp(compNameLC, "sch") || !stricmp(compNameLC, "eclsch") ||
  162. !stricmp(compNameLC, "scheduler") || !stricmp(compNameLC, "EclCCSchedulerProcess"))
  163. {
  164. out.append("eclscheduler");
  165. }
  166. else if (!stricmp(compNameLC, "dfu") || !stricmp(compNameLC, "dfusrv") ||
  167. !stricmp(compNameLC, "dfuserver") || !stricmp(compNameLC, "DfuServerProcess"))
  168. {
  169. out.append("dfuserver");
  170. }
  171. else if (!stricmp(compNameLC, "topo") || !stricmp(compNameLC, "Topology"))
  172. {
  173. out.append("topology");
  174. }
  175. else if (!stricmp(compNameLC, "fts") || !stricmp(compNameLC, "FTSlave") || !stricmp(compNameLC, "FTSlaveProcess"))
  176. {
  177. out.append("ftslave");
  178. }
  179. else if (!stricmp(compNameLC, "spark") || !stricmp(compNameLC, "sparkthor") || !stricmp(compNameLC, "SparkThorProcess"))
  180. {
  181. out.append("sparkthor");
  182. }
  183. else if (!stricmp(compNameLC, "ldap") || !stricmp(compNameLC, "ldapserver") || !stricmp(compNameLC, "LDAPServerProcess"))
  184. {
  185. out.append("ldapServer");
  186. }
  187. else
  188. {
  189. out.append(compNameLC);
  190. }
  191. }
  192. IConfigComp* Software::getSWComp(const char *compName)
  193. {
  194. //should call m_envHelper->getXMLTagName(compName)
  195. //const char *compNameLC = m_envHelper->getXMLTagName(compName);
  196. const char * compNameLC = (StringBuffer(compName).toLowerCase()).str();
  197. StringBuffer sbBuildSetName;
  198. getSWCompName(compNameLC, sbBuildSetName);
  199. const char* buildSetName = sbBuildSetName.str();
  200. IConfigComp * pComp = m_swCompMap.getValue(buildSetName);
  201. if (pComp) return pComp;
  202. if (!stricmp(buildSetName, "directories"))
  203. {
  204. pComp = (IConfigComp*) new SWDirectories(buildSetName, m_envHelper);
  205. }
  206. else if (!stricmp(buildSetName, "dali"))
  207. {
  208. pComp = (IConfigComp*) new SWDaliProcess(buildSetName, m_envHelper);
  209. }
  210. else if (!stricmp(buildSetName, "DropZone"))
  211. {
  212. pComp = (IConfigComp*) new SWDropZone(buildSetName, m_envHelper);
  213. }
  214. else if (!stricmp(buildSetName, "roxie"))
  215. {
  216. pComp = (IConfigComp*) new SWRoxieCluster(buildSetName, m_envHelper);
  217. }
  218. else if (!stricmp(buildSetName, "thor"))
  219. {
  220. pComp = (IConfigComp*) new SWThorCluster(buildSetName, m_envHelper);
  221. }
  222. else if (!stricmp(buildSetName, "esp"))
  223. {
  224. pComp = (IConfigComp*) new SWEspProcess(buildSetName, m_envHelper);
  225. }
  226. else if (!stricmp(buildSetName, "espsmc"))
  227. {
  228. pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
  229. }
  230. else if (!stricmp(buildSetName, "DynamicESDL"))
  231. {
  232. pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
  233. }
  234. else if (!stricmp(buildSetName, "ws_sql"))
  235. {
  236. pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
  237. }
  238. else if (!stricmp(buildSetName, "ws_ecl"))
  239. {
  240. pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
  241. }
  242. else if (!stricmp(buildSetName, "wslogging"))
  243. {
  244. pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
  245. }
  246. else if (!stricmp(buildSetName, "cassandraloggingagent"))
  247. {
  248. pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
  249. }
  250. else if (!stricmp(buildSetName, "esploggingagent"))
  251. {
  252. pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
  253. }
  254. else if (!stricmp(buildSetName, "loggingmanager"))
  255. {
  256. pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
  257. }
  258. else if (!stricmp(buildSetName, "eclagent"))
  259. {
  260. pComp = (IConfigComp*) new SWProcess(buildSetName, m_envHelper);
  261. }
  262. else if (!stricmp(buildSetName, "eclccserver"))
  263. {
  264. pComp = (IConfigComp*) new SWProcess(buildSetName, m_envHelper);
  265. }
  266. else if (!stricmp(buildSetName, "eclplus"))
  267. {
  268. pComp = (IConfigComp*) new SWProcess(buildSetName, m_envHelper);
  269. }
  270. else if (!stricmp(buildSetName, "eclscheduler"))
  271. {
  272. pComp = (IConfigComp*) new SWProcess(buildSetName, m_envHelper);
  273. }
  274. else if (!stricmp(buildSetName, "dfuserver"))
  275. {
  276. pComp = (IConfigComp*) new SWProcess(buildSetName, m_envHelper);
  277. }
  278. else if (!stricmp(buildSetName, "topology"))
  279. {
  280. pComp = (IConfigComp*) new SWTopology(m_envHelper);
  281. }
  282. else if (!stricmp(buildSetName, "ftslave"))
  283. {
  284. pComp = (IConfigComp*) new SWProcess(buildSetName, m_envHelper);
  285. }
  286. else if (!stricmp(buildSetName, "backupnode"))
  287. {
  288. pComp = (IConfigComp*) new SWBackupNode(buildSetName, m_envHelper);
  289. }
  290. else if (!stricmp(buildSetName, "ldapServer"))
  291. {
  292. pComp = (IConfigComp*) new SWLdapProcess(buildSetName, m_envHelper);
  293. }
  294. else
  295. {
  296. pComp = (IConfigComp*) new SWProcess(buildSetName, m_envHelper);
  297. }
  298. if (pComp != NULL)
  299. {
  300. m_swCompMap.setValue(buildSetName, pComp);
  301. }
  302. return pComp;
  303. }
  304. }