ThorDeploymentEngine.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 "ThorDeploymentEngine.hpp"
  19. //---------------------------------------------------------------------------
  20. // CThorDeploymentEngine
  21. //---------------------------------------------------------------------------
  22. CThorDeploymentEngine::CThorDeploymentEngine(IEnvDeploymentEngine& envDepEngine,
  23. IDeploymentCallback& callback,
  24. IPropertyTree& process)
  25. : CDeploymentEngine(envDepEngine, callback, process)
  26. {
  27. }
  28. //---------------------------------------------------------------------------
  29. // checkInstance
  30. //---------------------------------------------------------------------------
  31. void CThorDeploymentEngine::check()
  32. {
  33. CDeploymentEngine::check();
  34. const char* dali = m_process.queryProp("@daliServers");
  35. if (!dali || !*dali )
  36. throw MakeStringException(0, "No dali server is defined for thor %s", m_process.queryProp("@name"));
  37. }
  38. //---------------------------------------------------------------------------
  39. // copyInstallFiles
  40. //---------------------------------------------------------------------------
  41. void CThorDeploymentEngine::copyInstallFiles(IPropertyTree& instanceNode, const char* destPath)
  42. {
  43. // Copy install files
  44. CDeploymentEngine::copyInstallFiles(instanceNode, destPath);
  45. EnvMachineOS os = m_envDepEngine.lookupMachineOS(instanceNode);
  46. if (!m_compare)
  47. ensurePath(destPath);
  48. // Create slaves and spares files
  49. writeComputerFile("./ThorSlaveProcess", StringBuffer(destPath).append("slaves").str(), os);
  50. writeComputerFile("./ThorSpareProcess", StringBuffer(destPath).append("spares").str(), os);
  51. }
  52. //---------------------------------------------------------------------------
  53. // writeComputerFile
  54. //---------------------------------------------------------------------------
  55. void CThorDeploymentEngine::writeComputerFile(const char* type, const char* filename, EnvMachineOS os/*=MachineOsUnknown*/)
  56. {
  57. StringBuffer str;
  58. Owned<IPropertyTreeIterator> iter = m_process.getElements(type);
  59. for(iter->first(); iter->isValid(); iter->next())
  60. {
  61. StringAttr netAddress;
  62. if (m_envDepEngine.lookupNetAddress(netAddress, iter->query().queryProp("@computer")).length() > 0)
  63. str.appendf("%s\n", netAddress.get());
  64. }
  65. writeFile(filename, str.str(), os);
  66. }