item.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. var batchUtils = require('utils/batch_scheduled_requests');
  20. App.MainServiceItemView = Em.View.extend({
  21. templateName: require('templates/main/service/item'),
  22. maintenance: function(){
  23. var options = [];
  24. var service = this.get('controller.content');
  25. var hosts = App.Host.find().content.length;
  26. var allMasters = this.get('controller.content.hostComponents').filterProperty('isMaster').mapProperty('componentName').uniq();
  27. var disabled = this.get('controller.isStopDisabled');
  28. var serviceName = service.get('serviceName');
  29. if (service.get('isClientsOnly')) {
  30. var disableRefreshConfgis = !service.get('isRestartRequired');
  31. if (serviceName != 'TEZ') {
  32. options.push({action: 'runSmokeTest', cssClass: 'icon-thumbs-up-alt', 'label': Em.I18n.t('services.service.actions.run.smoke')});
  33. }
  34. options.push({action: 'refreshConfigs', cssClass: 'icon-refresh', 'label': Em.I18n.t('hosts.host.details.refreshConfigs'), disabled: disableRefreshConfgis});
  35. } else {
  36. // Restart All action
  37. options.push({action:'restartAllHostComponents', cssClass: 'icon-forward', context: serviceName, 'label': Em.I18n.t('restart.service.all'), disabled: false});
  38. // Rolling Restart action
  39. var rrComponentName = batchUtils.getRollingRestartComponentName(serviceName);
  40. if (rrComponentName) {
  41. var label = Em.I18n.t('rollingrestart.dialog.title').format(App.format.role(rrComponentName));
  42. options.push({action:'rollingRestart', cssClass: 'icon-time', context: rrComponentName, 'label': label, disabled: false});
  43. }
  44. // Service Check and Reassign Master actions
  45. switch (serviceName) {
  46. case 'GANGLIA':
  47. case 'NAGIOS':
  48. break;
  49. case 'YARN':
  50. case 'HDFS':
  51. case 'MAPREDUCE':
  52. if (App.supports.reassignMaster && hosts > 1) {
  53. allMasters.forEach(function (hostComponent) {
  54. if (App.get('components.reassignable').contains(hostComponent)) {
  55. options.push({action: 'reassignMaster', context: hostComponent, cssClass: 'icon-share-alt',
  56. 'label': Em.I18n.t('services.service.actions.reassign.master').format(App.format.role(hostComponent)), disabled: false});
  57. }
  58. })
  59. }
  60. default:
  61. options.push({action: 'runSmokeTest', cssClass: 'icon-thumbs-up-alt', 'label': Em.I18n.t('services.service.actions.run.smoke'), disabled:disabled});
  62. }
  63. var requestLabel = service.get('passiveState') === "OFF" ?
  64. Em.I18n.t('passiveState.turnOnFor').format(App.Service.DisplayNames[serviceName]) :
  65. Em.I18n.t('passiveState.turnOffFor').format(App.Service.DisplayNames[serviceName]);
  66. var passiveLabel = service.get('passiveState') === "OFF" ?
  67. Em.I18n.t('passiveState.turnOn') :
  68. Em.I18n.t('passiveState.turnOff');
  69. options.push({action:'turnOnOffPassive', cssClass: 'icon-medkit', context:requestLabel, 'label':passiveLabel , disabled: false});
  70. }
  71. return options;
  72. }.property('controller.content', 'controller.isStopDisabled'),
  73. isMaintenanceActive: function() {
  74. return this.get('maintenance').length !== 0;
  75. }.property('maintenance'),
  76. hasConfigTab: function(){
  77. return this.get("controller.content.isConfigurable");
  78. }.property('controller.content.isConfigurable'),
  79. didInsertElement: function () {
  80. this.get('controller').setStartStopState();
  81. },
  82. service:function () {
  83. var svc = this.get('controller.content');
  84. var svcName = svc.get('serviceName');
  85. if (svcName) {
  86. switch (svcName.toLowerCase()) {
  87. case 'hdfs':
  88. svc = App.HDFSService.find().objectAt(0);
  89. break;
  90. case 'yarn':
  91. svc = App.YARNService.find().objectAt(0);
  92. break;
  93. case 'mapreduce':
  94. svc = App.MapReduceService.find().objectAt(0);
  95. break;
  96. case 'hbase':
  97. svc = App.HBaseService.find().objectAt(0);
  98. break;
  99. case 'flume':
  100. svc = App.FlumeService.find().objectAt(0);
  101. break;
  102. default:
  103. break;
  104. }
  105. }
  106. return svc;
  107. }.property('controller.content.serviceName').volatile()
  108. });