params.py 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #!/usr/bin/python
  2. """
  3. Licensed to the Apache Software Foundation (ASF) under one
  4. or more contributor license agreements. See the NOTICE file
  5. distributed with this work for additional information
  6. regarding copyright ownership. The ASF licenses this file
  7. to you under the Apache License, Version 2.0 (the
  8. "License"); you may not use this file except in compliance
  9. with the License. You may obtain a copy of the License at
  10. http://www.apache.org/licenses/LICENSE-2.0
  11. Unless required by applicable law or agreed to in writing, software
  12. distributed under the License is distributed on an "AS IS" BASIS,
  13. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. See the License for the specific language governing permissions and
  15. limitations under the License.
  16. """
  17. from resource_management.libraries.functions.version import format_hdp_stack_version, compare_versions
  18. from resource_management import *
  19. from setup_spark import *
  20. import status_params
  21. config = Script.get_config()
  22. tmp_dir = Script.get_tmp_dir()
  23. # New Cluster Stack Version that is defined during the RESTART of a Rolling Upgrade
  24. version = default("/commandParams/version", None)
  25. hdp_stack_version = str(config['hostLevelParams']['stack_version'])
  26. hdp_stack_version = format_hdp_stack_version(hdp_stack_version)
  27. # TODO! FIXME! Version check is not working as of today :
  28. # $ yum list installed | grep hdp-select
  29. # hdp-select.noarch 2.2.1.0-2340.el6 @HDP-2.2
  30. # And hdp_stack_version returned from hostLevelParams/stack_version is : 2.2.0.0
  31. # Commenting out for time being
  32. #stack_is_hdp22_or_further = hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.2.1.0') >= 0
  33. stack_is_hdp22_or_further = hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.2') >= 0
  34. version = default("/commandParams/version", None)
  35. if stack_is_hdp22_or_further:
  36. hadoop_home = "/usr/hdp/current/hadoop-client"
  37. spark_conf = '/etc/spark/conf'
  38. spark_log_dir = config['configurations']['spark-env']['spark_log_dir']
  39. spark_pid_dir = status_params.spark_pid_dir
  40. spark_role_root = "spark-client"
  41. command_role = default("/role", "")
  42. if command_role == "SPARK_CLIENT":
  43. spark_role_root = "spark-client"
  44. elif command_role == "SPARK_JOBHISTORYSERVER":
  45. spark_role_root = "spark-historyserver"
  46. spark_home = format("/usr/hdp/current/{spark_role_root}")
  47. else:
  48. pass
  49. java_home = config['hostLevelParams']['java_home']
  50. hadoop_conf_dir = "/etc/hadoop/conf"
  51. spark_user = status_params.spark_user
  52. spark_group = status_params.spark_group
  53. user_group = status_params.user_group
  54. spark_history_server_pid_file = status_params.spark_history_server_pid_file
  55. spark_history_server_start = format("{spark_home}/sbin/start-history-server.sh")
  56. spark_history_server_stop = format("{spark_home}/sbin/stop-history-server.sh")
  57. spark_submit_cmd = format("{spark_home}/bin/spark-submit")
  58. spark_smoke_example = "org.apache.spark.examples.SparkPi"
  59. spark_service_check_cmd = format(
  60. "{spark_submit_cmd} --class {spark_smoke_example} --master yarn-cluster --num-executors 1 --driver-memory 256m --executor-memory 256m --executor-cores 1 {spark_home}/lib/spark-examples*.jar 1")
  61. spark_jobhistoryserver_hosts = default("/clusterHostInfo/spark_jobhistoryserver_hosts", [])
  62. if len(spark_jobhistoryserver_hosts) > 0:
  63. spark_history_server_host = spark_jobhistoryserver_hosts[0]
  64. else:
  65. spark_history_server_host = "localhost"
  66. # spark-defaults params
  67. spark_yarn_historyServer_address = default(spark_history_server_host, "localhost")
  68. spark_yarn_applicationMaster_waitTries = default(
  69. "/configurations/spark-defaults/spark.yarn.applicationMaster.waitTries", '10')
  70. spark_yarn_submit_file_replication = default("/configurations/spark-defaults/spark.yarn.submit.file.replication", '3')
  71. spark_yarn_preserve_staging_files = default("/configurations/spark-defaults/spark.yarn.preserve.staging.files", "false")
  72. spark_yarn_scheduler_heartbeat_interval = default(
  73. "/configurations/spark-defaults/spark.yarn.scheduler.heartbeat.interval-ms", "5000")
  74. spark_yarn_queue = default("/configurations/spark-defaults/spark.yarn.queue", "default")
  75. spark_yarn_containerLauncherMaxThreads = default(
  76. "/configurations/spark-defaults/spark.yarn.containerLauncherMaxThreads", "25")
  77. spark_yarn_max_executor_failures = default("/configurations/spark-defaults/spark.yarn.max.executor.failures", "3")
  78. spark_yarn_executor_memoryOverhead = default("/configurations/spark-defaults/spark.yarn.executor.memoryOverhead", "384")
  79. spark_yarn_driver_memoryOverhead = default("/configurations/spark-defaults/spark.yarn.driver.memoryOverhead", "384")
  80. spark_history_provider = default("/configurations/spark-defaults/spark.history.provider",
  81. "org.apache.spark.deploy.yarn.history.YarnHistoryProvider")
  82. spark_history_ui_port = default("/configurations/spark-defaults/spark.history.ui.port", "18080")
  83. spark_env_sh = config['configurations']['spark-env']['content']
  84. spark_log4j_properties = config['configurations']['spark-log4j-properties']['content']
  85. spark_metrics_properties = config['configurations']['spark-metrics-properties']['content']
  86. spark_javaopts_properties = config['configurations']['spark-javaopts-properties']['content']
  87. hive_server_host = default("/clusterHostInfo/hive_server_host", [])
  88. is_hive_installed = not len(hive_server_host) == 0
  89. hdp_full_version = get_hdp_version()
  90. spark_driver_extraJavaOptions = str(config['configurations']['spark-defaults']['spark.driver.extraJavaOptions'])
  91. if spark_driver_extraJavaOptions.find('-Dhdp.version') == -1:
  92. spark_driver_extraJavaOptions = spark_driver_extraJavaOptions + ' -Dhdp.version=' + str(hdp_full_version)
  93. spark_yarn_am_extraJavaOptions = str(config['configurations']['spark-defaults']['spark.yarn.am.extraJavaOptions'])
  94. if spark_yarn_am_extraJavaOptions.find('-Dhdp.version') == -1:
  95. spark_yarn_am_extraJavaOptions = spark_yarn_am_extraJavaOptions + ' -Dhdp.version=' + str(hdp_full_version)
  96. spark_javaopts_properties = str(spark_javaopts_properties)
  97. if spark_javaopts_properties.find('-Dhdp.version') == -1:
  98. spark_javaopts_properties = spark_javaopts_properties+ ' -Dhdp.version=' + str(hdp_full_version)
  99. security_enabled = config['configurations']['cluster-env']['security_enabled']
  100. kinit_path_local = functions.get_kinit_path(["/usr/bin", "/usr/kerberos/bin", "/usr/sbin"])
  101. spark_kerberos_keytab = config['configurations']['spark-defaults']['spark.history.kerberos.keytab']
  102. spark_kerberos_principal = config['configurations']['spark-defaults']['spark.history.kerberos.principal']
  103. if security_enabled:
  104. spark_principal = spark_kerberos_principal.replace('_HOST',spark_history_server_host.lower())