AMBARI-21581 - Replace Hard Coded conf-select Structures (jonathanhurley)
[ambari.git] / ambari-server / src / main / resources / common-services / HIVE / 0.12.0.2.0 / package / scripts / webhcat_server.py
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
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17
18 Ambari Agent
19
20 """
21 from resource_management.libraries.script.script import Script
22 from resource_management.libraries.functions import stack_select
23 from resource_management.libraries.functions.constants import StackFeature
24 from resource_management.libraries.functions.check_process_status import check_process_status
25 from resource_management.libraries.functions.stack_features import check_stack_feature
26 from resource_management.libraries.functions.security_commons import build_expectations, \
27 cached_kinit_executor, get_params_from_filesystem, validate_security_config_properties, \
28 FILE_TYPE_XML
29 from resource_management.core.logger import Logger
30 from webhcat import webhcat
31 from webhcat_service import webhcat_service
32 from ambari_commons import OSConst
33 from ambari_commons.os_family_impl import OsFamilyImpl
34
35
36 class WebHCatServer(Script):
37 def install(self, env):
38 import params
39 self.install_packages(env)
40
41 def start(self, env, upgrade_type=None):
42 import params
43 env.set_params(params)
44 self.configure(env) # FOR SECURITY
45 webhcat_service(action='start', upgrade_type=upgrade_type)
46
47 def stop(self, env, upgrade_type=None):
48 import params
49 env.set_params(params)
50 webhcat_service(action='stop')
51
52 def configure(self, env):
53 import params
54 env.set_params(params)
55 webhcat()
56
57
58 @OsFamilyImpl(os_family=OSConst.WINSRV_FAMILY)
59 class WebHCatServerWindows(WebHCatServer):
60 def status(self, env):
61 import status_params
62 env.set_params(status_params)
63 check_windows_service_status(status_params.webhcat_server_win_service_name)
64
65
66 @OsFamilyImpl(os_family=OsFamilyImpl.DEFAULT)
67 class WebHCatServerDefault(WebHCatServer):
68 def status(self, env):
69 import status_params
70 env.set_params(status_params)
71 check_process_status(status_params.webhcat_pid_file)
72
73 def pre_upgrade_restart(self, env, upgrade_type=None):
74 Logger.info("Executing WebHCat Stack Upgrade pre-restart")
75 import params
76 env.set_params(params)
77
78 if params.version and check_stack_feature(StackFeature.ROLLING_UPGRADE, params.version):
79 stack_select.select_packages(params.version)
80
81 def get_log_folder(self):
82 import params
83 return params.hcat_log_dir
84
85 def get_user(self):
86 import params
87 return params.webhcat_user
88
89 def get_pid_files(self):
90 import status_params
91 return [status_params.webhcat_pid_file]
92
93 if __name__ == "__main__":
94 WebHCatServer().execute()