step2_controller.js 4.3 KB

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