step2_controller.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. require('controllers/wizard/step5_controller');
  20. App.HighAvailabilityWizardStep2Controller = App.WizardStep5Controller.extend({
  21. name:"highAvailabilityWizardStep2Controller",
  22. /**
  23. * Load services info to appropriate variable and return masterComponentHosts
  24. * @return Array
  25. */
  26. masterHostMapping:function () {
  27. var mapping = [], mappingObject, self = this, mappedHosts, hostObj, hostInfo;
  28. //get the unique assigned hosts and find the master services assigned to them
  29. mappedHosts = this.get("selectedServicesMasters").mapProperty("selectedHost").uniq();
  30. mappedHosts.forEach(function (item) {
  31. hostObj = self.get("hosts").findProperty("host_name", item);
  32. console.log("Name of the host is: " + hostObj.host_name);
  33. var masterServices = self.get("selectedServicesMasters").filterProperty("selectedHost", item);
  34. masterServices.forEach(function(item){
  35. if(item.component_name == "NAMENODE" || item.component_name == "JOURNALNODE"){
  36. item.set('color','green');
  37. }else{
  38. item.set('color','grey');
  39. }
  40. })
  41. mappingObject = Ember.Object.create({
  42. host_name:item,
  43. hostInfo:hostObj.host_info,
  44. masterServices:masterServices
  45. });
  46. mapping.pushObject(mappingObject);
  47. }, this);
  48. mapping.sort(this.sortHostsByName);
  49. return mapping;
  50. }.property("selectedServicesMasters.@each.selectedHost"),
  51. /**
  52. * Put master components to <code>selectedServicesMasters</code>, which will be automatically rendered in template
  53. * @param masterComponents
  54. */
  55. renderComponents:function (masterComponents) {
  56. var services = this.get('content.services')
  57. .filterProperty('isInstalled', true).filterProperty('isInstalled', true).mapProperty('serviceName'); //list of shown services
  58. var result = [];
  59. var curNameNode = masterComponents.findProperty('component_name',"NAMENODE");
  60. curNameNode.isCurNameNode = true;
  61. curNameNode.zId = 0;
  62. //Create JOURNALNODE
  63. for (var index = 0; index < 3; index++) {
  64. masterComponents.push(
  65. {
  66. availableHosts: [],
  67. component_name: "JOURNALNODE",
  68. display_name: "Journal Node",
  69. isHiveCoHost: false,
  70. isInstalled: false,
  71. selectedHost: this.get("hosts")[index].get("host_name"),
  72. serviceId: "HDFS",
  73. zId: index
  74. }
  75. )
  76. }
  77. //Create Additional NameNode
  78. masterComponents.push(
  79. {
  80. availableHosts: [],
  81. component_name: "NAMENODE",
  82. display_name: "NameNode",
  83. isHiveCoHost: false,
  84. isInstalled: false,
  85. selectedHost: this.get("hosts").mapProperty('host_name').without(curNameNode.selectedHost)[0],
  86. serviceId: "HDFS",
  87. isAddNameNode: true,
  88. zId: 1
  89. }
  90. )
  91. masterComponents.forEach(function (item) {
  92. var componentObj = Ember.Object.create(item);
  93. componentObj.set("availableHosts", this.get("hosts"));
  94. result.push(componentObj);
  95. }, this);
  96. this.set("selectedServicesMasters", result);
  97. var components = result.filterProperty('component_name',"NAMENODE");
  98. components.push.apply(components, result.filterProperty('component_name',"JOURNALNODE"));
  99. this.set('servicesMasters', components);
  100. this.rebalanceComponentHosts("NAMENODE");
  101. this.rebalanceComponentHosts("JOURNALNODE");
  102. }
  103. });