123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- /**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- var App = require('app');
- App.MainHostSummaryView = Em.View.extend({
- templateName: require('templates/main/host/summary'),
- content: function () {
- return App.router.get('mainHostDetailsController.content');
- }.property('App.router.mainHostDetailsController.content'),
- showGangliaCharts: function () {
- var name = this.get('content.hostName');
- var gangliaMobileUrl = App.router.get('clusterController.gangliaUrl') + "/mobile_helper.php?show_host_metrics=1&h=" + name + "&c=HDPNameNode&r=hour&cs=&ce=";
- window.open(gangliaMobileUrl);
- },
- /**
- * @type: [{String}]
- */
- decommissionDataNodeHostNames: null,
- loadDecommissionNodesList: function () {
- var self = this;
- var clusterName = App.router.get('clusterController.clusterName');
- var persistUrl = App.apiPrefix + '/persist';
- var clusterUrl = App.apiPrefix + '/clusters/' + clusterName;
- var getConfigAjax = {
- type: 'GET',
- url: persistUrl,
- dataType: 'json',
- timeout: App.timeout,
- success: function (data) {
- if (data && data.decommissionDataNodesTag) {
- // We know the tag which contains the decommisioned nodes.
- var configsUrl = clusterUrl + '/configurations?type=hdfs-exclude-file&tag=' + data.decommissionDataNodesTag;
- var decomNodesAjax = {
- type: 'GET',
- url: configsUrl,
- dataType: 'json',
- timeout: App.timeout,
- success: function (data) {
- if (data && data.items) {
- var csv = data.items[0].properties.datanodes;
- self.set('decommissionDataNodeHostNames', csv.split(','));
- }
- },
- error: function (xhr, textStatus, errorThrown) {
- console.log(textStatus);
- console.log(errorThrown);
- }
- };
- jQuery.ajax(decomNodesAjax);
- }
- },
- error: function (xhr, textStatus, errorThrown) {
- // No tag pointer in persist. Rely on service's decomNodes.
- var hdfsSvcs = App.HDFSService.find();
- if (hdfsSvcs && hdfsSvcs.get('length') > 0) {
- var hdfsSvc = hdfsSvcs.objectAt(0);
- if (hdfsSvc) {
- var hostNames = [];
- var decomNodes = hdfsSvc.get('decommissionDataNodes');
- decomNodes.forEach(function (decomNode) {
- hostNames.push(decomNode.get('hostName'));
- });
- self.set('decommissionDataNodeHostNames', hostNames);
- }
- }
- }
- }
- jQuery.ajax(getConfigAjax);
- },
- didInsertElement: function () {
- this.loadDecommissionNodesList();
- },
- sortedComponents: function() {
- var slaveComponents = [];
- var masterComponents = [];
- this.get('content.hostComponents').forEach(function(component){
- if(component.get('workStatus') != 'INSTALLING'){
- if(component.get('isMaster')){
- masterComponents.push(component);
- } else if(component.get('isSlave')) {
- slaveComponents.push(component);
- }
- }
- }, this);
- return masterComponents.concat(slaveComponents);
- }.property('content', 'content.hostComponents.length'),
- clients: function(){
- var clients = [];
- this.get('content.hostComponents').forEach(function(component){
- if(!component.get('componentName')){
- //temporary fix because of different data in hostComponents and serviceComponents
- return;
- }
- if (!component.get('isSlave') && !component.get('isMaster')) {
- if (clients.length) {
- clients[clients.length-1].set('isLast', false);
- }
- component.set('isLast', true);
- clients.push(component);
- }
- }, this);
- return clients;
- }.property('content'),
- addableComponentObject: Em.Object.extend({
- componentName: '',
- displayName: function(){
- return App.format.role(this.get('componentName'));
- }.property('componentName')
- }),
- isAddComponent: function(){
- return this.get('content.healthClass') !== 'health-status-DEAD-YELLOW';
- }.property('content.healthClass'),
- addableComponents:function(){
- var components = [];
- var services = App.Service.find();
- var dataNodeExists = false;
- var taskTrackerExists = false;
- var regionServerExists = false;
- this.get('content.hostComponents').forEach(function(component) {
- switch (component.get('componentName')) {
- case 'DATANODE':
- dataNodeExists = true;
- break;
- case 'TASKTRACKER':
- taskTrackerExists = true;
- break;
- case 'HBASE_REGIONSERVER':
- regionServerExists = true;
- break;
- }
- }, this);
- if (!dataNodeExists) {
- components.pushObject(this.addableComponentObject.create({ 'componentName': 'DATANODE' }));
- }
- if (!taskTrackerExists && services.findProperty('serviceName', 'MAPREDUCE')) {
- components.pushObject(this.addableComponentObject.create({ 'componentName': 'TASKTRACKER' }));
- }
- if (!regionServerExists && services.findProperty('serviceName', 'HBASE')) {
- components.pushObject(this.addableComponentObject.create({ 'componentName': 'HBASE_REGIONSERVER' }));
- }
- return components;
- }.property('content', 'content.hostComponents.length'),
- ComponentView: Em.View.extend({
- content: null,
- didInsertElement: function () {
- if (this.get('isInProgress')) {
- this.doBlinking();
- }
- },
- hostComponent: function(){
- var hostComponent = null;
- var serviceComponent = this.get('content');
- var host = App.router.get('mainHostDetailsController.content');
- if(host){
- var hostComponent = host.get('hostComponents').findProperty('componentName', serviceComponent.get('componentName'));
- }
- return hostComponent;
- }.property('content', 'App.router.mainHostDetailsController.content'),
- workStatus: function(){
- var workStatus = this.get('content.workStatus');
- var hostComponent = this.get('hostComponent');
- if(hostComponent){
- workStatus = hostComponent.get('workStatus');
- }
- return workStatus;
- }.property('content.workStatus','hostComponent.workStatus'),
- statusClass: function(){
- var statusClass = null;
- if(this.get('isDataNode')){
- if(this.get('isDataNodeRecommissionAvailable') && this.get('isStart')){
- // Orange is shown only when service is started/starting and it is decommissioned.
- return 'health-status-DEAD-ORANGE';
- }
- }
- if(this.get('workStatus') === App.HostComponentStatus.install_failed){
- return 'icon-remove';
- }
- return 'health-status-' + App.HostComponentStatus.getKeyName(this.get('workStatus'));
- }.property('workStatus', 'isDataNodeRecommissionAvailable'),
- /**
- * For Upgrade failed state
- */
- isUpgradeFailed:function(){
- return App.HostComponentStatus.getKeyName(this.get('workStatus')) === "upgrade_failed";
- }.property("workStatus"),
- /**
- * For Install failed state
- */
- isInstallFailed:function(){
- return App.HostComponentStatus.getKeyName(this.get('workStatus')) === "install_failed";
- }.property("workStatus"),
- /**
- * Disable element while component is starting/stopping
- */
- disabledClass:function(){
- var workStatus = this.get('workStatus');
- if([App.HostComponentStatus.starting, App.HostComponentStatus.stopping, App.HostComponentStatus.unknown].contains(workStatus) ){
- return 'disabled';
- } else {
- return '';
- }
- }.property('workStatus'),
- /**
- * Do blinking for 1 minute
- */
- doBlinking : function(){
- var workStatus = this.get('workStatus');
- var self = this;
- var pulsate = [ App.HostComponentStatus.starting, App.HostComponentStatus.stopping ].contains(workStatus);
- if (!pulsate && this.get('isDataNode')) {
- var dataNodeComponent = this.get('content');
- if (dataNodeComponent)
- pulsate = dataNodeComponent.get('isDecommissioning');
- }
- if (pulsate) {
- this.$('.components-health').effect("pulsate", null, 1000, function () {
- self.doBlinking();
- });
- }
- },
- /**
- * Start blinking when host component is starting/stopping
- */
- startBlinking:function(){
- this.$('.components-health').stop(true, true);
- this.$('.components-health').css({opacity: 1.0});
- this.doBlinking();
- }.observes('workStatus'),
- isStart : function() {
- return (this.get('workStatus') === App.HostComponentStatus.started || this.get('workStatus') === App.HostComponentStatus.starting);
- }.property('workStatus'),
- isInProgress : function() {
- return (this.get('workStatus') === App.HostComponentStatus.stopping || this.get('workStatus') === App.HostComponentStatus.starting);
- }.property('workStatus'),
- /**
- * Shows whether we need to show Decommision/Recomission buttons
- */
- isDataNode: function() {
- return this.get('content.componentName') === 'DATANODE';
- }.property('content'),
- /**
- * Set in template via binding from parent view
- */
- decommissionDataNodeHostNames: null,
- /**
- * Decommission is available whenever the service is started.
- */
- isDataNodeDecommissionAvailable: function () {
- return this.get('isStart') && !this.get('isDataNodeRecommissionAvailable');
- }.property('isStart', 'isDataNodeRecommissionAvailable'),
- /**
- * Recommission is available only when this hostname shows up in the
- * 'decommissionDataNodeHostNames'
- */
- isDataNodeRecommissionAvailable: function () {
- var decommissionHostNames = this.get('decommissionDataNodeHostNames');
- var hostName = App.router.get('mainHostDetailsController.content.hostName');
- return decommissionHostNames!=null && decommissionHostNames.contains(hostName);
- }.property('App.router.mainHostDetailsController.content', 'decommissionDataNodeHostNames')
- }),
- timeSinceHeartBeat: function () {
- var d = this.get('content.lastHeartBeatTime');
- if (d) {
- return $.timeago(d);
- }
- return "";
- }.property('content.lastHeartBeatTime')
- });
|