123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- /**
- * 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');
- var uiEffects = require('utils/ui_effects');
- 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) {
- 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'),
- /**
- * Return host component text status
- */
- componentTextStatus: function () {
- var workStatus = this.get("workStatus");
- var componentTextStatus = this.get('content.componentTextStatus');
- var hostComponent = this.get('hostComponent');
- if (hostComponent) {
- componentTextStatus = hostComponent.get('componentTextStatus');
- if(this.get("isDataNode"))
- if(this.get('isDataNodeRecommissionAvailable')){
- if(App.HostComponentStatus.started == workStatus){
- componentTextStatus = "Decommissioning...";
- }else if(App.HostComponentStatus.stopped == workStatus){
- componentTextStatus = "Decommissioned";
- }
- }
- }
- return componentTextStatus;
- }.property('workStatus','isDataNodeRecommissionAvailable'),
- statusClass: function () {
- var statusClass = null;
- //If the component is DataNode
- if (this.get('isDataNode')) {
- if (this.get('isDataNodeRecommissionAvailable') && (this.get('isStart') || this.get('workStatus') == 'INSTALLED')) {
- return 'health-status-DEAD-ORANGE';
- }
- }
- //Class when install failed
- if (this.get('workStatus') === App.HostComponentStatus.install_failed) {
- return 'health-status-color-red icon-cog';
- }
- //Class when installing
- if (this.get('workStatus') === App.HostComponentStatus.installing) {
- return 'health-status-color-blue icon-cog';
- }
- //For all other cases
- return 'health-status-' + App.HostComponentStatus.getKeyName(this.get('workStatus'));
- }.property('workStatus', 'isDataNodeRecommissionAvailable', 'this.content.isDecommissioning'),
- /**
- * 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"),
- /**
- * 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 && workStatus != "INSTALLED") {
- pulsate = this.get('isDataNodeRecommissionAvailable');
- }
- }
- if (pulsate && !self.get('isBlinking')) {
- self.set('isBlinking', true);
- uiEffects.pulsate(self.$('.components-health'), 1000, function () {
- !self.get('isDestroyed') && self.set('isBlinking', false);
- 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','isDataNodeRecommissionAvailable'),
- isStart: function () {
- return (this.get('workStatus') == App.HostComponentStatus.started || this.get('workStatus') == App.HostComponentStatus.starting);
- }.property('workStatus'),
- /**
- * No action available while component is starting/stopping/unknown
- */
- noActionAvailable: function () {
- var workStatus = this.get('workStatus');
- if ([App.HostComponentStatus.starting, App.HostComponentStatus.stopping, App.HostComponentStatus.unknown].contains(workStatus)) {
- return "hidden";
- }else{
- return "";
- }
- }.property('workStatus'),
- isInProgress: function () {
- return (this.get('workStatus') === App.HostComponentStatus.stopping || this.get('workStatus') === App.HostComponentStatus.starting) || this.get('isDataNodeRecommissionAvailable');
- }.property('workStatus', 'isDataNodeRecommissionAvailable'),
- /**
- * Shows whether we need to show Decommision/Recomission buttons
- */
- isDataNode: function () {
- return this.get('content.componentName') === 'DATANODE';
- }.property('content'),
- isDecommissioning: function () {
- return this.get('isDataNode') && this.get("isDataNodeRecommissionAvailable");
- }.property("workStatus", "isDataNodeRecommissionAvailable"),
- /**
- * 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')
- });
|