config_mapping.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. /********************GLUSTERFS*************************************/
  70. {
  71. "name": "fs.glusterfs.impl",
  72. "templateName": ["fs_glusterfs_impl"],
  73. "foreignKey": null,
  74. "value": "<templateName[0]>",
  75. "filename": "core-site.xml"
  76. },
  77. {
  78. "name": "fs.glusterfs.volname",
  79. "templateName": ["fs_glusterfs_volname"],
  80. "foreignKey": null,
  81. "value": "<templateName[0]>",
  82. "filename": "core-site.xml"
  83. },
  84. {
  85. "name": "fs.glusterfs.mount",
  86. "templateName": ["fs_glusterfs_mount"],
  87. "foreignKey": null,
  88. "value": "<templateName[0]>",
  89. "filename": "core-site.xml"
  90. },
  91. {
  92. "name": "fs.glusterfs.getfattrcmd",
  93. "templateName": ["fs_glusterfs_getfattrcmd"],
  94. "foreignKey": null,
  95. "value": "<templateName[0]>",
  96. "filename": "core-site.xml"
  97. },
  98. {
  99. "name": "fs.AbstractFileSystem.glusterfs.impl",
  100. "templateName": ["fs_AbstractFileSystem_glusterfs_impl"],
  101. "foreignKey": null,
  102. "value": "<templateName[0]>",
  103. "filename": "core-site.xml"
  104. },
  105. /**********************************************hbase-site***************************************/
  106. {
  107. "name": "hbase.zookeeper.quorum",
  108. "templateName": ["zookeeperserver_hosts"],
  109. "foreignKey": null,
  110. "value": "<templateName[0]>",
  111. "filename": "hbase-site.xml"
  112. },
  113. /**********************************************webhcat-site***************************************/
  114. {
  115. "name": "templeton.zookeeper.hosts",
  116. "templateName": ["zookeeperserver_hosts"],
  117. "foreignKey": null,
  118. "value": "<templateName[0]>",
  119. "filename": "webhcat-site.xml"
  120. }
  121. ];
  122. /**
  123. * Configs consists of 2 types: Computed values, which cannot be modified by user
  124. * and overridable values, which user can modify. We provide interface how to get all of this
  125. * configs separately
  126. * @type {Object}
  127. */
  128. module.exports = {
  129. checkPrecondition: function () {
  130. return configs.filter(function (config) {
  131. return ((!config.precondition) || (config.precondition()));
  132. });
  133. },
  134. all: function (skipPreconditionCheck) {
  135. if (skipPreconditionCheck) {
  136. return configs.slice(0);
  137. } else {
  138. return this.checkPrecondition().slice(0);
  139. }
  140. },
  141. overridable: function (skipPreconditionCheck) {
  142. if (skipPreconditionCheck) {
  143. return configs.filterProperty('foreignKey');
  144. } else {
  145. return this.checkPrecondition().filterProperty('foreignKey');
  146. }
  147. },
  148. computed: function (skipPreconditionCheck) {
  149. if (skipPreconditionCheck) {
  150. return configs.filterProperty('foreignKey', null);
  151. } else {
  152. return this.checkPrecondition().filterProperty('foreignKey', null);
  153. }
  154. }
  155. };