hbase.py 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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 os
  18. from resource_management import *
  19. import sys
  20. from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
  21. from ambari_commons import OSConst
  22. @OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
  23. def hbase(name=None):
  24. import params
  25. XmlConfig("hbase-site.xml",
  26. conf_dir = params.hbase_conf_dir,
  27. configurations = params.config['configurations']['hbase-site'],
  28. configuration_attributes=params.config['configuration_attributes']['hbase-site']
  29. )
  30. # name is 'master' or 'regionserver' or 'queryserver' or 'client'
  31. @OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
  32. def hbase(name=None):
  33. import params
  34. Directory( params.hbase_conf_dir_prefix,
  35. mode=0755
  36. )
  37. Directory( params.hbase_conf_dir,
  38. owner = params.hbase_user,
  39. group = params.user_group,
  40. recursive = True
  41. )
  42. Directory (params.tmp_dir,
  43. owner = params.hbase_user,
  44. mode=0775,
  45. recursive = True,
  46. cd_access="a",
  47. )
  48. Directory (params.local_dir,
  49. owner = params.hbase_user,
  50. group = params.user_group,
  51. mode=0775,
  52. recursive = True
  53. )
  54. Directory (os.path.join(params.local_dir, "jars"),
  55. owner = params.hbase_user,
  56. group = params.user_group,
  57. mode=0775,
  58. recursive = True
  59. )
  60. XmlConfig( "hbase-site.xml",
  61. conf_dir = params.hbase_conf_dir,
  62. configurations = params.config['configurations']['hbase-site'],
  63. configuration_attributes=params.config['configuration_attributes']['hbase-site'],
  64. owner = params.hbase_user,
  65. group = params.user_group
  66. )
  67. XmlConfig( "core-site.xml",
  68. conf_dir = params.hbase_conf_dir,
  69. configurations = params.config['configurations']['core-site'],
  70. configuration_attributes=params.config['configuration_attributes']['core-site'],
  71. owner = params.hbase_user,
  72. group = params.user_group
  73. )
  74. if 'hdfs-site' in params.config['configurations']:
  75. XmlConfig( "hdfs-site.xml",
  76. conf_dir = params.hbase_conf_dir,
  77. configurations = params.config['configurations']['hdfs-site'],
  78. configuration_attributes=params.config['configuration_attributes']['hdfs-site'],
  79. owner = params.hbase_user,
  80. group = params.user_group
  81. )
  82. XmlConfig("hdfs-site.xml",
  83. conf_dir=params.hadoop_conf_dir,
  84. configurations=params.config['configurations']['hdfs-site'],
  85. configuration_attributes=params.config['configuration_attributes']['hdfs-site'],
  86. owner=params.hdfs_user,
  87. group=params.user_group
  88. )
  89. if 'hbase-policy' in params.config['configurations']:
  90. XmlConfig( "hbase-policy.xml",
  91. conf_dir = params.hbase_conf_dir,
  92. configurations = params.config['configurations']['hbase-policy'],
  93. configuration_attributes=params.config['configuration_attributes']['hbase-policy'],
  94. owner = params.hbase_user,
  95. group = params.user_group
  96. )
  97. # Manually overriding ownership of file installed by hadoop package
  98. else:
  99. File( format("{params.hbase_conf_dir}/hbase-policy.xml"),
  100. owner = params.hbase_user,
  101. group = params.user_group
  102. )
  103. File(format("{hbase_conf_dir}/hbase-env.sh"),
  104. owner = params.hbase_user,
  105. content=InlineTemplate(params.hbase_env_sh_template)
  106. )
  107. hbase_TemplateConfig( params.metric_prop_file_name,
  108. tag = 'GANGLIA-MASTER' if name == 'master' else 'GANGLIA-RS'
  109. )
  110. hbase_TemplateConfig( 'regionservers')
  111. if params.security_enabled:
  112. hbase_TemplateConfig( format("hbase_{name}_jaas.conf"))
  113. if name != "client":
  114. Directory( params.pid_dir,
  115. owner = params.hbase_user,
  116. recursive = True
  117. )
  118. Directory (params.log_dir,
  119. owner = params.hbase_user,
  120. recursive = True
  121. )
  122. if (params.log4j_props != None):
  123. File(format("{params.hbase_conf_dir}/log4j.properties"),
  124. mode=0644,
  125. group=params.user_group,
  126. owner=params.hbase_user,
  127. content=params.log4j_props
  128. )
  129. elif (os.path.exists(format("{params.hbase_conf_dir}/log4j.properties"))):
  130. File(format("{params.hbase_conf_dir}/log4j.properties"),
  131. mode=0644,
  132. group=params.user_group,
  133. owner=params.hbase_user
  134. )
  135. if name in ["master","regionserver", "queryserver"]:
  136. params.HdfsDirectory(params.hbase_hdfs_root_dir,
  137. action="create_delayed",
  138. owner=params.hbase_user
  139. )
  140. params.HdfsDirectory(params.hbase_staging_dir,
  141. action="create_delayed",
  142. owner=params.hbase_user,
  143. mode=0711
  144. )
  145. params.HdfsDirectory(None, action="create")
  146. def hbase_TemplateConfig(name, tag=None):
  147. import params
  148. TemplateConfig( format("{hbase_conf_dir}/{name}"),
  149. owner = params.hbase_user,
  150. template_tag = tag
  151. )