config_mapping.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. var App = require('app');
  19. var configs = [
  20. /**********************************************core-site***************************************/
  21. {
  22. "name": "hadoop.proxyuser.<foreignKey[0]>.groups",
  23. "templateName": ["proxyuser_group"],
  24. "foreignKey": ["hive_user"],
  25. "value": "<templateName[0]>",
  26. "filename": "core-site.xml",
  27. "isOverridable": true
  28. },
  29. {
  30. "name": "hadoop.proxyuser.<foreignKey[0]>.hosts",
  31. "templateName": ["hivemetastore_host"],
  32. "foreignKey": ["hive_user"],
  33. "value": "<templateName[0]>",
  34. "filename": "core-site.xml",
  35. "isOverridable": true
  36. },
  37. {
  38. "name": "hadoop.proxyuser.<foreignKey[0]>.groups",
  39. "templateName": ["proxyuser_group"],
  40. "foreignKey": ["oozie_user"],
  41. "value": "<templateName[0]>",
  42. "filename": "core-site.xml",
  43. "isOverridable": true
  44. },
  45. {
  46. "name": "hadoop.proxyuser.<foreignKey[0]>.hosts",
  47. "templateName": ["oozieserver_host"],
  48. "foreignKey": ["oozie_user"],
  49. "value": "<templateName[0]>",
  50. "filename": "core-site.xml",
  51. "isOverridable": true
  52. },
  53. {
  54. "name": "hadoop.proxyuser.<foreignKey[0]>.groups",
  55. "templateName": ["proxyuser_group"],
  56. "foreignKey": ["webhcat_user"],
  57. "value": "<templateName[0]>",
  58. "filename": "core-site.xml",
  59. "isOverridable": true
  60. },
  61. {
  62. "name": "hadoop.proxyuser.<foreignKey[0]>.hosts",
  63. "templateName": ["hivemetastore_host"],
  64. "foreignKey": ["webhcat_user"],
  65. "value": "<templateName[0]>",
  66. "filename": "core-site.xml",
  67. "isOverridable": true
  68. },
  69. /**********************************************hbase-site***************************************/
  70. {
  71. "name": "hbase.rootdir",
  72. "templateName": ["namenode_host", "hbase_hdfs_root_dir"],
  73. "foreignKey": null,
  74. "value": "hdfs://<templateName[0]>:8020<templateName[1]>",
  75. "precondition": function () {
  76. return (App.HDFSService.find('HDFS') && App.HDFSService.find('HDFS').get('snameNode'));
  77. },
  78. "filename": "hbase-site.xml"
  79. },
  80. {
  81. "name": "hbase.zookeeper.quorum",
  82. "templateName": ["zookeeperserver_hosts"],
  83. "foreignKey": null,
  84. "value": "<templateName[0]>",
  85. "filename": "hbase-site.xml"
  86. },
  87. /**********************************************webhcat-site***************************************/
  88. {
  89. "name": "templeton.zookeeper.hosts",
  90. "templateName": ["zookeeperserver_hosts"],
  91. "foreignKey": null,
  92. "value": "<templateName[0]>",
  93. "filename": "webhcat-site.xml"
  94. }
  95. ];
  96. /**
  97. * Configs consists of 2 types: Computed values, which cannot be modified by user
  98. * and overridable values, which user can modify. We provide interface how to get all of this
  99. * configs separately
  100. * @type {Object}
  101. */
  102. module.exports = {
  103. checkPrecondition: function () {
  104. return configs.filter(function (config) {
  105. return ((!config.precondition) || (config.precondition()));
  106. });
  107. },
  108. all: function (skipPreconditionCheck) {
  109. if (skipPreconditionCheck) {
  110. return configs.slice(0);
  111. } else {
  112. return this.checkPrecondition().slice(0);
  113. }
  114. },
  115. overridable: function (skipPreconditionCheck) {
  116. if (skipPreconditionCheck) {
  117. return configs.filterProperty('foreignKey');
  118. } else {
  119. return this.checkPrecondition().filterProperty('foreignKey');
  120. }
  121. },
  122. computed: function (skipPreconditionCheck) {
  123. if (skipPreconditionCheck) {
  124. return configs.filterProperty('foreignKey', null);
  125. } else {
  126. return this.checkPrecondition().filterProperty('foreignKey', null);
  127. }
  128. }
  129. };