params.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 resource_management.libraries.functions.version import format_hdp_stack_version, compare_versions
  17. from resource_management import *
  18. from status_params import *
  19. config = Script.get_config()
  20. # New Cluster Stack Version that is defined during the RESTART of a Rolling Upgrade
  21. version = default("/commandParams/version", None)
  22. stack_version_unformatted = str(config['hostLevelParams']['stack_version'])
  23. hdp_stack_version = format_hdp_stack_version(stack_version_unformatted)
  24. # hadoop params
  25. if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.2') >= 0:
  26. hadoop_bin_dir = "/usr/hdp/current/hadoop-client/bin"
  27. # if this is a server action, then use the server binaries; smoke tests
  28. # use the client binaries
  29. server_role_dir_mapping = { 'FALCON_SERVER' : 'falcon-server',
  30. 'FALCON_SERVICE_CHECK' : 'falcon-client' }
  31. command_role = default("/role", "")
  32. if command_role not in server_role_dir_mapping:
  33. command_role = 'FALCON_SERVICE_CHECK'
  34. falcon_root = server_role_dir_mapping[command_role]
  35. falcon_webapp_dir = format('/usr/hdp/current/{falcon_root}/webapp')
  36. falcon_home = format('/usr/hdp/current/{falcon_root}')
  37. else:
  38. hadoop_bin_dir = "/usr/bin"
  39. falcon_webapp_dir = '/var/lib/falcon/webapp'
  40. falcon_home = '/usr/lib/falcon'
  41. hadoop_conf_dir = "/etc/hadoop/conf"
  42. falcon_conf_dir_prefix = "/etc/falcon"
  43. falcon_conf_dir = format("{falcon_conf_dir_prefix}/conf")
  44. oozie_user = config['configurations']['oozie-env']['oozie_user']
  45. falcon_user = config['configurations']['falcon-env']['falcon_user']
  46. smoke_user = config['configurations']['cluster-env']['smokeuser']
  47. user_group = config['configurations']['cluster-env']['user_group']
  48. proxyuser_group = config['configurations']['hadoop-env']['proxyuser_group']
  49. java_home = config['hostLevelParams']['java_home']
  50. falcon_local_dir = config['configurations']['falcon-env']['falcon_local_dir']
  51. falcon_log_dir = config['configurations']['falcon-env']['falcon_log_dir']
  52. # falcon-startup.properties
  53. store_uri = config['configurations']['falcon-startup.properties']['*.config.store.uri']
  54. # If these properties are present, the directories need to be created.
  55. falcon_graph_storage_directory = default("/configurations/falcon-startup.properties/*.falcon.graph.storage.directory", None) # explicitly set in HDP 2.2 and higher
  56. falcon_graph_serialize_path = default("/configurations/falcon-startup.properties/*.falcon.graph.serialize.path", None) # explicitly set in HDP 2.2 and higher
  57. falcon_embeddedmq_data = config['configurations']['falcon-env']['falcon.embeddedmq.data']
  58. falcon_embeddedmq_enabled = config['configurations']['falcon-env']['falcon.embeddedmq']
  59. falcon_emeddedmq_port = config['configurations']['falcon-env']['falcon.emeddedmq.port']
  60. falcon_host = config['clusterHostInfo']['falcon_server_hosts'][0]
  61. falcon_port = config['configurations']['falcon-env']['falcon_port']
  62. falcon_runtime_properties = config['configurations']['falcon-runtime.properties']
  63. falcon_startup_properties = config['configurations']['falcon-startup.properties']
  64. smokeuser_keytab = config['configurations']['cluster-env']['smokeuser_keytab']
  65. falcon_env_sh_template = config['configurations']['falcon-env']['content']
  66. flacon_apps_dir = '/apps/falcon'
  67. #for create_hdfs_directory
  68. security_enabled = config['configurations']['cluster-env']['security_enabled']
  69. hostname = config["hostname"]
  70. hdfs_user_keytab = config['configurations']['hadoop-env']['hdfs_user_keytab']
  71. hdfs_user = config['configurations']['hadoop-env']['hdfs_user']
  72. hdfs_principal_name = config['configurations']['hadoop-env']['hdfs_principal_name']
  73. kinit_path_local = functions.get_kinit_path(["/usr/bin", "/usr/kerberos/bin", "/usr/sbin"])
  74. import functools
  75. #create partial functions with common arguments for every HdfsDirectory call
  76. #to create hdfs directory we need to call params.HdfsDirectory in code
  77. HdfsDirectory = functools.partial(
  78. HdfsDirectory,
  79. conf_dir=hadoop_conf_dir,
  80. hdfs_user=hdfs_user,
  81. security_enabled = security_enabled,
  82. keytab = hdfs_user_keytab,
  83. kinit_path_local = kinit_path_local,
  84. bin_dir = hadoop_bin_dir
  85. )