move_namenode_config_initializer.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. require('utils/configs/move_component_config_initializer_class');
  20. /**
  21. * Initializer for configs which should be affected when NameNode is moved from one host to another
  22. * If NameNode HA-mode is already activated, several configs are also updated
  23. *
  24. * @instance MoveComponentConfigInitializerClass
  25. */
  26. App.MoveNameNodeConfigInitializer = App.MoveComponentConfigInitializerClass.create({
  27. initializers: {
  28. 'dfs.namenode.http-address.{{namespaceId}}.{{suffix}}': App.MoveComponentConfigInitializerClass.getTargetHostConfig(50070),
  29. 'dfs.namenode.https-address.{{namespaceId}}.{{suffix}}': App.MoveComponentConfigInitializerClass.getTargetHostConfig(50470),
  30. 'dfs.namenode.rpc-address.{{namespaceId}}.{{suffix}}': App.MoveComponentConfigInitializerClass.getTargetHostConfig(8020)
  31. },
  32. uniqueInitializers: {
  33. 'instance.volumes': '_initInstanceVolumes',
  34. 'instance.volumes.replacements': '_initInstanceVolumesReplacements',
  35. 'hbase.rootdir': '_initHbaseRootDir',
  36. 'hawq_dfs_url': '_initHawqDfsUrl'
  37. },
  38. /**
  39. * Unique initializer for <code>instance.volumes</code>-config
  40. * Value example: 'hdfs://host1:8020/apps/accumulo/data'
  41. *
  42. * @param {configProperty} configProperty
  43. * @param {extendedTopologyLocalDB} localDB
  44. * @param {reassignComponentDependencies} dependencies
  45. * @returns {object}
  46. * @private
  47. * @method _initInstanceVolumes
  48. */
  49. _initInstanceVolumes: function (configProperty, localDB, dependencies) {
  50. if (!App.get('isHaEnabled') && localDB.installedServices.contains('ACCUMULO')) {
  51. var value = Em.get(configProperty, 'value');
  52. value = value.replace(/\/\/[^\/]*/, '//' + dependencies.targetHostName + ':8020');
  53. Em.set(configProperty, 'value', value);
  54. }
  55. return configProperty;
  56. },
  57. /**
  58. * Unique initializer for <code>instance.volumes.replacements</code>-config
  59. * Value example: 'hdfs://host1:8020/apps/accumulo/data hdfs://host2:8020/apps/accumulo/data'
  60. *
  61. * @param {configProperty} configProperty
  62. * @param {extendedTopologyLocalDB} localDB
  63. * @param {reassignComponentDependencies} dependencies
  64. * @returns {object}
  65. * @private
  66. * @method _initInstanceVolumesReplacements
  67. */
  68. _initInstanceVolumesReplacements: function (configProperty, localDB, dependencies) {
  69. if (!App.get('isHaEnabled') && localDB.installedServices.contains('ACCUMULO')) {
  70. var target = 'hdfs://' + dependencies.targetHostName + ':8020' + '/apps/accumulo/data';
  71. var source = 'hdfs://' + dependencies.sourceHostName + ':8020' + '/apps/accumulo/data';
  72. var value = source + ' ' + target;
  73. Em.set(configProperty, 'value', value);
  74. }
  75. return configProperty;
  76. },
  77. /**
  78. * Unique initializer for <code>hbase.rootdir</code>-config (for HIVE service)
  79. *
  80. * @param {configProperty} configProperty
  81. * @param {extendedTopologyLocalDB} localDB
  82. * @param {reassignComponentDependencies} dependencies
  83. * @returns {object}
  84. * @private
  85. * @method _initHbaseRootDir
  86. */
  87. _initHbaseRootDir: function (configProperty, localDB, dependencies) {
  88. if (!App.get('isHaEnabled') && localDB.installedServices.contains('HBASE') && 'hbase-site' === configProperty.filename) {
  89. var value = Em.get(configProperty, 'value');
  90. value = value.replace(/\/\/[^\/]*/, '//' + dependencies.targetHostName + ':8020');
  91. Em.set(configProperty, 'value', value);
  92. }
  93. return configProperty;
  94. },
  95. /**
  96. * Unique initializer for <code>hawq_dfs_url</code>-config (for HAWQ service)
  97. *
  98. * @param {configProperty} configProperty
  99. * @param {extendedTopologyLocalDB} localDB
  100. * @param {reassignComponentDependencies} dependencies
  101. * @returns {object}
  102. * @private
  103. * @method _initHawqDfsUrl
  104. */
  105. _initHawqDfsUrl: function (configProperty, localDB, dependencies) {
  106. if (!App.get('isHaEnabled') && localDB.installedServices.contains('HAWQ') && 'hawq-site' === configProperty.filename) {
  107. var value = Em.get(configProperty, 'value');
  108. value = value.replace(/(.*):/, dependencies.targetHostName + ':');
  109. Em.set(configProperty, 'value', value);
  110. }
  111. return configProperty;
  112. }
  113. });