step5_controller.js 5.5 KB

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