Skip to content

Commit d23ebc4

Browse files
authored
YARN-11757. [UI2] Add partition usage overview to the Queues page (#7330)
1 parent 2c694e1 commit d23ebc4

File tree

4 files changed

+168
-0
lines changed

4 files changed

+168
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import Ember from 'ember';
20+
21+
22+
function getNestedValue(obj, path) {
23+
return path.split('.').reduce((acc, key) => {
24+
if (acc === null || acc === undefined) {
25+
return undefined;
26+
}
27+
28+
/* Handle array indexing.
29+
Sample input data:
30+
{
31+
"partitionKey": {
32+
"configuredMinResource": {
33+
"resourceInformations": {
34+
"resourceInformation": [
35+
{
36+
"maximumAllocation": 1024
37+
},
38+
{
39+
"maximumAllocation": 88
40+
}
41+
]
42+
}
43+
}
44+
}
45+
}
46+
*/
47+
const arrayMatch = key.match(/(\w+)\[(\d+)\]/);
48+
if (arrayMatch) {
49+
const arrayKey = arrayMatch[1];
50+
const arrayIndex = parseInt(arrayMatch[2], 10);
51+
return acc[arrayKey] && acc[arrayKey][arrayIndex];
52+
}
53+
54+
return acc[key];
55+
}, obj);
56+
}
57+
58+
export function getFromMap(params, hash) {
59+
/*
60+
Extract map values based on the key provided and the path to the nested value
61+
Example:
62+
XPATH from the metrics: /scheduler/schedulerInfo/capacities/queueCapacitiesByPartition[3]/configuredMinResource/resourceInformations/resourceInformation[2]/maximumAllocation
63+
The partition map is: queueCapacitiesByPartition and accessed as "partitionMap" from the code defined in the models/yarn-queue/capacity-queue.js
64+
The supplied hash.map is partitionMap
65+
The supplied key is the partition name (nodelabel), e.g. "customPartition"
66+
The parameter is "configuredMinResource/resourceInformations/resourceInformation[2]/maximumAllocation"
67+
The returned value is the value of the maximumAllocation, which in this case will be the number of vCores present.
68+
*/
69+
return getNestedValue(hash.map[hash.key], hash.parameter);
70+
}
71+
72+
export default Ember.Helper.helper(getFromMap);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{!
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
}}
18+
<div class="row">
19+
<div class="col-md-12 container-fluid">
20+
<div class="panel panel-default queue-page-breadcrumb" id="partition-usage-container">
21+
<div class="panel-heading">
22+
{{model.firstObject.type}} scheduler - Partition usage overview
23+
</div>
24+
<div class="flex">
25+
{{log module.exports}}
26+
{{#if (eq model.firstObject.type "capacity")}}
27+
28+
<table class="table table-striped table-bordered active-user-table">
29+
<thead>
30+
<tr>
31+
<th>Node Label</th>
32+
<th>Resource Used from the Partition</th>
33+
<th>Total Resource in the Partition</th>
34+
</tr>
35+
</thead>
36+
<tbody>
37+
<tr style="display: none;">
38+
</tr>
39+
{{#each model.firstObject.partitions as |part|}}
40+
<tr>
41+
<td>{{part}}</td>
42+
<td>{{getFromMap map=model.firstObject.partitionMap key=part parameter="usedCapacity" }}%</td>
43+
<!--
44+
/scheduler/schedulerInfo/queues/queue[1]/capacities/queueCapacitiesByPartition[1]/effectiveMaxResource/resourceInformations/resourceInformation[1]/name[text()='memory-mb']
45+
/scheduler/schedulerInfo/queues/queue[1]/capacities/queueCapacitiesByPartition[1]/effectiveMaxResource/resourceInformations/resourceInformation[1]/value[text()='2703']
46+
-->
47+
<td>
48+
{{#each (getFromMap map=model.firstObject.partitionMap key=part parameter="effectiveMaxResource.resourceInformations.resourceInformation") as |resource|}}
49+
<span class="yarn-label secondary">
50+
<span class="label-key">{{resource.name}}</span>
51+
<span class="label-value">{{resource.value}}</span>
52+
</span>
53+
{{/each}}
54+
</td>
55+
</tr>
56+
{{/each}}
57+
</tbody>
58+
</table>
59+
60+
{{/if}}
61+
</div>
62+
</div>
63+
</div>
64+
</div>
65+
66+
{{yield}}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/yarn-queue/capacity-queue.hbs

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* limitations under the License.
1717
}}
1818

19+
{{partition-usage model=model.queues}}
20+
1921
{{queue-navigator model=model.queues selected=model.selected
2022
used="usedCapacity" max="absMaxCapacity" setFilter=(action setFilter)}}
2123

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import { getFromMap } from '../../../helpers/get-from-map';
20+
import { module, test } from 'qunit';
21+
22+
module('Unit | Helper | get from map');
23+
24+
// Replace this with your real tests.
25+
test('it works', function(assert) {
26+
let result = getFromMap(42);
27+
assert.ok(result);
28+
});

0 commit comments

Comments
 (0)