nimbus.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. import sys
  18. from resource_management.libraries.functions import check_process_status
  19. from resource_management.libraries.script import Script
  20. from resource_management.libraries.functions import format
  21. from resource_management.libraries.functions import conf_select
  22. from resource_management.libraries.functions import stack_select
  23. from resource_management.core.resources.system import Execute
  24. from resource_management.libraries.functions.stack_features import check_stack_feature
  25. from resource_management.libraries.functions import StackFeature
  26. from storm import storm
  27. from service import service
  28. from resource_management.libraries.functions.security_commons import build_expectations, \
  29. cached_kinit_executor, get_params_from_filesystem, validate_security_config_properties, \
  30. FILE_TYPE_JAAS_CONF
  31. from setup_ranger_storm import setup_ranger_storm
  32. from ambari_commons import OSConst
  33. from ambari_commons.os_family_impl import OsFamilyImpl
  34. from resource_management.core.resources.service import Service
  35. class Nimbus(Script):
  36. def get_component_name(self):
  37. return "storm-nimbus"
  38. def install(self, env):
  39. self.install_packages(env)
  40. self.configure(env)
  41. def configure(self, env):
  42. import params
  43. env.set_params(params)
  44. storm("nimbus")
  45. @OsFamilyImpl(os_family=OsFamilyImpl.DEFAULT)
  46. class NimbusDefault(Nimbus):
  47. def pre_upgrade_restart(self, env, upgrade_type=None):
  48. import params
  49. env.set_params(params)
  50. if params.version and check_stack_feature(StackFeature.ROLLING_UPGRADE, params.version):
  51. conf_select.select(params.stack_name, "storm", params.version)
  52. stack_select.select("storm-client", params.version)
  53. stack_select.select("storm-nimbus", params.version)
  54. def start(self, env, upgrade_type=None):
  55. import params
  56. env.set_params(params)
  57. self.configure(env)
  58. setup_ranger_storm(upgrade_type=upgrade_type)
  59. service("nimbus", action="start")
  60. def stop(self, env, upgrade_type=None):
  61. import params
  62. env.set_params(params)
  63. service("nimbus", action="stop")
  64. def status(self, env):
  65. import status_params
  66. env.set_params(status_params)
  67. check_process_status(status_params.pid_nimbus)
  68. def get_log_folder(self):
  69. import params
  70. return params.log_dir
  71. def get_user(self):
  72. import params
  73. return params.storm_user
  74. @OsFamilyImpl(os_family=OSConst.WINSRV_FAMILY)
  75. class NimbusWindows(Nimbus):
  76. def start(self, env):
  77. import status_params
  78. env.set_params(status_params)
  79. Service(status_params.nimbus_win_service_name, action="start")
  80. def stop(self, env):
  81. import status_params
  82. env.set_params(status_params)
  83. Service(status_params.nimbus_win_service_name, action="stop")
  84. def status(self, env):
  85. import status_params
  86. from resource_management.libraries.functions.windows_service_utils import check_windows_service_status
  87. env.set_params(status_params)
  88. check_windows_service_status(status_params.nimbus_win_service_name)
  89. if __name__ == "__main__":
  90. Nimbus().execute()