-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
YARN-11757. [UI2] Add partition usage overview to the Queues page
- Loading branch information
Showing
4 changed files
with
169 additions
and
1 deletion.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/helpers/get-from-map.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
66 changes: 66 additions & 0 deletions
66
...t/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/partition-usage.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>Partition Name</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}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...roject/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/tests/unit/helpers/get-from-map-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); |