Yarn 资源管理
更新时间:2026-07-23
接口总览
| 接口名称 | 说明 | openapi 方法 | openapi 路径 |
|---|---|---|---|
| DescribeYarnGlobalConfig | 查询 YARN 全局调度配置 | POST | /v2/bcc/yarnQueue/[clusterId]/globalConf/detail |
| ModifyYarnGlobalConfig | 修改 YARN 全局调度配置 | POST | /v2/bcc/yarnQueue/[clusterId]/globalConf/update |
| DescribeCapacityQueues | 查询 Capacity 队列详情 | POST | /v2/bcc/yarnQueue/[clusterId]/capacity/detail |
| ModifyCapacityQueues | 修改 Capacity 队列配置 | POST | /v2/bcc/yarnQueue/[clusterId]/capacity/update |
| DescribeFairQueues | 查询 Fair 队列详情 | POST | /v2/bcc/yarnQueue/[clusterId]/fair/detail |
| ModifyFairQueues | 修改 Fair 队列配置 | POST | /v2/bcc/yarnQueue/[clusterId]/fair/update |
| GetLabelSchedulingStatus | 查询标签调度状态 | POST | /v2/bcc/yarnLabel/[clusterId]/status |
| ToggleLabelScheduling | 开启/关闭标签调度 | POST | /v2/bcc/yarnLabel/[clusterId]/toggle |
| DescribeLabels | 查询标签详情 | POST | /v2/bcc/yarnLabel/[clusterId]/detail |
| ModifyLabels | 变更标签 | POST | /v2/bcc/yarnLabel/[clusterId]/update |
| SyncLabels | 同步标签 | POST | /v2/bcc/yarnLabel/[clusterId]/sync |
DescribeYarnGlobalConfig
接口描述
查询集群 YARN 的全局调度配置。
请求结构
Plain Text
1POST /v2/bcc/yarnQueue/[clusterId]/globalConf/detail HTTP/1.1
请求参数
| 名称 | 类型 | 是否必须 | 参数位置 | 参数描述 |
|---|---|---|---|---|
| clusterId | String | 是 | URL | 集群 ID |
响应参数
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| success | Boolean | 请求是否成功 |
| status | Int | HTTP 状态码 |
| result | YarnGlobalConf | Yarn 全局调度配置 |
请求示例
Plain Text
1POST /v2/bcc/yarnQueue/[clusterId]/globalConf/detail HTTP/1.1
响应示例
JSON
1{
2 "success": true,
3 "status": 200,
4 "result": {
5 "clusterId": "0181b994-576a-4a00-b04e-f6fa9d5eee48",
6 "capacityNodeLocalityDelay": 40,
7 "capacityResourceCalculator": "DefaultResourceCalculator",
8 "queueType": "capacity",
9 "queueMappings": "u:%user:%user"
10 }
11}
ModifyYarnGlobalConfig
接口描述
修改集群 YARN 的全局调度配置。
请求结构
Plain Text
1POST /v2/bcc/yarnQueue/[clusterId]/globalConf/update HTTP/1.1
2Content-Type: application/json
3
4{
5 "clusterId": clusterId,
6 "capacityNodeLocalityDelay": capacityNodeLocalityDelay,
7 "capacityResourceCalculator": capacityResourceCalculator,
8 "queueType": queueType,
9 "queueMappings": queueMappings
10}
请求参数
| 名称 | 类型 | 是否必须 | 参数位置 | 参数描述 |
|---|---|---|---|---|
| clusterId | String | 是 | URL/RequestBody | 集群 ID |
| capacityResourceCalculator | String | 是 | RequestBody | 资源计算器类型,取值:DefaultResourceCalculator / DominantResourceCalculator |
| queueType | String | 是 | RequestBody | 队列调度类型(capacity / fair),默认 capacity |
| capacityNodeLocalityDelay | Int | 否 | RequestBody | 节点本地化延迟调度参数,默认 -1 |
| queueMappings | String | 否 | RequestBody | 队列映射规则 |
响应参数
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| success | Boolean | 请求是否成功 |
| status | Int | HTTP 状态码 |
| result | Null | 成功时为空 |
请求示例
JSON
1{
2 "clusterId": "0181b994-576a-4a00-b04e-f6fa9d5eee48",
3 "capacityNodeLocalityDelay": 40,
4 "capacityResourceCalculator": "DefaultResourceCalculator",
5 "queueType": "capacity",
6 "queueMappings": "u:%user:%user"
7}
响应示例
JSON
1{
2 "success": true,
3 "status": 200,
4 "result": null
5}
DescribeCapacityQueues
接口描述
查询 Capacity 调度器的队列列表。
请求结构
Plain Text
1POST /v2/bcc/yarnQueue/[clusterId]/capacity/detail HTTP/1.1
请求参数
| 名称 | 类型 | 是否必须 | 参数位置 | 参数描述 |
|---|---|---|---|---|
| clusterId | String | 是 | URL | 集群 ID |
响应参数
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| success | Boolean | 请求是否成功 |
| status | Int | HTTP 状态码 |
| result.capacityQueue | List |
Capacity 队列列表 |
请求示例
Plain Text
1POST /v2/bcc/yarnQueue/[clusterId]/capacity/detail HTTP/1.1
响应示例
JSON
1{
2 "success": true,
3 "status": 200,
4 "result": {
5 "capacityQueue": [
6 {
7 "id": 1,
8 "name": "root",
9 "fullQueueName": "root",
10 "parentId": 0,
11 "level": 0,
12 "capacity": 100,
13 "maxCapacity": 100,
14 "userLimitFactor": 1,
15 "minUserLimit": 100,
16 "maxAllocMb": 8192,
17 "maxAllocVcore": 4,
18 "maxApplications": 10000,
19 "maxAmResource": 10,
20 "status": "RUNNING",
21 "allowedUsers": ["*"],
22 "accessibleLabels": [],
23 "defaultLabelExpression": ""
24 },
25 {
26 "id": 2,
27 "name": "default",
28 "fullQueueName": "root.default",
29 "parentId": 1,
30 "level": 1,
31 "capacity": 60,
32 "maxCapacity": 100,
33 "userLimitFactor": 1,
34 "minUserLimit": 100,
35 "maxAllocMb": 8192,
36 "maxAllocVcore": 4,
37 "maxApplications": 10000,
38 "maxAmResource": 10,
39 "status": "RUNNING",
40 "allowedUsers": ["*"],
41 "accessibleLabels": [
42 {"labelName": "ssd", "capacity": 60, "maxCapacity": 100}
43 ],
44 "defaultLabelExpression": "ssd"
45 }
46 ]
47 }
48}
ModifyCapacityQueues
接口描述
全量刷新(修改)Capacity 调度器的队列配置。
请求结构
Plain Text
1POST /v2/bcc/yarnQueue/[clusterId]/capacity/update HTTP/1.1
2Content-Type: application/json
3
4{
5 "capacityQueue": [
6 {
7 "name": queueName,
8 "fullQueueName": fullQueueName,
9 "parentId": parentId,
10 "capacity": capacity,
11 "maxCapacity": maxCapacity,
12 "userLimitFactor": userLimitFactor,
13 "minUserLimit": minUserLimit,
14 "maxAllocMb": maxAllocMb,
15 "maxAllocVcore": maxAllocVcore,
16 "maxApplications": maxApplications,
17 "maxAmResource": maxAmResource,
18 "status": status,
19 "allowedUsers": ["username"],
20 "accessibleLabels": [
21 {
22 "labelName": labelName,
23 "capacity": capacity,
24 "maxCapacity": maxCapacity
25 }
26 ],
27 "defaultLabelExpression": "string"
28 }
29 ]
30}
请求参数
| 名称 | 类型 | 是否必须 | 参数位置 | 参数描述 |
|---|---|---|---|---|
| clusterId | String | 是 | URL | 集群 ID |
| capacityQueue | List |
是 | RequestBody | Capacity 队列配置列表(全量),元素结构见数据类型 |
响应参数
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| success | Boolean | 请求是否成功 |
| status | Int | HTTP 状态码 |
| result | Null | 成功时为空 |
请求示例
JSON
1{
2 "capacityQueue": [
3 {
4 "name": "root",
5 "fullQueueName": "root",
6 "parentId": 0,
7 "capacity": 100,
8 "maxCapacity": 100,
9 "userLimitFactor": 1,
10 "minUserLimit": 100,
11 "maxAllocMb": 8192,
12 "maxAllocVcore": 4,
13 "maxApplications": 10000,
14 "maxAmResource": 10,
15 "status": "RUNNING",
16 "allowedUsers": ["*"],
17 "accessibleLabels": [],
18 "defaultLabelExpression": ""
19 },
20 {
21 "name": "default",
22 "fullQueueName": "root.default",
23 "parentId": 1,
24 "capacity": 60,
25 "maxCapacity": 100,
26 "userLimitFactor": 1,
27 "minUserLimit": 100,
28 "maxAllocMb": 8192,
29 "maxAllocVcore": 4,
30 "maxApplications": 10000,
31 "maxAmResource": 10,
32 "status": "RUNNING",
33 "allowedUsers": ["*"],
34 "accessibleLabels": [
35 {"labelName": "ssd", "capacity": 60, "maxCapacity": 100}
36 ],
37 "defaultLabelExpression": "ssd"
38 }
39 ]
40}
响应示例
JSON
1{
2 "success": true,
3 "status": 200,
4 "result": null
5}
DescribeFairQueues
接口描述
查询 Fair 调度器的队列列表。
请求结构
Plain Text
1POST /v2/bcc/yarnQueue/[clusterId]/fair/detail HTTP/1.1
请求参数
| 名称 | 类型 | 是否必须 | 参数位置 | 参数描述 |
|---|---|---|---|---|
| clusterId | String | 是 | URL | 集群 ID |
响应参数
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| success | Boolean | 请求是否成功 |
| status | Int | HTTP 状态码 |
| result.fairQueue | List |
Fair 队列列表 |
请求示例
Plain Text
1POST /v2/bcc/yarnQueue/[clusterId]/fair/detail HTTP/1.1
响应示例
JSON
1{
2 "success": true,
3 "status": 200,
4 "result": {
5 "fairQueue": [
6 {
7 "id": 1,
8 "createAt": "2026-06-01T10:00:00Z",
9 "name": "root",
10 "fullQueueName": "root",
11 "parentId": 0,
12 "level": 0,
13 "status": "RUNNING",
14 "weight": 1,
15 "minResources": "0 mb,0 vcores",
16 "maxResources": "8192 mb,4 vcores",
17 "maxRunningApps": 100,
18 "maxAmShare": -1,
19 "schedulingPolicy": "fair",
20 "allowPreemptionFrom": true,
21 "fairSharePreemptionThreshold": 0.5,
22 "fairSharePreemptionTimeout": 60,
23 "minSharePreemptionTimeout": 60
24 }
25 ]
26 }
27}
ModifyFairQueues
接口描述
全量刷新(修改)Fair 调度器的队列配置。
请求结构
Plain Text
1POST /v2/bcc/yarnQueue/[clusterId]/fair/update HTTP/1.1
2Content-Type: application/json
3
4{
5 "fairQueue": [
6 {
7 "name": "string",
8 "fullQueueName": "string",
9 "parentId": 0,
10 "weight": 0,
11 "minResources": "string",
12 "maxResources": "string",
13 "maxRunningApps": 0,
14 "maxAmShare": 0,
15 "schedulingPolicy": "string",
16 "allowPreemptionFrom": false,
17 "fairSharePreemptionThreshold": 0,
18 "fairSharePreemptionTimeout": 0,
19 "minSharePreemptionTimeout": 0,
20 "status": "string"
21 }
22 ]
23}
请求参数
| 名称 | 类型 | 是否必须 | 参数位置 | 参数描述 |
|---|---|---|---|---|
| clusterId | String | 是 | URL | 集群 ID |
| fairQueue | List |
是 | RequestBody | Fair 队列配置列表(全量),元素结构见数据类型 |
响应参数
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| success | Boolean | 请求是否成功 |
| status | Int | HTTP 状态码 |
| result | Null | 成功时为空 |
请求示例
JSON
1{
2 "fairQueue": [
3 {
4 "name": "root",
5 "fullQueueName": "root",
6 "parentId": 0,
7 "weight": 1,
8 "minResources": "0 mb,0 vcores",
9 "maxResources": "8192 mb,4 vcores",
10 "maxRunningApps": 100,
11 "maxAmShare": -1,
12 "schedulingPolicy": "fair",
13 "allowPreemptionFrom": true,
14 "fairSharePreemptionThreshold": 0.5,
15 "fairSharePreemptionTimeout": 60,
16 "minSharePreemptionTimeout": 60,
17 "status": "RUNNING"
18 }
19 ]
20}
响应示例
JSON
1{
2 "success": true,
3 "status": 200,
4 "result": null
5}
GetLabelSchedulingStatus
接口描述
查询集群 YARN 标签调度是否开启。
请求结构
Plain Text
1POST /v2/bcc/yarnLabel/[clusterId]/status HTTP/1.1
请求参数
| 名称 | 类型 | 是否必须 | 参数位置 | 参数描述 |
|---|---|---|---|---|
| clusterId | String | 是 | URL | 集群 ID |
响应参数
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| success | Boolean | 请求是否成功 |
| status | Int | HTTP 状态码 |
| result.enabled | Boolean | 标签调度是否开启 |
请求示例
Plain Text
1POST /v2/bcc/yarnLabel/[clusterId]/status
响应示例
JSON
1{
2 "success": true,
3 "status": 200,
4 "result": {
5 "enabled": true
6 }
7}
ToggleLabelScheduling
接口描述
开启或关闭集群 YARN 标签调度。
请求结构
Plain Text
1POST /v2/bcc/yarnLabel/[clusterId]/toggle?enable=true HTTP/1.1
请求参数
| 名称 | 类型 | 是否必须 | 参数位置 | 参数描述 |
|---|---|---|---|---|
| clusterId | String | 是 | URL | 集群 ID |
| enable | String | 是 | Query | 是否开启,true 开启、其余值关闭。缺失时报参数错误 |
响应参数
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| success | Boolean | 请求是否成功 |
| status | Int | HTTP 状态码 |
| result.operationId | String | 操作 ID |
请求示例
Plain Text
1POST /v2/bcc/yarnLabel/[clusterId]/toggle?enable=true HTTP/1.1
响应示例
JSON
1{
2 "success": true,
3 "status": 200,
4 "result": {
5 "operationId": "op-xxxx"
6 }
7}
ListTags
接口描述
查询集群的 YARN 节点标签列表。
请求结构
Plain Text
1POST /v2/bcc/yarnLabel/[clusterId]/detail HTTP/1.1
请求参数
| 名称 | 类型 | 是否必须 | 参数位置 | 参数描述 |
|---|---|---|---|---|
| clusterId | String | 是 | URL | 集群 ID |
响应参数
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| success | Boolean | 请求是否成功 |
| status | Int | HTTP 状态码 |
| result | List |
标签列表 |
请求示例
Plain Text
1POST /v2/bcc/yarnLabel/[clusterId]/detail HTTP/1.1
响应示例
JSON
1{
2 "success": true,
3 "status": 200,
4 "result": [
5 {
6 "name": "ssd",
7 "isExclusive": true,
8 "nodeCount": 2,
9 "nodes": ["host-1", "host-2"],
10 "totalCpu": 16,
11 "totalMemoryGB": 64,
12 "isDefaultPartition": false
13 },
14 {
15 "name": "",
16 "isExclusive": true,
17 "nodeCount": 1,
18 "nodes": ["host-3"],
19 "totalCpu": 8,
20 "totalMemoryGB": 32,
21 "isDefaultPartition": true
22 }
23 ]
24}
ModifyTags
接口描述
声明式更新集群的 YARN 节点标签(以传入列表为最终状态)。
请求结构
Plain Text
1POST /v2/bcc/yarnLabel/[clusterId]/update HTTP/1.1
2Content-Type: application/json
3
4{
5 "labels": [
6 {
7 "name": labelName,
8 "isExclusive": isExclusive,
9 "nodes": [nodename1, nodename2]
10 },
11 {
12 "name": "hdd",
13 "isExclusive": false,
14 "nodes": [nodename3]
15 }
16 ]
17}
请求参数
| 名称 | 类型 | 是否必须 | 参数位置 | 参数描述 |
|---|---|---|---|---|
| clusterId | String | 是 | URL | 集群 ID |
| labels | List |
是 | RequestBody | 标签列表(声明式全量) |
响应参数
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| success | Boolean | 请求是否成功 |
| status | Int | HTTP 状态码 |
| result.operationId | String | 操作 ID(无变更时 result 为空) |
请求示例
JSON
1{
2 "labels": [
3 {
4 "name": "ssd",
5 "isExclusive": true,
6 "nodes": ["host-1", "host-2"]
7 },
8 {
9 "name": "hdd",
10 "isExclusive": false,
11 "nodes": ["host-3"]
12 }
13 ]
14}
响应示例
JSON
1{
2 "success": true,
3 "status": 200,
4 "result": {
5 "operationId": "op-xxxx"
6 }
7}
SyncTags
接口描述
从集群侧同步 YARN 标签信息到 Console 数据库。
请求结构
Plain Text
1POST /v2/bcc/yarnLabel/[clusterId]/sync HTTP/1.1
请求参数
| 名称 | 类型 | 是否必须 | 参数位置 | 参数描述 |
|---|---|---|---|---|
| clusterId | String | 是 | URL | 集群 ID |
响应参数
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| success | Boolean | 请求是否成功 |
| status | Int | HTTP 状态码 |
| result | List |
同步后的标签列表 |
| result[].isDefaultPartition | Bool | 是否为默认分区 |
请求示例
Plain Text
1POST /v2/bcc/yarnLabel/[clusterId]/sync HTTP/1.1
响应示例
JSON
1{
2 "success": true,
3 "status": 200,
4 "result": [
5 {
6 "name": "ssd",
7 "isExclusive": true,
8 "nodeCount": 2,
9 "nodes": ["host-1", "host-2"],
10 "totalCpu": 16,
11 "totalMemoryGB": 64,
12 "isDefaultPartition": false
13 }
14 ]
15}
错误返回码
| HTTP Status | Code | Message | 触发场景 |
|---|---|---|---|
| 400 | MalformedJSON | The JSON provided is not well-formed | 请求体不是合法 JSON,参数绑定失败 |
| 400 | InvalidParameter | Invalid request parameter | 请求参数不合法(如 cluster_id 缺失、必填字段为空) |
| 400 | InvalidArguments | Invalid arguments | 入参组合或取值不合法 |
| 400 | InvalidParameter | queue {queue}: defaultLabelExpression '{label}' is not in accessibleLabels | 队列设置的 defaultLabelExpression 不在该队列的 accessibleLabels 中 |
| 400 | InvalidParameter | labels {labels} not found | 队列引用了集群中不存在的标签 |
| 400 | InvalidParameter | label '{label}' capacity sum is {sum}, expected 100 [{queues}] | 同一标签下各子队列容量之和不等于 100 |
| 400 | InvalidParameter | non-leaf queue {queue} has label '{label}' but no direct child carries this label | 非叶子队列声明了某标签,但其直接子队列均未携带该标签 |
| 400 | InvalidParameter | queue {queue}: parent queue id {id} not found in request | 队列的 parentId 在本次提交的列表中找不到对应队列 |
| 400 | InvalidParameter | queue {queue}: accessibleLabels [{labels}] not subset of parent {parent} | 子队列的 accessibleLabels 不是父队列的子集 |
| 400 | InvalidParameter | invalid label name: {name} | 标签名不符合 ^[a-zA-Z0-9][a-zA-Z0-9_\-]{0,254}$ |
| 400 | InvalidParameter | duplicate label name: {name} | labels 列表中存在重名标签 |
| 400 | InvalidParameter | node {node} is bound to multiple labels: {labelA}, {labelB} | 同一节点被绑定到多个标签 |
| 400 | LabelSchedulingNotEnabled | please enable label scheduling first | 集群标签调度未开启 |
| 400 | LabelSchedulingNotEnabled | 队列 {queues} 设置了 defaultLabelExpression,但当前集群标签调度已关闭,请先启用调度或清空该字段 | 队列设置了 defaultLabelExpression,但集群标签调度未启用 |
| 400 | SchedulerTypeError | label scheduling only supports Capacity Scheduler, please switch scheduler first | 当前调度器非 Capacity Scheduler |
| 401 | Unauthorized | Check unauthorized | 身份未认证或认证失败 |
| 403 | AccessDenied | Access denied, please contact your administrator | 无权限访问该资源(IAM/Console 鉴权拒绝) |
| 404 | ClusterNotFound | The cluster not found | cluster_id 对应的集群不存在 |
| 429 | RequestLimited | Request frequency is too high, please slow down and try again later | 请求频率过高,被限流 |
| 500 | InternalError | Internal Server Error | 服务内部错误(包括下游 Ambari / formation 调用失败) |
| 503 | ServiceUnavailable | Service is unavailable | 依赖的下游服务不可用 |
评价此篇文章
