cluster.js 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. var url = App.formatUrl(
  29. App.apiPrefix + "/stacks",
  30. {},
  31. '/data/wizard/stack/stacks.json'
  32. );
  33. var upgradeVersion = this.get('upgradeVersion') || App.defaultStackVersion;
  34. var installedServices = {};
  35. var newServices = {};
  36. $.ajax({
  37. type: "GET",
  38. url: url,
  39. async: false,
  40. dataType: 'json',
  41. timeout: App.timeout,
  42. success: function (data) {
  43. upgradeVersion = upgradeVersion.replace(/HDP-/, '');
  44. data.filterProperty('name', 'HDP').mapProperty('version').forEach(function(version){
  45. upgradeVersion = (upgradeVersion < version) ? version : upgradeVersion;
  46. });
  47. installedServices = data.findProperty('version', App.currentStackVersion.replace(/HDP-/, ''));
  48. newServices = data.findProperty('version', upgradeVersion);
  49. upgradeVersion = 'HDP-' + upgradeVersion;
  50. },
  51. error: function (request, ajaxOptions, error) {
  52. console.log('Error message is: ' + request.responseText);
  53. },
  54. statusCode: require('data/statusCodes')
  55. });
  56. this.set('upgradeVersion', upgradeVersion);
  57. this.parseServicesInfo(installedServices, newServices);
  58. }
  59. }.observes('App.router.clusterController.isLoaded'),
  60. /**
  61. * parse services info(versions, description) by version
  62. */
  63. parseServicesInfo: function (oldServices, newServices) {
  64. var result = [];
  65. var installedServices = App.Service.find().mapProperty('serviceName');
  66. var displayOrderConfig = require('data/services');
  67. if(oldServices.services && newServices.services){
  68. // loop through all the service components
  69. for (var i = 0; i < displayOrderConfig.length; i++) {
  70. var entry = oldServices.services.findProperty("name", displayOrderConfig[i].serviceName);
  71. if (installedServices.contains(entry.name)) {
  72. var myService = Em.Object.create({
  73. serviceName: entry.name,
  74. displayName: displayOrderConfig[i].displayName,
  75. isDisabled: i === 0,
  76. isSelected: true,
  77. isInstalled: false,
  78. isHidden: displayOrderConfig[i].isHidden,
  79. description: entry.comment,
  80. version: entry.version,
  81. newVersion: newServices.services.findProperty("name", displayOrderConfig[i].serviceName).version
  82. });
  83. //From 1.3.0 for Hive we display only "Hive" (but it installes HCat and WebHCat as well)
  84. if (this.get('upgradeVersion').replace(/HDP-/, '') >= '1.3.0' && displayOrderConfig[i].serviceName == 'HIVE') {
  85. myService.set('displayName', 'Hive');
  86. }
  87. result.push(myService);
  88. }
  89. }
  90. }
  91. this.set('services', result);
  92. }
  93. });