123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336 |
- /*##############################################################################
- HPCC SYSTEMS software Copyright (C) 2018 HPCC Systems®.
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- ############################################################################## */
- #include "Software.hpp"
- #include "SWProcess.hpp"
- #include "SWDropZone.hpp"
- #include "SWThorCluster.hpp"
- #include "SWRoxieCluster.hpp"
- #include "SWEspProcess.hpp"
- #include "SWEspService.hpp"
- #include "SWDirectories.hpp"
- #include "SWDaliProcess.hpp"
- #include "SWBackupNode.hpp"
- #include "SWTopology.hpp"
- #include "deployutils.hpp"
- #include "ComponentBase.hpp"
- #include "SWLdapProcess.hpp"
- namespace ech
- {
- Software::Software(EnvHelper * envHelper):ComponentBase("software", envHelper)
- {
- }
- Software::~Software()
- {
- HashIterator swCompIter(m_swCompMap);
- ForEach(swCompIter)
- {
- IMapping &cur = swCompIter.query();
- IConfigComp* pSWComp = m_swCompMap.mapToValue(&cur);
- SWComponentBase *swcb = (SWComponentBase*) pSWComp;
- //swcb-Release();
- ::Release(swcb);
- }
- }
- void Software::create(IPropertyTree *params)
- {
- IPropertyTree * envTree = m_envHelper->getEnvTree();
- const IPropertyTree * buildSetTree = m_envHelper->getBuildSetTree();
- envTree->addPropTree(XML_TAG_SOFTWARE, createPTreeFromIPT(
- buildSetTree->queryPropTree("./" XML_TAG_SOFTWARE)));
- getSWComp("esp")->create(params);
- StringBuffer xpath;
- xpath.clear().appendf("./%s/%s/%s", XML_TAG_PROGRAMS, XML_TAG_BUILD, XML_TAG_BUILDSET);
- Owned<IPropertyTreeIterator> buildSetInsts = buildSetTree->getElements(xpath.str());
- const GenEnvRules& rules = m_envHelper->getGenEnvRules();
- ForEach(*buildSetInsts)
- {
- IPropertyTree* pBuildSet = &buildSetInsts->query();
- const char* buildSetName = pBuildSet->queryProp(XML_ATTR_NAME);
- if (stricmp(buildSetName, "esp") == 0) continue;
- if (rules.foundInProp("do_not_generate", buildSetName)) continue;
- getSWComp(buildSetName)->create(params);
- }
- }
- unsigned Software::add(IPropertyTree *params)
- {
- const char *comp = params->queryProp("@component");
- return getSWComp(comp)->add(params);
- }
- void Software::modify(IPropertyTree *params)
- {
- //IPropertyTree * envTree = m_envHelper->getEnvTree();
- const char *comp = params->queryProp("@component");
- getSWComp(comp)->modify(params);
- }
- void Software::remove(IPropertyTree *params)
- {
- const char *comp = params->queryProp("@component");
- getSWComp(comp)->remove(params);
- }
- void Software::getSWCompName(const char *inputName, StringBuffer& out)
- {
- const char * compNameLC = (StringBuffer(inputName).toLowerCase()).str();
- // Return xsd name in buildset.xml
- out.clear();
- if (!stricmp(compNameLC, "directories") || !stricmp(compNameLC, "dirs"))
- {
- out.append("directories");
- }
- else if (!stricmp(compNameLC, "dali") || !stricmp(compNameLC, "DaliServerProcess"))
- {
- out.append("dali");
- }
- else if (!stricmp(compNameLC, "dropzone"))
- {
- out.append("DropZone");
- }
- else if (!stricmp(compNameLC, "roxie") || !stricmp(compNameLC, "RoxieCluster"))
- {
- out.append("roxie");
- }
- else if (!stricmp(compNameLC, "thor") || !stricmp(compNameLC, "ThorCluster"))
- {
- out.append("thor");
- }
- else if (!stricmp(compNameLC, "esp") || !stricmp(compNameLC, "EspProcess"))
- {
- out.append("esp");
- }
- else if (!stricmp(compNameLC, "elcwatch") || !stricmp(compNameLC, "espsmc"))
- {
- out.append("espsmc");
- }
- else if (!stricmp(compNameLC, "esdl") || !stricmp(compNameLC, "DynamicESDL") ||
- !stricmp(compNameLC, "DESDLBindingTemplate"))
- {
- out.append("DynamicESDL");
- }
- else if (!stricmp(compNameLC, "ws_sql") || !stricmp(compNameLC, "wssql"))
- {
- out.append("ws_sql");
- }
- else if (!stricmp(compNameLC, "ws_ecl") || !stricmp(compNameLC, "wsecl"))
- {
- out.append("ws_ecl");
- }
- else if (!stricmp(compNameLC, "wslogging"))
- {
- out.append("wslogging");
- }
- else if (!stricmp(compNameLC, "cassandra") || !stricmp(compNameLC, "CassandraLoggingAgent"))
- {
- out.append("cassandraloggingagent");
- }
- else if (!stricmp(compNameLC, "esplogging") || !stricmp(compNameLC, "EspLoggingAgent"))
- {
- out.append("esploggingagent");
- }
- else if (!stricmp(compNameLC, "loggingmgr") || !stricmp(compNameLC, "loggingmanager"))
- {
- out.append("loggingmanager");
- }
- else if (!stricmp(compNameLC, "backup") || !stricmp(compNameLC, "backupnode"))
- {
- out.append("backupnode");
- }
- else if (!stricmp(compNameLC, "agent") || !stricmp(compNameLC, "eclagent") ||
- !stricmp(compNameLC, "EclAgentiProcess"))
- {
- out.append("eclagent");
- }
- else if (!stricmp(compNameLC, "eclccsrv") || !stricmp(compNameLC, "eclccserver") ||
- !stricmp(compNameLC, "eclcc") || !stricmp(compNameLC, "EclCCServerProcess"))
- {
- out.append("eclccserver");
- }
- else if (!stricmp(compNameLC, "eclplus") || !stricmp(compNameLC, "eclplusserver") ||
- !stricmp(compNameLC, "EclPlusProcess"))
- {
- out.append("eclplus");
- }
- else if (!stricmp(compNameLC, "sch") || !stricmp(compNameLC, "eclsch") ||
- !stricmp(compNameLC, "scheduler") || !stricmp(compNameLC, "EclCCSchedulerProcess"))
- {
- out.append("eclscheduler");
- }
- else if (!stricmp(compNameLC, "dfu") || !stricmp(compNameLC, "dfusrv") ||
- !stricmp(compNameLC, "dfuserver") || !stricmp(compNameLC, "DfuServerProcess"))
- {
- out.append("dfuserver");
- }
- else if (!stricmp(compNameLC, "topo") || !stricmp(compNameLC, "Topology"))
- {
- out.append("topology");
- }
- else if (!stricmp(compNameLC, "fts") || !stricmp(compNameLC, "FTSlave") || !stricmp(compNameLC, "FTSlaveProcess"))
- {
- out.append("ftslave");
- }
- else if (!stricmp(compNameLC, "spark") || !stricmp(compNameLC, "sparkthor") || !stricmp(compNameLC, "SparkThorProcess"))
- {
- out.append("sparkthor");
- }
- else if (!stricmp(compNameLC, "ldap") || !stricmp(compNameLC, "ldapserver") || !stricmp(compNameLC, "LDAPServerProcess"))
- {
- out.append("ldapServer");
- }
- else
- {
- out.append(compNameLC);
- }
- }
- IConfigComp* Software::getSWComp(const char *compName)
- {
- //should call m_envHelper->getXMLTagName(compName)
- //const char *compNameLC = m_envHelper->getXMLTagName(compName);
- const char * compNameLC = (StringBuffer(compName).toLowerCase()).str();
- StringBuffer sbBuildSetName;
- getSWCompName(compNameLC, sbBuildSetName);
- const char* buildSetName = sbBuildSetName.str();
- IConfigComp * pComp = m_swCompMap.getValue(buildSetName);
- if (pComp) return pComp;
- if (!stricmp(buildSetName, "directories"))
- {
- pComp = (IConfigComp*) new SWDirectories(buildSetName, m_envHelper);
- }
- else if (!stricmp(buildSetName, "dali"))
- {
- pComp = (IConfigComp*) new SWDaliProcess(buildSetName, m_envHelper);
- }
- else if (!stricmp(buildSetName, "DropZone"))
- {
- pComp = (IConfigComp*) new SWDropZone(buildSetName, m_envHelper);
- }
- else if (!stricmp(buildSetName, "roxie"))
- {
- pComp = (IConfigComp*) new SWRoxieCluster(buildSetName, m_envHelper);
- }
- else if (!stricmp(buildSetName, "thor"))
- {
- pComp = (IConfigComp*) new SWThorCluster(buildSetName, m_envHelper);
- }
- else if (!stricmp(buildSetName, "esp"))
- {
- pComp = (IConfigComp*) new SWEspProcess(buildSetName, m_envHelper);
- }
- else if (!stricmp(buildSetName, "espsmc"))
- {
- pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
- }
- else if (!stricmp(buildSetName, "DynamicESDL"))
- {
- pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
- }
- else if (!stricmp(buildSetName, "ws_sql"))
- {
- pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
- }
- else if (!stricmp(buildSetName, "ws_ecl"))
- {
- pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
- }
- else if (!stricmp(buildSetName, "wslogging"))
- {
- pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
- }
- else if (!stricmp(buildSetName, "cassandraloggingagent"))
- {
- pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
- }
- else if (!stricmp(buildSetName, "esploggingagent"))
- {
- pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
- }
- else if (!stricmp(buildSetName, "loggingmanager"))
- {
- pComp = (IConfigComp*) new SWEspService(buildSetName, m_envHelper);
- }
- else if (!stricmp(buildSetName, "eclagent"))
- {
- pComp = (IConfigComp*) new SWProcess(buildSetName, m_envHelper);
- }
- else if (!stricmp(buildSetName, "eclccserver"))
- {
- pComp = (IConfigComp*) new SWProcess(buildSetName, m_envHelper);
- }
- else if (!stricmp(buildSetName, "eclplus"))
- {
- pComp = (IConfigComp*) new SWProcess(buildSetName, m_envHelper);
- }
- else if (!stricmp(buildSetName, "eclscheduler"))
- {
- pComp = (IConfigComp*) new SWProcess(buildSetName, m_envHelper);
- }
- else if (!stricmp(buildSetName, "dfuserver"))
- {
- pComp = (IConfigComp*) new SWProcess(buildSetName, m_envHelper);
- }
- else if (!stricmp(buildSetName, "topology"))
- {
- pComp = (IConfigComp*) new SWTopology(m_envHelper);
- }
- else if (!stricmp(buildSetName, "ftslave"))
- {
- pComp = (IConfigComp*) new SWProcess(buildSetName, m_envHelper);
- }
- else if (!stricmp(buildSetName, "backupnode"))
- {
- pComp = (IConfigComp*) new SWBackupNode(buildSetName, m_envHelper);
- }
- else if (!stricmp(buildSetName, "ldapServer"))
- {
- pComp = (IConfigComp*) new SWLdapProcess(buildSetName, m_envHelper);
- }
- else
- {
- pComp = (IConfigComp*) new SWProcess(buildSetName, m_envHelper);
- }
- if (pComp != NULL)
- {
- m_swCompMap.setValue(buildSetName, pComp);
- }
- return pComp;
- }
- }
|