
# Superior Scheduler REST API接口介绍
#### 功能简介
REST/HTTP是Superior Scheduler在YARN资源管理器主机和YARN资源管理网络服务端口的一部分。通常以*address:port* as*SS_REST_SERVER*.的形式指示YARN。
下面使用HTTP作为URL的一部分，并且只有HTTP将得到支持。
#### Superior Scheduler接口
- **查询** **Application**
  - 查询scheduler engine中的所有 application。
    - URL GET http://\<SS_REST_SERVER\>/ws/v1/sscheduler/applications/list
      ![](https://support.huaweicloud.com/devg3-mrs/public_sys-resources/note_3.0-zh-cn.png)
      "SS_REST_SERVER"即：*ResourceManager IP地址:端口*
      - ResourceManager IP地址：可登录FusionInsight Manager界面，选择"集群 \> 服务 \> Yarn \> 实例"查看任一ResourceManager的业务IP获取。
      
      - 端口：ResourceManager的HTTP端口。可登录FusionInsight Manager界面，选择"集群 \> 服务 \> Yarn \> 配置 \> 全部配置"搜索并查看"yarn.resourcemanager.webapp.port"参数值获取。
        
    
    - 输入 无
      
    
    - 输出
      ```
      JSON Response：
      {
       "applicationlist": [
        {
         "id": "1020201_0123_12",
         "queue": "root.Q1.Q11",
         "user": "cchen",
         "resource_request": {
             "vcores" : 10,
             "memory" : 100
        },
        "resource_inuse": {
          "vcores" : 100,
          "memory" : 2000
        },
        "number_running_container": 100,
        "number_pending_request": 10
        },
        {
        "id": "1020201_0123_15",
        "queue": "root.Q2.Q21",
        "user": "Test",
        "resource_request": {
          "vcores" : 4,
          "memory" : 100
        },
        "resource_inuse": {
          "vcores" : 20,
          "memory" : 200
        },
        "resource_reserved": {
          "vcores" : 10, 
          "memory" : 100
        },
        "number_running_container": 20,
        "number_pending_container": 4,
        "number_reserved_container":2
        }
       ]
      }
      ```
      
    
    
    表1all application参数 
    | **参数属性**                  | **参数类型** | **参数描述**                               |
    |:---|:---|:---|
    | applicationlist           | array    | applicationID的数组。                      |
    | queue                     | String   | application队列名称。                       |
    | user                      | String   | 提交application的用户名称。                    |
    | resource_request          | object   | 当前所需要的资源，包括vcores、内存等。                 |
    | resource_inuse            | object   | 当前所使用的资源，包括vcores、内存等。                 |
    | resource_reserved         | object   | 当前所预留的资源，包括vcores、内存等。                 |
    | number_running_container  | int      | 正在运行的container的总数。这反映了superior引擎的判定数量。 |
    | number_pending_request    | int      | 挂起申请的总数。这是所有分配请求总和。                    |
    | number_reserved_container | int      | 预留container的总数。这反映了superior引擎的判定数量。    |
    | id                        | String   | application ID。                        |
       
    
  
  
  
  - 查询scheduler engine中的单个application。
    - URL GET http://\<SS_REST_SERVER\>/ws/v1/sscheduler/applications/*{application_id}*
      
    
    - 输入 无
      
    
    - 输出
      ```
      JSON Response：
      {
       "applicationlist": [
        {
         "id": "1020201_0123_12",
         "queue": "root.Q1.Q11",
         "user": "cchen",
         "resource_request": {
             "vcores" : 3,
             "memory" : 3072
        },
        "resource_inuse": {
          "vcores" : 100,
          "memory" : 2048
        },
        "number_running_container": 2,
        "number_pending_request": 3,
        "number_reserved_container":1
        "master_container_id": 23402_3420842
        "master_container_resource": node1.domain.com
        "blacklist": [
          {
           "resource": "node5"
          },
          {
           "resource": "node8"
          }
        ],
        "demand": [
          {
           "priority": 1,
           "ismaster": true,
           "capability": {
           "vcores": 2,
            "memory": 2048
          },
          "count": 1,
          "relaxlocality": true,
          "locality": [
           {
            "target": "node1",
            "count": 1,
            "strict": false
           }
          ],
          "resourceselect": "label1",
          "pending_reason": "application limit reached",
          "reserved_resource": {
           "vcores":1,
            "memory":1024
          },
          "reservations":[
          "id": "23402_3420878",
          "resource": "node1.domain.com",
          "reservedAmount": {
           "vcores":1,
           "memory":1024
          } 
         ] 
        },
        {
         "priority": 1,
         "ismaster": false,
         "capability": {
         "vcores": 1,
         "memory": 1024
        },
        "count": 2,
        "relaxlocality": true,
        "locality": [
         {
          "target": "node1",
          "count": 1,
          "strict": false
         },
         {
          "target": "node2",
          "count": 1,
          "strict": false
         },
         {
          "target": "rackA",
          "count": 2,
          "strict": false
         },
        ],
        "resourceselect": "label1",
        "pending_reason": "no available resource"
        }
       ],
       "containers": [
         {
          "id": "23402_3420842",
          "resource": "node1.domain.com",
          "capability": {
           "vcores": 1,
           "memory": 1024
         }
        },
        {
          "id": "23402_3420853",
          "resource": "node2.domain.com",
          "capability": {
           "vcores": 1,
           "memory": 1024
          }
         }
        ]
       }
      }
      ```
      
    
    - 异常 未找到应用程序。
      
    
    
    表2single application参数 
    | **参数属性**                    | **参数类型** | **参数描述**                               |
    |:---|:---|:---|
    | application                 | object   | application对象。                         |
    | id                          | String   | application ID。                        |
    | queue                       | String   | application队列名称。                       |
    | user                        | String   | application的用户名称。                      |
    | resource_request            | object   | 当前所申请的资源，包括vcores、内存等。                 |
    | resource_inuse              | object   | 当前所使用的资源，包括vcores、内存等。                 |
    | resource_reserved           | object   | 当前所预留的资源，包括vcores、内存等。                 |
    | number_running_container    | int      | 正在运行的container的总数。这反映了superior引擎的判定数量。 |
    | number_pending_request      | int      | 挂起申请的总数。这反映了superior引擎的判定数量。           |
    | number_reserved_container   | int      | 预留container的总数。这反映了superior引擎的判定数量。    |
    | master_container_id         | String   | 总containerID。                          |
    | master_container_resource   | String   | 运行的主container的主机名。                     |
    | demand                      | array    | demand对象数组。                            |
    | priority                    | int      | 请求的优先级。                                |
    | ismaster                    | boolean  | 判断是否为application master需求。             |
    | capability                  | object   | Capability对象。                          |
    | vcores, memory, ..          | int      | 数值可消耗资源属性，给该命令定义分配"单元"。                |
    | count                       | int      | 单元所需的数量。                               |
    | relaxlocality               | boolean  | 本地化需求优先，如果不能满足则不强制满足。                  |
    | locality                    | object   | 本地化对象。                                 |
    | target                      | string   | 本地化目标的名称（即：节点1，框架1）。                   |
    | count                       | int      | 资源"单元"数量与所需的本地需求。                      |
    | strict                      | boolean  | 是否强制本地性。                               |
    | resourceselect              | String   | application资源选择。                       |
    | pending_reason              | String   | 该application pending的理由。               |
    | resource_reserved           | object   | 当前需求的预留资源，包括vcores、内存等。                |
    | reservations                | Array    | 预留container对象的数组。                      |
    | reservations:id             | String   | 预留container的ID。                        |
    | reservations:resource       | String   | container的分配地址。                        |
    | reservations:reserveAmount  | Object   | 预留项的总数。                                |
    | containers                  | array    | 分配container对象的数组。                      |
    | containers:id               | String   | containerID。                           |
    | containers:resource         | String   | container分配的位置。                        |
    | containers:capability       | object   | Capability对象。                          |
    | containers:vcores,memory... | int      | 分配给该container的可消耗数值型资源属性。              |
       
    
   
 
- **查询** **Queue**
  - 查询scheduler engine中的所有queue，包括叶子节点和所有中间队列。
    - URL GET http://\<SS_REST_SERVER\>/ws/v1/sscheduler/queues/list
      
    
    - 输入 无
      
    
    - 输出
      ```
      JSON Response:
      {
        "queuelist": [
          {
            "name": "root.default",
            "eopen_state": "OPEN",
            "eactive_state": "ACTIVE",
            "open_state": "OPEN",
            "active_state": "ACTIVE",
            "number_pending_application": 2,
            "number_running_application": 10,
            "number_pending_request": 2,
            "number_running_container": 10,
            "number_reserved_container":1,
            "resource_inuse" {
                "vcores": 10,
                "memory": 10240
            },
            "resource_request" {
                "vcores": 2,
                "memory": 2048
            },
            "resource_reserved" {
                "vcores": 1
                "memory": 1024
            }
            
          },
          {
            "name": "root.dev",
            "eopen_state": "OPEN",
            "eactive_state": "INACTIVE",
            "open_state": "OPEN",
            "active_state": "INACTIVE",
            "number_pending_application": 2,
            "number_running_application": 10,
            "number_pending_request": 2,
            "number_running_container": 10,
            "number_reserved_container":0,
            "resource_inuse" {
                "vcores": 10,
                "memory": 10240
            },
            "resource_request" {
                "vcores": 2,
                "memory": 2048
            },
            "resource_reserved" {
                "vcores": 0
                "memory": 0
            }
          },
          {
            "name": "root.qa",
            "eopen_state" : "CLOSED",
            "eactive_state" : "ACTIVE",
            "open_state": "CLOSED",
            "active_state": "ACTIVE",
            "number_pending_application": 2,
            "number_running_application": 10,
            "number_pending_request": 2,
            "number_running_container": 10,
            "number_reserved_container":0,
            "resource_inuse" {
                "vcores": 10,
                "memory": 10240
            },
            "resource_request" {
                "vcores": 2,
                "memory": 2048
            },
            "resource_reserved" {
                "vcores": 1
                "memory": 1024
            }
          },
          
        ]
      }
      ```
      
     
  
  
  表3all queues参数 
  | **参数属性**                   | **参数类型** | **参数描述**                                                             |
  |:---|:---|:---|
  | queuelist                  | array    | 队列名称列表。                                                              |
  | name                       | String   | 队列名称。                                                                |
  | open_state                 | String   | 队列的内在状态（自身状态）。表示队列的有效状态为OPEN或CLOSED。CLOSED状态的队列不接受任何新的allocation请求。  |
  | eopen_state                | String   | 队列的外在状态（父队列状态）。有效状态为队列自身状态及其父队列状态的组合。CLOSED状态的队列不接受任何新的allocation请求。 |
  | active_state               | String   | 队列的内在状态（自身状态）。表示队列的有效状态为ACTIVE或INACTIVE。INACTIVE状态的队列不能调度任何应用程序。     |
  | eactive_state              | String   | 队列的外在状态（父队列状态）。有效状态为队列自身状态及其父队列状态的组合。INACTIVE状态的队列不能调度任何应用程序。        |
  | number_pending_application | int      | 挂起应用的总和。                                                             |
  | number_running_application | int      | 正在运行应用的总和。                                                           |
  | number_pending_request     | int      | 挂起请求的总和。                                                             |
  | number_running_container   | int      | 正在运行container的总和。                                                    |
  | number_reserved_container  | int      | 预留container的总和。                                                      |
  | resource_request           | object   | 以vcores和内存等形式在队列中挂起的资源请求。                                            |
  | resource_inuse             | object   | 以vcores和内存等形式在队列中使用的资源。                                              |
  | resource_reserved          | object   | 以vcores和内存等形式在队列中预留的资源。                                              |
  | active_state               | String   | 描述表示队列ACTIVE或INACTIVE状态。一个INACTIVE队列不能调度任何分配请求。                      |
     
  - 查询scheduler engine中的单个queue，包括叶子节点和所有中间队列。
    - URL GET http://\<SS_REST_SERVER\>/ws/v1/sscheduler/queues/*{queuename}*
      
    
    
    
    - 输入 无
      
    
    
    
    - 输出
      ```
      JSON Response:
      {
        "queue": {
      "name": "root.default",
      "eopen_state": "CLOSED",
      "eactive_state": "INACTIVE",
          "open_state": "CLOSED",
      "active_state": "INACTIVE",
      "leaf_queue" : yes,
          "number_pending_application": 100,
      "number_running_application": 10,
          "number_pending_request": 10,
      "number_running_container": 10,
      "number_reserved_container:1,
      "resource_inuse" {
                "vcores": 10,
                "memory": 10240
            },
            "resource_request" {
                "vcores": 2,
                "memory": 2048
            },
            "resource_reserved" {
                 "vcores": 1, 
                 "memory": 1024
            }
          "configuration": {
        "description": "Production spark queue",
            "max_pending_application": 10000,
            "max_running_application": 1000,
            "allocation_order_policy": "FIFO",
            "default_resource_select": "label1",
            "max_master_share": 10%,
            "max_running_application_per_user": -1,
            "max_allocation_unit": {
                 "vcores": 32,
                 "memory": 128000
            },
            "user_acl": [
              {
                "user": "user1"
              },
              {
                "group": "group1"
              }
            ],
            "admin_acl": [
              {
                "user": "user2"
              },
              {
                "group": "group2"
              }
            ]
          }
        }
      }
      ```
      
    
    
    
    - 异常 未找到队列。
      表4single queue参数 
      | **参数属性**                         | **参数类型** | **参数描述**                                                             |
      |:---|:---|:---|
      | queue                            | object   | 队列对象。                                                                |
      | name                             | String   | 队列名称。                                                                |
      | description                      | String   | 队列描述。                                                                |
      | open_state                       | String   | 队列的内在状态（自身状态）。表示队列的有效状态为OPEN或CLOSED。CLOSED状态的队列不接受任何新的allocation请求。  |
      | eopen_state                      | String   | 队列的外在状态（父队列状态）。有效状态为队列自身状态及其父队列状态的组合。CLOSED状态的队列不接受任何新的allocation请求。 |
      | active_state                     | String   | 队列的内在状态（自身状态）。表示队列的有效状态为ACTIVE或INACTIVE。INACTIVE状态的队列不能调度任何应用程序。     |
      | eactive_state                    | String   | 队列的外在状态（父队列状态）。有效状态为队列自身状态及其父队列状态的组合。INACTIVE状态的队列不能调度任何应用程序。        |
      | leaf_queue                       | boolean  | 表示队列是否在树节点或中间队列。表示叶子节点队列。                                            |
      | number_pending_application       | int      | 当前的挂起请求数量。如果是中间队列/父队列，这是所有子队列的集合。                                    |
      | number_running_application       | int      | 当前正在运行应用的数量。如果是中间队列/父队列，这是所有子队列的集合。                                  |
      | number_pending_request           | int      | 挂起命令的数量；每个未完成命令的总计数。如果是中间队列/父队列，这是所有子队列的集合。                          |
      | number_running_container         | int      | 正在运行container的数量。如果是中间队列/父队列，这是所有子队列的集合。                             |
      | number_reserved_container        | int      | 预留container的数量。如果是中间队列/父队列，这是所有子队列的集合。                               |
      | resource_request                 | object   | 以vcores和内存等形式在队列中挂起的资源请求。                                            |
      | resource_inuse                   | object   | 以vcores和内存等形式在队列中使用的资源。                                              |
      | resource_reserved                | object   | 以vcores和内存等形式预留在队列中的资源。                                              |
      | configuration                    | object   | 队列配置目标。                                                              |
      | max_pending_application          | int      | 最大挂起应用数。如果是中间队列/父队列，这是所有子队列的集合。                                      |
      | max_running_application          | int      | 最大运行应用数。如果是中间队列/父队列，这是所有子队列的集合。                                      |
      | allocation_order_policy          | String   | 分配策略，可以使用FIFO原则，PRIORITY原则或者FAIR原则。                                  |
      | max_running_application_per_user | int      | 每个使用者运行应用的最大数量。                                                      |
      | max_master_share                 | string   | 该队列共享的百分比。                                                           |
      | max_allocation_unit              | object   | 单个container允许的最大资源，该资源以vcores和内存等形式存在。                               |
      | default_resource_select          | String   | 缺省资源选择表达式。它被使用在当应用没有被指定一个提交区间值时。                                     |
      | user_acl                         | array    | 队列中被给予user权限的使用者。                                                    |
      | admin_acl                        | array    | 该队列中被给予admin权限的使用者。                                                  |
      | group                            | String   | 用户组名称。                                                               |
      | user                             | String   | 用户名称。                                                                |
         
      
     
   
- **查询Resource Pool**
  - 查询scheduler engine中所有resource pool。
    - URL GET https://\<SS_REST_SERVER\>/ws/v1/sscheduler/resourcepools/list
      
    
    
    
    - 输入 无
      
    
    
    
    - 输出
      ```
      JSON Response:
      {
        "resourcepool_list": [
          {
            "name": "pool1",
            "description": "resource pool for crc",
            "number_member": 5,
            "members": [
              {
                "resource": "node1"
              },
              {
                "resource": "node2"
              },
              {
                "resource": "node3"
              },
              {
                "resource": "node4"
              },
              {
                "resource": "node5"
              }
            ],
            "available_resource": {
              "vcores": 60,
              "memory": 60000
            },
            "total_resource": {
              "vcores": 100,
              "memory": 128000
            },
            "configuration": {
              "resources": [
                {
                  "resource": "node1"
                },
                {
                  "resource": "node[2-5]"
                }
              ],
              "resource_select": "label1"
            }
          },
          {
            "name": "pool2",
            "description": "resource pool for erc",
            "number_member": 4
            "members": [
              {
                "resource": "node6"
              },
              {
                "resource": "node7"
              },
              {
                "resource": "node8"
              },
              {
                "resource": "node9"
              }
            ],
            "available_resource": {
              "vcores": 56,
              "memory": 48000
            },
            "total_resource": {
               "vcores": 100,
               "memory": 128000
            },
            "configuration": {
              "resources": [
                {
                  "resource": "node6"
                },
                {
                  "resource": "node[7-9]"
                }
              ],
              "resource_select": "label1"
            }
          },
          {
            "name": "default",
            "description": "system-generated",
            "number_member": 1,
            "members": [
              {
                "resource": "node0"
              }
            ],
            "available_resource": {
              "vcores": 8,
              "memory": 8192
            },
            "total_resource": {
              "vcores": 16,
              "memory": 12800
            }
          }
        ]
      }
      ```
      
    
    
    表5all resource pools参数 
    | **参数属性**           | **参数类型** | **参数描述**                                       |
    |:---|:---|:---|
    | resourcepool_list  | array    | resource pool对象数组。                             |
    | name               | String   | resource pool名称。                               |
    | number_member      | int      | resource pool成员数量。                             |
    | description        | String   | resource pool描述。                               |
    | members            | array    | 当前resource pool成员的资源名称数组。                      |
    | resource           | String   | 资源名称。                                          |
    | available_resource | object   | 该resource pool中当前可使用的资源。                       |
    | vcores, memory, .. | int      | 可消耗数值型资源属性，当前resource pool中可用资源的属性，该属性的值以数字表示。 |
    | total_resource     | object   | 该resource pool所有资源。                            |
    | vcores, memory, .. | int      | 可消耗数值型资源属性，当前resource pool中总资源的属性，该属性的值以数字表示。  |
    | configuration      | object   | 配置目标。                                          |
    | resources          | array    | 所配置的资源名称pattern数组。                             |
    | resource           | String   | 资源名称模式。                                        |
    | resource_select    | String   | 资源选择表达式。                                       |
       
    
  
  - 查询scheduler engine中单个resource pool
    - URL GET https://\<SS_REST_SERVER\>/ws/v1/sscheduler/resourcepools/*{resourcepoolname}*
      
    
    
    
    - 输入 无
      
    
    
    
    - 输出
      ```
      JSON Response:
      {
        "resourcepool": {
          "name": "pool1",
          "description": "resource pool for crc",
          "number_member": 5
          "members": [
            {
              "resource": "node1"
            },
            {
              "resource": "node2"
            },
            {
              "resource": "node3"
            },
            {
              "resource": "node4"
            },
            {
              "resource": "node5"
            }
          ],
          "available_resource": {
            "vcores": 60,
            "memory": 60000
      },
      "total_resource": {
        "vcores": 100,
        "memory": 128000
      },
          "configuration": {
            "resources": [
              {
                "resource": "node6"
              },
              {
                "resource": "node[7-9]"
              }
            ],
            "resource_select": "label1"
          }
        }
      }
      ```
      
    
    
    
    - 异常 未找到resource pool。
      
    
    
    表6single resource pool参数 
    | **参数属性**           | **参数类型** | **参数描述**                                       |
    |:---|:---|:---|
    | resourcepool       | object   | resource pool对象。                               |
    | name               | String   | resource pool名称。                               |
    | description        | String   | resource pool描述。                               |
    | number_member      | int      | resource pool成员数量。                             |
    | members            | array    | 该resource pool现任成员的资源名称数组。                     |
    | resource           | String   | 资源名称。                                          |
    | available_resource | object   | 该resource pool当前可用资源。                          |
    | vcores, memory, .. | int      | 可消耗数值型资源属性，当前resource pool中可用资源的属性，该属性的值以数字表示。 |
    | total_resource     | object   | 该resource pool中所有资源。                           |
    | vcores, memory, .. | int      | 可消耗数值型资源属性，当前resource pool中总资源的属性，该属性的值以数字表示。  |
    | configuration      | object   | 配置目标。                                          |
    | resources          | array    | 所配置的资源名称pattern数组。                             |
    | resource           | String   | 资源名称模式。                                        |
    | resource_select    | String   | 资源选择表达式。                                       |
       
    
   
- **查询policiesxmlconf**
  - URL GET http://\<SS_REST_SERVER\>/ws/v1/sscheduler/policiesxmlconf/list
    
  
  
  
  - 输入 无
    
  
  
  
  - 输出
    ```
    <policies>
      <policlist>
        <resourcepool>default</resourcepool>
        <queues>
          <name>default</name>
          <fullname>root.default</fullname>
          <share>20.0</share>
          <reserve>memory 0,vcores 0 : 0.0%</reserve>
          <minimum>memory 0,vcores 0 : 20.0%</minimum>
          <maximum>memory 0,vcores 0 : 100.0%</maximum>
          <defaultuser>
            <maximum>100.0%</maximum>
            <weight>1.0</weight>
          </defaultuser>
        </queues>
      </policlist>
    </policies>
    ```
    
   
 
