thorconfiggenengine.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*##############################################################################
  2. Copyright (C) 2011 HPCC Systems.
  3. All rights reserved. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ############################################################################## */
  14. #include "jexcept.hpp"
  15. #include "jfile.hpp"
  16. #include "jptree.hpp"
  17. #include "xslprocessor.hpp"
  18. #include "thorconfiggenengine.hpp"
  19. //---------------------------------------------------------------------------
  20. // CThorConfigGenEngine
  21. //---------------------------------------------------------------------------
  22. CThorConfigGenEngine::CThorConfigGenEngine(IEnvDeploymentEngine& envDepEngine,
  23. IDeploymentCallback& callback,
  24. IPropertyTree& process,
  25. const char* inputDir,
  26. const char* outputDir)
  27. : CConfigGenEngine(envDepEngine, callback, process, inputDir, outputDir)
  28. {
  29. }
  30. //---------------------------------------------------------------------------
  31. // checkInstance
  32. //---------------------------------------------------------------------------
  33. void CThorConfigGenEngine::check()
  34. {
  35. CDeploymentEngine::check();
  36. const char* dali = m_process.queryProp("@daliServers");
  37. if (!dali || !*dali )
  38. throw MakeStringException(0, "No dali server is defined for thor %s", m_process.queryProp("@name"));
  39. }
  40. //---------------------------------------------------------------------------
  41. // copyInstallFiles
  42. //---------------------------------------------------------------------------
  43. void CThorConfigGenEngine::copyInstallFiles(IPropertyTree& instanceNode, const char* destPath)
  44. {
  45. // Copy install files
  46. CDeploymentEngine::copyInstallFiles(instanceNode, destPath);
  47. EnvMachineOS os = m_envDepEngine.lookupMachineOS(instanceNode);
  48. if (!m_compare)
  49. ensurePath(destPath);
  50. StringBuffer sbDestDir(StringBuffer(destPath).append(m_process.queryProp("@name")).append(PATHSEPCHAR));
  51. // Create slaves and spares files
  52. writeComputerFile("./ThorSlaveProcess", StringBuffer(sbDestDir).append("slaves").str(), os);
  53. writeComputerFile("./ThorSpareProcess", StringBuffer(sbDestDir).append("spares").str(), os);
  54. }
  55. //---------------------------------------------------------------------------
  56. // writeComputerFile
  57. //---------------------------------------------------------------------------
  58. void CThorConfigGenEngine::writeComputerFile(const char* type, const char* filename, EnvMachineOS os/*=MachineOsUnknown*/)
  59. {
  60. StringBuffer str;
  61. Owned<IPropertyTreeIterator> iter = m_process.getElements(type);
  62. for(iter->first(); iter->isValid(); iter->next())
  63. {
  64. StringAttr netAddress;
  65. if (m_envDepEngine.lookupNetAddress(netAddress, iter->query().queryProp("@computer")).length() > 0)
  66. str.appendf("%s\n", netAddress.get());
  67. }
  68. writeFile(filename, str.str(), os);
  69. }