RoxieDeploymentEngine.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 "RoxieDeploymentEngine.hpp"
  19. //---------------------------------------------------------------------------
  20. // CRoxieDeploymentEngine
  21. //---------------------------------------------------------------------------
  22. CRoxieDeploymentEngine::CRoxieDeploymentEngine(IEnvDeploymentEngine& envDepEngine,
  23. IDeploymentCallback& callback,
  24. IPropertyTree& process)
  25. : CDeploymentEngine(envDepEngine, callback, process, "*")
  26. {
  27. ForEachItemIn(idx, m_instances)
  28. {
  29. IPropertyTree& instance = m_instances.item(idx);
  30. if (!strcmp(instance.queryName(), "RoxieServerProcess"))
  31. m_allInstances.append( *LINK(&instance) );
  32. }
  33. }
  34. void CRoxieDeploymentEngine::checkInstance(IPropertyTree& node) const
  35. {
  36. if (!m_process.getPropInt("@numChannels", 0))
  37. throw MakeStringException(0, "Number of channels must be set for process %s", m_name.get());
  38. CDeploymentEngine::checkInstance(node);
  39. }
  40. //---------------------------------------------------------------------------
  41. // start
  42. //---------------------------------------------------------------------------
  43. void CRoxieDeploymentEngine::start()
  44. {
  45. if (m_instances.ordinality() > 0)
  46. {
  47. checkAbort();
  48. char tempPath[_MAX_PATH];
  49. getTempPath(tempPath, sizeof(tempPath), m_name);
  50. ensurePath(tempPath);
  51. m_envDepEngine.addTempDirectory( tempPath );
  52. int nInstances = m_instances.ordinality();
  53. if ( nInstances == m_allInstances.ordinality())
  54. {
  55. IPropertyTree& instance = m_instances.item(0);
  56. m_curInstance = instance.queryProp("@name");
  57. startInstance(instance); //only start the first Roxie server - it starts the rest
  58. }
  59. else
  60. {
  61. for (int i=0; i<nInstances; i++)
  62. {
  63. checkAbort();
  64. IPropertyTree& instance = m_instances.item(i);
  65. m_curInstance = instance.queryProp("@name");
  66. startInstance(instance, "start_one_roxie");
  67. }
  68. }
  69. m_curInstance = NULL;
  70. }
  71. }
  72. //---------------------------------------------------------------------------
  73. // stop
  74. //---------------------------------------------------------------------------
  75. void CRoxieDeploymentEngine::stop()
  76. {
  77. if (m_instances.ordinality() > 0)
  78. {
  79. checkAbort();
  80. char tempPath[_MAX_PATH];
  81. getTempPath(tempPath, sizeof(tempPath), m_name);
  82. ensurePath(tempPath);
  83. m_envDepEngine.addTempDirectory( tempPath );
  84. int nInstances = m_instances.ordinality();
  85. if ( nInstances == m_allInstances.ordinality())
  86. {
  87. //only stop the first Roxie server - it stops the rest
  88. IPropertyTree& instance = m_instances.item(0);
  89. m_curInstance = instance.queryProp("@name");
  90. stopInstance(instance);
  91. }
  92. else
  93. {
  94. for (int i=0; i<nInstances; i++)
  95. {
  96. checkAbort();
  97. IPropertyTree& instance = m_instances.item(i);
  98. m_curInstance = instance.queryProp("@name");
  99. stopInstance(instance, "stop_one_roxie");
  100. }
  101. }
  102. m_curInstance = NULL;
  103. }
  104. }