params.py 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. """
  2. Licensed to the Apache Software Foundation (ASF) under one
  3. or more contributor license agreements. See the NOTICE file
  4. distributed with this work for additional information
  5. regarding copyright ownership. The ASF licenses this file
  6. to you under the Apache License, Version 2.0 (the
  7. "License"); you may not use this file except in compliance
  8. with the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. """
  16. from ambari_commons import OSCheck
  17. from resource_management.libraries.functions.default import default
  18. from resource_management.libraries.functions import format
  19. from resource_management.libraries.functions.version import format_stack_version
  20. from resource_management.libraries.functions.default import default
  21. from resource_management.libraries.script.script import Script
  22. from ambari_commons.ambari_metrics_helper import select_metric_collector_hosts_from_hostnames
  23. if OSCheck.is_windows_family():
  24. from params_windows import *
  25. else:
  26. from params_linux import *
  27. config = Script.get_config()
  28. stack_root = Script.get_stack_root()
  29. stack_name = default("/hostLevelParams/stack_name", None)
  30. # New Cluster Stack Version that is defined during the RESTART of a Stack Upgrade
  31. version = default("/commandParams/version", None)
  32. user_group = config['configurations']['cluster-env']['user_group']
  33. proxyuser_group = config['configurations']['hadoop-env']['proxyuser_group']
  34. security_enabled = False
  35. stack_version_unformatted = config['hostLevelParams']['stack_version']
  36. stack_version_formatted = format_stack_version(stack_version_unformatted)
  37. # hadoop default parameters
  38. flume_bin = '/usr/bin/flume-ng'
  39. flume_hive_home = '/usr/lib/hive'
  40. flume_hcat_home = '/usr/lib/hive-hcatalog'
  41. # hadoop parameters for stack supporting rolling upgrade
  42. if stack_version_formatted and check_stack_feature(StackFeature.ROLLING_UPGRADE, stack_version_formatted):
  43. flume_bin = format('{stack_root}/current/flume-server/bin/flume-ng')
  44. flume_hive_home = format('{stack_root}/current/hive-metastore')
  45. flume_hcat_home = format('{stack_root}/current/hive-webhcat')
  46. java_home = config['hostLevelParams']['java_home']
  47. flume_log_dir = config['configurations']['flume-env']['flume_log_dir']
  48. flume_run_dir = config['configurations']['flume-env']['flume_run_dir']
  49. ambari_state_file = format("{flume_run_dir}/ambari-state.txt")
  50. if (('flume-conf' in config['configurations']) and('content' in config['configurations']['flume-conf'])):
  51. flume_conf_content = config['configurations']['flume-conf']['content']
  52. else:
  53. flume_conf_content = None
  54. if (('flume-log4j' in config['configurations']) and ('content' in config['configurations']['flume-log4j'])):
  55. flume_log4j_content = config['configurations']['flume-log4j']['content']
  56. else:
  57. flume_log4j_content = None
  58. targets = default('/commandParams/flume_handler', None)
  59. flume_command_targets = [] if targets is None else targets.split(',')
  60. flume_env_sh_template = config['configurations']['flume-env']['content']
  61. ganglia_server_hosts = default('/clusterHostInfo/ganglia_server_host', [])
  62. ganglia_server_host = None
  63. if 0 != len(ganglia_server_hosts):
  64. ganglia_server_host = ganglia_server_hosts[0]
  65. hostname = None
  66. if config.has_key('hostname'):
  67. hostname = config['hostname']
  68. set_instanceId = "false"
  69. cluster_name = config["clusterName"]
  70. if 'cluster-env' in config['configurations'] and \
  71. 'metrics_collector_external_hosts' in config['configurations']['cluster-env']:
  72. ams_collector_hosts = config['configurations']['cluster-env']['metrics_collector_external_hosts']
  73. set_instanceId = "true"
  74. else:
  75. ams_collector_hosts = ",".join(default("/clusterHostInfo/metrics_collector_hosts", []))
  76. has_metric_collector = not len(ams_collector_hosts) == 0
  77. metric_collector_port = None
  78. if has_metric_collector:
  79. metric_collector_host = select_metric_collector_hosts_from_hostnames(ams_collector_hosts)
  80. if 'cluster-env' in config['configurations'] and \
  81. 'metrics_collector_external_port' in config['configurations']['cluster-env']:
  82. metric_collector_port = config['configurations']['cluster-env']['metrics_collector_external_port']
  83. else:
  84. metric_collector_web_address = default("/configurations/ams-site/timeline.metrics.service.webapp.address", "0.0.0.0:6188")
  85. if metric_collector_web_address.find(':') != -1:
  86. metric_collector_port = metric_collector_web_address.split(':')[1]
  87. else:
  88. metric_collector_port = '6188'
  89. if default("/configurations/ams-site/timeline.metrics.service.http.policy", "HTTP_ONLY") == "HTTPS_ONLY":
  90. metric_collector_protocol = 'https'
  91. else:
  92. metric_collector_protocol = 'http'
  93. metric_truststore_path= default("/configurations/ams-ssl-client/ssl.client.truststore.location", "")
  94. metric_truststore_type= default("/configurations/ams-ssl-client/ssl.client.truststore.type", "")
  95. metric_truststore_password= default("/configurations/ams-ssl-client/ssl.client.truststore.password", "")
  96. pass
  97. metrics_report_interval = default("/configurations/ams-site/timeline.metrics.sink.report.interval", 60)
  98. metrics_collection_period = default("/configurations/ams-site/timeline.metrics.sink.collection.period", 10)
  99. # Cluster Zookeeper quorum
  100. zookeeper_quorum = None
  101. if not len(default("/clusterHostInfo/zookeeper_hosts", [])) == 0:
  102. if 'zoo.cfg' in config['configurations'] and 'clientPort' in config['configurations']['zoo.cfg']:
  103. zookeeper_clientPort = config['configurations']['zoo.cfg']['clientPort']
  104. else:
  105. zookeeper_clientPort = '2181'
  106. zookeeper_quorum = (':' + zookeeper_clientPort + ',').join(config['clusterHostInfo']['zookeeper_hosts'])
  107. # last port config
  108. zookeeper_quorum += ':' + zookeeper_clientPort