params.py 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #!/usr/bin/env 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 functions import calc_xmn_from_xms
  18. from resource_management import *
  19. import status_params
  20. from ambari_commons import OSCheck
  21. if OSCheck.is_windows_family():
  22. from params_windows import *
  23. else:
  24. from params_linux import *
  25. # server configurations
  26. config = Script.get_config()
  27. exec_tmp_dir = Script.get_tmp_dir()
  28. #AMS data
  29. ams_pid_dir = status_params.ams_collector_pid_dir
  30. ams_collector_script = "/usr/sbin/ambari-metrics-collector"
  31. ams_collector_pid_dir = status_params.ams_collector_pid_dir
  32. ams_collector_hosts = default("/clusterHostInfo/metric_collector_hosts", [])
  33. ams_collector_host_single = ams_collector_hosts[0] #TODO cardinality is 1+ so we can have more than one host
  34. metric_collector_port = default("/configurations/ams-site/timeline.metrics.service.webapp.address", "0.0.0.0:8188")
  35. if metric_collector_port and metric_collector_port.find(':') != -1:
  36. metric_collector_port = metric_collector_port.split(':')[1]
  37. pass
  38. ams_collector_log_dir = config['configurations']['ams-env']['ams_collector_log_dir']
  39. ams_monitor_log_dir = config['configurations']['ams-env']['ams_monitor_log_dir']
  40. ams_monitor_dir = "/usr/lib/python2.6/site-packages/resource_monitoring"
  41. ams_monitor_pid_dir = status_params.ams_monitor_pid_dir
  42. ams_monitor_script = "/usr/sbin/ambari-metrics-monitor"
  43. #hadoop params
  44. hbase_excluded_hosts = config['commandParams']['excluded_hosts']
  45. hbase_drain_only = config['commandParams']['mark_draining_only']
  46. hbase_included_hosts = config['commandParams']['included_hosts']
  47. hbase_user = status_params.hbase_user
  48. smokeuser = config['configurations']['cluster-env']['smokeuser']
  49. hbase_root_dir = config['configurations']['ams-hbase-site']['hbase.rootdir']
  50. is_hbase_distributed = hbase_root_dir.startswith('hdfs://')
  51. # security is disabled for embedded mode, when HBase is backed by file
  52. security_enabled = False if not is_hbase_distributed else config['configurations']['cluster-env']['security_enabled']
  53. # this is "hadoop-metrics.properties" for 1.x stacks
  54. metric_prop_file_name = "hadoop-metrics2-hbase.properties"
  55. # not supporting 32 bit jdk.
  56. java64_home = config['hostLevelParams']['java_home']
  57. hbase_log_dir = config['configurations']['ams-hbase-env']['hbase_log_dir']
  58. master_heapsize = config['configurations']['ams-hbase-env']['hbase_master_heapsize']
  59. regionserver_heapsize = config['configurations']['ams-hbase-env']['hbase_regionserver_heapsize']
  60. regionserver_xmn_max = config['configurations']['ams-hbase-env']['hbase_regionserver_xmn_max']
  61. regionserver_xmn_percent = config['configurations']['ams-hbase-env']['hbase_regionserver_xmn_ratio']
  62. regionserver_xmn_size = calc_xmn_from_xms(regionserver_heapsize, regionserver_xmn_percent, regionserver_xmn_max)
  63. # For embedded mode
  64. hbase_heapsize = master_heapsize
  65. ams_checkpoint_dir = config['configurations']['ams-site']['timeline.metrics.aggregator.checkpoint.dir']
  66. hbase_pid_dir = status_params.hbase_pid_dir
  67. hbase_tmp_dir = config['configurations']['ams-hbase-site']['hbase.tmp.dir']
  68. # TODO UPGRADE default, update site during upgrade
  69. _local_dir_conf = default('/configurations/ams-hbase-site/hbase.local.dir', "${hbase.tmp.dir}/local")
  70. local_dir = substitute_vars(_local_dir_conf, config['configurations']['ams-hbase-site'])
  71. client_jaas_config_file = format("{hbase_conf_dir}/hbase_client_jaas.conf")
  72. master_jaas_config_file = format("{hbase_conf_dir}/hbase_master_jaas.conf")
  73. regionserver_jaas_config_file = format("{hbase_conf_dir}/hbase_regionserver_jaas.conf")
  74. rs_hosts = ["localhost"]
  75. smoke_test_user = config['configurations']['cluster-env']['smokeuser']
  76. smokeuser_permissions = "RWXCA"
  77. service_check_data = functions.get_unique_id_and_date()
  78. user_group = config['configurations']['cluster-env']["user_group"]
  79. hadoop_user = "hadoop"
  80. if security_enabled:
  81. _hostname_lowercase = config['hostname'].lower()
  82. master_jaas_princ = default('/configurations/ams-hbase-site/hbase.master.kerberos.principal', 'hbase/_HOST@EXAMPLE.COM').replace('_HOST',_hostname_lowercase)
  83. regionserver_jaas_princ = default('/configurations/ams-hbase-site/hbase.regionserver.kerberos.principal', 'hbase/_HOST@EXAMPLE.COM').replace('_HOST',_hostname_lowercase)
  84. master_keytab_path = config['configurations']['ams-hbase-site']['hbase.master.keytab.file']
  85. regionserver_keytab_path = config['configurations']['ams-hbase-site']['hbase.regionserver.keytab.file']
  86. smoke_user_keytab = config['configurations']['cluster-env']['smokeuser_keytab']
  87. hbase_user_keytab = config['configurations']['ams-hbase-env']['hbase_user_keytab']
  88. kinit_path_local = functions.get_kinit_path(["/usr/bin", "/usr/kerberos/bin", "/usr/sbin"])
  89. if security_enabled:
  90. kinit_cmd = format("{kinit_path_local} -kt {hbase_user_keytab} {hbase_user};")
  91. else:
  92. kinit_cmd = ""
  93. #log4j.properties
  94. if (('ams-hbase-log4j' in config['configurations']) and ('content' in config['configurations']['ams-hbase-log4j'])):
  95. hbase_log4j_props = config['configurations']['ams-hbase-log4j']['content']
  96. else:
  97. hbase_log4j_props = None
  98. if (('ams-log4j' in config['configurations']) and ('content' in config['configurations']['ams-log4j'])):
  99. log4j_props = config['configurations']['ams-log4j']['content']
  100. else:
  101. log4j_props = None
  102. hbase_env_sh_template = config['configurations']['ams-hbase-env']['content']
  103. ams_env_sh_template = config['configurations']['ams-env']['content']
  104. hbase_staging_dir = "/apps/hbase/staging"
  105. #for create_hdfs_directory
  106. hostname = config["hostname"]
  107. hdfs_user_keytab = config['configurations']['hadoop-env']['hdfs_user_keytab']
  108. hdfs_user = config['configurations']['hadoop-env']['hdfs_user']
  109. hdfs_principal_name = config['configurations']['hadoop-env']['hdfs_principal_name']
  110. kinit_path_local = functions.get_kinit_path(["/usr/bin", "/usr/kerberos/bin", "/usr/sbin"])
  111. import functools
  112. # create partial functions with common arguments for every HdfsDirectory call
  113. # to create hdfs directory we need to call params.HdfsDirectory in code
  114. HdfsDirectory = functools.partial(
  115. HdfsDirectory,
  116. conf_dir=hadoop_conf_dir,
  117. hdfs_user=hdfs_user,
  118. security_enabled = security_enabled,
  119. keytab = hdfs_user_keytab,
  120. kinit_path_local = kinit_path_local,
  121. bin_dir = hadoop_bin_dir
  122. )