step9_controller.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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.HighAvailabilityWizardStep9Controller = App.HighAvailabilityProgressPageController.extend({
  20. name:"highAvailabilityWizardStep9Controller",
  21. commands: ['startSecondNameNode', 'installZKFC', 'startZKFC', 'reconfigureHBase', 'startAllServices', 'deleteSNameNode'],
  22. hbaseSiteTag: "",
  23. clearStep: function () {
  24. this._super();
  25. if (!App.Service.find().someProperty('serviceName', 'HBASE')) {
  26. this.get('tasks').splice(this.get('tasks').findProperty('command', 'reconfigureHBase').get('id'), 1);
  27. }
  28. },
  29. startSecondNameNode: function () {
  30. var hostName = this.get('content.masterComponentHosts').findProperty('isAddNameNode', true).hostName;
  31. this.startComponent('NAMENODE', hostName);
  32. },
  33. installZKFC: function () {
  34. App.ajax.send({
  35. name: 'admin.high_availability.create_zkfc',
  36. sender: this,
  37. success: 'onZKFCCreate',
  38. error: 'onZKFCCreate'
  39. });
  40. },
  41. onZKFCCreate: function () {
  42. var hostName = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE').mapProperty('hostName');
  43. this.createComponent('ZKFC', hostName);
  44. },
  45. startZKFC: function () {
  46. var hostName = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE').mapProperty('hostName');
  47. this.startComponent('ZKFC', hostName);
  48. },
  49. reconfigureHBase: function () {
  50. this.loadConfigsTags();
  51. },
  52. loadConfigsTags: function () {
  53. App.ajax.send({
  54. name: 'config.tags',
  55. sender: this,
  56. success: 'onLoadConfigsTags',
  57. error: 'onTaskError'
  58. });
  59. },
  60. onLoadConfigsTags: function (data) {
  61. var hbaseSiteTag = data.Clusters.desired_configs['hbase-site'].tag;
  62. this.set("hbaseSiteTag", {name : "hbaseSiteTag", value : hbaseSiteTag});
  63. App.ajax.send({
  64. name: 'admin.high_availability.load_hbase_configs',
  65. sender: this,
  66. data: {
  67. hbaseSiteTag: hbaseSiteTag
  68. },
  69. success: 'onLoadConfigs',
  70. error: 'onTaskError'
  71. });
  72. },
  73. onLoadConfigs: function (data) {
  74. var hbaseSiteProperties = data.items.findProperty('type', 'hbase-site').properties;
  75. var nameServiceId = this.get('content.nameServiceId');
  76. //hbase-site configs changes
  77. hbaseSiteProperties['hbase.rootdir'] = hbaseSiteProperties['hbase.rootdir'].replace(/\/\/[^\/]*/, '//' + nameServiceId);
  78. App.ajax.send({
  79. name: 'admin.high_availability.save_configs',
  80. sender: this,
  81. data: {
  82. siteName: 'hbase-site',
  83. properties: hbaseSiteProperties
  84. },
  85. success: 'saveConfigTag',
  86. error: 'onTaskError'
  87. });
  88. },
  89. saveConfigTag: function () {
  90. App.router.get(this.get('content.controllerName')).saveConfigTag(this.get("hbaseSiteTag"));
  91. App.clusterStatus.setClusterStatus({
  92. clusterName: this.get('content.cluster.name'),
  93. clusterState: 'HIGH_AVAILABILITY_DEPLOY',
  94. wizardControllerName: this.get('content.controllerName'),
  95. localdb: App.db.data
  96. });
  97. this.onTaskCompleted();
  98. },
  99. startAllServices: function () {
  100. App.ajax.send({
  101. name: 'admin.high_availability.start_all_services',
  102. sender: this,
  103. success: 'startPolling',
  104. error: 'onTaskError'
  105. });
  106. },
  107. deleteSNameNode: function () {
  108. var hostName = this.get('content.masterComponentHosts').findProperty('component', 'SECONDARY_NAMENODE').hostName;
  109. App.ajax.send({
  110. name: 'admin.high_availability.delete_component',
  111. sender: this,
  112. data: {
  113. componentName: 'SECONDARY_NAMENODE',
  114. hostName: hostName
  115. },
  116. success: 'onTaskCompleted',
  117. error: 'onTaskError'
  118. });
  119. }
  120. });