This is an automated email from the ASF dual-hosted git repository. ababiichuk pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push: new f20beb6 AMBARI-24003 Duplicate data is showing up when enabling NN Federation. (ababiichuk) f20beb6 is described below commit f20beb60ebed026e0c9e7764fedcd90aeb43bcab Author: ababiichuk <ababiic...@hortonworks.com> AuthorDate: Thu May 31 21:50:36 2018 +0300 AMBARI-24003 Duplicate data is showing up when enabling NN Federation. (ababiichuk) --- .../app/controllers/global/update_controller.js | 4 +- ambari-web/app/data/dashboard_widgets.js | 3 +- ambari-web/app/mappers/service_metrics_mapper.js | 12 ++-- ambari-web/app/messages.js | 3 +- ambari-web/app/mixins.js | 1 + .../main/service/summary/hdfs_summary_widgets.js | 29 ++++++++ ambari-web/app/models/service/hdfs.js | 16 ++--- ambari-web/app/styles/application.less | 2 +- .../templates/main/service/info/summary/base.hbs | 3 +- .../service/info/summary/hdfs/common_widgets.hbs | 53 +++++++++++++++ .../main/service/info/summary/hdfs/widgets.hbs | 36 ++-------- .../service/info/summary/master_components.hbs | 3 + .../app/templates/main/service/services/hdfs.hbs | 6 +- ambari-web/app/views.js | 1 + .../views/main/dashboard/widgets/hdfs_capacity.js | 12 ++-- .../service/info/summary/hdfs/common_widgets.js | 77 ++++++++++++++++++++++ .../main/service/info/summary/hdfs/widgets.js | 63 ++---------------- ambari-web/app/views/main/service/services/hdfs.js | 3 + 18 files changed, 205 insertions(+), 122 deletions(-) diff --git a/ambari-web/app/controllers/global/update_controller.js b/ambari-web/app/controllers/global/update_controller.js index ec2e3c3..2bcbd08 100644 --- a/ambari-web/app/controllers/global/update_controller.js +++ b/ambari-web/app/controllers/global/update_controller.js @@ -73,8 +73,8 @@ App.UpdateController = Em.Controller.extend({ }, nameNodeMetricsModelProperties: [ - 'jvm_memory_heap_max_values', 'jvm_memory_heap_used_values', 'capacity_used_values', 'capacity_total_values', - 'capacity_remaining_values', 'capacity_non_dfs_used_values', 'name_node_rpc_values', 'name_node_start_time_values' + 'jvm_memory_heap_max_values', 'jvm_memory_heap_used_values', 'capacity_used', 'capacity_total', + 'capacity_remaining', 'capacity_non_dfs_used', 'name_node_rpc_values', 'name_node_start_time_values' ], /** diff --git a/ambari-web/app/data/dashboard_widgets.js b/ambari-web/app/data/dashboard_widgets.js index 85d497a..520e606 100644 --- a/ambari-web/app/data/dashboard_widgets.js +++ b/ambari-web/app/data/dashboard_widgets.js @@ -30,8 +30,7 @@ module.exports = [ viewName: 'NameNodeCapacityPieChartView', sourceName: 'HDFS', title: Em.I18n.t('dashboard.widgets.HDFSDiskUsage'), - threshold: [85, 95], - groupName: 'nn' + threshold: [85, 95] }, { id: 3, diff --git a/ambari-web/app/mappers/service_metrics_mapper.js b/ambari-web/app/mappers/service_metrics_mapper.js index 4832d97..e780d78 100644 --- a/ambari-web/app/mappers/service_metrics_mapper.js +++ b/ambari-web/app/mappers/service_metrics_mapper.js @@ -53,10 +53,10 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({ live_data_nodes: 'live_data_nodes', dead_data_nodes: 'dead_data_nodes', decommission_data_nodes: 'decommission_data_nodes', - capacity_used_values: 'capacity_used_values', - capacity_total_values: 'capacity_total_values', - capacity_remaining_values: 'capacity_remaining_values', - capacity_non_dfs_used_values: 'capacity_non_dfs_used_values', + capacity_used: 'nameNodeComponent.host_components[0].metrics.dfs.FSNamesystem.CapacityUsed', + capacity_total: 'nameNodeComponent.host_components[0].metrics.dfs.FSNamesystem.CapacityTotal', + capacity_remaining: 'nameNodeComponent.host_components[0].metrics.dfs.FSNamesystem.CapacityRemaining', + capacity_non_dfs_used: 'nameNodeComponent.host_components[0].metrics.dfs.FSNamesystem.CapacityNonDFSUsed', dfs_total_blocks_values: 'dfs_total_blocks_values', dfs_corrupt_blocks_values: 'dfs_corrupt_blocks_values', dfs_missing_blocks_values: 'dfs_missing_blocks_values', @@ -76,10 +76,6 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({ activeNameNodeConfig: { name_node_start_time_values: 'metrics.runtime.StartTime', jvm_memory_heap_used_values: 'metrics.jvm.HeapMemoryUsed', - capacity_used_values: 'metrics.dfs.FSNamesystem.CapacityUsed', - capacity_total_values: 'metrics.dfs.FSNamesystem.CapacityTotal', - capacity_remaining_values: 'metrics.dfs.FSNamesystem.CapacityRemaining', - capacity_non_dfs_used_values: 'metrics.dfs.FSNamesystem.CapacityNonDFSUsed', jvm_memory_heap_max_values: 'metrics.jvm.HeapMemoryMax', dfs_total_blocks_values: 'metrics.dfs.FSNamesystem.BlocksTotal', dfs_corrupt_blocks_values: 'metrics.dfs.FSNamesystem.CorruptBlocks', diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index 7efddae..1dd12a2 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -2011,7 +2011,7 @@ Em.I18n.translations = { 'services.service.summary.safeModeStatus.notInSafeMode':'Not in safe mode', 'services.service.summary.dataNodes':'DataNodes', 'services.service.summary.diskCapacity':'HDFS Disk Capacity', - 'services.service.summary.blocksTotal':'Blocks (total)', + 'services.service.summary.blocks':'Blocks', 'services.service.summary.blockErrors':'Block Errors', 'services.service.summary.totalFiles':'Total Files + Dirs', 'services.service.summary.jobTracker':'JobTracker', @@ -3057,6 +3057,7 @@ Em.I18n.translations = { 'dashboard.services.hdfs.nodes.heapUsed':'{0} / {1}', 'dashboard.services.hdfs.chart.label':'Capacity (Used/Total)', + 'dashboard.services.hdfs.blockErrors.total': 'total', 'dashboard.services.hdfs.blockErrors.corrupt': 'corrupt replica', 'dashboard.services.hdfs.blockErrors.replicated': 'under replicated', 'dashboard.services.hdfs.blockErrors.missing': 'missing', diff --git a/ambari-web/app/mixins.js b/ambari-web/app/mixins.js index 1ec7752..ce8c22f 100644 --- a/ambari-web/app/mixins.js +++ b/ambari-web/app/mixins.js @@ -44,6 +44,7 @@ require('mixins/main/service/themes_mapping'); require('mixins/main/service/configs/config_overridable'); require('mixins/main/service/configs/widget_popover_support'); require('mixins/main/service/configs/component_actions_by_configs'); +require('mixins/main/service/summary/hdfs_summary_widgets'); require('mixins/routers/redirections'); require('mixins/wizard/wizardProgressPageController'); require('mixins/wizard/wizardDeployProgressController'); diff --git a/ambari-web/app/mixins/main/service/summary/hdfs_summary_widgets.js b/ambari-web/app/mixins/main/service/summary/hdfs_summary_widgets.js new file mode 100644 index 0000000..8dc308c --- /dev/null +++ b/ambari-web/app/mixins/main/service/summary/hdfs_summary_widgets.js @@ -0,0 +1,29 @@ +/** + * 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. + */ + +App.HDFSSummaryWidgetsMixin = Em.Mixin.create({ + + model: function () { + return App.HDFSService.find().objectAt(0); + }.property('controller.content.serviceName'), + + isFederatedHDFS: Em.computed.gt('model.masterComponentGroups.length', 1), + + isNonFederatedHDFS: Em.computed.not('isFederatedHDFS', 1) + +}); diff --git a/ambari-web/app/models/service/hdfs.js b/ambari-web/app/models/service/hdfs.js index f63cf6c..b7f97cb 100644 --- a/ambari-web/app/models/service/hdfs.js +++ b/ambari-web/app/models/service/hdfs.js @@ -50,18 +50,10 @@ App.HDFSService = App.Service.extend({ decommissionDataNodes: DS.hasMany('App.HostComponent'), liveDataNodes: DS.hasMany('App.HostComponent'), deadDataNodes: DS.hasMany('App.HostComponent'), - capacityUsedValues: DS.attr('object', { - defaultValue: {} - }), - capacityTotalValues: DS.attr('object', { - defaultValue: {} - }), - capacityRemainingValues: DS.attr('object', { - defaultValue: {} - }), - capacityNonDfsUsedValues: DS.attr('object', { - defaultValue: {} - }), + capacityUsed: DS.attr('number'), + capacityTotal: DS.attr('number'), + capacityRemaining: DS.attr('number'), + capacityNonDfsUsed: DS.attr('number'), dfsTotalBlocksValues: DS.attr('object', { defaultValue: {} }), diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less index 406bca1..2abc21c 100644 --- a/ambari-web/app/styles/application.less +++ b/ambari-web/app/styles/application.less @@ -2560,7 +2560,7 @@ a.abort-icon:hover { flex: 1; .metrics-summary { margin-top: 40px; - &.multiple-master-groups { + &.not-separate-section { margin-top: 0; } } diff --git a/ambari-web/app/templates/main/service/info/summary/base.hbs b/ambari-web/app/templates/main/service/info/summary/base.hbs index 582d815..4ec75a4 100644 --- a/ambari-web/app/templates/main/service/info/summary/base.hbs +++ b/ambari-web/app/templates/main/service/info/summary/base.hbs @@ -17,7 +17,8 @@ }} <div class="row component-summary"> - {{view App.SummaryMasterComponentsView mastersCompBinding="view.parentView.mastersObj"}} + {{view App.SummaryMasterComponentsView mastersCompBinding="view.parentView.mastersObj" + componentCommonWidgetsViewBinding="view.parentView.componentCommonWidgetsView"}} <div class="col-md-12"> <div class="col-md-2"> {{#if view.parentView.showComponentsTitleForNonMasters}} diff --git a/ambari-web/app/templates/main/service/info/summary/hdfs/common_widgets.hbs b/ambari-web/app/templates/main/service/info/summary/hdfs/common_widgets.hbs new file mode 100644 index 0000000..1c74c2a --- /dev/null +++ b/ambari-web/app/templates/main/service/info/summary/hdfs/common_widgets.hbs @@ -0,0 +1,53 @@ +{{! +* 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. +}} + +{{! Service Metrics Section (common data for all namespaces) }} +<div class="col-md-12 metrics-summary not-separate-section"> + <div class="col-md-2"> + {{#if view.isFederatedHDFS}} + {{t dashboard.services.hdfs.summary.service-metrics}} + {{/if}} + </div> + <div class="col-md-10"> + {{#if view.isNonFederatedHDFS}} + <div class="row"></div> + {{/if}} + {{! HDFS Capacity (Disk Usage)}} + <div class="row dfs-usage col-md-3"> + <div class="summary-value"> + <div class="main-info">{{view.dfsUsedDiskPercent}}</div> + <div class="info-desc">{{view.dfsUsedDisk}}</div> + </div> + <div class="summary-label">{{t dashboard.services.hdfs.capacity.dfsUsed}}</div> + </div> + <div class="row non-dfs-used col-md-3"> + <div class="summary-value main-info"> + <div class="main-info">{{view.nonDfsUsedDiskPercent}}</div> + <div class="info-desc">{{view.nonDfsUsedDisk}}</div> + </div> + <div class="summary-label">{{t dashboard.services.hdfs.capacity.nonDfsUsed}}</div> + </div> + <div class="row capacity-remaining col-md-3"> + <div class="summary-value"> + <div class="main-info">{{view.remainingDiskPercent}}</div> + <div class="info-desc">{{view.remainingDisk}}</div> + </div> + <div class="summary-label">{{t dashboard.services.hdfs.capacity.remaining}}</div> + </div> + </div> +</div> diff --git a/ambari-web/app/templates/main/service/info/summary/hdfs/widgets.hbs b/ambari-web/app/templates/main/service/info/summary/hdfs/widgets.hbs index e81e284..82cddd6 100644 --- a/ambari-web/app/templates/main/service/info/summary/hdfs/widgets.hbs +++ b/ambari-web/app/templates/main/service/info/summary/hdfs/widgets.hbs @@ -38,44 +38,22 @@ {{view view.slaveComponentsView summaryViewBinding="view.parentView.summaryView"}} {{/if}} -{{! Service Metrics Section }} -<div {{bindAttr class=":col-md-12 :metrics-summary view.isNonFederatedHDFS::multiple-master-groups"}}> +{{! Service Metrics Section (namespace specific data)}} +<div {{bindAttr class=":col-md-12 :metrics-summary view.isNonFederatedHDFS::not-separate-section"}}> <div class="col-md-2"> {{#if view.isNonFederatedHDFS}} {{t dashboard.services.hdfs.summary.service-metrics}} {{/if}} </div> <div class="col-md-10"> - {{! HDFS Capacity (Disk Usage)}} - <div class="row dfs-usage col-md-3"> - <div class="summary-value"> - <div class="main-info">{{view.dfsUsedDiskPercent}}</div> - <div class="info-desc">{{view.dfsUsedDisk}}</div> - </div> - <div class="summary-label">{{t dashboard.services.hdfs.capacity.dfsUsed}}</div> - </div> - <div class="row non-dfs-used col-md-3"> - <div class="summary-value main-info"> - <div class="main-info">{{view.nonDfsUsedDiskPercent}}</div> - <div class="info-desc">{{view.nonDfsUsedDisk}}</div> - </div> - <div class="summary-label">{{t dashboard.services.hdfs.capacity.nonDfsUsed}}</div> - </div> - <div class="row capacity-remaining col-md-3"> - <div class="summary-value"> - <div class="main-info">{{view.remainingDiskPercent}}</div> - <div class="info-desc">{{view.remainingDisk}}</div> - </div> - <div class="summary-label">{{t dashboard.services.hdfs.capacity.remaining}}</div> - </div> + <div class="summary-label col-md-12">{{t services.service.summary.blocks}}</div> {{! Blocks Total }} <div class="row blocks-total col-md-3"> - <div class="summary-value main-info">{{view.dfsTotalBlocks}}</div> - <div class="summary-label">{{t services.service.summary.blocksTotal}}</div> + <div class="summary-value main-info"> + <div class="main-info">{{view.dfsTotalBlocks}}</div> + <div class="info-desc">{{t dashboard.services.hdfs.blockErrors.total}}</div> + </div> </div> - {{! indent next row}} - <div class="row"></div> - <div class="summary-label col-md-12">{{t services.service.summary.blockErrors}}</div> {{! Block Errors corrupt }} <div class="row block-errors-corrupt col-md-3"> <div class="summary-value main-info"> diff --git a/ambari-web/app/templates/main/service/info/summary/master_components.hbs b/ambari-web/app/templates/main/service/info/summary/master_components.hbs index f604e40..6c672e7 100644 --- a/ambari-web/app/templates/main/service/info/summary/master_components.hbs +++ b/ambari-web/app/templates/main/service/info/summary/master_components.hbs @@ -62,3 +62,6 @@ {{/if}} {{/if}} {{/each}} +{{#if view.componentCommonWidgetsView}} + {{view view.componentCommonWidgetsView}} +{{/if}} diff --git a/ambari-web/app/templates/main/service/services/hdfs.hbs b/ambari-web/app/templates/main/service/services/hdfs.hbs index d3a5a62..43a0083 100644 --- a/ambari-web/app/templates/main/service/services/hdfs.hbs +++ b/ambari-web/app/templates/main/service/services/hdfs.hbs @@ -19,9 +19,11 @@ <div class="row"> {{! Component Section }} <div class="component-summary"> - {{view view.dashboardMasterComponentView slaveComponentsViewBinding="view.slaveComponentsView" summaryViewBinding="view"}} + {{view view.dashboardMasterComponentView slaveComponentsViewBinding="view.slaveComponentsView" + summaryViewBinding="view" componentCommonWidgetsViewBinding="view.componentCommonWidgetsView"}} {{#if view.hasMultipleMasterGroups}} - {{view view.slaveComponentsView slaveComponentsViewBinding="view.slaveComponentsView" summaryViewBinding="view" showTitle=true}} + {{view view.slaveComponentsView slaveComponentsViewBinding="view.slaveComponentsView" summaryViewBinding="view" + showTitle=true}} {{/if}} </div> </div> diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js index da64f1d..2d03460 100644 --- a/ambari-web/app/views.js +++ b/ambari-web/app/views.js @@ -312,6 +312,7 @@ require('views/main/service/reconfigure'); require('views/main/service/info/components_list_view'); require('views/main/service/info/menu'); require('views/main/service/info/summary'); +require('views/main/service/info/summary/hdfs/common_widgets'); require('views/main/service/info/summary/hdfs/slaves'); require('views/main/service/info/summary/hdfs/widgets'); require('views/main/service/info/configs'); diff --git a/ambari-web/app/views/main/dashboard/widgets/hdfs_capacity.js b/ambari-web/app/views/main/dashboard/widgets/hdfs_capacity.js index 21e3b0d..e73b516 100644 --- a/ambari-web/app/views/main/dashboard/widgets/hdfs_capacity.js +++ b/ambari-web/app/views/main/dashboard/widgets/hdfs_capacity.js @@ -19,16 +19,16 @@ var App = require('app'); var numberUtils = require('utils/number_utils'); -App.NameNodeCapacityPieChartView = App.PieChartDashboardWidgetView.extend(App.NameNodeWidgetMixin, { +App.NameNodeCapacityPieChartView = App.PieChartDashboardWidgetView.extend({ - modelValueMax: Em.computed.getByKey('model.capacityTotalValues', 'hostName'), + modelValueMax: Em.computed.alias('model.capacityTotal'), /** * HDFS model has 'remaining' value, but not 'used' */ - modelValueUsed: Em.computed.getByKey('model.capacityRemainingValues', 'hostName'), - modelValueCapacityUsed: Em.computed.getByKey('model.capacityUsedValues', 'hostName'), - modelValueNonDfsUsed: Em.computed.getByKey('model.capacityNonDfsUsedValues', 'hostName'), - widgetHtmlId: Em.computed.format('widget-nn-capacity-{0}', 'subGroupId'), + modelValueUsed: Em.computed.alias('model.capacityRemaining'), + modelValueCapacityUsed: Em.computed.alias('model.capacityUsed'), + modelValueNonDfsUsed: Em.computed.alias('model.capacityNonDfsUsed'), + widgetHtmlId: Em.computed.format('widget-nn-capacity'), hiddenInfoClass: "hidden-info-six-line", didInsertElement: function() { diff --git a/ambari-web/app/views/main/service/info/summary/hdfs/common_widgets.js b/ambari-web/app/views/main/service/info/summary/hdfs/common_widgets.js new file mode 100644 index 0000000..508a2c0 --- /dev/null +++ b/ambari-web/app/views/main/service/info/summary/hdfs/common_widgets.js @@ -0,0 +1,77 @@ +/** + * 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. + */ + +const numberUtils = require('utils/number_utils'); + +function diskPart(i18nKey, totalKey, usedKey) { + return Em.computed(totalKey, usedKey, function () { + const text = Em.I18n.t(i18nKey), + total = this.get(totalKey), + used = this.get(usedKey); + return text.format(numberUtils.bytesToSize(used, 1, 'parseFloat'), numberUtils.bytesToSize(total, 1, 'parseFloat')); + }); +} + +function diskPartPercent(i18nKey, totalKey, usedKey) { + return Em.computed(totalKey, usedKey, function () { + const text = Em.I18n.t(i18nKey), + total = this.get(totalKey), + used = this.get(usedKey); + let 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(percent); + }); +} + +/** + * Metric widgets which are common for all namespaces + */ +App.HDFSSummaryCommonWidgetsView = Em.View.extend(App.HDFSSummaryWidgetsMixin, { + + templateName: require('templates/main/service/info/summary/hdfs/common_widgets'), + + dfsUsedDiskPercent: diskPartPercent( + 'dashboard.services.hdfs.capacityUsedPercent', 'model.capacityTotal', 'model.capacityUsed' + ), + + dfsUsedDisk: diskPart( + 'dashboard.services.hdfs.capacityUsed', 'model.capacityTotal', 'model.capacityUsed' + ), + + nonDfsUsed: function () { + const total = this.get('model.capacityTotal'), + remaining = this.get('model.capacityRemaining'), + dfsUsed = this.get('model.capacityUsed'); + return (Em.isNone(total) || Em.isNone(remaining) || Em.isNone(dfsUsed)) ? null : total - remaining - dfsUsed; + }.property('model.capacityTotal', 'model.capacityRemaining', 'model.capacityUsed'), + + nonDfsUsedDiskPercent: diskPartPercent( + 'dashboard.services.hdfs.capacityUsedPercent', 'model.capacityTotal', 'nonDfsUsed' + ), + + nonDfsUsedDisk: diskPart('dashboard.services.hdfs.capacityUsed', 'model.capacityTotal', 'nonDfsUsed'), + + remainingDiskPercent: diskPartPercent( + 'dashboard.services.hdfs.capacityUsedPercent', 'model.capacityTotal', 'model.capacityRemaining' + ), + + remainingDisk: diskPart('dashboard.services.hdfs.capacityUsed', 'model.capacityTotal', 'model.capacityRemaining') + +}); diff --git a/ambari-web/app/views/main/service/info/summary/hdfs/widgets.js b/ambari-web/app/views/main/service/info/summary/hdfs/widgets.js index 4e03db9..3071f3d 100644 --- a/ambari-web/app/views/main/service/info/summary/hdfs/widgets.js +++ b/ambari-web/app/views/main/service/info/summary/hdfs/widgets.js @@ -17,40 +17,16 @@ */ const date = require('utils/date/date'); -const numberUtils = require('utils/number_utils'); - -function diskPart(i18nKey, totalKey, usedKey) { - return Em.computed(totalKey, usedKey, function () { - const text = Em.I18n.t(i18nKey), - total = this.get(totalKey), - used = this.get(usedKey); - return text.format(numberUtils.bytesToSize(used, 1, 'parseFloat'), numberUtils.bytesToSize(total, 1, 'parseFloat')); - }); -} - -function diskPartPercent(i18nKey, totalKey, usedKey) { - return Em.computed(totalKey, usedKey, function () { - const text = Em.I18n.t(i18nKey), - total = this.get(totalKey), - used = this.get(usedKey); - let 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(percent); - }); -} -App.HDFSSummaryWidgetsView = Em.View.extend(App.NameNodeWidgetMixin, { +/** + * Metric widgets which are specific for different namespaces + */ +App.HDFSSummaryWidgetsView = Em.View.extend(App.NameNodeWidgetMixin, App.HDFSSummaryWidgetsMixin, { templateName: require('templates/main/service/info/summary/hdfs/widgets'), nameSpace: 'default', - model: function () { - return App.HDFSService.find().objectAt(0); - }.property('controller.content.serviceName'), - subGroupId: Em.computed.alias('nameSpace'), showSlaveComponents: false, @@ -83,33 +59,6 @@ App.HDFSSummaryWidgetsView = Em.View.extend(App.NameNodeWidgetMixin, { 'dashboard.services.hdfs.nodes.heapUsed', 'jvmMemoryHeapUsed', 'jvmMemoryHeapMax' ), - capacityTotal: Em.computed.getByKey('model.capacityTotalValues', 'hostName'), - - capacityUsed: Em.computed.getByKey('model.capacityUsedValues', 'hostName'), - - capacityRemaining: Em.computed.getByKey('model.capacityRemainingValues', 'hostName'), - - dfsUsedDiskPercent: diskPartPercent('dashboard.services.hdfs.capacityUsedPercent', 'capacityTotal', 'capacityUsed'), - - dfsUsedDisk: diskPart('dashboard.services.hdfs.capacityUsed', 'capacityTotal', 'capacityUsed'), - - nonDfsUsed: function () { - const total = this.get('capacityTotal'), - remaining = this.get('capacityRemaining'), - dfsUsed = this.get('capacityUsed'); - return (Em.isNone(total) || Em.isNone(remaining) || Em.isNone(dfsUsed)) ? null : total - remaining - dfsUsed; - }.property('capacityTotal', 'capacityRemaining', 'capacityUsed'), - - nonDfsUsedDiskPercent: diskPartPercent('dashboard.services.hdfs.capacityUsedPercent', 'capacityTotal', 'nonDfsUsed'), - - nonDfsUsedDisk: diskPart('dashboard.services.hdfs.capacityUsed', 'capacityTotal', 'nonDfsUsed'), - - remainingDiskPercent: diskPartPercent( - 'dashboard.services.hdfs.capacityUsedPercent', 'capacityTotal', 'capacityRemaining' - ), - - remainingDisk: diskPart('dashboard.services.hdfs.capacityUsed', 'capacityTotal', 'capacityRemaining'), - dfsTotalBlocksValue: Em.computed.getByKey('model.dfsTotalBlocksValues', 'hostName'), dfsTotalBlocks: Em.computed.formatUnavailable('dfsTotalBlocksValue'), @@ -162,8 +111,6 @@ App.HDFSSummaryWidgetsView = Em.View.extend(App.NameNodeWidgetMixin, { } else { return Em.I18n.t('services.service.summary.safeModeStatus.inSafeMode'); } - }.property('safeModeStatusValue'), - - isNonFederatedHDFS: Em.computed.lt('model.masterComponentGroups.length', 2) + }.property('safeModeStatusValue') }); diff --git a/ambari-web/app/views/main/service/services/hdfs.js b/ambari-web/app/views/main/service/services/hdfs.js index 485e448..374161a 100644 --- a/ambari-web/app/views/main/service/services/hdfs.js +++ b/ambari-web/app/views/main/service/services/hdfs.js @@ -18,6 +18,7 @@ var App = require('app'); var date = require('utils/date/date'); require('views/main/service/info/summary/hdfs/slaves'); +require('views/main/service/info/summary/hdfs/common_widgets'); App.MainDashboardServiceHdfsView = App.MainDashboardServiceView.extend({ templateName: require('templates/main/service/services/hdfs'), @@ -25,6 +26,8 @@ App.MainDashboardServiceHdfsView = App.MainDashboardServiceView.extend({ slaveComponentsView: App.HDFSSlaveComponentsView.extend(), + componentCommonWidgetsView: App.HDFSSummaryCommonWidgetsView.extend(), + metricsNotAvailableObserver: function () { if(!this.get("service.metricsNotAvailable")) { App.tooltip($("[rel='tooltip']")); -- To stop receiving notification emails like this one, please contact ababiic...@apache.org.