params.py 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. import sys
  17. from resource_management import *
  18. from resource_management.core.logger import Logger
  19. from resource_management.libraries.functions import default
  20. Logger.initialize_logger()
  21. reload(sys)
  22. sys.setdefaultencoding('utf-8')
  23. # server configurations
  24. config = Script.get_config()
  25. # conf_dir = "/etc/"
  26. dolphin_home = "/opt/soft/dolphinscheduler"
  27. dolphin_conf_dir = dolphin_home + "/conf"
  28. dolphin_log_dir = dolphin_home + "/logs"
  29. dolphin_bin_dir = dolphin_home + "/bin"
  30. dolphin_lib_jars = dolphin_home + "/lib/*"
  31. dolphin_pidfile_dir = "/opt/soft/run/dolphinscheduler"
  32. rmHosts = default("/clusterHostInfo/rm_host", [])
  33. # dolphin-env
  34. dolphin_env_map = {}
  35. dolphin_env_map.update(config['configurations']['dolphin-env'])
  36. # which user to install and admin dolphin scheduler
  37. dolphin_user = dolphin_env_map['dolphin.user']
  38. dolphin_group = dolphin_env_map['dolphin.group']
  39. # .dolphinscheduler_env.sh
  40. dolphin_env_path = dolphin_conf_dir + '/env/dolphinscheduler_env.sh'
  41. dolphin_env_content = dolphin_env_map['dolphinscheduler-env-content']
  42. # database config
  43. dolphin_database_config = {}
  44. dolphin_database_config['dolphin_database_type'] = dolphin_env_map['dolphin.database.type']
  45. dolphin_database_config['dolphin_database_username'] = dolphin_env_map['dolphin.database.username']
  46. dolphin_database_config['dolphin_database_password'] = dolphin_env_map['dolphin.database.password']
  47. if 'mysql' == dolphin_database_config['dolphin_database_type']:
  48. dolphin_database_config['dolphin_database_driver'] = 'com.mysql.jdbc.Driver'
  49. dolphin_database_config['driverDelegateClass'] = 'org.quartz.impl.jdbcjobstore.StdJDBCDelegate'
  50. dolphin_database_config['dolphin_database_url'] = 'jdbc:mysql://' + dolphin_env_map['dolphin.database.host'] \
  51. + ':' + dolphin_env_map['dolphin.database.port'] \
  52. + '/dolphinscheduler?useUnicode=true&characterEncoding=UTF-8'
  53. else:
  54. dolphin_database_config['dolphin_database_driver'] = 'org.postgresql.Driver'
  55. dolphin_database_config['driverDelegateClass'] = 'org.quartz.impl.jdbcjobstore.PostgreSQLDelegate'
  56. dolphin_database_config['dolphin_database_url'] = 'jdbc:postgresql://' + dolphin_env_map['dolphin.database.host'] \
  57. + ':' + dolphin_env_map['dolphin.database.port'] \
  58. + '/dolphinscheduler'
  59. # application-alert.properties
  60. dolphin_alert_map = {}
  61. wechat_push_url = 'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$token'
  62. wechat_token_url = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$corpId&corpsecret=$secret'
  63. wechat_team_send_msg = '{\"toparty\":\"$toParty\",\"agentid\":\"$agentId\",\"msgtype\":\"text\",\"text\":{\"content\":\"$msg\"},\"safe\":\"0\"}'
  64. wechat_user_send_msg = '{\"touser\":\"$toUser\",\"agentid\":\"$agentId\",\"msgtype\":\"markdown\",\"markdown\":{\"content\":\"$msg\"}}'
  65. dolphin_alert_config_map = config['configurations']['dolphin-alert']
  66. if dolphin_alert_config_map['enterprise.wechat.enable']:
  67. dolphin_alert_map['enterprise.wechat.push.ur'] = wechat_push_url
  68. dolphin_alert_map['enterprise.wechat.token.url'] = wechat_token_url
  69. dolphin_alert_map['enterprise.wechat.team.send.msg'] = wechat_team_send_msg
  70. dolphin_alert_map['enterprise.wechat.user.send.msg'] = wechat_user_send_msg
  71. dolphin_alert_map.update(dolphin_alert_config_map)
  72. # application-api.properties
  73. dolphin_app_api_map = {}
  74. dolphin_app_api_map.update(config['configurations']['dolphin-application-api'])
  75. # common.properties
  76. dolphin_common_map = {}
  77. if 'yarn-site' in config['configurations'] and \
  78. 'yarn.resourcemanager.webapp.address' in config['configurations']['yarn-site']:
  79. yarn_resourcemanager_webapp_address = config['configurations']['yarn-site']['yarn.resourcemanager.webapp.address']
  80. yarn_application_status_address = 'http://' + yarn_resourcemanager_webapp_address + '/ws/v1/cluster/apps/%s'
  81. dolphin_common_map['yarn.application.status.address'] = yarn_application_status_address
  82. rmHosts = default("/clusterHostInfo/rm_host", [])
  83. if len(rmHosts) > 1:
  84. dolphin_common_map['yarn.resourcemanager.ha.rm.ids'] = ','.join(rmHosts)
  85. else:
  86. dolphin_common_map['yarn.resourcemanager.ha.rm.ids'] = ''
  87. dolphin_common_map_tmp = config['configurations']['dolphin-common']
  88. data_basedir_path = dolphin_common_map_tmp['data.basedir.path']
  89. dolphin_common_map['dolphinscheduler.env.path'] = dolphin_env_path
  90. dolphin_common_map.update(config['configurations']['dolphin-common'])
  91. # datasource.properties
  92. dolphin_datasource_map = {}
  93. dolphin_datasource_map['spring.datasource.type'] = 'com.alibaba.druid.pool.DruidDataSource'
  94. dolphin_datasource_map['spring.datasource.driver-class-name'] = dolphin_database_config['dolphin_database_driver']
  95. dolphin_datasource_map['spring.datasource.url'] = dolphin_database_config['dolphin_database_url']
  96. dolphin_datasource_map['spring.datasource.username'] = dolphin_database_config['dolphin_database_username']
  97. dolphin_datasource_map['spring.datasource.password'] = dolphin_database_config['dolphin_database_password']
  98. dolphin_datasource_map.update(config['configurations']['dolphin-datasource'])
  99. # master.properties
  100. dolphin_master_map = config['configurations']['dolphin-master']
  101. # quartz.properties
  102. dolphin_quartz_map = {}
  103. dolphin_quartz_map['org.quartz.jobStore.driverDelegateClass'] = dolphin_database_config['driverDelegateClass']
  104. dolphin_quartz_map.update(config['configurations']['dolphin-quartz'])
  105. # worker.properties
  106. dolphin_worker_map = config['configurations']['dolphin-worker']
  107. # zookeeper.properties
  108. dolphin_zookeeper_map={}
  109. zookeeperHosts = default("/clusterHostInfo/zookeeper_hosts", [])
  110. if len(zookeeperHosts) > 0 and "clientPort" in config['configurations']['zoo.cfg']:
  111. clientPort = config['configurations']['zoo.cfg']['clientPort']
  112. zookeeperPort = ":" + clientPort + ","
  113. dolphin_zookeeper_map['zookeeper.quorum'] = zookeeperPort.join(zookeeperHosts) + ":" + clientPort
  114. dolphin_zookeeper_map.update(config['configurations']['dolphin-zookeeper'])