cluster.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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.MainAdminClusterController = Em.Controller.extend({
  20. name:'mainAdminClusterController',
  21. services: [],
  22. upgradeVersion: '',
  23. /**
  24. * get the newest version of HDP from server
  25. */
  26. updateUpgradeVersion: function(){
  27. if(App.router.get('clusterController.isLoaded')){
  28. App.ajax.send({
  29. name: 'cluster.update_upgrade_version',
  30. sender: this,
  31. success: 'updateUpgradeVersionSuccessCallback',
  32. error: 'updateUpgradeVersionErrorCallback'
  33. });
  34. }
  35. }.observes('App.router.clusterController.isLoaded', 'App.currentStackVersion'),
  36. updateUpgradeVersionSuccessCallback: function(data) {
  37. var upgradeVersion = this.get('upgradeVersion') || App.defaultStackVersion;
  38. var currentStack = {};
  39. var upgradeStack = {};
  40. var currentVersion = App.currentStackVersion.replace(/HDP-/, '');
  41. var minUpgradeVersion = currentVersion;
  42. upgradeVersion = upgradeVersion.replace(/HDP-/, '');
  43. data.items.mapProperty('Versions.stack_version').forEach(function(version){
  44. upgradeVersion = (upgradeVersion < version) ? version : upgradeVersion;
  45. });
  46. currentStack = data.items.findProperty('Versions.stack_version', currentVersion);
  47. upgradeStack = data.items.findProperty('Versions.stack_version', upgradeVersion);
  48. minUpgradeVersion = upgradeStack.Versions.min_upgrade_version;
  49. if(minUpgradeVersion && (minUpgradeVersion > currentVersion)){
  50. upgradeVersion = currentVersion;
  51. upgradeStack = currentStack;
  52. }
  53. upgradeVersion = 'HDP-' + upgradeVersion;
  54. this.set('upgradeVersion', upgradeVersion);
  55. if(currentStack && upgradeStack) {
  56. this.parseServicesInfo(currentStack, upgradeStack);
  57. }
  58. else {
  59. console.log('HDP stack doesn\'t have services with defaultStackVersion');
  60. }
  61. },
  62. updateUpgradeVersionErrorCallback: function(request, ajaxOptions, error) {
  63. console.log('Error message is: ' + request.responseText);
  64. console.log('HDP stack doesn\'t have services with defaultStackVersion');
  65. },
  66. /**
  67. * parse services info(versions, description) by version
  68. */
  69. parseServicesInfo: function (currentStack, upgradeStack) {
  70. var result = [];
  71. var installedServices = App.Service.find().mapProperty('serviceName');
  72. var displayOrderConfig = require('data/services');
  73. if(currentStack.stackServices.length && upgradeStack.stackServices.length){
  74. // loop through all the service components
  75. for (var i = 0; i < displayOrderConfig.length; i++) {
  76. var entry = currentStack.stackServices.
  77. findProperty("StackServices.service_name", displayOrderConfig[i].serviceName);
  78. if (entry) {
  79. entry = entry.StackServices;
  80. if (installedServices.contains(entry.service_name)) {
  81. var myService = Em.Object.create({
  82. serviceName: entry.service_name,
  83. displayName: displayOrderConfig[i].displayName,
  84. isDisabled: i === 0,
  85. isSelected: true,
  86. isInstalled: false,
  87. isHidden: displayOrderConfig[i].isHidden,
  88. description: entry.comments,
  89. version: entry.service_version,
  90. newVersion: upgradeStack.stackServices.
  91. findProperty("StackServices.service_name", displayOrderConfig[i].serviceName).
  92. StackServices.service_version
  93. });
  94. //From 1.3.0 for Hive we display only "Hive" (but it install HCat and WebHCat as well)
  95. if (this.get('upgradeVersion').replace(/HDP-/, '') >= '1.3.0' && displayOrderConfig[i].serviceName == 'HIVE') {
  96. myService.set('displayName', 'Hive');
  97. }
  98. result.push(myService);
  99. }
  100. }
  101. else {
  102. console.warn('Service not found - ', displayOrderConfig[i].serviceName);
  103. }
  104. }
  105. }
  106. this.set('services', result);
  107. }
  108. });