step5_controller.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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').findProperty('isAddNameNode').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. var hdfsSiteProperties = data.items.findProperty('type', 'hdfs-site').properties;
  76. var coreSiteProperties = data.items.findProperty('type', 'core-site').properties;
  77. var self = this;
  78. App.ajax.send({
  79. name: 'admin.high_availability.save_configs',
  80. sender: this,
  81. data: {
  82. siteName: 'hdfs-site',
  83. properties: hdfsSiteProperties
  84. },
  85. error: 'onTaskError'
  86. }).done(function() {
  87. App.ajax.send({
  88. name: 'admin.high_availability.save_configs',
  89. sender: self,
  90. data: {
  91. siteName: 'core-site',
  92. properties: coreSiteProperties
  93. },
  94. error: 'onTaskError',
  95. success: 'installHDFSClients'
  96. });
  97. });
  98. },
  99. installHDFSClients: function () {
  100. var nnHostNames = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE').mapProperty('hostName');
  101. var jnHostNames = this.get('content.masterComponentHosts').filterProperty('component', 'JOURNALNODE').mapProperty('hostName');
  102. var hostNames = nnHostNames.concat(jnHostNames).uniq();
  103. this.createComponent('HDFS_CLIENT', hostNames);
  104. App.router.get(this.get('content.controllerName')).saveHdfsClientHosts(hostNames);
  105. App.clusterStatus.setClusterStatus({
  106. clusterName: this.get('content.cluster.name'),
  107. clusterState: 'HIGH_AVAILABILITY_DEPLOY',
  108. wizardControllerName: this.get('content.controllerName'),
  109. localdb: App.db.data
  110. });
  111. }
  112. });