This is an automated email from the ASF dual-hosted git repository. bteke pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push: new d23ebc45121 YARN-11757. [UI2] Add partition usage overview to the Queues page (#7330) d23ebc45121 is described below commit d23ebc451213fd65be224955c7472bf3a6178e5d Author: Ferenc Erdelyi <55103964+ferde...@users.noreply.github.com> AuthorDate: Mon Feb 24 15:26:29 2025 +0100 YARN-11757. [UI2] Add partition usage overview to the Queues page (#7330) --- .../src/main/webapp/app/helpers/get-from-map.js | 72 ++++++++++++++++++++++ .../app/templates/components/partition-usage.hbs | 66 ++++++++++++++++++++ .../components/yarn-queue/capacity-queue.hbs | 2 + .../webapp/tests/unit/helpers/get-from-map-test.js | 28 +++++++++ 4 files changed, 168 insertions(+) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/helpers/get-from-map.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/helpers/get-from-map.js new file mode 100644 index 00000000000..440a9a0cab0 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/helpers/get-from-map.js @@ -0,0 +1,72 @@ +/** + * 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. + */ + +import Ember from 'ember'; + + +function getNestedValue(obj, path) { + return path.split('.').reduce((acc, key) => { + if (acc === null || acc === undefined) { + return undefined; + } + + /* Handle array indexing. + Sample input data: + { + "partitionKey": { + "configuredMinResource": { + "resourceInformations": { + "resourceInformation": [ + { + "maximumAllocation": 1024 + }, + { + "maximumAllocation": 88 + } + ] + } + } + } + } + */ + const arrayMatch = key.match(/(\w+)\[(\d+)\]/); + if (arrayMatch) { + const arrayKey = arrayMatch[1]; + const arrayIndex = parseInt(arrayMatch[2], 10); + return acc[arrayKey] && acc[arrayKey][arrayIndex]; + } + + return acc[key]; + }, obj); +} + +export function getFromMap(params, hash) { + /* + Extract map values based on the key provided and the path to the nested value + Example: + XPATH from the metrics: /scheduler/schedulerInfo/capacities/queueCapacitiesByPartition[3]/configuredMinResource/resourceInformations/resourceInformation[2]/maximumAllocation + The partition map is: queueCapacitiesByPartition and accessed as "partitionMap" from the code defined in the models/yarn-queue/capacity-queue.js + The supplied hash.map is partitionMap + The supplied key is the partition name (nodelabel), e.g. "customPartition" + The parameter is "configuredMinResource/resourceInformations/resourceInformation[2]/maximumAllocation" + The returned value is the value of the maximumAllocation, which in this case will be the number of vCores present. + */ + return getNestedValue(hash.map[hash.key], hash.parameter); +} + +export default Ember.Helper.helper(getFromMap); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/partition-usage.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/partition-usage.hbs new file mode 100644 index 00000000000..f5a9054c7ab --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/partition-usage.hbs @@ -0,0 +1,66 @@ +{! + * 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. +}} +<div class="row"> + <div class="col-md-12 container-fluid"> + <div class="panel panel-default queue-page-breadcrumb" id="partition-usage-container"> + <div class="panel-heading"> + {{model.firstObject.type}} scheduler - Partition usage overview + </div> + <div class="flex"> + {{log module.exports}} + {{#if (eq model.firstObject.type "capacity")}} + + <table class="table table-striped table-bordered active-user-table"> + <thead> + <tr> + <th>Node Label</th> + <th>Resource Used from the Partition</th> + <th>Total Resource in the Partition</th> + </tr> + </thead> + <tbody> + <tr style="display: none;"> + </tr> + {{#each model.firstObject.partitions as |part|}} + <tr> + <td>{{part}}</td> + <td>{{getFromMap map=model.firstObject.partitionMap key=part parameter="usedCapacity" }}%</td> + <!-- + /scheduler/schedulerInfo/queues/queue[1]/capacities/queueCapacitiesByPartition[1]/effectiveMaxResource/resourceInformations/resourceInformation[1]/name[text()='memory-mb'] + /scheduler/schedulerInfo/queues/queue[1]/capacities/queueCapacitiesByPartition[1]/effectiveMaxResource/resourceInformations/resourceInformation[1]/value[text()='2703'] + --> + <td> + {{#each (getFromMap map=model.firstObject.partitionMap key=part parameter="effectiveMaxResource.resourceInformations.resourceInformation") as |resource|}} + <span class="yarn-label secondary"> + <span class="label-key">{{resource.name}}</span> + <span class="label-value">{{resource.value}}</span> + </span> + {{/each}} + </td> + </tr> + {{/each}} + </tbody> + </table> + + {{/if}} + </div> + </div> + </div> +</div> + +{{yield}} \ No newline at end of file diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/yarn-queue/capacity-queue.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/yarn-queue/capacity-queue.hbs index e9fc80e1c64..d9f79e98005 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/yarn-queue/capacity-queue.hbs +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/yarn-queue/capacity-queue.hbs @@ -16,6 +16,8 @@ * limitations under the License. }} +{{partition-usage model=model.queues}} + {{queue-navigator model=model.queues selected=model.selected used="usedCapacity" max="absMaxCapacity" setFilter=(action setFilter)}} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/tests/unit/helpers/get-from-map-test.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/tests/unit/helpers/get-from-map-test.js new file mode 100644 index 00000000000..499a205f82b --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/tests/unit/helpers/get-from-map-test.js @@ -0,0 +1,28 @@ +/** + * 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. + */ + +import { getFromMap } from '../../../helpers/get-from-map'; +import { module, test } from 'qunit'; + +module('Unit | Helper | get from map'); + +// Replace this with your real tests. +test('it works', function(assert) { + let result = getFromMap(42); + assert.ok(result); +}); \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org