123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- /**
- * 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 date = require('utils/date/date');
- var numberUtils = require('utils/number_utils');
- function diskPart(i18nKey, totalKey, usedKey) {
- return Em.computed(totalKey, usedKey, function () {
- var text = Em.I18n.t(i18nKey);
- var total = this.get(totalKey);
- var used = this.get(usedKey);
- var percent = total > 0 ? ((used * 100) / total).toFixed(2) : 0;
- if (percent == "NaN" || percent < 0) {
- percent = Em.I18n.t('services.service.summary.notAvailable') + " ";
- }
- return text.format(numberUtils.bytesToSize(used, 1, 'parseFloat'), numberUtils.bytesToSize(total, 1, 'parseFloat'), percent);
- });
- }
- App.MainDashboardServiceHdfsView = App.MainDashboardServiceView.extend({
- templateName: require('templates/main/service/services/hdfs'),
- serviceName: 'HDFS',
- Chart: App.ChartPieView.extend({
- service: null,
- color: '#0066B3',
- stroke: '#0066B3',
- palette: new Rickshaw.Color.Palette({
- scheme: [ 'rgba(0,102,179,0)', 'rgba(0,102,179,1)'].reverse()
- }),
- data: function () {
- var total = this.get('service.capacityTotal') + 0;
- var remaining = (this.get('service.capacityRemaining') + 0);
- var used = total - remaining;
- return [ used, remaining ];
- }.property('service.capacityUsed', 'service.capacityTotal')
- }),
- dashboardMasterComponentView: Em.View.extend({
- didInsertElement: function() {
- App.tooltip($('[rel=healthTooltip]'));
- },
- templateName: require('templates/main/service/info/summary/master_components'),
- mastersComp: function() {
- var masterComponents = [];
- var zkfcs = this.get('parentView.service.hostComponents').filterProperty('componentName', 'ZKFC');
- this.get('parentView.service.hostComponents').forEach(function (comp) {
- if (comp.get('isMaster') && comp.get('componentName') !== 'JOURNALNODE') {
- masterComponents.push(comp);
- var zkfc = zkfcs.findProperty('hostName', comp.get('hostName'));
- if (zkfc) {
- zkfc.set('isSubComponent', true);
- masterComponents.push(zkfc);
- }
- }
- });
- return masterComponents;
- }.property('parentView.service.hostComponents.length'),
- willDestroyElement: function() {
- $('[rel=healthTooltip]').tooltip('destroy')
- }
- }),
- didInsertElement: function() {
- App.tooltip($("[rel='tooltip']"));
- },
- willDestroyElement: function() {
- $("[rel='tooltip']").tooltip('destroy');
- },
- dataNodesDead: Em.computed.alias('service.dataNodesInstalled'),
- showJournalNodes: Em.computed.gt('service.journalNodes.length', 0),
- journalNodesLive: function () {
- return this.get('service.journalNodes').filterProperty("workStatus", "STARTED").get("length");
- }.property("service.journalNodes.@each.workStatus"),
- journalNodesTotal: Em.computed.alias('service.journalNodes.length'),
- dfsTotalBlocks: Em.computed.formatUnavailable('service.dfsTotalBlocks'),
- dfsTotalFiles: Em.computed.formatUnavailable('service.dfsTotalFiles'),
- dfsCorruptBlocks: Em.computed.formatUnavailable('service.dfsCorruptBlocks'),
- dfsMissingBlocks: Em.computed.formatUnavailable('service.dfsMissingBlocks'),
- dfsUnderReplicatedBlocks: Em.computed.formatUnavailable('service.dfsUnderReplicatedBlocks'),
- blockErrorsMessage: Em.computed.i18nFormat('dashboard.services.hdfs.blockErrors', 'dfsCorruptBlocks', 'dfsMissingBlocks', 'dfsUnderReplicatedBlocks'),
- nodeUptime: function () {
- var uptime = this.get('service').get('nameNodeStartTime');
- if (uptime && uptime > 0){
- var diff = App.dateTime() - uptime;
- if (diff < 0) {
- diff = 0;
- }
- var formatted = date.timingFormat(diff);
- return this.t('dashboard.services.uptime').format(formatted);
- }
- return this.t('services.service.summary.notRunning');
- }.property("service.nameNodeStartTime"),
- nodeWebUrl: function () {
- return "http://" + (App.singleNodeInstall ? App.singleNodeAlias : this.get('service').get('nameNode').get('publicHostName')) + ":50070";
- }.property('service.nameNode'),
- nodeHeap: App.MainDashboardServiceView.formattedHeap('dashboard.services.hdfs.nodes.heapUsed', 'service.jvmMemoryHeapUsed', 'service,jvmMemoryHeapMax'),
- dfsUsedDisk: diskPart('dashboard.services.hdfs.capacityUsed', 'service.capacityTotal', 'service.capacityUsed'),
- nonDfsUsed: function () {
- var total = this.get('service.capacityTotal');
- var remaining = this.get('service.capacityRemaining');
- var dfsUsed = this.get('service.capacityUsed');
- return total !== null && remaining !== null && dfsUsed !== null ? total - remaining - dfsUsed : null;
- }.property('service.capacityTotal', 'service.capacityRemaining', 'service.capacityUsed'),
- nonDfsUsedDisk: diskPart('dashboard.services.hdfs.capacityUsed', 'service.capacityTotal', 'nonDfsUsed'),
- remainingDisk: diskPart('dashboard.services.hdfs.capacityUsed', 'service.capacityTotal', 'service.capacityRemaining'),
- dataNodeComponent: Em.Object.create({
- componentName: 'DATANODE'
- }),
- nfsGatewayComponent: Em.Object.create({
- componentName: 'NFS_GATEWAY'
- }),
- /**
- * Define if NFS_GATEWAY is present in the installed stack
- * @type {Boolean}
- */
- isNfsInStack: function () {
- return App.StackServiceComponent.find().someProperty('componentName', 'NFS_GATEWAY');
- }.property(),
-
- journalNodeComponent: Em.computed.alias('service.journalNodes.firstObject'),
- safeModeStatus: function () {
- var safeMode = this.get('service.safeModeStatus');
- if (safeMode == null) {
- return Em.I18n.t("services.service.summary.notAvailable");
- } else if (safeMode.length == 0) {
- return Em.I18n.t("services.service.summary.safeModeStatus.notInSafeMode");
- } else {
- return Em.I18n.t("services.service.summary.safeModeStatus.inSafeMode");
- }
- }.property('service.safeModeStatus'),
- upgradeStatus: function () {
- var upgradeStatus = this.get('service.upgradeStatus');
- var healthStatus = this.get('service.healthStatus');
- if (upgradeStatus == 'true') {
- return Em.I18n.t('services.service.summary.pendingUpgradeStatus.notPending');
- } else if (upgradeStatus == 'false' && healthStatus == 'green') {
- return Em.I18n.t('services.service.summary.pendingUpgradeStatus.notFinalized');
- } else {
- // upgrade status == null
- return Em.I18n.t("services.service.summary.notAvailable");
- }
- }.property('service.upgradeStatus', 'service.healthStatus'),
- isUpgradeStatusWarning: function () {
- var upgradeStatus = this.get('service.upgradeStatus');
- var healthStatus = this.get('service.healthStatus');
- return upgradeStatus == 'false' && healthStatus == 'green';
- }.property('service.upgradeStatus', 'service.healthStatus')
- });
|