step5_controller.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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: 'admin.high_availability.stop_all_services',
  28. sender: this,
  29. success: 'startPolling',
  30. error: 'onTaskError'
  31. });
  32. },
  33. installNameNode: function () {
  34. var hostName = this.get('content.masterComponentHosts').findProperty('isAddNameNode').hostName;
  35. this.createComponent('NAMENODE', hostName);
  36. },
  37. installJournalNodes: function () {
  38. App.ajax.send({
  39. name: 'admin.high_availability.create_journalnode',
  40. sender: this,
  41. success: 'onJournalNodeCreate',
  42. error: 'onJournalNodeCreate'
  43. });
  44. },
  45. onJournalNodeCreate: function () {
  46. var hostNames = this.get('content.masterComponentHosts').filterProperty('component', 'JOURNALNODE').mapProperty('hostName');
  47. this.createComponent('JOURNALNODE', hostNames);
  48. },
  49. startJournalNodes: function () {
  50. var hostNames = this.get('content.masterComponentHosts').filterProperty('component', 'JOURNALNODE').mapProperty('hostName');
  51. this.startComponent('JOURNALNODE', hostNames);
  52. },
  53. disableSNameNode: function () {
  54. var hostName = this.get('content.masterComponentHosts').findProperty('component', 'SECONDARY_NAMENODE').hostName;
  55. App.ajax.send({
  56. name: 'admin.high_availability.maintenance_mode',
  57. sender: this,
  58. data: {
  59. hostName: hostName,
  60. componentName: 'SECONDARY_NAMENODE'
  61. },
  62. success: 'onTaskCompleted',
  63. error: 'onTaskError'
  64. });
  65. },
  66. reconfigureHDFS: function () {
  67. var data = this.get('content.serviceConfigProperties');
  68. var hdfsSiteProperties = data.items.findProperty('type', 'hdfs-site').properties;
  69. var coreSiteProperties = data.items.findProperty('type', 'core-site').properties;
  70. this.set('configsSaved', false);
  71. App.ajax.send({
  72. name: 'admin.high_availability.save_configs',
  73. sender: this,
  74. data: {
  75. siteName: 'hdfs-site',
  76. properties: hdfsSiteProperties
  77. },
  78. success: 'installHDFSClients',
  79. error: 'onTaskError'
  80. });
  81. App.ajax.send({
  82. name: 'admin.high_availability.save_configs',
  83. sender: this,
  84. data: {
  85. siteName: 'core-site',
  86. properties: coreSiteProperties
  87. },
  88. success: 'installHDFSClients',
  89. error: 'onTaskError'
  90. });
  91. },
  92. configsSaved: false,
  93. installHDFSClients: function () {
  94. if (!this.get('configsSaved')) {
  95. this.set('configsSaved', true);
  96. return;
  97. }
  98. var nnHostNames = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE').mapProperty('hostName');
  99. var jnHostNames = this.get('content.masterComponentHosts').filterProperty('component', 'JOURNALNODE').mapProperty('hostName');
  100. var hostNames = $.extend([], nnHostNames, jnHostNames);
  101. this.createComponent('HDFS_CLIENT', hostNames);
  102. App.router.get(this.get('content.controllerName')).saveHdfsClientHosts(hostNames);
  103. App.clusterStatus.setClusterStatus({
  104. clusterName: this.get('content.cluster.name'),
  105. clusterState: 'HIGH_AVAILABILITY_DEPLOY',
  106. wizardControllerName: this.get('content.controllerName'),
  107. localdb: App.db.data
  108. });
  109. }
  110. });