sparkThor.xsl.in 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. ################################################################################
  4. # HPCC SYSTEMS software Copyright (C) 2018 HPCC Systems®.
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. ################################################################################
  18. -->
  19. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xml:space="default">
  20. <xsl:output method="text" indent="no" omit-xml-declaration="yes"/>
  21. <xsl:strip-space elements="*"/>
  22. <xsl:param name="process" select="'sparkthor'"/>
  23. <xsl:param name="isLinuxInstance" select="0" />
  24. <xsl:param name="outputFilePath" />
  25. <xsl:template match="/">
  26. <xsl:apply-templates select="/Environment/Software/SparkThorProcess[@name=$process]"/>
  27. </xsl:template>
  28. <xsl:template match="SparkThorProcess">
  29. <xsl:call-template name="printVariable">
  30. <xsl:with-param name="var" select="'SPARK_EXECUTOR_CORES'"/>
  31. <xsl:with-param name="val" select="@SPARK_EXECUTOR_CORES"/>
  32. </xsl:call-template>
  33. <xsl:call-template name="printVariable">
  34. <xsl:with-param name="var" select="'SPARK_EXECUTOR_MEMORY'"/>
  35. <xsl:with-param name="val" select="@SPARK_EXECUTOR_MEMORY"/>
  36. </xsl:call-template>
  37. <xsl:call-template name="printVariable">
  38. <xsl:with-param name="var" select="'SPARK_MASTER_HOST'"/>
  39. <xsl:with-param name="val" select="Instance/@netAddress[1]"/>
  40. </xsl:call-template>
  41. <xsl:call-template name="printVariable">
  42. <xsl:with-param name="var" select="'SPARK_MASTER_WEBUI_PORT'"/>
  43. <xsl:with-param name="val" select="@SPARK_MASTER_WEBUI_PORT"/>
  44. </xsl:call-template>
  45. <xsl:call-template name="printVariable">
  46. <xsl:with-param name="var" select="'SPARK_MASTER_PORT'"/>
  47. <xsl:with-param name="val" select="@SPARK_MASTER_PORT"/>
  48. </xsl:call-template>
  49. <xsl:call-template name="printVariable">
  50. <xsl:with-param name="var" select="'SPARK_WORKER_CORES'"/>
  51. <xsl:with-param name="val" select="@SPARK_WORKER_CORES"/>
  52. </xsl:call-template>
  53. <xsl:call-template name="printVariable">
  54. <xsl:with-param name="var" select="'SPARK_WORKER_MEMORY'"/>
  55. <xsl:with-param name="val" select="@SPARK_WORKER_MEMORY"/>
  56. </xsl:call-template>
  57. <xsl:call-template name="printVariable">
  58. <xsl:with-param name="var" select="'SPARK_WORKER_PORT'"/>
  59. <xsl:with-param name="val" select="@SPARK_WORKER_PORT"/>
  60. </xsl:call-template>
  61. <xsl:call-template name="printVariable">
  62. <xsl:with-param name="var" select="'NODEGROUP'"/>
  63. <xsl:with-param name="val" select="@ThorClusterName"/>
  64. </xsl:call-template>
  65. <xsl:text>export DALISERVER=</xsl:text>
  66. <xsl:call-template name="getThorNodeDali">
  67. <xsl:with-param name="thorNode" select="@ThorClusterName"/>
  68. </xsl:call-template>
  69. <xsl:text>&#xa;</xsl:text>
  70. <xsl:text>export SPARK_LOG_DIR=@LOG_PATH@/</xsl:text><xsl:value-of select="@name"/><xsl:text>&#xa;</xsl:text>
  71. <xsl:text>export SPARK_PID_DIR=@PID_PATH@&#xa;</xsl:text>
  72. <xsl:text>export SPARK_CONF_DIR=@RUNTIME_PATH@/</xsl:text><xsl:value-of select="@name"/><xsl:text>&#xa;</xsl:text>
  73. <xsl:text>export SPARK_WORKER_DIR=@RUNTIME_PATH@/</xsl:text><xsl:value-of select="@name"/><xsl:text>&#xa;</xsl:text>
  74. <!-- Allow for user defined spark-env.sh variables under @CONFIG_DIR@ -->
  75. <xsl:text>if [[ -f @CONFIG_DIR@/externals/spark-hadoop/spark-env.sh ]]; then</xsl:text><xsl:text>&#xa;</xsl:text>
  76. <xsl:text>source @CONFIG_DIR@/externals/spark-hadoop/spark-env.sh</xsl:text><xsl:text>&#xa;</xsl:text>
  77. <xsl:text>fi</xsl:text><xsl:text>&#xa;</xsl:text>
  78. </xsl:template>
  79. <!-- printVariable -->
  80. <xsl:template name="printVariable">
  81. <xsl:param name="var"/>
  82. <xsl:param name="val"/>
  83. <xsl:if test="$val">
  84. <xsl:text>export </xsl:text><xsl:value-of select="$var"/><xsl:text>=</xsl:text><xsl:value-of select="$val"/><xsl:text>&#xa;</xsl:text>
  85. </xsl:if>
  86. </xsl:template>
  87. <!-- printVariable -->
  88. <!-- getThorNodeDali -->
  89. <xsl:template name="getThorNodeDali">
  90. <xsl:param name="thorNode"/>
  91. <xsl:if test="not(/Environment/Software/ThorCluster[@name=$thorNode])">
  92. <xsl:message terminate="yes">Thor cluster specified in ThorNode: <xsl:value-of select="$thorNode"/> has not been declared in this environment</xsl:message>
  93. </xsl:if>
  94. <xsl:for-each select="/Environment/Software/ThorCluster[@name=$thorNode]">
  95. <xsl:call-template name="getDaliServers">
  96. <xsl:with-param name="daliServer" select="@daliServers"/>
  97. </xsl:call-template>
  98. </xsl:for-each>
  99. </xsl:template>
  100. <!-- getThorNodeDali -->
  101. <!-- getDaliServers -->
  102. <xsl:template name="getDaliServers">
  103. <xsl:param name="daliServer"/>
  104. <xsl:for-each select="/Environment/Software/DaliServerProcess[@name=$daliServer]/Instance">
  105. <xsl:call-template name="getNetAddress">
  106. <xsl:with-param name="computer" select="@computer"/>
  107. </xsl:call-template>
  108. <xsl:if test="string(@port) != ''">:<xsl:value-of select="@port"/></xsl:if>
  109. <xsl:if test="position() != last()">, </xsl:if>
  110. </xsl:for-each>
  111. </xsl:template>
  112. <!-- getDaliServers -->
  113. <!-- getNetAddress -->
  114. <xsl:template name="getNetAddress">
  115. <xsl:param name="computer"/>
  116. <xsl:value-of select="/Environment/Hardware/Computer[@name=$computer]/@netAddress"/>
  117. </xsl:template>
  118. <!-- getNetAddress -->
  119. </xsl:stylesheet>