step5_controller.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. App.HighAvailabilityWizardStep5Controller = App.HighAvailabilityProgressPageController.extend({
  20. name:"highAvailabilityWizardStep5Controller",
  21. commands: ['stopServices', 'installNameNode', 'installJournalNodes', 'reconfigureHDFS', 'startJournalNodes', 'disableSNameNode'],
  22. hdfsSiteTag : "",
  23. coreSiteTag : "",
  24. installNameNode: function () {
  25. var hostName = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE').findProperty('isInstalled', false).hostName;
  26. this.createInstallComponentTask('NAMENODE', hostName, "HDFS");
  27. },
  28. installJournalNodes: function () {
  29. var hostNames = this.get('content.masterComponentHosts').filterProperty('component', 'JOURNALNODE').mapProperty('hostName');
  30. this.createInstallComponentTask('JOURNALNODE', hostNames, "HDFS");
  31. },
  32. startJournalNodes: function () {
  33. var hostNames = this.get('content.masterComponentHosts').filterProperty('component', 'JOURNALNODE').mapProperty('hostName');
  34. this.updateComponent('JOURNALNODE', hostNames, "HDFS", "Start");
  35. },
  36. disableSNameNode: function () {
  37. var hostName = this.get('content.masterComponentHosts').findProperty('component', 'SECONDARY_NAMENODE').hostName;
  38. App.ajax.send({
  39. name: 'common.host.host_component.passive',
  40. sender: this,
  41. data: {
  42. hostName: hostName,
  43. passive_state: "ON",
  44. componentName: 'SECONDARY_NAMENODE'
  45. },
  46. success: 'onTaskCompleted',
  47. error: 'onTaskError'
  48. });
  49. },
  50. reconfigureHDFS: function () {
  51. var data = this.get('content.serviceConfigProperties');
  52. if (App.get('isKerberosEnabled')) {
  53. this.reconfigureSecureHDFS();
  54. } else {
  55. this.updateConfigProperties(data);
  56. }
  57. },
  58. /**
  59. * Update service configurations
  60. * @param {Object} data - config object to update
  61. */
  62. updateConfigProperties: function(data) {
  63. var siteNames = ['hdfs-site','core-site'];
  64. if (App.Service.find().someProperty('serviceName', 'RANGER')) {
  65. var hdfsPluginConfig = data.items.findProperty('type', 'ranger-hdfs-plugin-properties');
  66. if (hdfsPluginConfig) {
  67. if ('xasecure.audit.destination.hdfs.dir' in hdfsPluginConfig.properties) {
  68. siteNames.push('ranger-hdfs-plugin-properties');
  69. }
  70. }
  71. var hdfsAuditConfig = data.items.findProperty('type', 'ranger-hdfs-audit');
  72. if (hdfsAuditConfig) {
  73. if ('xasecure.audit.destination.hdfs.dir' in hdfsAuditConfig.properties) {
  74. siteNames.push('ranger-hdfs-audit');
  75. }
  76. }
  77. }
  78. var configData = this.reconfigureSites(siteNames, data, Em.I18n.t('admin.highAvailability.step4.save.configuration.note').format(App.format.role('NAMENODE', false)));
  79. App.ajax.send({
  80. name: 'common.service.configurations',
  81. sender: this,
  82. data: {
  83. desired_config: configData
  84. },
  85. error: 'onTaskError',
  86. success: 'installHDFSClients'
  87. });
  88. },
  89. installHDFSClients: function () {
  90. var nnHostNames = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE').mapProperty('hostName');
  91. var jnHostNames = this.get('content.masterComponentHosts').filterProperty('component', 'JOURNALNODE').mapProperty('hostName');
  92. var hostNames = nnHostNames.concat(jnHostNames).uniq();
  93. this.createInstallComponentTask('HDFS_CLIENT', hostNames, 'HDFS');
  94. App.router.get(this.get('content.controllerName')).saveHdfsClientHosts(hostNames);
  95. App.clusterStatus.setClusterStatus({
  96. clusterName: this.get('content.cluster.name'),
  97. clusterState: 'HIGH_AVAILABILITY_DEPLOY',
  98. wizardControllerName: this.get('content.controllerName'),
  99. localdb: App.db.data
  100. });
  101. },
  102. /**
  103. * Process configurations for hdfs on kerberized cluster.
  104. * Secure properties will be applied to hdfs and core site after installing JournalNode.
  105. * For this case we need to pull updated configurations from API, merge them with configurations created
  106. * during `Review` step and store new configurations.
  107. */
  108. reconfigureSecureHDFS: function() {
  109. App.router.get('highAvailabilityWizardStep3Controller').loadConfigsTags.call(this);
  110. },
  111. onLoadConfigsTags: function() {
  112. App.router.get('highAvailabilityWizardStep3Controller').onLoadConfigsTags.apply(this, [].slice.call(arguments));
  113. },
  114. onLoadConfigs: function(data) {
  115. var self = this;
  116. var configController = App.router.get('highAvailabilityWizardStep3Controller');
  117. var configItems = data.items.map(function(item) {
  118. var fileName = Em.get(item, 'type');
  119. var configTypeObject = self.get('content.serviceConfigProperties').items.findProperty('type', fileName);
  120. if (configTypeObject) {
  121. $.extend(item.properties, configTypeObject.properties);
  122. }
  123. return item;
  124. });
  125. configItems = configController.removeConfigs(configController.get('configsToRemove'), {items: configItems});
  126. this.updateConfigProperties(configItems);
  127. }
  128. });