ResourceManager REST API

概觀

ResourceManager REST API 允許使用者取得叢集資訊,包括叢集狀態、叢集指標、排程器資訊、叢集節點資訊和叢集應用程式資訊。

啟用 CORS 支援

若要僅為 RM 啟用跨來源支援 (CORS)(不為 NM 啟用),請設定下列組態參數

在 core-site.xml 中,將 org.apache.hadoop.security.HttpCrossOriginFilterInitializer 新增至 hadoop.http.filter.initializers。在 yarn-site.xml 中,將 yarn.resourcemanager.webapp.cross-origin.enabled 設定為 true。

叢集資訊 API

叢集資訊資源提供叢集的整體資訊。

URI

以下兩個 URI 都會提供您叢集資訊。

支援的 HTTP 作業

  • GET

支援的查詢參數

  None

clusterInfo 物件的元素

項目 資料類型 說明
id 長整數 叢集 ID
startedOn 長整數 叢集啟動時間(自紀元以來的毫秒數)
state 字串 ResourceManager 狀態,有效值包括:NOTINITED、INITED、STARTED、STOPPED
haState 字串 ResourceManager HA 狀態,有效值包括:INITIALIZING、ACTIVE、STANDBY、STOPPED
rmStateStoreName 字串 實作 ResourceManager 狀態儲存的類別的完整限定名稱
resourceManagerVersion 字串 ResourceManager 版本
resourceManagerBuildVersion 字串 ResourceManager 建置字串,包含建置版本、使用者和檢查碼
resourceManagerVersionBuiltOn 字串 ResourceManager 建置時間(自紀元以來的毫秒數)
hadoopVersion 字串 Hadoop Common 版本
hadoopBuildVersion 字串 Hadoop Common 建置字串,包含建置版本、使用者和檢查碼
hadoopVersionBuiltOn 字串 Hadoop Common 建置時間(自紀元以來的毫秒數)
haZooKeeperConnectionState 字串 高可用性服務的 ZooKeeper 連線狀態

回應範例

JSON 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/info

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

回應本文

{
  "clusterInfo":
  {
    "id":1324053971963,
    "startedOn":1324053971963,
    "state":"STARTED",
    "haState":"ACTIVE",
    "rmStateStoreName":"org.apache.hadoop.yarn.server.resourcemanager.recovery.NullRMStateStore",
    "resourceManagerVersion":"3.0.0-SNAPSHOT",
    "resourceManagerBuildVersion":"3.0.0-SNAPSHOT from unknown by user1 source checksum 11111111111111111111111111111111",
    "resourceManagerVersionBuiltOn":"2016-01-01T01:00Z",
    "hadoopVersion":"3.0.0-SNAPSHOT",
    "hadoopBuildVersion":"3.0.0-SNAPSHOT from unknown by user1 source checksum 11111111111111111111111111111111",
    "hadoopVersionBuiltOn":"2016-01-01T01:00Z",
    "haZooKeeperConnectionState": "ResourceManager HA is not enabled."  }
}

XML 回應

HTTP 要求

  Accept: application/xml
  GET http://rm-http-address:port/ws/v1/cluster/info

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Content-Length: 712
  Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<clusterInfo>
  <id>1476912658570</id>
  <startedOn>1476912658570</startedOn>
  <state>STARTED</state>
  <haState>ACTIVE</haState>
  <rmStateStoreName>org.apache.hadoop.yarn.server.resourcemanager.recovery.NullRMStateStore</rmStateStoreName>
  <resourceManagerVersion>3.0.0-SNAPSHOT</resourceManagerVersion>
  <resourceManagerBuildVersion>3.0.0-SNAPSHOT from unknown by user1 source checksum 11111111111111111111111111111111</resourceManagerBuildVersion>
  <resourceManagerVersionBuiltOn>2016-01-01T01:00Z</resourceManagerVersionBuiltOn>
  <hadoopVersion>3.0.0-SNAPSHOT</hadoopVersion>
  <hadoopBuildVersion>3.0.0-SNAPSHOT from unknown by user1 source checksum 11111111111111111111111111111111</hadoopBuildVersion>
  <hadoopVersionBuiltOn>2016-01-01T01:00Z</hadoopVersionBuiltOn>
  <haZooKeeperConnectionState>ResourceManager HA is not enabled.</haZooKeeperConnectionState>
</clusterInfo>

叢集指標 API

叢集指標資源提供一些關於叢集的整體指標。更詳細的指標應從 jmx 介面中擷取。

URI

支援的 HTTP 作業

  • GET

支援的查詢參數

  None

clusterMetrics 物件的元素

項目 資料類型 說明
appsSubmitted int 提交的應用程式數量
appsCompleted int 已完成的應用程式數量
appsPending int 待處理的應用程式數量
appsRunning int 正在執行的應用程式數量
appsFailed int 失敗的應用程式數量
appsKilled int 已終止的應用程式數量
reservedMB 長整數 保留的記憶體量(MB)
availableMB 長整數 可用的記憶體量(MB)
allocatedMB 長整數 已配置的記憶體量(MB)
totalMB 長整數 總記憶體量(MB)
reservedVirtualCores 長整數 保留的虛擬核心數量
availableVirtualCores 長整數 可用的虛擬核心數量
allocatedVirtualCores 長整數 已配置的虛擬核心數量
totalVirtualCores 長整數 總虛擬核心數量
containersAllocated int 已配置的容器數量
containersReserved int 保留的容器數量
containersPending int 待處理的容器數量
totalNodes int 總節點數
activeNodes int 活動節點數
lostNodes int 遺失節點數
unhealthyNodes int 異常節點數
decommissioningNodes int 正在停用的節點數
decommissionedNodes int 已停用的節點數
rebootedNodes int 已重新開機的節點數
shutdownNodes int 已關閉的節點數

回應範例

JSON 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/metrics

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

回應本文

{
  "clusterMetrics":
  {
    "appsSubmitted":0,
    "appsCompleted":0,
    "appsPending":0,
    "appsRunning":0,
    "appsFailed":0,
    "appsKilled":0,
    "reservedMB":0,
    "availableMB":17408,
    "allocatedMB":0,
    "reservedVirtualCores":0,
    "availableVirtualCores":7,
    "allocatedVirtualCores":1,
    "containersAllocated":0,
    "containersReserved":0,
    "containersPending":0,
    "totalMB":17408,
    "totalVirtualCores":8,
    "totalNodes":1,
    "lostNodes":0,
    "unhealthyNodes":0,
    "decommissioningNodes":0,
    "decommissionedNodes":0,
    "rebootedNodes":0,
    "activeNodes":1,
    "shutdownNodes":0
  }
}

XML 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/metrics
  Accept: application/xml

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Content-Length: 432
  Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<clusterMetrics>
  <appsSubmitted>0</appsSubmitted>
  <appsCompleted>0</appsCompleted>
  <appsPending>0</appsPending>
  <appsRunning>0</appsRunning>
  <appsFailed>0</appsFailed>
  <appsKilled>0</appsKilled>
  <reservedMB>0</reservedMB>
  <availableMB>17408</availableMB>
  <allocatedMB>0</allocatedMB>
  <reservedVirtualCores>0</reservedVirtualCores>
  <availableVirtualCores>7</availableVirtualCores>
  <allocatedVirtualCores>1</allocatedVirtualCores>
  <containersAllocated>0</containersAllocated>
  <containersReserved>0</containersReserved>
  <containersPending>0</containersPending>
  <totalMB>17408</totalMB>
  <totalVirtualCores>8</totalVirtualCores>
  <totalNodes>1</totalNodes>
  <lostNodes>0</lostNodes>
  <unhealthyNodes>0</unhealthyNodes>
  <decommissioningNodes>0</decommissioningNodes>
  <decommissionedNodes>0</decommissionedNodes>
  <rebootedNodes>0</rebootedNodes>
  <activeNodes>1</activeNodes>
  <shutdownNodes>0</shutdownNodes>
</clusterMetrics>

叢集排程器 API

排程器資源包含叢集中所配置的目前排程器資訊。它目前支援 Fifo、Capacity 和 Fair 排程器。您會取得不同的資訊,具體取決於已配置哪個排程器,因此請務必查看類型資訊。

URI

支援的 HTTP 作業

  • GET

支援的查詢參數

  None

容量排程器 API

容量排程器支援階層式佇列。此請求會列印所有佇列及其子佇列的資訊。可提交作業的佇列稱為葉狀佇列。這些佇列有額外資料與之關聯。

schedulerInfo 物件的元素

項目 資料類型 說明
類型 字串 排程器類型 - capacityScheduler
容量 浮點數 相對於其父佇列的已設定佇列容量(百分比)
已用容量 浮點數 已用佇列容量(百分比)
最大容量 浮點數 相對於其父佇列的已設定最大佇列容量(百分比)
佇列名稱 字串 佇列名稱
佇列 佇列陣列 (JSON)/零個或多個佇列物件 (XML) 佇列資源的集合
狀態 單一狀態物件 容量排程器的狀態指標。此指標自 2.8.0 版開始存在,但輸出格式不佳。因此,使用者無法明確地使用此欄位,這已自 3.2.0 版起最佳化。

父佇列的佇列物件元素

項目 資料類型 說明
容量 浮點數 相對於其父佇列的已設定佇列容量(百分比)
已用容量 浮點數 已用佇列容量(百分比)
最大容量 浮點數 相對於其父佇列的已設定最大佇列容量(百分比)
絕對容量 浮點數 此佇列可使用的整個叢集的絕對容量百分比
絕對最大容量 浮點數 此佇列可使用的整個叢集的絕對最大容量百分比
絕對已用容量 浮點數 此佇列正在使用的整個叢集的絕對已用容量百分比
應用程式數量 int 目前佇列中的應用程式數量
已用資源 字串 描述佇列目前已用資源的字串
佇列名稱 字串 佇列名稱
state 佇列狀態字串 佇列狀態
佇列 佇列陣列 (JSON)/零個或多個佇列物件 (XML) 子佇列資訊的集合。如果佇列沒有子佇列,則省略。
已用資源 單一資源物件 此佇列使用的總資源量

葉狀佇列的佇列物件元素 - 包含父佇列中所有元素,但下列項目除外:‘佇列’,並加上下列項目:

項目 資料類型 說明
類型 字串 佇列類型 - capacitySchedulerLeafQueueInfo
已啟用應用程式數量 int 此佇列中的已啟用應用程式數量
待處理應用程式數量 int 此佇列中待處理的應用程式數量
numContainers int 正在使用的容器數量
allocatedContainers int 此佇列中已配置的容器數量
reservedContainers int 此佇列中已保留的容器數量
pendingContainers int 此佇列中待處理的容器數量
maxApplications int 此佇列可擁有的最大應用程式數量
maxApplicationsPerUser int 此佇列可擁有的每個使用者最大應用程式數量
maxActiveApplications int 此佇列可擁有的最大活動應用程式數量
maxActiveApplicationsPerUser int 此佇列可擁有的每個使用者最大活動應用程式數量
userLimit int 設定中設定的最小使用者限制百分比
userLimitFactor 浮點數 設定中設定的使用者限制因子
users 使用者陣列 (JSON)/零個或多個使用者物件 (XML) 包含已使用資源的使用者物件集合

使用者物件的元素,適用於使用者

項目 資料類型 說明
username 字串 使用資源的使用者使用者名稱
已用資源 單一資源物件 此佇列中使用者使用的資源數量
已啟用應用程式數量 int 此佇列中此使用者的活動應用程式數量
待處理應用程式數量 int 此佇列中此使用者的待處理應用程式數量

使用者和佇列中 resourcesUsed 的資源物件元素

項目 資料類型 說明
memory int 已使用的記憶體數量 (MB)
vCores int 虛擬核心數量

schedulerInfo 中 health 物件的元素

項目 資料類型 說明
lastrun 長整數 應用程式開始的時間 (自紀元以來的毫秒數)
operationsInfo 作業陣列 (JSON)/作業物件 (XML) 作業物件集合
lastRunDetails lastRunDetails 陣列 (JSON)/lastRunDetail 物件 (XML) lastRunDetail 物件集合

health 中作業物件的元素

項目 資料類型 說明
operation 字串 作業類型
nodeId 字串 作業所關聯的節點 ID
containerId 字串 作業所關聯的容器 ID
queue 字串 作業所關聯的佇列名稱

health 中 lastRunDetail 物件的元素

項目 資料類型 說明
operation 字串 作業類型
count 長整數 作業所關聯的節點 ID
資源 單一資源物件 作業相關的資源

回應範例

JSON 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/scheduler

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

回應本文

{
    "scheduler": {
        "schedulerInfo": {
            "capacity": 100.0,
            "maxCapacity": 100.0,
            "queueName": "root",
            "queues": {
                "queue": [
                    {
                        "absoluteCapacity": 10.5,
                        "absoluteMaxCapacity": 50.0,
                        "absoluteUsedCapacity": 0.0,
                        "capacity": 10.5,
                        "maxCapacity": 50.0,
                        "numApplications": 0,
                        "queueName": "a",
                        "queues": {
                            "queue": [
                                {
                                    "absoluteCapacity": 3.15,
                                    "absoluteMaxCapacity": 25.0,
                                    "absoluteUsedCapacity": 0.0,
                                    "capacity": 30.000002,
                                    "maxCapacity": 50.0,
                                    "numApplications": 0,
                                    "queueName": "a1",
                                    "queues": {
                                        "queue": [
                                            {
                                                "absoluteCapacity": 2.6775,
                                                "absoluteMaxCapacity": 25.0,
                                                "absoluteUsedCapacity": 0.0,
                                                "capacity": 85.0,
                                                "maxActiveApplications": 1,
                                                "maxActiveApplicationsPerUser": 1,
                                                "maxApplications": 267,
                                                "maxApplicationsPerUser": 267,
                                                "maxCapacity": 100.0,
                                                "numActiveApplications": 0,
                                                "numApplications": 0,
                                                "numContainers": 0,
                                                "numPendingApplications": 0,
                                                "queueName": "a1a",
                                                "resourcesUsed": {
                                                    "memory": 0,
                                                    "vCores": 0
                                                },
                                                "state": "RUNNING",
                                                "type": "capacitySchedulerLeafQueueInfo",
                                                "usedCapacity": 0.0,
                                                "usedResources": "<memory:0, vCores:0>",
                                                "userLimit": 100,
                                                "userLimitFactor": 1.0,
                                                "users": null
                                            },
                                            {
                                                "absoluteCapacity": 0.47250003,
                                                "absoluteMaxCapacity": 25.0,
                                                "absoluteUsedCapacity": 0.0,
                                                "capacity": 15.000001,
                                                "maxActiveApplications": 1,
                                                "maxActiveApplicationsPerUser": 1,
                                                "maxApplications": 47,
                                                "maxApplicationsPerUser": 47,
                                                "maxCapacity": 100.0,
                                                "numActiveApplications": 0,
                                                "numApplications": 0,
                                                "numContainers": 0,
                                                "numPendingApplications": 0,
                                                "queueName": "a1b",
                                                "resourcesUsed": {
                                                    "memory": 0,
                                                    "vCores": 0
                                                },
                                                "state": "RUNNING",
                                                "type": "capacitySchedulerLeafQueueInfo",
                                                "usedCapacity": 0.0,
                                                "usedResources": "<memory:0, vCores:0>",
                                                "userLimit": 100,
                                                "userLimitFactor": 1.0,
                                                "users": null
                                            }
                                        ]
                                    },
                                    "resourcesUsed": {
                                        "memory": 0,
                                        "vCores": 0
                                    },
                                    "state": "RUNNING",
                                    "usedCapacity": 0.0,
                                    "usedResources": "<memory:0, vCores:0>"
                                },
                                {
                                    "absoluteCapacity": 7.35,
                                    "absoluteMaxCapacity": 50.0,
                                    "absoluteUsedCapacity": 0.0,
                                    "capacity": 70.0,
                                    "maxActiveApplications": 1,
                                    "maxActiveApplicationsPerUser": 100,
                                    "maxApplications": 735,
                                    "maxApplicationsPerUser": 73500,
                                    "maxCapacity": 100.0,
                                    "numActiveApplications": 0,
                                    "numApplications": 0,
                                    "numContainers": 0,
                                    "numPendingApplications": 0,
                                    "queueName": "a2",
                                    "resourcesUsed": {
                                        "memory": 0,
                                        "vCores": 0
                                    },
                                    "state": "RUNNING",
                                    "type": "capacitySchedulerLeafQueueInfo",
                                    "usedCapacity": 0.0,
                                    "usedResources": "<memory:0, vCores:0>",
                                    "userLimit": 100,
                                    "userLimitFactor": 100.0,
                                    "users": null
                                }
                            ]
                        },
                        "resourcesUsed": {
                            "memory": 0,
                            "vCores": 0
                        },
                        "state": "RUNNING",
                        "usedCapacity": 0.0,
                        "usedResources": "<memory:0, vCores:0>"
                    },
                    {
                        "absoluteCapacity": 89.5,
                        "absoluteMaxCapacity": 100.0,
                        "absoluteUsedCapacity": 0.0,
                        "capacity": 89.5,
                        "maxCapacity": 100.0,
                        "numApplications": 2,
                        "queueName": "b",
                        "queues": {
                            "queue": [
                                {
                                    "absoluteCapacity": 53.7,
                                    "absoluteMaxCapacity": 100.0,
                                    "absoluteUsedCapacity": 0.0,
                                    "capacity": 60.000004,
                                    "maxActiveApplications": 1,
                                    "maxActiveApplicationsPerUser": 100,
                                    "maxApplications": 5370,
                                    "maxApplicationsPerUser": 537000,
                                    "maxCapacity": 100.0,
                                    "numActiveApplications": 1,
                                    "numApplications": 2,
                                    "numContainers": 0,
                                    "numPendingApplications": 1,
                                    "queueName": "b1",
                                    "resourcesUsed": {
                                        "memory": 0,
                                        "vCores": 0
                                    },
                                    "state": "RUNNING",
                                    "type": "capacitySchedulerLeafQueueInfo",
                                    "usedCapacity": 0.0,
                                    "usedResources": "<memory:0, vCores:0>",
                                    "userLimit": 100,
                                    "userLimitFactor": 100.0,
                                    "users": {
                                        "user": [
                                            {
                                                "numActiveApplications": 0,
                                                "numPendingApplications": 1,
                                                "resourcesUsed": {
                                                    "memory": 0,
                                                    "vCores": 0
                                                },
                                                "username": "user2"
                                            },
                                            {
                                                "numActiveApplications": 1,
                                                "numPendingApplications": 0,
                                                "resourcesUsed": {
                                                    "memory": 0,
                                                    "vCores": 0
                                                },
                                                "username": "user1"
                                            }
                                        ]
                                    }
                                },
                                {
                                    "absoluteCapacity": 35.3525,
                                    "absoluteMaxCapacity": 100.0,
                                    "absoluteUsedCapacity": 0.0,
                                    "capacity": 39.5,
                                    "maxActiveApplications": 1,
                                    "maxActiveApplicationsPerUser": 100,
                                    "maxApplications": 3535,
                                    "maxApplicationsPerUser": 353500,
                                    "maxCapacity": 100.0,
                                    "numActiveApplications": 0,
                                    "numApplications": 0,
                                    "numContainers": 0,
                                    "numPendingApplications": 0,
                                    "queueName": "b2",
                                    "resourcesUsed": {
                                        "memory": 0,
                                        "vCores": 0
                                    },
                                    "state": "RUNNING",
                                    "type": "capacitySchedulerLeafQueueInfo",
                                    "usedCapacity": 0.0,
                                    "usedResources": "<memory:0, vCores:0>",
                                    "userLimit": 100,
                                    "userLimitFactor": 100.0,
                                    "users": null
                                },
                                {
                                    "absoluteCapacity": 0.4475,
                                    "absoluteMaxCapacity": 100.0,
                                    "absoluteUsedCapacity": 0.0,
                                    "capacity": 0.5,
                                    "maxActiveApplications": 1,
                                    "maxActiveApplicationsPerUser": 100,
                                    "maxApplications": 44,
                                    "maxApplicationsPerUser": 4400,
                                    "maxCapacity": 100.0,
                                    "numActiveApplications": 0,
                                    "numApplications": 0,
                                    "numContainers": 0,
                                    "numPendingApplications": 0,
                                    "queueName": "b3",
                                    "resourcesUsed": {
                                        "memory": 0,
                                        "vCores": 0
                                    },
                                    "state": "RUNNING",
                                    "type": "capacitySchedulerLeafQueueInfo",
                                    "usedCapacity": 0.0,
                                    "usedResources": "<memory:0, vCores:0>",
                                    "userLimit": 100,
                                    "userLimitFactor": 100.0,
                                    "users": null
                                }
                            ]
                        },
                        "resourcesUsed": {
                            "memory": 0,
                            "vCores": 0
                        },
                        "state": "RUNNING",
                        "usedCapacity": 0.0,
                        "usedResources": "<memory:0, vCores:0>"
                    }
                ]
            },
            "health": {
                "lastrun": 1326381444693,
                "operationsInfo": [
                    {
                        "operation": "last-allocation",
                        "nodeId": "N/A",
                        "containerId": "N/A",
                        "queue": "N/A"
                    },
                    {
                        "operation": "last-release",
                        "nodeId": "host.domain.com:8041",
                        "containerId": "container_1326821518301_0005_01_000001",
                        "queue": "root.default"
                    },
                    {
                        "operation": "last-preemption",
                        "nodeId": "N/A",
                        "containerId": "N/A",
                        "queue": "N/A"
                    },
                    {
                        "operation": "last-reservation",
                        "nodeId": "N/A",
                        "containerId": "N/A",
                        "queue": "N/A"
                    }
                ],
                "lastRunDetails": [
                    {
                        "operation": "releases",
                        "count": 0,
                        "resources": {
                            "memory": 0,
                            "vCores": 0
                        }
                    },
                    {
                        "operation": "allocations",
                        "count": 0,
                        "resources": {
                            "memory": 0,
                            "vCores": 0
                        }
                    },
                    {
                        "operation": "reservations",
                        "count": 0,
                        "resources": {
                            "memory": 0,
                            "vCores": 0
                        }
                    }
                ]
            },
            "type": "capacityScheduler",
            "usedCapacity": 0.0
        }
    }
}
```json

**XML response**

HTTP Request:

      Accept: application/xml
      GET http://rm-http-address:port/ws/v1/cluster/scheduler

Response Header:

      HTTP/1.1 200 OK
      Content-Type: application/xml
      Content-Length: 5778
      Server: Jetty(6.1.26)

Response Body:

```xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<scheduler>
  <schedulerInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="capacityScheduler">
    <capacity>100.0</capacity>
    <usedCapacity>0.0</usedCapacity>
    <maxCapacity>100.0</maxCapacity>
    <queueName>root</queueName>
    <queues>
      <queue>
        <capacity>10.5</capacity>
        <usedCapacity>0.0</usedCapacity>
        <maxCapacity>50.0</maxCapacity>
        <absoluteCapacity>10.5</absoluteCapacity>
        <absoluteMaxCapacity>50.0</absoluteMaxCapacity>
        <absoluteUsedCapacity>0.0</absoluteUsedCapacity>
        <numApplications>0</numApplications>
        <usedResources>&lt;memory:0, vCores:0&gt;</usedResources>
        <queueName>a</queueName>
        <state>RUNNING</state>
        <queues>
          <queue>
            <capacity>30.000002</capacity>
            <usedCapacity>0.0</usedCapacity>
            <maxCapacity>50.0</maxCapacity>
            <absoluteCapacity>3.15</absoluteCapacity>
            <absoluteMaxCapacity>25.0</absoluteMaxCapacity>
            <absoluteUsedCapacity>0.0</absoluteUsedCapacity>
            <numApplications>0</numApplications>
            <usedResources>&lt;memory:0, vCores:0&gt;</usedResources>
            <queueName>a1</queueName>
            <state>RUNNING</state>
            <queues>
              <queue xsi:type="capacitySchedulerLeafQueueInfo">
                <capacity>85.0</capacity>
                <usedCapacity>0.0</usedCapacity>
                <maxCapacity>100.0</maxCapacity>
                <absoluteCapacity>2.6775</absoluteCapacity>
                <absoluteMaxCapacity>25.0</absoluteMaxCapacity>
                <absoluteUsedCapacity>0.0</absoluteUsedCapacity>
                <numApplications>0</numApplications>
                <usedResources>&lt;memory:0, vCores:0&gt;</usedResources>
                <queueName>a1a</queueName>
                <state>RUNNING</state>
                <resourcesUsed>
                  <memory>0</memory>
                  <vCores>0</vCores>
                </resourcesUsed>
                <numActiveApplications>0</numActiveApplications>
                <numPendingApplications>0</numPendingApplications>
                <numContainers>0</numContainers>
                <maxApplications>267</maxApplications>
                <maxApplicationsPerUser>267</maxApplicationsPerUser>
                <maxActiveApplications>1</maxActiveApplications>
                <maxActiveApplicationsPerUser>1</maxActiveApplicationsPerUser>
                <userLimit>100</userLimit>
                <users/>
                <userLimitFactor>1.0</userLimitFactor>
              </queue>
              <queue xsi:type="capacitySchedulerLeafQueueInfo">
                <capacity>15.000001</capacity>
                <usedCapacity>0.0</usedCapacity>
                <maxCapacity>100.0</maxCapacity>
                <absoluteCapacity>0.47250003</absoluteCapacity>
                <absoluteMaxCapacity>25.0</absoluteMaxCapacity>
                <absoluteUsedCapacity>0.0</absoluteUsedCapacity>
                <numApplications>0</numApplications>
                <usedResources>&lt;memory:0, vCores:0&gt;</usedResources>
                <queueName>a1b</queueName>
                <state>RUNNING</state>
                <resourcesUsed>
                  <memory>0</memory>
                  <vCores>0</vCores>
                </resourcesUsed>
                <numActiveApplications>0</numActiveApplications>
                <numPendingApplications>0</numPendingApplications>
                <numContainers>0</numContainers>
                <maxApplications>47</maxApplications>
                <maxApplicationsPerUser>47</maxApplicationsPerUser>
                <maxActiveApplications>1</maxActiveApplications>
                <maxActiveApplicationsPerUser>1</maxActiveApplicationsPerUser>
                <userLimit>100</userLimit>
                <users/>
                <userLimitFactor>1.0</userLimitFactor>
              </queue>
            </queues>
            <resourcesUsed>
              <memory>0</memory>
              <vCores>0</vCores>
            </resourcesUsed>
          </queue>
          <queue xsi:type="capacitySchedulerLeafQueueInfo">
            <capacity>70.0</capacity>
            <usedCapacity>0.0</usedCapacity>
            <maxCapacity>100.0</maxCapacity>
            <absoluteCapacity>7.35</absoluteCapacity>
            <absoluteMaxCapacity>50.0</absoluteMaxCapacity>
            <absoluteUsedCapacity>0.0</absoluteUsedCapacity>
            <numApplications>0</numApplications>
            <usedResources>&lt;memory:0, vCores:0&gt;</usedResources>
            <queueName>a2</queueName>
            <state>RUNNING</state>
            <resourcesUsed>
              <memory>0</memory>
              <vCores>0</vCores>
            </resourcesUsed>
            <numActiveApplications>0</numActiveApplications>
            <numPendingApplications>0</numPendingApplications>
            <numContainers>0</numContainers>
            <maxApplications>735</maxApplications>
            <maxApplicationsPerUser>73500</maxApplicationsPerUser>
            <maxActiveApplications>1</maxActiveApplications>
            <maxActiveApplicationsPerUser>100</maxActiveApplicationsPerUser>
            <userLimit>100</userLimit>
            <users/>
            <userLimitFactor>100.0</userLimitFactor>
          </queue>
        </queues>
        <resourcesUsed>
          <memory>0</memory>
          <vCores>0</vCores>
        </resourcesUsed>
      </queue>
      <queue>
        <capacity>89.5</capacity>
        <usedCapacity>0.0</usedCapacity>
        <maxCapacity>100.0</maxCapacity>
        <absoluteCapacity>89.5</absoluteCapacity>
        <absoluteMaxCapacity>100.0</absoluteMaxCapacity>
        <absoluteUsedCapacity>0.0</absoluteUsedCapacity>
        <numApplications>2</numApplications>
        <usedResources>&lt;memory:0, vCores:0&gt;</usedResources>
        <queueName>b</queueName>
        <state>RUNNING</state>
        <queues>
          <queue xsi:type="capacitySchedulerLeafQueueInfo">
            <capacity>60.000004</capacity>
            <usedCapacity>0.0</usedCapacity>
            <maxCapacity>100.0</maxCapacity>
            <absoluteCapacity>53.7</absoluteCapacity>
            <absoluteMaxCapacity>100.0</absoluteMaxCapacity>
            <absoluteUsedCapacity>0.0</absoluteUsedCapacity>
            <numApplications>2</numApplications>
            <usedResources>&lt;memory:0, vCores:0&gt;</usedResources>
            <queueName>b1</queueName>
            <state>RUNNING</state>
            <resourcesUsed>
              <memory>0</memory>
              <vCores>0</vCores>
            </resourcesUsed>
            <numActiveApplications>1</numActiveApplications>
            <numPendingApplications>1</numPendingApplications>
            <numContainers>0</numContainers>
            <maxApplications>5370</maxApplications>
            <maxApplicationsPerUser>537000</maxApplicationsPerUser>
            <maxActiveApplications>1</maxActiveApplications>
            <maxActiveApplicationsPerUser>100</maxActiveApplicationsPerUser>
            <userLimit>100</userLimit>
            <users>
              <user>
                <username>user2</username>
                <resourcesUsed>
                  <memory>0</memory>
                  <vCores>0</vCores>
                </resourcesUsed>
                <numPendingApplications>1</numPendingApplications>
                <numActiveApplications>0</numActiveApplications>
              </user>
              <user>
                <username>user1</username>
                <resourcesUsed>
                  <memory>0</memory>
                  <vCores>0</vCores>
                </resourcesUsed>
                <numPendingApplications>0</numPendingApplications>
                <numActiveApplications>1</numActiveApplications>
              </user>
            </users>
            <userLimitFactor>100.0</userLimitFactor>
          </queue>
          <queue xsi:type="capacitySchedulerLeafQueueInfo">
            <capacity>39.5</capacity>
            <usedCapacity>0.0</usedCapacity>
            <maxCapacity>100.0</maxCapacity>
            <absoluteCapacity>35.3525</absoluteCapacity>
            <absoluteMaxCapacity>100.0</absoluteMaxCapacity>
            <absoluteUsedCapacity>0.0</absoluteUsedCapacity>
            <numApplications>0</numApplications>
            <usedResources>&lt;memory:0, vCores:0&gt;</usedResources>
            <queueName>b2</queueName>
            <state>RUNNING</state>
            <resourcesUsed>
              <memory>0</memory>
              <vCores>0</vCores>
            </resourcesUsed>
            <numActiveApplications>0</numActiveApplications>
            <numPendingApplications>0</numPendingApplications>
            <numContainers>0</numContainers>
            <maxApplications>3535</maxApplications>
            <maxApplicationsPerUser>353500</maxApplicationsPerUser>
            <maxActiveApplications>1</maxActiveApplications>
            <maxActiveApplicationsPerUser>100</maxActiveApplicationsPerUser>
            <userLimit>100</userLimit>
            <users/>
            <userLimitFactor>100.0</userLimitFactor>
          </queue>
          <queue xsi:type="capacitySchedulerLeafQueueInfo">
            <capacity>0.5</capacity>
            <usedCapacity>0.0</usedCapacity>
            <maxCapacity>100.0</maxCapacity>
            <absoluteCapacity>0.4475</absoluteCapacity>
            <absoluteMaxCapacity>100.0</absoluteMaxCapacity>
            <absoluteUsedCapacity>0.0</absoluteUsedCapacity>
            <numApplications>0</numApplications>
            <usedResources>&lt;memory:0, vCores:0&gt;</usedResources>
            <queueName>b3</queueName>
            <state>RUNNING</state>
            <resourcesUsed>
              <memory>0</memory>
              <vCores>0</vCores>
            </resourcesUsed>
            <numActiveApplications>0</numActiveApplications>
            <numPendingApplications>0</numPendingApplications>
            <numContainers>0</numContainers>
            <maxApplications>44</maxApplications>
            <maxApplicationsPerUser>4400</maxApplicationsPerUser>
            <maxActiveApplications>1</maxActiveApplications>
            <maxActiveApplicationsPerUser>100</maxActiveApplicationsPerUser>
            <userLimit>100</userLimit>
            <users/>
            <userLimitFactor>100.0</userLimitFactor>
          </queue>
        </queues>
        <resourcesUsed>
          <memory>0</memory>
          <vCores>0</vCores>
        </resourcesUsed>
      </queue>
    </queues>
    <health>
      <lastrun>1326381444693</lastrun>
      <operationsInfo>
        <operation>last-allocation</operation>
        <nodeId>N/A</nodeId>
        <containerId>N/A</containerId>
        <queue>N/A</queue>
      </operationsInfo>
      <operationsInfo>
        <operation>last-release</operation>
        <nodeId>host.domain.com:8041</nodeId>
        <containerId>container_1326821518301_0005_01_000001</containerId>
        <queue>root.default</queue>
      </operationsInfo>
      <operationsInfo>
        <operation>last-preemption</operation>
        <nodeId>N/A</nodeId>
        <containerId>N/A</containerId>
        <queue>N/A</queue>
      </operationsInfo>
      <operationsInfo>
        <operation>last-reservation</operation>
        <nodeId>N/A</nodeId>
        <containerId>N/A</containerId>
        <queue>N/A</queue>
      </operationsInfo>
      <lastRunDetails>
        <operation>releases</operation>
        <count>0</count>
        <resources>
          <memory>0</memory>
          <vCores>0</vCores>
        </resources>
      </lastRunDetails>
      <lastRunDetails>
        <operation>allocations</operation>
        <count>0</count>
        <resources>
          <memory>0</memory>
          <vCores>0</vCores>
        </resources>
      </lastRunDetails>
      <lastRunDetails>
        <operation>reservations</operation>
        <count>0</count>
        <resources>
          <memory>0</memory>
          <vCores>0</vCores>
        </resources>
      </lastRunDetails>
    </health>
  </schedulerInfo>
</scheduler>

Fifo Scheduler API

schedulerInfo 物件的元素

項目 資料類型 說明
類型 字串 排程器類型 - fifoScheduler
容量 浮點數 佇列容量(百分比)
已用容量 浮點數 已用佇列容量(百分比)
qstate 字串 佇列狀態 - 有效值:已停止、執行中
minQueueMemoryCapacity int 最小佇列記憶體容量
maxQueueMemoryCapacity int 最大佇列記憶體容量
numNodes int 總節點數
usedNodeCapacity int 已使用的節點容量
availNodeCapacity int 可用的節點容量
totalNodeCapacity int 總節點容量
numContainers int 容器數量

回應範例

JSON 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/scheduler

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

回應本文

{
  "scheduler":
  {
    "schedulerInfo":
    {
      "type":"fifoScheduler",
      "capacity":1,
      "usedCapacity":"NaN",
      "qstate":"RUNNING",
      "minQueueMemoryCapacity":1024,
      "maxQueueMemoryCapacity":10240,
      "numNodes":0,
      "usedNodeCapacity":0,
      "availNodeCapacity":0,
      "totalNodeCapacity":0,
      "numContainers":0
    }
  }
}

XML 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/scheduler
  Accept: application/xml

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Content-Length: 432
  Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<scheduler>
  <schedulerInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="fifoScheduler">
    <capacity>1.0</capacity>
    <usedCapacity>NaN</usedCapacity>
    <qstate>RUNNING</qstate>
    <minQueueMemoryCapacity>1024</minQueueMemoryCapacity>
    <maxQueueMemoryCapacity>10240</maxQueueMemoryCapacity>
    <numNodes>0</numNodes>
    <usedNodeCapacity>0</usedNodeCapacity>
    <availNodeCapacity>0</availNodeCapacity>
    <totalNodeCapacity>0</totalNodeCapacity>
    <numContainers>0</numContainers>
  </schedulerInfo>
</scheduler>

Fair Scheduler API

schedulerInfo 物件的元素

項目 資料類型 說明
類型 字串 排程器類型 - fairScheduler
rootQueue 根佇列物件 根佇列資源集合

所有佇列物件的元素

項目 資料類型 說明
maxApps int 佇列可擁有的最大應用程式數量
minResources 單一資源物件 保證提供給佇列的設定最小資源
maxResources 單一資源物件 允許提供給佇列的設定最大資源
已用資源 單一資源物件 佇列中容器分配的資源總和
fairResources 單一資源物件 佇列公平共享的資源
clusterResources 單一資源物件 叢集容量
佇列名稱 字串 佇列名稱
schedulingPolicy 字串 佇列使用的排程政策名稱
childQueues 佇列陣列(JSON)/佇列物件(XML) 子佇列資訊集合。如果佇列沒有子佇列或為葉狀佇列,則省略。
allocatedContainers int 已分配容器數量
demandResources 單一資源物件 此佇列中容器要求但排程器尚未滿足的資源
pendingContainers int 未處理容器數量
preemptable 布林值 如果此佇列中的容器可以被搶佔,則為 true
reservedContainers int 已保留容器數量
steadyFairResources 單一資源物件 佇列的穩定公平共享

葉狀佇列物件的其他元素(「childQueues」屬性除外)

項目 資料類型 說明
類型 字串 佇列類型 - fairSchedulerLeafQueueInfo
numActiveApps int 此佇列中的已啟用應用程式數量
numPendingApps int 此佇列中待處理的應用程式數量

佇列中(叢集/需求/公平/最大/最小/已使用/*)資源物件的元素

項目 資料類型 說明
memory int 已使用的記憶體數量 (MB)
vCores int 虛擬核心數量

回應範例

JSON 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/scheduler

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

回應本文

{
    "scheduler": {
        "schedulerInfo": {
            "rootQueue": {
                "allocatedContainers": 0,
                "childQueues": {
                    "queue": [
                        {
                            "allocatedContainers": 0,
                            "clusterResources": {
                                "memory": 8192,
                                "vCores": 8
                            },
                            "demandResources": {
                                "memory": 0,
                                "vCores": 0
                            },
                            "fairResources": {
                                "memory": 0,
                                "vCores": 0
                            },
                            "maxApps": 2147483647,
                            "maxResources": {
                                "memory": 8192,
                                "vCores": 8
                            },
                            "minResources": {
                                "memory": 0,
                                "vCores": 0
                            },
                            "numActiveApps": 0,
                            "numPendingApps": 0,
                            "pendingContainers": 0,
                            "preemptable": true,
                            "queueName": "root.default",
                            "reservedContainers": 0,
                            "schedulingPolicy": "fair",
                            "steadyFairResources": {
                                "memory": 4096,
                                "vCores": 0
                            },
                            "type": "fairSchedulerLeafQueueInfo",
                            "usedResources": {
                                "memory": 0,
                                "vCores": 0
                            }
                        },
                        {
                            "allocatedContainers": 0,
                            "childQueues": {
                                "queue": [
                                    {
                                        "allocatedContainers": 0,
                                        "clusterResources": {
                                            "memory": 8192,
                                            "vCores": 8
                                        },
                                        "demandResources": {
                                            "memory": 0,
                                            "vCores": 0
                                        },
                                        "fairResources": {
                                            "memory": 10000,
                                            "vCores": 0
                                        },
                                        "maxApps": 2147483647,
                                        "maxResources": {
                                            "memory": 8192,
                                            "vCores": 8
                                        },
                                        "minResources": {
                                            "memory": 5000,
                                            "vCores": 0
                                        },
                                        "numActiveApps": 0,
                                        "numPendingApps": 0,
                                        "pendingContainers": 0,
                                        "preemptable": true,
                                        "queueName": "root.sample_queue.sample_sub_queue",
                                        "reservedContainers": 0,
                                        "schedulingPolicy": "fair",
                                        "steadyFairResources": {
                                            "memory": 4096,
                                            "vCores": 0
                                        },
                                        "type": "fairSchedulerLeafQueueInfo",
                                        "usedResources": {
                                            "memory": 0,
                                            "vCores": 0
                                        }
                                    }
                                ]
                            },
                            "clusterResources": {
                                "memory": 8192,
                                "vCores": 8
                            },
                            "demandResources": {
                                "memory": 0,
                                "vCores": 0
                            },
                            "fairResources": {
                                "memory": 10000,
                                "vCores": 0
                            },
                            "maxApps": 50,
                            "maxResources": {
                                "memory": 8192,
                                "vCores": 0
                            },
                            "minResources": {
                                "memory": 10000,
                                "vCores": 0
                            },
                            "pendingContainers": 0,
                            "preemptable": true,
                            "queueName": "root.sample_queue",
                            "reservedContainers": 0,
                            "schedulingPolicy": "fair",
                            "steadyFairResources": {
                                "memory": 4096,
                                "vCores": 0
                            },
                            "usedResources": {
                                "memory": 0,
                                "vCores": 0
                            }
                        }
                    ]
                },
                "clusterResources": {
                    "memory": 8192,
                    "vCores": 8
                },
                "demandResources": {
                    "memory": 0,
                    "vCores": 0
                },
                "fairResources": {
                    "memory": 8192,
                    "vCores": 8
                },
                "maxApps": 2147483647,
                "maxResources": {
                    "memory": 8192,
                    "vCores": 8
                },
                "minResources": {
                    "memory": 0,
                    "vCores": 0
                },
                "pendingContainers": 0,
                "preemptable": true,
                "queueName": "root",
                "reservedContainers": 0,
                "schedulingPolicy": "fair",
                "steadyFairResources": {
                    "memory": 8192,
                    "vCores": 8
                },
                "usedResources": {
                    "memory": 0,
                    "vCores": 0
                }
            },
            "type": "fairScheduler"
        }
    }
}

XML 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/scheduler
  Accept: application/xml

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Content-Length: 2321
  Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<scheduler>
  <schedulerInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="fairScheduler">
    <rootQueue>
      <maxApps>2147483647</maxApps>
      <minResources>
        <memory>0</memory>
        <vCores>0</vCores>
      </minResources>
      <maxResources>
        <memory>8192</memory>
        <vCores>8</vCores>
      </maxResources>
      <usedResources>
        <memory>0</memory>
        <vCores>0</vCores>
      </usedResources>
      <demandResources>
        <memory>0</memory>
        <vCores>0</vCores>
      </demandResources>
      <steadyFairResources>
        <memory>8192</memory>
        <vCores>8</vCores>
      </steadyFairResources>
      <fairResources>
        <memory>8192</memory>
        <vCores>8</vCores>
      </fairResources>
      <clusterResources>
        <memory>8192</memory>
        <vCores>8</vCores>
      </clusterResources>
      <pendingContainers>0</pendingContainers>
      <allocatedContainers>0</allocatedContainers>
      <reservedContainers>0</reservedContainers>
      <queueName>root</queueName>
      <schedulingPolicy>fair</schedulingPolicy>
      <preemptable>true</preemptable>
      <childQueues>
        <queue xsi:type="fairSchedulerLeafQueueInfo">
          <maxApps>2147483647</maxApps>
          <minResources>
            <memory>0</memory>
            <vCores>0</vCores>
          </minResources>
          <maxResources>
            <memory>8192</memory>
            <vCores>8</vCores>
          </maxResources>
          <usedResources>
            <memory>0</memory>
            <vCores>0</vCores>
          </usedResources>
          <demandResources>
            <memory>0</memory>
            <vCores>0</vCores>
          </demandResources>
          <steadyFairResources>
            <memory>4096</memory>
            <vCores>0</vCores>
          </steadyFairResources>
          <fairResources>
            <memory>0</memory>
            <vCores>0</vCores>
          </fairResources>
          <clusterResources>
            <memory>8192</memory>
            <vCores>8</vCores>
          </clusterResources>
          <pendingContainers>0</pendingContainers>
          <allocatedContainers>0</allocatedContainers>
          <reservedContainers>0</reservedContainers>
          <queueName>root.default</queueName>
          <schedulingPolicy>fair</schedulingPolicy>
          <preemptable>true</preemptable>
          <numPendingApps>0</numPendingApps>
          <numActiveApps>0</numActiveApps>
        </queue>
        <queue>
          <maxApps>50</maxApps>
          <minResources>
            <memory>0</memory>
            <vCores>0</vCores>
          </minResources>
          <maxResources>
            <memory>8192</memory>
            <vCores>0</vCores>
          </maxResources>
          <usedResources>
            <memory>0</memory>
            <vCores>0</vCores>
          </usedResources>
          <demandResources>
            <memory>0</memory>
            <vCores>0</vCores>
          </demandResources>
          <steadyFairResources>
            <memory>4096</memory>
            <vCores>0</vCores>
          </steadyFairResources>
          <fairResources>
            <memory>10000</memory>
            <vCores>0</vCores>
          </fairResources>
          <clusterResources>
            <memory>8192</memory>
            <vCores>8</vCores>
          </clusterResources>
          <pendingContainers>0</pendingContainers>
          <allocatedContainers>0</allocatedContainers>
          <reservedContainers>0</reservedContainers>
          <queueName>root.sample_queue</queueName>
          <schedulingPolicy>fair</schedulingPolicy>
          <preemptable>true</preemptable>
          <childQueues>
            <queue xsi:type="fairSchedulerLeafQueueInfo">
              <maxApps>2147483647</maxApps>
              <minResources>
                <memory>5000</memory>
                <vCores>0</vCores>
              </minResources>
              <maxResources>
                <memory>8192</memory>
                <vCores>8</vCores>
              </maxResources>
              <usedResources>
                <memory>0</memory>
                <vCores>0</vCores>
              </usedResources>
              <demandResources>
                <memory>0</memory>
                <vCores>0</vCores>
              </demandResources>
              <steadyFairResources>
                <memory>4096</memory>
                <vCores>0</vCores>
              </steadyFairResources>
              <fairResources>
                <memory>10000</memory>
                <vCores>0</vCores>
              </fairResources>
              <clusterResources>
                <memory>8192</memory>
                <vCores>8</vCores>
              </clusterResources>
              <pendingContainers>0</pendingContainers>
              <allocatedContainers>0</allocatedContainers>
              <reservedContainers>0</reservedContainers>
              <queueName>root.sample_queue.sample_sub_queue</queueName>
              <schedulingPolicy>fair</schedulingPolicy>
              <preemptable>true</preemptable>
              <numPendingApps>0</numPendingApps>
              <numActiveApps>0</numActiveApps>
            </queue>
          </childQueues>
        </queue>
      </childQueues>
    </rootQueue>
  </schedulerInfo>
</scheduler>

叢集應用程式 API

使用應用程式 API,您可以取得資源集合,每個資源都代表一個應用程式。當您對此資源執行 GET 作業時,您會取得應用程式物件集合。

URI

支援的 HTTP 作業

  • GET

支援的查詢參數

GET 作業可指定多個參數。已開始和已完成時間有開始和結束參數,可讓您指定範圍。例如,可以要求在 2011/12/19 上午 1:00 到下午 2:00 之間開始的所有應用程式,其 startedTimeBegin=1324256400&startedTimeEnd=1324303200。如果未指定開始參數,其預設值為 0,如果未指定結束參數,其預設值為無限大。此 API 的所有查詢參數會過濾所有應用程式。但是,queue 查詢參數只會隱含地過濾目前在指定佇列中的未完成應用程式。

  • state [已棄用] - 應用程式的狀態
    • states - 與指定應用程式狀態相符的應用程式,指定為逗號分隔清單。
    • finalStatus - 應用程式的最終狀態 - 由應用程式本身報告
    • user - 使用者名稱
    • queue - 目前在這個佇列中的未完成應用程式
    • limit - 要傳回的 app 物件總數
    • startedTimeBegin - 開始時間以此時間開始的應用程式,以自紀元以來的毫秒數指定
    • startedTimeEnd - 開始時間以此時間結束的應用程式,以自紀元以來的毫秒數指定
    • finishedTimeBegin - 完成時間以此時間開始的應用程式,以自紀元以來的毫秒數指定
    • finishedTimeEnd - 完成時間以此時間結束的應用程式,以自紀元以來的毫秒數指定
    • applicationTypes - 與指定應用程式類型相符的應用程式,指定為逗號分隔清單。
    • applicationTags - 與任何指定應用程式標籤相符的應用程式,指定為逗號分隔清單。
    • name - 應用程式的名稱
    • deSelects - 結果中會略過的通用欄位。

apps (應用程式) 物件的元素

當您要求應用程式清單時,資訊會傳回為 app 物件的集合。另請參閱 應用程式 API 以取得 app 物件的語法。

項目 資料類型 說明
app app 物件陣列 (JSON)/零個或多個應用程式物件 (XML) 應用程式物件的集合

deSelects 參數的元素

協助不需要特定資訊的請求者減少負擔。

目前支援的項目

項目 資料類型 說明
resouceRequests 逗號分隔字串 略過應用程式的資源要求

例如

回應範例

JSON 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/apps

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

回應本文

{
  "apps":
  {
    "app":
    [
      {
        "id": "application_1476912658570_0002",
        "user": "user2",
        "name": "word count",
        "queue": "default",
        "state": "FINISHED",
        "finalStatus": "SUCCEEDED",
        "progress": 100,
        "trackingUI": "History",
        "trackingUrl": "http://host.domain.com:8088/cluster/app/application_1476912658570_0002",
        "diagnostics": "...",
        "clusterId": 1476912658570,
        "applicationType": "MAPREDUCE",
        "applicationTags": "",
        "priority": -1,
        "startedTime": 1476913457320,
        "finishedTime": 1476913761898,
        "elapsedTime": 304578,
        "amContainerLogs": "http://host.domain.com:8042/node/containerlogs/container_1476912658570_0002_02_000001/user2",
        "amHostHttpAddress": "host.domain.com:8042",
        "allocatedMB": 0,
        "allocatedVCores": 0,
        "runningContainers": 0,
        "memorySeconds": 206464,
        "vcoreSeconds": 201,
        "queueUsagePercentage": 0,
        "clusterUsagePercentage": 0,
        "preemptedResourceMB": 0,
        "preemptedResourceVCores": 0,
        "numNonAMContainerPreempted": 0,
        "numAMContainerPreempted": 0,
        "logAggregationStatus": "DISABLED",
        "unmanagedApplication": false,
        "appNodeLabelExpression": "",
        "amNodeLabelExpression": "",
        "resourceRequests": [
        {
            "capability": {
                "memory": 4096,
                "virtualCores": 1
            },
            "nodeLabelExpression": "",
            "numContainers": 0,
            "priority": {
                "priority": 0
            },
            "relaxLocality": true,
            "resourceName": "*"
        },
        {
            "capability": {
                "memory": 4096,
                "virtualCores": 1
            },
            "nodeLabelExpression": "",
            "numContainers": 0,
            "priority": {
                "priority": 20
            },
            "relaxLocality": true,
            "resourceName": "host1.domain.com"
        },
        {
            "capability": {
                "memory": 4096,
                "virtualCores": 1
            },
            "nodeLabelExpression": "",
            "numContainers": 0,
            "priority": {
                "priority": 20
            },
            "relaxLocality": true,
            "resourceName": "host2.domain.com"
        }]
      },
      {
        "id": "application_1476912658570_0001",
        "user": "user1",
        "name": "Sleep job",
        "queue": "default",
        "state": "FINISHED",
        "finalStatus": "SUCCEEDED",
        "progress": 100,
        "trackingUI": "History",
        "trackingUrl": "http://host.domain.com:8088/cluster/app/application_1476912658570_0001",
        "diagnostics": "...",
        "clusterId": 1476912658570,
        "applicationType": "YARN",
        "applicationTags": "",
        "priority": -1,
        "startedTime": 1476913464750,
        "finishedTime": 1476913863175,
        "elapsedTime": 398425,
        "amContainerLogs": "http://host.domain.com:8042/node/containerlogs/container_1476912658570_0001_02_000001/user1",
        "amHostHttpAddress": "host.domain.com:8042",
        "allocatedMB": 0,
        "allocatedVCores": 0,
        "runningContainers": 0,
        "memorySeconds": 205410,
        "vcoreSeconds": 200,
        "queueUsagePercentage": 0,
        "clusterUsagePercentage": 0,
        "preemptedResourceMB": 0,
        "preemptedResourceVCores": 0,
        "numNonAMContainerPreempted": 0,
        "numAMContainerPreempted": 0,
        "logAggregationStatus": "DISABLED",
        "unmanagedApplication": false,
        "appNodeLabelExpression": "",
        "amNodeLabelExpression": "",
        "resourceRequests": [
        {
            "capability": {
                "memory": 4096,
                "virtualCores": 1
            },
            "nodeLabelExpression": "",
            "numContainers": 0,
            "priority": {
                "priority": 0
            },
            "relaxLocality": true,
            "resourceName": "*"
        },
        {
            "capability": {
                "memory": 4096,
                "virtualCores": 1
            },
            "nodeLabelExpression": "",
            "numContainers": 0,
            "priority": {
                "priority": 20
            },
            "relaxLocality": true,
            "resourceName": "host3.domain.com"
        },
        {
            "capability": {
                "memory": 4096,
                "virtualCores": 1
            },
            "nodeLabelExpression": "",
            "numContainers": 0,
            "priority": {
                "priority": 20
            },
            "relaxLocality": true,
            "resourceName": "host4.domain.com"
        }]
      }
    ]
  }
}

XML 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/apps
  Accept: application/xml

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Content-Length: 2459
  Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<apps>
    <app>
        <id>application_1476912658570_0002</id>
        <user>user2</user>
        <name>word count</name>
        <queue>default</queue>
        <state>FINISHED</state>
        <finalStatus>SUCCEEDED</finalStatus>
        <progress>100.0</progress>
        <trackingUI>History</trackingUI>
        <trackingUrl>http://host.domain.com:8088/cluster/app/application_1476912658570_0002</trackingUrl>
        <diagnostics>...</diagnostics>
        <clusterId>1476912658570</clusterId>
        <applicationType>YARN</applicationType>
        <applicationTags></applicationTags>
        <priority>-1</priority>
        <startedTime>1476913457320</startedTime>
        <finishedTime>1476913761898</finishedTime>
        <elapsedTime>304578</elapsedTime>
        <amContainerLogs>http://host.domain.com:8042/node/containerlogs/container_1476912658570_0002_02_000001/user2</amContainerLogs>
        <amHostHttpAddress>host.domain.com:8042</amHostHttpAddress>
        <allocatedMB>-1</allocatedMB>
        <allocatedVCores>-1</allocatedVCores>
        <runningContainers>-1</runningContainers>
        <memorySeconds>206464</memorySeconds>
        <vcoreSeconds>201</vcoreSeconds>
        <queueUsagePercentage>0.0</queueUsagePercentage>
        <clusterUsagePercentage>0.0</clusterUsagePercentage>
        <preemptedResourceMB>0</preemptedResourceMB>
        <preemptedResourceVCores>0</preemptedResourceVCores>
        <numNonAMContainerPreempted>0</numNonAMContainerPreempted>
        <numAMContainerPreempted>0</numAMContainerPreempted>
        <logAggregationStatus>DISABLED</logAggregationStatus>
        <unmanagedApplication>false</unmanagedApplication>
        <appNodeLabelExpression></appNodeLabelExpression>
        <amNodeLabelExpression></amNodeLabelExpression>
        <resourceRequests>
          <capability>
            <memory>4096</memory>
            <virtualCores>1</virtualCores>
          </capability>
          <nodeLabelExpression/>
          <numContainers>0</numContainers>
          <priority>
            <priority>0</priority>
          </priority>
          <relaxLocality>true</relaxLocality>
          <resourceName>*</resourceName>
        </resourceRequests>
        <resourceRequests>
          <capability>
            <memory>4096</memory>
            <virtualCores>1</virtualCores>
          </capability>
          <nodeLabelExpression/>
          <numContainers>0</numContainers>
          <priority>
            <priority>20</priority>
          </priority>
          <relaxLocality>true</relaxLocality>
          <resourceName>host1.domain.com</resourceName>
        </resourceRequests>
        <resourceRequests>
          <capability>
            <memory>4096</memory>
            <virtualCores>1</virtualCores>
          </capability>
          <nodeLabelExpression/>
          <numContainers>0</numContainers>
          <priority>
            <priority>20</priority>
          </priority>
          <relaxLocality>true</relaxLocality>
          <resourceName>host2.domain.com</resourceName>
        </resourceRequests>
    </app>
    <app>
        <id>application_1476912658570_0001</id>
        <user>user1</user>
        <name>Sleep job</name>
        <queue>default</queue>
        <state>FINISHED</state>
        <finalStatus>SUCCEEDED</finalStatus>
        <progress>100.0</progress>
        <trackingUI>History</trackingUI>
        <trackingUrl>http://host.domain.com:8088/cluster/app/application_1476912658570_0001</trackingUrl>
        <diagnostics>...</diagnostics>
        <clusterId>1476912658570</clusterId>
        <applicationType>YARN</applicationType>
        <applicationTags></applicationTags>
        <priority>-1</priority>
        <startedTime>1476913464750</startedTime>
        <finishedTime>1476913863175</finishedTime>
        <elapsedTime>398425</elapsedTime>
        <amContainerLogs>http://host.domain.com:8042/node/containerlogs/container_1476912658570_0001_02_000001/user1</amContainerLogs>
        <amHostHttpAddress>host.domain.com:8042</amHostHttpAddress>
        <allocatedMB>-1</allocatedMB>
        <allocatedVCores>-1</allocatedVCores>
        <runningContainers>-1</runningContainers>
        <memorySeconds>205410</memorySeconds>
        <vcoreSeconds>200</vcoreSeconds>
        <queueUsagePercentage>0.0</queueUsagePercentage>
        <clusterUsagePercentage>0.0</clusterUsagePercentage>
        <preemptedResourceMB>0</preemptedResourceMB>
        <preemptedResourceVCores>0</preemptedResourceVCores>
        <numNonAMContainerPreempted>0</numNonAMContainerPreempted>
        <numAMContainerPreempted>0</numAMContainerPreempted>
        <logAggregationStatus>DISABLED</logAggregationStatus>
        <unmanagedApplication>false</unmanagedApplication>
        <appNodeLabelExpression></appNodeLabelExpression>
        <amNodeLabelExpression></amNodeLabelExpression>
        <resourceRequests>
          <capability>
            <memory>4096</memory>
            <virtualCores>1</virtualCores>
          </capability>
          <nodeLabelExpression/>
          <numContainers>0</numContainers>
          <priority>
            <priority>0</priority>
          </priority>
          <relaxLocality>true</relaxLocality>
          <resourceName>*</resourceName>
        </resourceRequests>
        <resourceRequests>
          <capability>
            <memory>4096</memory>
            <virtualCores>1</virtualCores>
          </capability>
          <nodeLabelExpression/>
          <numContainers>0</numContainers>
          <priority>
            <priority>20</priority>
          </priority>
          <relaxLocality>true</relaxLocality>
          <resourceName>host1.domain.com</resourceName>
        </resourceRequests>
        <resourceRequests>
          <capability>
            <memory>4096</memory>
            <virtualCores>1</virtualCores>
          </capability>
          <nodeLabelExpression/>
          <numContainers>0</numContainers>
          <priority>
            <priority>20</priority>
          </priority>
          <relaxLocality>true</relaxLocality>
          <resourceName>host2.domain.com</resourceName>
        </resourceRequests>
    </app>
</apps>

叢集應用程式統計資料 API

使用應用程式統計資料 API,您可以取得一組三元組,其中每個三元組包含應用程式類型、應用程式狀態以及 ResourceManager 環境中此類型和此狀態的應用程式數量。請注意,考量到效能問題,我們目前每個查詢僅支援最多一個 applicationType。我們未來可能會支援每個查詢多個 applicationType 以及更多統計資料。當您對此資源執行 GET 作業時,您會取得一組 statItem 物件。

URI

支援的 HTTP 作業

  • GET

必要的查詢參數

可以指定兩個參數。參數不區分大小寫。

  • states - 應用程式的狀態,指定為逗號分隔清單。如果未提供 states,API 會列舉所有應用程式狀態並傳回其計數。
    • applicationTypes - 應用程式的類型,指定為逗號分隔清單。如果未提供 applicationTypes,API 會計算任何應用程式類型的應用程式。在此情況下,回應會顯示 * 以表示任何應用程式類型。請注意,我們目前僅支援最多一個 applicationType。否則,使用者會收到 BadRequestException。

appStatInfo (statItems) 物件的元素

當您要求統計項目清單時,資訊會傳回為 statItem 物件的集合

項目 資料類型 說明
statItem statItem 物件陣列 (JSON)/零個或多個 statItem 物件 (XML) statItem 物件集合

回應範例

JSON 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/appstatistics?states=accepted,running,finished&applicationTypes=mapreduce

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

回應本文

{
  "appStatInfo":
  {
    "statItem":
    [
       {
          "state" : "accepted",
          "type" : "mapreduce",
          "count" : 4
       },
       {
          "state" : "running",
          "type" : "mapreduce",
          "count" : 1
       },
       {
          "state" : "finished",
          "type" : "mapreduce",
          "count" : 7
       }
    ]
  }
}

XML 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/appstatistics?states=accepted,running,finished&applicationTypes=mapreduce
  Accept: application/xml

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Content-Length: 2459
  Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<appStatInfo>
  <statItem>
    <state>accepted</state>
    <type>mapreduce</type>
    <count>4</count>
  </statItem>
  <statItem>
    <state>running</state>
    <type>mapreduce</type>
    <count>1</count>
  </statItem>
  <statItem>
    <state>finished</state>
    <type>mapreduce</type>
    <count>7</count>
  </statItem>
</appStatInfo>

叢集應用程式 API

應用程式資源包含已提交至叢集的特定應用程式的資訊。

URI

使用下列 URI 從由 appid 值識別的應用程式取得 app 物件。

支援的 HTTP 作業

  • GET

支援的查詢參數

  None

app (Application) 物件的元素

請注意,使用者可能無法看到所有欄位,這取決於安全性設定。

項目 資料類型 說明
id 字串 應用程式 ID
使用者 字串 啟動應用程式的使用者
名稱 字串 應用程式名稱
queue 字串 應用程式提交的佇列
state 字串 根據 ResourceManager 的應用程式狀態 - 有效值是 YarnApplicationState 列舉的成員:NEW、NEW_SAVING、SUBMITTED、ACCEPTED、RUNNING、FINISHED、FAILED、KILLED
finalStatus 字串 已完成的應用程式的最終狀態 - 由應用程式本身報告 - 有效值是 FinalApplicationStatus 列舉的成員:UNDEFINED、SUCCEEDED、FAILED、KILLED
進度 浮點數 應用程式的進度(百分比)
追蹤 UI 字串 追蹤 URL 目前指向的位置 - 歷程記錄(針對歷程記錄伺服器)或 ApplicationMaster
追蹤 URL 字串 可使用來追蹤應用程式的 Web URL
診斷 字串 詳細的診斷資訊
叢集 ID 長整數 叢集 ID
應用程式類型 字串 應用程式類型
應用程式標籤 字串 應用程式的逗號分隔標籤
優先順序 字串 已提交應用程式的優先順序
開始時間 長整數 應用程式開始的時間 (自紀元以來的毫秒數)
完成時間 長整數 應用程式完成的時間(自紀元以來的毫秒數)
經過時間 長整數 自應用程式開始以來的經過時間(毫秒)
amContainerLogs 字串 應用程式主控容器記錄的 URL
amHostHttpAddress 字串 應用程式主控的節點 http 位址
amRPCAddress 字串 應用程式主控的 RPC 位址
allocatedMB int 分配給應用程式執行中容器的記憶體總和(MB)
allocatedVCores int 分配給應用程式執行中容器的虛擬核心總和
runningContainers int 目前為應用程式執行的容器數量
memorySeconds 長整數 應用程式已分配的記憶體量(MB-秒)
vcoreSeconds 長整數 應用程式已分配的 CPU 資源量(虛擬核心-秒)
queueUsagePercentage 浮點數 應用程式使用的佇列資源百分比
clusterUsagePercentage 浮點數 應用程式使用的叢集資源百分比。
preemptedResourceMB 長整數 被搶佔容器使用的記憶體
preemptedResourceVCores 長整數 被搶佔容器使用的虛擬核心數量
numNonAMContainerPreempted int 被搶佔的標準容器數量
numAMContainerPreempted int 被搶佔的應用程式主控容器數量
logAggregationStatus 字串 記錄聚合狀態 - 有效值是 LogAggregationStatus 列舉的成員:DISABLED、NOT_START、RUNNING、RUNNING_WITH_FAILURE、SUCCEEDED、FAILED、TIME_OUT
非受管應用程式 布林值 應用程式是否為非受管。
應用程式節點標籤表達式 字串 節點標籤表達式,用於識別預設情況下應用程式容器預期執行的節點。
AM 節點標籤表達式 字串 節點標籤表達式,用於識別預期執行應用程式 AM 容器的節點。

回應範例

JSON 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/apps/application_1476912658570_0002

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

回應本文

{
  "app": {
    "id": "application_1476912658570_0002",
    "user": "user2",
    "name": "word count",
    "queue": "default",
    "state": "FINISHED",
    "finalStatus": "SUCCEEDED",
    "progress": 100,
    "trackingUI": "History",
    "trackingUrl": "http://host.domain.com:8088/cluster/app/application_1476912658570_0002",
    "diagnostics": "...",
    "clusterId": 1476912658570,
    "applicationType": "YARN",
    "applicationTags": "",
    "priority": -1,
    "startedTime": 1476913457320,
    "finishedTime": 1476913761898,
    "elapsedTime": 304578,
    "amContainerLogs": "http://host.domain.com:8042/node/containerlogs/container_1476912658570_0002_02_000001/dr.who",
    "amHostHttpAddress": "host.domain.com:8042",
    "allocatedMB": -1,
    "allocatedVCores": -1,
    "runningContainers": -1,
    "memorySeconds": 206464,
    "vcoreSeconds": 201,
    "queueUsagePercentage": 0,
    "clusterUsagePercentage": 0,
    "preemptedResourceMB": 0,
    "preemptedResourceVCores": 0,
    "numNonAMContainerPreempted": 0,
    "numAMContainerPreempted": 0,
    "logAggregationStatus": "DISABLED",
    "unmanagedApplication": false,
    "appNodeLabelExpression": "",
    "amNodeLabelExpression": ""
  }
}

XML 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/apps/application_1326821518301_0005
  Accept: application/xml

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Content-Length: 847
  Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<app>
    <id>application_1476912658570_0002</id>
    <user>user2</user>
    <name>word count</name>
    <queue>default</queue>
    <state>FINISHED</state>
    <finalStatus>SUCCEEDED</finalStatus>
    <progress>100.0</progress>
    <trackingUI>History</trackingUI>
    <trackingUrl>http://host.domain.com:8088/cluster/app/application_1476912658570_0002</trackingUrl>
    <diagnostics>...</diagnostics>
    <clusterId>1476912658570</clusterId>
    <applicationType>YARN</applicationType>
    <applicationTags></applicationTags>
    <priority>-1</priority>
    <startedTime>1476913457320</startedTime>
    <finishedTime>1476913761898</finishedTime>
    <elapsedTime>304578</elapsedTime>
    <amContainerLogs>http://host.domain.com:8042/node/containerlogs/container_1476912658570_0002_02_000001/dr.who</amContainerLogs>
    <amHostHttpAddress>host.domain.com:8042</amHostHttpAddress>
    <allocatedMB>-1</allocatedMB>
    <allocatedVCores>-1</allocatedVCores>
    <runningContainers>-1</runningContainers>
    <memorySeconds>206464</memorySeconds>
    <vcoreSeconds>201</vcoreSeconds>
    <queueUsagePercentage>0.0</queueUsagePercentage>
    <clusterUsagePercentage>0.0</clusterUsagePercentage>
    <preemptedResourceMB>0</preemptedResourceMB>
    <preemptedResourceVCores>0</preemptedResourceVCores>
    <numNonAMContainerPreempted>0</numNonAMContainerPreempted>
    <numAMContainerPreempted>0</numAMContainerPreempted>
    <logAggregationStatus>DISABLED</logAggregationStatus>
    <unmanagedApplication>false</unmanagedApplication>
    <appNodeLabelExpression></appNodeLabelExpression>
    <amNodeLabelExpression></amNodeLabelExpression>
</app>

叢集應用程式嘗試 API

使用應用程式嘗試 API,您可以取得代表應用程式嘗試的資源集合。當您對此資源執行 GET 作業時,您會取得 App 嘗試物件集合。

URI

支援的 HTTP 作業

  • GET

支援的查詢參數

  None

appAttempts 物件的元素

當您要求提供應用程式嘗試清單時,資訊將會以應用程式嘗試物件陣列的形式傳回。

appAttempts

項目 資料類型 說明
appAttempt 應用程式嘗試物件陣列 (JSON)/零個或多個應用程式嘗試物件 (XML) 應用程式嘗試物件集合

appAttempt 物件的元素

項目 資料類型 說明
id 字串 應用程式嘗試 ID
nodeId 字串 嘗試執行的節點的節點 ID
nodeHttpAddress 字串 嘗試執行的節點的節點 HTTP 位址
logsLink 字串 應用程式嘗試記錄的 HTTP 連結
containerId 字串 應用程式嘗試的容器 ID
startTime 長整數 嘗試的開始時間 (自紀元以來經過的毫秒數)

回應範例

JSON 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/apps/application_1326821518301_0005/appattempts

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

回應本文

{
   "appAttempts" : {
      "appAttempt" : [
         {
            "nodeId" : "host.domain.com:8041",
            "nodeHttpAddress" : "host.domain.com:8042",
            "startTime" : 1326381444693,
            "id" : 1,
            "logsLink" : "http://host.domain.com:8042/node/containerlogs/container_1326821518301_0005_01_000001/user1",
            "containerId" : "container_1326821518301_0005_01_000001"
         }
      ]
   }
}

XML 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/apps/application_1326821518301_0005/appattempts
  Accept: application/xml

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Content-Length: 575
  Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<appAttempts>
  <appttempt>
    <nodeHttpAddress>host.domain.com:8042</nodeHttpAddress>
    <nodeId>host.domain.com:8041</nodeId>
    <id>1</id>
    <startTime>1326381444693</startTime>
    <containerId>container_1326821518301_0005_01_000001</containerId>
    <logsLink>http://host.domain.com:8042/node/containerlogs/container_1326821518301_0005_01_000001/user1</logsLink>
  </appAttempt>
</appAttempts>

應用程式嘗試容器 API

使用應用程式嘗試容器 API,您可以取得屬於應用程式嘗試的容器清單。

URI

支援的 HTTP 作業

  • GET

支援的查詢參數

  None

containers 物件的元素

當您要求提供容器清單時,資訊將會以容器物件陣列的形式傳回。

containers

項目 資料類型 說明
containers 應用程式容器物件陣列 (JSON)/零個或多個容器物件 (XML) 應用程式容器物件集合

container 物件的元素

項目 資料類型 說明
containerId 字串 容器 ID
allocatedMB 長整數 分配給容器的記憶體量 (MB)
allocatedVCores int 分配給容器的虛擬核心數
已指派節點 ID 字串 嘗試執行的節點的節點 ID
優先順序 int 已配置的容器優先權
開始時間 長整數 嘗試的開始時間 (自紀元以來經過的毫秒數)
完成時間 長整數 嘗試完成時間(自紀元以來的毫秒數),若未完成則為 0
經過時間 長整數 自開始時間以來的經過時間(毫秒數)
logUrl 字串 可使用來查看容器日誌的網路 URL
containerExitStatus int 容器的最終結束狀態
containerState 字串 容器狀態,可以是 NEW、RUNNING 或 COMPLETE
nodeHttpAddress 字串 嘗試執行的節點的節點 HTTP 位址
nodeId 字串 嘗試執行的節點的節點 ID
allocatedResources 資源陣列(JSON)/零個或多個資源物件(XML) 已配置的容器資源

資源物件的元素

項目 資料類型 說明
memory int 容器的最大記憶體
vCores int 容器的最大 vcore 數

JSON 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/apps/{appid}/appattempts/{appAttemptId}/containers

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

回應本文

{
  "containers" : {
    "container": [
      {
      "containerId": "container_1531404209605_0008_01_000001",
      "allocatedMB": "1536",
      "allocatedVCores": "1",
      "assignedNodeId": "host.domain.com:37814",
      "priority": "0",
      "startedTime": "1531405909444",
      "finishedTime": "0",
      "elapsedTime": "4112",
      "logUrl": "http://host.domain.com:8042/node/containerlogs/container_1531404209605_0008_01_000001/systest",
      "containerExitStatus": "0",
      "containerState": "RUNNING",
      "nodeHttpAddress": "http://host.domain.com:8042",
      "nodeId": "host.domain.com:37814",
      "allocatedResources": [
         {
            "key": "memory-mb",
            "value": "1536"
         },
         {
            "key": "vcores",
            "value": "1"
         }
       ]
      }
    ]
  }
}

XML 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/apps/{appid}/appattempts/{appAttemptId}/containers
  Accept: application/xml

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Content-Length: 1104
  Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<containers>
  <container>
    <containerId>container_1531404209605_0008_01_000001</containerId>
    <allocatedMB>1536</allocatedMB>
    <allocatedVCores>1</allocatedVCores>
    <assignedNodeId>host.domain.com:37814</assignedNodeId>
    <priority>0</priority>
    <startedTime>1531405909444</startedTime>
    <finishedTime>0</finishedTime>
    <elapsedTime>4112</elapsedTime>
    <logUrl>
    http://host.domain.com:8042/node/containerlogs/container_1531404209605_0008_01_000001/systest
    </logUrl>
    <containerExitStatus>0</containerExitStatus>
    <containerState>RUNNING</containerState>
    <nodeHttpAddress>http://host.domain.com:8042</nodeHttpAddress>
    <nodeId>host.domain.com:37814</nodeId>
    <allocatedResources>
      <entry>
        <key>memory-mb</key>
        <value>1536</value>
      </entry>
      <entry>
        <key>vcores</key>
        <value>1</value>
      </entry>
    </allocatedResources>
  </container>
</containers>

應用程式嘗試的特定容器 API

使用應用程式嘗試的特定容器 API,您可以取得特定容器的資訊,此容器屬於應用程式嘗試,並由容器 ID 選取。

URI

支援的 HTTP 作業

  • GET

支援的查詢參數

  None

container 物件的元素

項目 資料類型 說明
containerId 字串 容器 ID
allocatedMB 長整數 分配給容器的記憶體量 (MB)
allocatedVCores int 分配給容器的虛擬核心數
已指派節點 ID 字串 嘗試執行的節點的節點 ID
優先順序 int 已配置的容器優先權
開始時間 長整數 嘗試的開始時間 (自紀元以來經過的毫秒數)
完成時間 長整數 嘗試完成時間(自紀元以來的毫秒數),若未完成則為 0
經過時間 長整數 自開始時間以來的經過時間(毫秒數)
logUrl 字串 可使用來查看容器日誌的網路 URL
containerExitStatus int 容器的最終結束狀態
containerState 字串 容器狀態,可以是 NEW、RUNNING 或 COMPLETE
nodeHttpAddress 字串 嘗試執行的節點的節點 HTTP 位址
nodeId 字串 嘗試執行的節點的節點 ID
allocatedResources 資源陣列(JSON)/零個或多個資源物件(XML) 已配置的容器資源

資源物件的元素

項目 資料類型 說明
memory int 容器的最大記憶體
vCores int 容器的最大 vcore 數

JSON 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/apps/{appid}/appattempts/{appAttemptId}/containers/{containerId}

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

回應本文

{
  "container": {
    "containerId": "container_1531404209605_0008_01_000001",
    "allocatedMB": "1536",
    "allocatedVCores": "1",
    "assignedNodeId": "host.domain.com:37814",
    "priority": "0",
    "startedTime": "1531405909444",
    "finishedTime": "0",
    "elapsedTime": "4112",
    "logUrl": "http://host.domain.com:8042/node/containerlogs/container_1531404209605_0008_01_000001/systest",
    "containerExitStatus": "0",
    "containerState": "RUNNING",
    "nodeHttpAddress": "http://host.domain.com:8042",
    "nodeId": "host.domain.com:37814",
    "allocatedResources": [
       {
          "key": "memory-mb",
          "value": "1536"
       },
       {
          "key": "vcores",
          "value": "1"
       }
    ]
  }
}

XML 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/apps/{appid}/appattempts/{appAttemptId}/containers/{containerId}
  Accept: application/xml

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Content-Length: 1104
  Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<container>
  <containerId>container_1531404209605_0008_01_000001</containerId>
  <allocatedMB>1536</allocatedMB>
  <allocatedVCores>1</allocatedVCores>
  <assignedNodeId>host.domain.com:37814</assignedNodeId>
  <priority>0</priority>
  <startedTime>1531405909444</startedTime>
  <finishedTime>0</finishedTime>
  <elapsedTime>4112</elapsedTime>
  <logUrl>
  http://host.domain.com:8042/node/containerlogs/container_1531404209605_0008_01_000001/systest
  </logUrl>
  <containerExitStatus>0</containerExitStatus>
  <containerState>RUNNING</containerState>
  <nodeHttpAddress>http://host.domain.com:8042</nodeHttpAddress>
  <nodeId>host.domain.com:37814</nodeId>
  <allocatedResources>
    <entry>
      <key>memory-mb</key>
      <value>1536</value>
    </entry>
    <entry>
      <key>vcores</key>
      <value>1</value>
    </entry>
  </allocatedResources>
</container>

叢集節點 API

使用節點 API,您可以取得資源集合,其中每個資源都代表一個節點。當您對此資源執行 GET 作業時,您會取得節點物件集合。

URI

支援的 HTTP 作業

  • GET

支援的查詢參數

  • states - 節點的狀態,指定為逗號分隔清單,有效值為:NEW、RUNNING、UNHEALTHY、DECOMMISSIONING、DECOMMISSIONED、LOST、REBOOTED、SHUTDOWN

節點物件的元素

當您提出節點清單要求時,資訊將以節點物件集合的形式傳回。另請參閱 節點 API 以取得節點物件的語法。

項目 資料類型 說明
node 節點物件陣列(JSON)/零個或多個節點物件(XML) 節點物件集合

回應範例

JSON 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/nodes

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

回應本文

{
  "nodes":
  {
    "node":
    [
      {
        "rack":"\/default-rack",
        "state":"RUNNING",
        "id":"host.domain.com:54158",
        "nodeHostName":"host.domain.com",
        "nodeHTTPAddress":"host.domain.com:8042",
        "lastHealthUpdate": 1476995346399,
        "version": "3.0.0-alpha2-SNAPSHOT",
        "healthReport":"",
        "numContainers":0,
        "usedMemoryMB":0,
        "availMemoryMB":8192,
        "usedVirtualCores":0,
        "availableVirtualCores":8,
        "resourceUtilization":
        {
          "nodePhysicalMemoryMB":1027,
          "nodeVirtualMemoryMB":1027,
          "nodeCPUUsage":0.016661113128066063,
          "aggregatedContainersPhysicalMemoryMB":0,
          "aggregatedContainersVirtualMemoryMB":0,
          "containersCPUUsage":0
        }
      },
      {
        "rack":"\/default-rack",
        "state":"RUNNING",
        "id":"host.domain.com:54158",
        "nodeHostName":"host.domain.com",
        "nodeHTTPAddress":"host.domain.com:8042",
        "lastHealthUpdate":1476995346399,
        "version":"3.0.0-alpha2-SNAPSHOT",
        "healthReport":"",
        "numContainers":0,
        "usedMemoryMB":0,
        "availMemoryMB":8192,
        "usedVirtualCores":0,
        "availableVirtualCores":8,
        "resourceUtilization":
        {
          "nodePhysicalMemoryMB":1027,
          "nodeVirtualMemoryMB":1027,
          "nodeCPUUsage":0.016661113128066063,
          "aggregatedContainersPhysicalMemoryMB":0,
          "aggregatedContainersVirtualMemoryMB":0,
          "containersCPUUsage":0
        }
      }
    ]
  }
}

XML 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/nodes
  Accept: application/xml

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Content-Length: 1104
  Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<nodes>
  <node>
    <rack>/default-rack</rack>
    <state>RUNNING</state>
    <id>host1.domain.com:54158</id>
    <nodeHostName>host1.domain.com</nodeHostName>
    <nodeHTTPAddress>host1.domain.com:8042</nodeHTTPAddress>
    <lastHealthUpdate>1476995346399</lastHealthUpdate>
    <version>3.0.0-SNAPSHOT</version>
    <healthReport></healthReport>
    <numContainers>0</numContainers>
    <usedMemoryMB>0</usedMemoryMB>
    <availMemoryMB>8192</availMemoryMB>
    <usedVirtualCores>0</usedVirtualCores>
    <availableVirtualCores>8</availableVirtualCores>
    <resourceUtilization>
        <nodePhysicalMemoryMB>1027</nodePhysicalMemoryMB>
        <nodeVirtualMemoryMB>1027</nodeVirtualMemoryMB>
        <nodeCPUUsage>0.006664445623755455</nodeCPUUsage>
        <aggregatedContainersPhysicalMemoryMB>0</aggregatedContainersPhysicalMemoryMB>
        <aggregatedContainersVirtualMemoryMB>0</aggregatedContainersVirtualMemoryMB>
        <containersCPUUsage>0.0</containersCPUUsage>
    </resourceUtilization>
  </node>
  <node>
    <rack>/default-rack</rack>
    <state>RUNNING</state>
    <id>host2.domain.com:54158</id>
    <nodeHostName>host2.domain.com</nodeHostName>
    <nodeHTTPAddress>host2.domain.com:8042</nodeHTTPAddress>
    <lastHealthUpdate>1476995346399</lastHealthUpdate>
    <version>3.0.0-SNAPSHOT</version>
    <healthReport></healthReport>
    <numContainers>0</numContainers>
    <usedMemoryMB>0</usedMemoryMB>
    <availMemoryMB>8192</availMemoryMB>
    <usedVirtualCores>0</usedVirtualCores>
    <availableVirtualCores>8</availableVirtualCores>
    <resourceUtilization>
        <nodePhysicalMemoryMB>1027</nodePhysicalMemoryMB>
        <nodeVirtualMemoryMB>1027</nodeVirtualMemoryMB>
        <nodeCPUUsage>0.006664445623755455</nodeCPUUsage>
        <aggregatedContainersPhysicalMemoryMB>0</aggregatedContainersPhysicalMemoryMB>
        <aggregatedContainersVirtualMemoryMB>0</aggregatedContainersVirtualMemoryMB>
        <containersCPUUsage>0.0</containersCPUUsage>
    </resourceUtilization>
  </node>
</nodes>

叢集節點 API

節點資源包含叢集中節點的資訊。

URI

使用下列 URI 從由 nodeid 值識別的節點取得節點物件。

支援的 HTTP 作業

  • GET

支援的查詢參數

  None

節點物件的元素

項目 資料類型 說明
rack 字串 此節點的機架位置
state 字串 節點狀態 - 有效值為:NEW、RUNNING、UNHEALTHY、DECOMMISSIONING、DECOMMISSIONED、LOST、REBOOTED、SHUTDOWN
id 字串 節點 ID
nodeHostName 字串 節點的主機名稱
nodeHTTPAddress 字串 節點的 HTTP 位址
lastHealthUpdate 長整數 節點上次報告其健康狀況的時間(自紀元以來的毫秒數)
版本 字串 執行於節點上的 Hadoop 版本
健康報告 字串 詳細的健康報告
numContainers int 目前執行於節點上的容器總數
usedMemoryMB 長整數 目前使用於節點上的記憶體總量 (MB)
availMemoryMB 長整數 目前可用於節點上的記憶體總量 (MB)
usedVirtualCores 長整數 目前使用於節點上的 vCore 總數
availableVirtualCores 長整數 可用於節點上的 vCore 總數
資源使用率 物件 節點上的資源使用率
totalResource 物件 節點上的資源

resourceUtilization 物件包含下列元素

項目 資料類型 說明
nodePhysicalMemoryMB int 節點實體記憶體使用率
nodeVirtualMemoryMB int 節點虛擬記憶體使用率
nodeCPUUsage 雙精度 節點 CPU 使用率
aggregatedContainersPhysicalMemoryMB int 容器的累計實體記憶體使用率
aggregatedContainersVirtualMemoryMB int 容器的累計虛擬記憶體使用率
containersCPUUsage 雙精度 容器的累計 CPU 使用率

回應範例

JSON 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/nodes/h2:1235

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

回應本文

{
  "node":
  {
    "rack":"\/default-rack",
    "state":"RUNNING",
    "id":"host.domain.com:54158",
    "nodeHostName":"host.domain.com",
    "nodeHTTPAddress":"host.domain.com:8042",
    "lastHealthUpdate":1476916746399,
    "version":"3.0.0-SNAPSHOT",
    "healthReport":"",
    "numContainers":0,
    "usedMemoryMB":0,
    "availMemoryMB":8192,
    "usedVirtualCores":0,
    "availableVirtualCores":8,
    "resourceUtilization":
    {
      "nodePhysicalMemoryMB": 968,
      "nodeVirtualMemoryMB": 968,
      "nodeCPUUsage": 0.01332889124751091,
      "aggregatedContainersPhysicalMemoryMB": 0,
      "aggregatedContainersVirtualMemoryMB": 0,
      "containersCPUUsage": 0
    },
    "totalResource":
    {
      "memory": 2048,
      "vCores": 5
    }
  }
}

XML 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/node/h2:1235
  Accept: application/xml

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Content-Length: 552
  Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<node>
  <rack>/default-rack</rack>
  <state>RUNNING</state>
  <id>host.domain.com:54158</id>
  <nodeHostName>host.domain.com</nodeHostName>
  <nodeHTTPAddress>host.domain.com:8042</nodeHTTPAddress>
  <lastHealthUpdate>1476916746399</lastHealthUpdate>
  <version>3.0.0-SNAPSHOT</version>
  <healthReport></healthReport>
  <numContainers>0</numContainers>
  <usedMemoryMB>0</usedMemoryMB>
  <availMemoryMB>8192</availMemoryMB>
  <usedVirtualCores>0</usedVirtualCores>
  <availableVirtualCores>8</availableVirtualCores>
  <resourceUtilization>
    <nodePhysicalMemoryMB>968</nodePhysicalMemoryMB>
    <nodeVirtualMemoryMB>968</nodeVirtualMemoryMB>
    <nodeCPUUsage>0.01332889124751091</nodeCPUUsage>
    <aggregatedContainersPhysicalMemoryMB>0</aggregatedContainersPhysicalMemoryMB>
    <aggregatedContainersVirtualMemoryMB>0</aggregatedContainersVirtualMemoryMB>
    <containersCPUUsage>0.0</containersCPUUsage>
  </resourceUtilization>
  <totalResource>
    <memory>2048</memory>
    <vCores>5</vCores>
  </totalResource>
</node>

叢集節點更新資源 API

更新節點中的總資源。

URI

使用下列 URI 更新由 nodeid 值識別的節點物件的資源。

  http://rm-http-address:port/ws/v1/cluster/nodes/{nodeid}/resource

支援的 HTTP 作業

  POST

支援的查詢參數

  None

resourceOption 物件的元素

項目 資料類型 說明
memory 長整數 設定於節點上的記憶體總量 (MB)
vcores 長整數 設定於節點上的 vCore 總數
overCommitTimeout 長整數 搶占容器的逾時時間

回應範例

JSON 回應

HTTP 要求

  POST http://rm-http-address:port/ws/v1/cluster/nodes/h2:1235/resource

要求主體

{
  "resource":
  {
    "memory": 1024,
    "vCores": 3
  },
  "overCommitTimeout": -1
}

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

回應本文

{
  "resourceInfo":
  {
    "memory": 8192,
    "vCores": 5
  }
}

XML 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/node/h2:1235/resource
  Accept: application/xml

要求主體

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<resourceOption>
  <resource>
    <memory>8192</memory>
    <vCores>5</vCores>
  </resource>
  <overCommitTimeout>1000</overCommitTimeout>
</resourceOption>

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Content-Length: 552
  Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<resourceInfo>
  <memory>8192</memory>
  <vCores>5</vCores>
</resourceInfo>

叢集可寫入 API

下列區段是指允許建立和修改應用程式的 API。這些 API 目前處於 alpha 階段,未來可能會變更。

叢集新應用程式 API

使用新應用程式 API,您可以取得應用程式 ID,然後可將其用作 叢集提交應用程式 API 的一部分,以提交應用程式。回應中也包含叢集上可用的最大資源功能。

此功能目前處於 alpha 階段,未來可能會變更。

URI

支援的 HTTP 作業

  • POST

支援的查詢參數

  None

NewApplication 物件的元素

NewApplication 回應包含下列元素

項目 資料類型 說明
application-id 字串 新建立的應用程式 ID
maximum-resource-capabilities 物件 此叢集上可用的最大資源功能

maximum-resource-capabilites 物件包含下列元素

項目 資料類型 說明
memory int 容器可用的最大記憶體
vCores int 容器可用的最大核心數

回應範例

JSON 回應

HTTP 要求

  POST http://rm-http-address:port/ws/v1/cluster/apps/new-application

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

回應本文

{
  "application-id":"application_1404198295326_0003",
  "maximum-resource-capability":
    {
      "memory":8192,
      "vCores":32
    }
}

XML 回應

HTTP 要求

  POST http://rm-http-address:port/ws/v1/cluster/apps/new-application

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Content-Length: 248
  Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<NewApplication>
  <application-id>application_1404198295326_0003</application-id>
  <maximum-resource-capability>
    <memory>8192</memory>
    <vCores>32</vCores>
  </maximum-resource-capability>
</NewApplication>

叢集應用程式 API(提交應用程式)

提交應用程式 API 可用於提交應用程式。在提交應用程式時,您必須先使用 叢集新應用程式 API 取得應用程式 ID。應用程式 ID 必須是要求主體的一部分。回應會包含應用程式頁面的 URL,可用於追蹤應用程式的狀態和進度。

URI

支援的 HTTP 作業

  • POST

POST 回應範例

POST 要求可用於將應用程式提交至資源管理員。如上所述,必須先取得應用程式 ID。提交成功會產生 202 回應代碼和 Location 標頭,指定取得應用程式資訊的位置。請注意,若要提交應用程式,您必須為 HTTP 介面設定驗證過濾器。此功能需要在 HttpServletRequest 中設定使用者名稱。如果未設定過濾器,回應會是「UNAUTHORIZED」回應。

請注意,此功能目前處於 alpha 階段,未來可能會變更。

POST 要求物件的元素

項目 資料類型 說明
application-id 字串 應用程式 ID
application-name 字串 應用程式名稱
queue 字串 應將應用程式提交至的佇列名稱
優先順序 int 應用程式的優先順序
am-container-spec 物件 應用程式主容器啟動內容,如下所述
unmanaged-AM 布林值 應用程式是否使用非受管理應用程式主控
max-app-attempts int 此應用程式的最大嘗試次數
resource 物件 應用程式主控所需的資源,如下所述
application-type 字串 應用程式類型(MapReduce、Pig、Hive 等)
keep-containers-across-application-attempts 布林值 YARN 是否應保留此應用程式使用的容器,而不是銷毀它們
application-tags 物件 應用程式標籤清單,請參閱要求範例了解如何指定標籤
log-aggregation-context 物件 代表 NodeManager 處理此應用程式日誌所需的所有資訊
attempt-failures-validity-interval 長整數 失敗次數不會將發生在有效區間外的嘗試失敗計入失敗次數
保留 ID 字串 表示排程器中對應保留資源配置的唯一 ID
am 黑名單要求 物件 包含黑名單資訊,例如「啟用/停用 AM 黑名單」和「停用失敗閾值」

am-container-spec 物件的元素

am-container-spec 物件應用於提供應用程式主機的容器啟動內容。

項目 資料類型 說明
本機資源 物件 描述需要本機化的資源的物件,說明如下
環境 物件 容器的環境變數,指定為金鑰值對
指令 物件 用於啟動容器的指令,依序執行
服務資料 物件 應用程式特定服務資料;金鑰是輔助服務的名稱,值是您想要傳遞資料的 base-64 編碼
憑證 物件 應用程式執行所需的憑證,說明如下
應用程式 ACL 物件 應用程式的 ACL;金鑰可以是「VIEW_APP」或「MODIFY_APP」,值是具有權限的使用者清單

本機資源 物件的元素

物件是金鑰值對的集合。金鑰是需要本機化的資源的識別碼,而值是資源的詳細資料。值的元素說明如下

項目 資料類型 說明
resource 字串 需要本機化的資源位置
類型 字串 資源類型;選項為「ARCHIVE」、「FILE」和「PATTERN」
可見度 字串 需要本機化的資源可見度;選項為「PUBLIC」、「PRIVATE」和「APPLICATION」
大小 長整數 需要本機化的資源大小
時間戳記 長整數 需要本機化的資源時間戳記

憑證 物件的元素

憑證物件應用於傳遞應用程式自我驗證所需的資料,例如委派權杖和機密。

項目 資料類型 說明
權杖 物件 您想要傳遞給應用程式的權杖,指定為金鑰值對。金鑰是權杖的識別碼,而值是權杖(應該使用各自的網路服務取得)
機密 物件 您想要在應用程式中使用的機密,指定為金鑰值對。金鑰是識別碼,而值是機密的 base-64 編碼

POST 要求主體 資源 物件的元素

項目 資料類型 說明
memory int 每個容器所需的記憶體
vCores int 每個容器所需的虛擬核心

POST 要求主體 日誌彙總內容 物件的元素

項目 資料類型 說明
日誌包含模式 字串 符合定義包含模式的日誌檔案會在應用程式完成時上傳
日誌排除模式 字串 當應用程式完成時,符合已定義排除模式的日誌檔將不會上傳
rolled-log-include-pattern 字串 符合已定義包含模式的日誌檔將以滾動方式彙總
rolled-log-exclude-pattern 字串 符合已定義排除模式的日誌檔將不會以滾動方式彙總
log-aggregation-policy-class-name 字串 NodeManager 將使用此政策彙總日誌
log-aggregation-policy-parameters 字串 傳遞至政策類別的參數

POST 要求主體 am-black-listing-requests 物件的元素

項目 資料類型 說明
am-black-listing-enabled 布林值 是否啟用 AM 黑名單
disable-failure-threshold 浮點數 AM 黑名單停用失敗閾值

JSON 回應

HTTP 要求

  POST http://rm-http-address:port/ws/v1/cluster/apps
  Accept: application/json
  Content-Type: application/json
  {
    "application-id":"application_1404203615263_0001",
    "application-name":"test",
    "am-container-spec":
    {
      "local-resources":
      {
        "entry":
        [
          {
            "key":"AppMaster.jar",
            "value":
            {
              "resource":"hdfs://hdfs-namenode:9000/user/testuser/DistributedShell/demo-app/AppMaster.jar",
              "type":"FILE",
              "visibility":"APPLICATION",
              "size": 43004,
              "timestamp": 1405452071209
            }
          }
        ]
      },
      "commands":
      {
        "command":"{{JAVA_HOME}}/bin/java -Xmx10m org.apache.hadoop.yarn.applications.distributedshell.ApplicationMaster --container_memory 10 --container_vcores 1 --num_containers 1 --priority 0 1><LOG_DIR>/AppMaster.stdout 2><LOG_DIR>/AppMaster.stderr"
      },
      "environment":
      {
        "entry":
        [
          {
            "key": "DISTRIBUTEDSHELLSCRIPTTIMESTAMP",
            "value": "1405459400754"
          },
          {
            "key": "CLASSPATH",
            "value": "{{CLASSPATH}}<CPS>./*<CPS>{{HADOOP_CONF_DIR}}<CPS>{{HADOOP_COMMON_HOME}}/share/hadoop/common/*<CPS>{{HADOOP_COMMON_HOME}}/share/hadoop/common/lib/*<CPS>{{HADOOP_HDFS_HOME}}/share/hadoop/hdfs/*<CPS>{{HADOOP_HDFS_HOME}}/share/hadoop/hdfs/lib/*<CPS>{{HADOOP_YARN_HOME}}/share/hadoop/yarn/*<CPS>{{HADOOP_YARN_HOME}}/share/hadoop/yarn/lib/*<CPS>./log4j.properties"
          },
          {
            "key": "DISTRIBUTEDSHELLSCRIPTLEN",
            "value": "6"
          },
          {
            "key": "DISTRIBUTEDSHELLSCRIPTLOCATION",
            "value": "hdfs://hdfs-namenode:9000/user/testuser/demo-app/shellCommands"
          }
        ]
      }
    },
    "unmanaged-AM":false,
    "max-app-attempts":2,
    "resource":
    {
      "memory":1024,
      "vCores":1
    },
    "application-type":"YARN",
    "keep-containers-across-application-attempts":false,
    "log-aggregation-context":
    {
      "log-include-pattern":"file1",
      "log-exclude-pattern":"file2",
      "rolled-log-include-pattern":"file3",
      "rolled-log-exclude-pattern":"file4",
      "log-aggregation-policy-class-name":"org.apache.hadoop.yarn.server.nodemanager.containermanager.logaggregation.AllContainerLogAggregationPolicy",
      "log-aggregation-policy-parameters":""
    },
    "attempt-failures-validity-interval":3600000,
    "reservation-id":"reservation_1454114874_1",
    "am-black-listing-requests":
    {
      "am-black-listing-enabled":true,
      "disable-failure-threshold":0.01
    }
  }

回應標頭

  HTTP/1.1 202
  Transfer-Encoding: chunked
  Location: http://rm-http-address:port/ws/v1/cluster/apps/application_1404203615263_0001
  Content-Type: application/json
  Server: Jetty(6.1.26)

回應本文

  No response body

XML 回應

HTTP 要求

POST http://rm-http-address:port/ws/v1/cluster/apps
Accept: application/xml
Content-Type: application/xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<application-submission-context>
  <application-id>application_1404204891930_0002</application-id>
  <application-name>test</application-name>
  <queue>testqueue</queue>
  <priority>3</priority>
  <am-container-spec>
    <local-resources>
      <entry>
        <key>example</key>
        <value>
          <resource>hdfs://hdfs-namenode:9000/user/testuser/DistributedShell/demo-app/AppMaster.jar</resource>
          <type>FILE</type>
          <visibility>APPLICATION</visibility>
          <size>43004</size>
          <timestamp>1405452071209</timestamp>
        </value>
      </entry>
    </local-resources>
    <environment>
      <entry>
        <key>DISTRIBUTEDSHELLSCRIPTTIMESTAMP</key>
        <value>1405459400754</value>
      </entry>
      <entry>
        <key>CLASSPATH</key>
        <value>{{CLASSPATH}}&lt;CPS&gt;./*&lt;CPS&gt;{{HADOOP_CONF_DIR}}&lt;CPS&gt;{{HADOOP_COMMON_HOME}}/share/hadoop/common/*&lt;CPS&gt;{{HADOOP_COMMON_HOME}}/share/hadoop/common/lib/*&lt;CPS&gt;{{HADOOP_HDFS_HOME}}/share/hadoop/hdfs/*&lt;CPS&gt;{{HADOOP_HDFS_HOME}}/share/hadoop/hdfs/lib/*&lt;CPS&gt;{{HADOOP_YARN_HOME}}/share/hadoop/yarn/*&lt;CPS&gt;{{HADOOP_YARN_HOME}}/share/hadoop/yarn/lib/*&lt;CPS&gt;./log4j.properties</value>
      </entry>
      <entry>
        <key>DISTRIBUTEDSHELLSCRIPTLEN</key>
        <value>6</value>
      </entry>
      <entry>
        <key>DISTRIBUTEDSHELLSCRIPTLOCATION</key>
        <value>hdfs://hdfs-namenode:9000/user/testuser/demo-app/shellCommands</value>
      </entry>
    </environment>
    <commands>
      <command>{{JAVA_HOME}}/bin/java -Xmx10m org.apache.hadoop.yarn.applications.distributedshell.ApplicationMaster --container_memory 10 --container_vcores 1 --num_containers 1 --priority 0 1&gt;&lt;LOG_DIR&gt;/AppMaster.stdout 2&gt;&lt;LOG_DIR&gt;/AppMaster.stderr</command>
    </commands>
    <service-data>
      <entry>
        <key>test</key>
        <value>dmFsdWUxMg</value>
      </entry>
    </service-data>
    <credentials>
      <tokens/>
      <secrets>
        <entry>
          <key>secret1</key>
          <value>c2VjcmV0MQ</value>
        </entry>
      </secrets>
    </credentials>
    <application-acls>
      <entry>
        <key>VIEW_APP</key>
        <value>testuser3, testuser4</value>
      </entry>
      <entry>
        <key>MODIFY_APP</key>
        <value>testuser1, testuser2</value>
      </entry>
    </application-acls>
  </am-container-spec>
  <unmanaged-AM>false</unmanaged-AM>
  <max-app-attempts>2</max-app-attempts>
  <resource>
    <memory>1024</memory>
    <vCores>1</vCores>
  </resource>
  <application-type>YARN</application-type>
  <keep-containers-across-application-attempts>false</keep-containers-across-application-attempts>
  <application-tags>
    <tag>tag 2</tag>
    <tag>tag1</tag>
  </application-tags>
  <log-aggregation-context>
    <log-include-pattern>file1</log-include-pattern>
    <log-exclude-pattern>file2</log-exclude-pattern>
    <rolled-log-include-pattern>file3</rolled-log-include-pattern>
    <rolled-log-exclude-pattern>file4</rolled-log-exclude-pattern>
    <log-aggregation-policy-class-name>org.apache.hadoop.yarn.server.nodemanager.containermanager.logaggregation.AllContainerLogAggregationPolicy</log-aggregation-policy-class-name>
    <log-aggregation-policy-parameters></log-aggregation-policy-parameters>
  </log-aggregation-context>
  <attempt-failures-validity-interval>3600000</attempt-failures-validity-interval>
  <reservation-id>reservation_1454114874_1</reservation-id>
  <am-black-listing-requests>
    <am-black-listing-enabled>true</am-black-listing-enabled>
    <disable-failure-threshold>0.01</disable-failure-threshold>
  </am-black-listing-requests>
</application-submission-context>

回應標頭

  HTTP/1.1 202
  Transfer-Encoding: chunked
  Location: http://rm-http-address:port/ws/v1/cluster/apps/application_1404204891930_0002
  Content-Type: application/xml
  Server: Jetty(6.1.26)

回應本文

  No response body

叢集應用程式狀態 API

使用應用程式狀態 API,您可以查詢已提交應用程式的狀態,也可以透過修改執行中應用程式的狀態,使用設定為「KILLED」的 PUT 要求來終止執行中的應用程式。若要執行 PUT 作業,必須為 RM 網路服務設定驗證。此外,您必須有權限終止應用程式。目前您只能將狀態變更為「KILLED」;嘗試將狀態變更為任何其他狀態都會產生 400 錯誤回應。以下是未授權和錯誤要求錯誤的範例。當您執行成功的 PUT 時,初始回應可能是 202。您可以重複 PUT 要求,直到收到 200、使用 GET 方法查詢狀態或查詢應用程式資訊並檢查狀態,來確認應用程式已終止。在以下範例中,我們重複 PUT 要求並收到 200 回應。

請注意,若要終止應用程式,您必須為 HTTP 介面設定驗證篩選器。此功能需要在 HttpServletRequest 中設定使用者名稱。如果未設定篩選器,回應將會是「UNAUTHORIZED」回應。

此功能目前處於 alpha 階段,未來可能會變更。

URI

支援的 HTTP 作業

  • GET
    • PUT

支援的查詢參數

  None

appstate 物件的元素

當您要求應用程式的狀態時,傳回的資訊具有下列欄位

項目 資料類型 說明
state 字串 應用程式狀態 - 可能為「NEW」、「NEW_SAVING」、「SUBMITTED」、「ACCEPTED」、「RUNNING」、「FINISHED」、「FAILED」、「KILLED」之一

回應範例

JSON 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/apps/application_1399397633663_0003/state

回應標頭

HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked
Server: Jetty(6.1.26)

回應本文

{
  "state":"ACCEPTED"
}

HTTP 要求

  PUT http://rm-http-address:port/ws/v1/cluster/apps/application_1399397633663_0003/state

要求主體

{
  "state":"KILLED"
}

回應標頭

HTTP/1.1 202 Accepted
Content-Type: application/json
Transfer-Encoding: chunked
Location: http://rm-http-address:port/ws/v1/cluster/apps/application_1399397633663_0003
Server: Jetty(6.1.26)

回應本文

{
  "state":"ACCEPTED"
}

  PUT http://rm-http-address:port/ws/v1/cluster/apps/application_1399397633663_0003/state

要求主體

{
  "state":"KILLED"
}

回應標頭

HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked
Server: Jetty(6.1.26)

回應本文

{
  "state":"KILLED"
}

XML 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/apps/application_1399397633663_0003/state

回應標頭

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 99
Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<appstate>
  <state>ACCEPTED</state>
</appstate>

HTTP 要求

  PUT http://rm-http-address:port/ws/v1/cluster/apps/application_1399397633663_0003/state

要求主體

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<appstate>
  <state>KILLED</state>
</appstate>

回應標頭

HTTP/1.1 202 Accepted
Content-Type: application/xml
Content-Length: 794
Location: http://rm-http-address:port/ws/v1/cluster/apps/application_1399397633663_0003
Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<appstate>
  <state>ACCEPTED</state>
</appstate>

HTTP 要求

  PUT http://rm-http-address:port/ws/v1/cluster/apps/application_1399397633663_0003/state

要求主體

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<appstate>
  <state>KILLED</state>
</appstate>

回應標頭

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 917
Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<appstate>
  <state>KILLED</state>
</appstate>

未授權錯誤回應

HTTP 要求

  PUT http://rm-http-address:port/ws/v1/cluster/apps/application_1399397633663_0003/state

要求主體

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<appstate>
  <state>KILLED</state>
</appstate>

回應標頭

HTTP/1.1 403 Unauthorized
Server: Jetty(6.1.26)

錯誤要求錯誤回應

HTTP 要求

  PUT http://rm-http-address:port/ws/v1/cluster/apps/application_1399397633663_0003/state

要求主體

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<appstate>
  <state>RUNNING</state>
</appstate>

回應標頭

HTTP/1.1 400
Content-Length: 295
Content-Type: application/xml
Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RemoteException>
  <exception>BadRequestException</exception>
  <message>java.lang.Exception: Only 'KILLED' is allowed as a target state.</message>
  <javaClassName>org.apache.hadoop.yarn.webapp.BadRequestException</javaClassName>
</RemoteException>

叢集應用程式佇列 API

使用應用程式佇列 API,您可以查詢已提交應用程式的佇列,並使用指定目標佇列的 PUT 要求將正在執行的應用程式移至另一個佇列。若要執行 PUT 作業,必須為 RM 網路服務設定驗證。此外,您必須有權限移動應用程式。目前,只有在您使用容量排程器或公平排程器時,才能移動應用程式。

請注意,若要移動應用程式,您必須為 HTTP 介面設定驗證篩選器。此功能需要在 HttpServletRequest 中設定使用者名稱。如果未設定篩選器,回應將會是「未授權」回應。

此功能目前處於 alpha 階段,未來可能會變更。

URI

支援的 HTTP 作業

  • GET
    • PUT

支援的查詢參數

  None

appqueue 物件的元素

當您要求應用程式的狀態時,傳回的資訊具有下列欄位

項目 資料類型 說明
queue 字串 應用程式佇列

回應範例

JSON 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/apps/application_1399397633663_0003/queue

回應標頭

HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked
Server: Jetty(6.1.26)

回應本文

{
  "queue":"default"
}

HTTP 要求

  PUT http://rm-http-address:port/ws/v1/cluster/apps/application_1399397633663_0003/queue

要求主體

{
  "queue":"test"
}

回應標頭

HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked
Server: Jetty(6.1.26)

回應本文

{
  "queue":"test"
}

XML 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/apps/application_1399397633663_0003/queue

回應標頭

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 98
Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<appqueue>
  <queue>default</queue>
</appqueue>

HTTP 要求

  PUT http://rm-http-address:port/ws/v1/cluster/apps/application_1399397633663_0003/queue

要求主體

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<appqueue>
  <queue>test</queue>
</appqueue>

回應標頭

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 95
Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<appqueue>
  <queue>test</queue>
</appqueue>

叢集應用程式優先順序 API

使用應用程式優先順序 API,您可以查詢已提交應用程式的優先順序,並使用指定目標優先順序的 PUT 要求更新正在執行或已接受應用程式的優先順序。若要執行 PUT 作業,必須為 RM 網路服務設定驗證。此外,您必須有權限更新應用程式優先順序。目前,只有在您使用容量排程器時,才能更新應用程式優先順序。

請注意,若要更新應用程式的優先順序,您必須為 HTTP 介面設定驗證篩選器。此功能需要在 HttpServletRequest 中設定使用者名稱。如果未設定篩選器,回應將會是「未授權」回應。

此功能目前處於 alpha 階段,未來可能會變更。

URI

支援的 HTTP 作業

  • GET
    • PUT

支援的查詢參數

  None

apppriority 物件的元素

當您要求應用程式的狀態時,傳回的資訊具有下列欄位

項目 資料類型 說明
優先順序 int 應用程式優先順序

回應範例

JSON 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/apps/application_1399397633663_0003/priority

回應標頭

HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked
Server: Jetty(6.1.26)

回應本文

{
  "priority":0
}

HTTP 要求

  PUT http://rm-http-address:port/ws/v1/cluster/apps/application_1399397633663_0003/priority

要求主體

{
  "priority":8
}

回應標頭

HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked
Server: Jetty(6.1.26)

回應本文

{
  "priority":8
}

XML 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/apps/application_1399397633663_0003/priority

回應標頭

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 98
Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<applicationpriority>
  <priority>0</priority>
</applicationpriority>

HTTP 要求

  PUT http://rm-http-address:port/ws/v1/cluster/apps/application_1399397633663_0003/priority

要求主體

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<applicationpriority>
  <priority>8</priority>
</applicationpriority>

回應標頭

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 95
Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<applicationpriority>
  <priority>8</priority>
</applicationpriority>

叢集委派權杖 API

委派權杖 API 可用於建立、更新和取消 YARN ResourceManager 委派權杖。所有委派權杖要求都必須在 Kerberos 驗證連線(使用 SPNEGO)上執行。在非 Kerberos 連線上執行作業將導致禁止回應。在更新權杖時,只有在建立權杖時指定的更新者才能更新權杖。其他使用者(包括擁有者)禁止更新權杖。請注意,在取消或更新權杖時,會透過設定標頭來指定要取消或更新的權杖。

此功能目前處於 alpha 階段,未來可能會變更。

URI

使用下列 URI 建立和取消委派權杖。

使用下列 URI 更新委派權杖。

支援的 HTTP 作業

  • POST
    • DELETE

支援的查詢參數

  None

delegation-token 物件的元素

委派權杖 API 的回應包含下列欄位之一。

項目 資料類型 說明
權杖 字串 委派權杖
更新者 字串 允許更新委派權杖的使用者
擁有者 字串 委派權杖的擁有者
類型 字串 委派權杖的類型
到期時間 長整數 權杖的到期時間
最大有效期限 長整數 權杖的最大有效期限

回應範例

建立權杖

JSON 回應

HTTP 要求

  POST http://rm-http-address:port/ws/v1/cluster/delegation-token
  Accept: application/json
  Content-Type: application/json
  {
    "renewer" : "test-renewer"
  }

回應標頭

  HTTP/1.1 200 OK
  WWW-Authenticate: Negotiate ...
  Date: Sat, 28 Jun 2014 18:08:11 GMT
  Server: Jetty(6.1.26)
  Set-Cookie: ...
  Content-Type: application/json

回應主體

  {
    "token":"MgASY2xpZW50QEVYQU1QTEUuQ09NDHRlc3QtcmVuZXdlcgCKAUckiEZpigFHSJTKaQECFN9EMM9BzfPoDxu572EVUpzqhnSGE1JNX0RFTEVHQVRJT05fVE9LRU4A",
    "renewer":"test-renewer",
    "owner":"client@EXAMPLE.COM",
    "kind":"RM_DELEGATION_TOKEN",
    "expiration-time":1405153616489,
    "max-validity":1405672016489
  }

XML 回應

HTTP 要求

  POST http://rm-http-address:port/ws/v1/cluster/delegation-token
  Accept: application/xml
  Content-Type: application/xml
  <delegation-token>
    <renewer>test-renewer</renewer>
  </delegation-token>

回應標頭

  HTTP/1.1 200 OK
  WWW-Authenticate: Negotiate ...
  Date: Sat, 28 Jun 2014 18:08:11 GMT
  Content-Length: 423
  Server: Jetty(6.1.26)
  Set-Cookie: ...
  Content-Type: application/xml

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<delegation-token>  <token>MgASY2xpZW50QEVYQU1QTEUuQ09NDHRlc3QtcmVuZXdlcgCKAUckgZ8yigFHSI4jMgcCFDTG8X6XFFn2udQngzSXQL8vWaKIE1JNX0RFTEVHQVRJT05fVE9LRU4A</token>
  <renewer>test-renewer</renewer>
  <owner>client@EXAMPLE.COM</owner>
  <kind>RM_DELEGATION_TOKEN</kind>
  <expiration-time>1405153180466</expiration-time>
  <max-validity>1405671580466</max-validity>
</delegation-token>

更新權杖

JSON 回應

HTTP 要求

  POST http://rm-http-address:port/ws/v1/cluster/delegation-token/expiration
  Accept: application/json
  Hadoop-YARN-RM-Delegation-Token: MgASY2xpZW50QEVYQU1QTEUuQ09NDHRlc3QtcmVuZXdlcgCKAUbjqcHHigFHB7ZFxwQCFKWD3znCkDSy6SQIjRCLDydxbxvgE1JNX0RFTEVHQVRJT05fVE9LRU4A
  Content-Type: application/json

回應標頭

  HTTP/1.1 200 OK
  WWW-Authenticate: Negotiate ...
  Date: Sat, 28 Jun 2014 18:08:11 GMT
  Server: Jetty(6.1.26)
  Set-Cookie: ...
  Content-Type: application/json

回應主體

  {
    "expiration-time":1404112520402
  }

XML 回應

HTTP 要求

  POST http://rm-http-address:port/ws/v1/cluster/delegation-token/expiration
  Accept: application/xml
  Content-Type: application/xml
  Hadoop-YARN-RM-Delegation-Token: MgASY2xpZW50QEVYQU1QTEUuQ09NDHRlc3QtcmVuZXdlcgCKAUbjqcHHigFHB7ZFxwQCFKWD3znCkDSy6SQIjRCLDydxbxvgE1JNX0RFTEVHQVRJT05fVE9LRU4A

回應標頭

  HTTP/1.1 200 OK
  WWW-Authenticate: Negotiate ...
  Date: Sat, 28 Jun 2014 18:08:11 GMT
  Content-Length: 423
  Server: Jetty(6.1.26)
  Set-Cookie: ...
  Content-Type: application/xml

回應本文

  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  <delegation-token>
    <expiration-time>1404112520402</expiration-time>
  </delegation-token>

取消權杖

HTTP 要求

DELETE http://rm-http-address:port/ws/v1/cluster/delegation-token
Hadoop-YARN-RM-Delegation-Token: MgASY2xpZW50QEVYQU1QTEUuQ09NDHRlc3QtcmVuZXdlcgCKAUbjqcHHigFHB7ZFxwQCFKWD3znCkDSy6SQIjRCLDydxbxvgE1JNX0RFTEVHQVRJT05fVE9LRU4A
Accept: application/xml

回應標頭

  HTTP/1.1 200 OK
  WWW-Authenticate: Negotiate ...
  Date: Sun, 29 Jun 2014 07:25:18 GMT
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)
  Set-Cookie: ...
  Content-Type: application/xml

沒有回應主體。

使用委派權杖進行驗證

此功能處於 alpha 模式,未來可能會變更。

您可以在使用 YARN RM 網路服務時使用委派權杖進行驗證。不過,這需要設定正確的組態。其條件如下

  • Hadoop 已在安全模式中設定,且驗證類型設定為 kerberos。

  • Hadoop HTTP 驗證已設定,且驗證類型設定為 kerberos

設定後,可以使用上面列出的網路服務取得委派權杖,並如以下範例所示使用

  PUT http://rm-http-address:port/ws/v1/cluster/apps/application_1399397633663_0003/state
  X-Hadoop-Delegation-Token: MgASY2xpZW50QEVYQU1QTEUuQ09NDHRlc3QtcmVuZXdlcgCKAUbjqcHHigFHB7ZFxwQCFKWD3znCkDSy6SQIjRCLDydxbxvgE1JNX0RFTEVHQVRJT05fVE9LRU4A
  Content-Type: application/json; charset=UTF8
  {
    "state":"KILLED"
  }

叢集預約 API 清單

叢集預約 API 可用於列出預約。在列出預約時,使用者必須指定佇列、預約 ID、開始時間或結束時間的限制條件。使用者還必須指定是否包含要列出的預約的完整資源配置。結果頁面會傳回包含預約相關資訊的回應,例如接受時間、使用者、資源配置、預約 ID,以及預約定義。

URI

支援的 HTTP 作業

  • GET

支援的查詢參數

  • 佇列 - 包含要列出的預約的佇列名稱。如果未設定,此值會預設為「預設」。
    • 預約 ID - 要列出的預約的預約 ID。如果存在此參數,則會忽略開始時間和結束時間。
    • 開始時間 - 將列出在此開始時間後結束的預約。如果未指定或無效,這將預設為 0。
    • 結束時間 - 將列出在此結束時間後開始的預約。如果未指定或無效,這將預設為 Long.MaxValue。
    • 包含資源配置 - true 或 false。如果為 true,預約的資源配置將包含在回應中。如果為 false,回應中將不包含任何資源配置。這將預設為 false。

ReservationListInfo 物件的元素

項目 資料類型 說明
預約 ReservationInfo(JSON) 陣列 / 零個或多個 ReservationInfo 物件 (XML) 使用所提供查詢列出的預約

reservations 物件的元素

項目 資料類型 說明
接受時間 長整數 接受預約的時間
資源配置 ResourceAllocationInfo(JSON) 陣列 / 零個或多個 ResourceAllocationInfo 物件 (XML) 預約的資源配置資訊
保留 ID 單一 ReservationId 字串 唯一的預約識別碼
預約定義 單一 ReservationDefinition 物件 一組限制條件,表示使用者在一段時間內對資源的需求
使用者 字串 進行預約的使用者

resource-allocations 物件的元素

項目 資料類型 說明
resource 單一資源物件 預約配置分配的資源
startTime 長整數 分配資源的開始時間
結束時間 長整數 分配資源的結束時間

resource 物件的元素

項目 資料類型 說明
memory int 預約配置分配的記憶體
vCores int 預約配置分配的核心數

reservation-definition 物件的元素

項目 資料類型 說明
抵達 長整數 此預約最早可從中配置的 UTC 時間表示。
截止時間 長整數 此預約可在其中配置的最晚 UTC 時間表示。
預約名稱 字串 預約的助記名稱 (不是有效的識別碼)。
預約要求 物件 此預約的「階段」或階段清單,每個階段都描述資源需求和持續時間
優先順序 int 表示預約優先順序的整數。優先順序數字較小表示優先順序較高。定期預約的優先順序永遠高於非定期預約。非定期預約的優先順序僅與非定期預約進行比較。定期預約亦同。
遞迴表達式 字串 遞迴表達式代表定期工作的時間週期。目前僅支援長整數值。稍後會新增支援表示任意遞迴模式(例如每週二和週四)的正規表示式。遞迴以毫秒為單位表示定期工作。非定期工作的遞迴為 0。定期工作有效,直到明確取消,且優先順序高於非定期工作(在初始配置和重新規劃期間)。定期工作配置在各次執行中保持一致(配置的彈性僅在初始配置期間使用,之後配置會保持一致)。請注意,遞迴表達式必須大於預約的持續時間(截止時間 - 到達時間)。另請注意,設定的最大週期必須可以被遞迴表達式整除。

reservation-requests 物件的元素

項目 資料類型 說明
reservation-request-interpreter int 如何詮釋 ReservationRequest 集合的數字選項:0 為任意、1 為全部、2 為順序、3 為無間隙順序
reservation-request 物件 此預約階段/步驟的資源和時間功能說明

reservation-request 物件的元素

項目 資料類型 說明
duration 長整數 ReservationRequest 的持續時間(以毫秒為單位)(此預約部分的滿意配置應存在的連續毫秒數)。
num-containers int 此預約階段中所需容器的數量(擷取此階段中工作最大並行度)。
min-concurrency int 滿足此配置所必須同時配置的最小容器數量(擷取最小並行度,可用於表示群組語意)。
capability 物件 允許指定每個容器的大小(記憶體、虛擬核心)。

GET 回應範例

GET 要求可用於將預約清單傳送至 ResourceManager。如上所述,成功時會傳回與預約相關的資訊(在回應主體中)。成功的清單要求會產生 200 回應。請注意,若要提交預約,您必須為 HTTP 介面設定驗證過濾器。此功能要求在 HttpServletRequest 中設定使用者名稱。如果未設定過濾器,回應會是「未授權」回應。請注意,此功能目前處於 alpha 階段,未來可能會變更。

JSON 回應

此要求傳回 1455159355000 和 1475160036000 開始時間內所有活動的預約。由於 include-resource-allocations 設為 true,因此回應中會包含完整的資源配置集。

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/reservation/list?queue=dedicated&start-time=1455159355000&end-time=1475160036000&include-resource-allocations=true

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Cache-Control: no-cache
  Content-Encoding: gzip
  Pragma: no-cache,no-cache
  Server: Jetty(6.1.26)

回應本文

{
  "reservations": {
    "acceptance-time": "1455160008442",
    "user": "submitter",
    "resource-allocations": [
      {
        "resource": {
          "memory": "0",
          "vCores": "0"
        },
        "startTime": "1465541532000",
        "endTime": "1465542250000"
      },
      {
        "resource": {
          "memory": "1024",
          "vCores": "1"
        },
        "startTime": "1465542250000",
        "endTime": "1465542251000"
      },
      {
        "resource": {
          "memory": "0",
          "vCores": "0"
        },
        "startTime": "1465542251000",
        "endTime": "1465542252000"
      }
    ],
    "reservation-id": "reservation_1458852875788_0002",
    "reservation-definition": {
      "arrival": "1465541532000",
      "deadline": "1465542252000",
      "reservation-requests": {
        "reservation-request-interpreter": "0",
        "reservation-request": {
          "capability": {
            "memory": "1024",
            "vCores": "1"
          },
          "min-concurrency": "1",
          "num-containers": "1",
          "duration": "60"
        }
      },
      "reservation-name": "res_1"
    }
  }
}

XML 回應

HTTP 要求

  GET http://rm-http-address:port/ws/v1/cluster/reservation/list?queue=dedicated&start-time=1455159355000&end-time=1475160036000&include-resource-allocations=true

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Content-length: 395
  Cache-Control: no-cache
  Content-Encoding: gzip
  Pragma: no-cache,no-cache
  Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <reservationListInfo>
        <reservations>
        <acceptance-time>1455233661003</acceptance-time>
        <user>dr.who</user>
        <resource-allocations>
            <resource>
                <memory>0</memory>
                <vCores>0</vCores>
            </resource>
            <startTime>1465541532000</startTime>
            <endTime>1465542251000</endTime>
        </resource-allocations>
        <resource-allocations>
            <resource>
                <memory>1024</memory>
                <vCores>1</vCores>
            </resource>
            <startTime>1465542251000</startTime>
            <endTime>1465542252000</endTime>
        </resource-allocations>
        <reservation-id>reservation_1458852875788_0002</reservation-id>
        <reservation-definition>
            <arrival>1465541532000</arrival>
            <deadline>1465542252000</deadline>
            <reservation-requests>
                <reservation-request-interpreter>0</reservation-request-interpreter>
                <reservation-request>
                    <capability>
                        <memory>1024</memory>
                        <vCores>1</vCores>
                    </capability>
                    <min-concurrency>1</min-concurrency>
                    <num-containers>1</num-containers>
                    <duration>60</duration>
                </reservation-request>
            </reservation-requests>
            <reservation-name>res_1</reservation-name>
        </reservation-definition>
    </reservations>
</reservationListInfo>

叢集預約 API 建立

使用新的預約 API 取得預約 ID,然後可將其用於 叢集預約 API 提交的一部分,以提交預約。

此功能目前處於 alpha 階段,未來可能會變更。

URI

支援的 HTTP 作業

  • POST

支援的查詢參數

  None

new-reservation 物件的元素

new-reservation 回應包含下列元素

項目 資料類型 說明
保留 ID 字串 新建立的預約 ID

回應範例

JSON 回應

HTTP 要求

  POST http://rm-http-address:port/ws/v1/cluster/reservation/new-reservation

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

回應本文

{
  "reservation-id":"reservation_1404198295326_0003"
}

XML 回應

HTTP 要求

  POST http://rm-http-address:port/ws/v1/cluster/reservation/new-reservation

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Content-Length: 248
  Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<new-reservation>
  <reservation-id>reservation_1404198295326_0003</reservation-id>
</new-reservation>

叢集預約 API 提交

叢集預約 API 可用於提交預約。提交預約時,使用者會指定資源和時間方面的限制。如果可以預約,結果回應會成功。如果使用預約 ID 多次提交預約,如果預約定義相同,要求會成功,但只會建立一個預約。如果預約定義不同,伺服器會回應錯誤回應。預約建立後,使用者可以使用用於提交預約的預約 ID,透過指定它作為 叢集提交應用程式 API 的一部分來取得資源存取權。

URI

支援的 HTTP 作業

  • POST

POST 回應範例

POST 要求可用於向資源管理員提交預約。如上所述,成功時會傳回預約 ID(在答案主體中)。成功的提交會產生 200 回應。請注意,若要提交預約,您必須為 HTTP 介面設定驗證過濾器。此功能需要在 HttpServletRequest 中設定使用者名稱。如果未設定過濾器,回應會是「UNAUTHORIZED」回應。

請注意,此功能目前處於 alpha 階段,未來可能會變更。

POST 要求物件的元素

項目 資料類型 說明
queue 字串 您要提交到的(可預約)佇列
預約定義 物件 一組限制,表示使用者隨著時間推移對資源的需求。
保留 ID 字串 用於提交預訂的預訂 ID。

reservation-definition 物件的元素

項目 資料類型 說明
抵達 長整數 此預約最早可從中配置的 UTC 時間表示。
截止時間 長整數 此預約可在其中配置的最晚 UTC 時間表示。
預約名稱 字串 預約的助記名稱 (不是有效的識別碼)。
預約要求 物件 此預約的「階段」或階段清單,每個階段都描述資源需求和持續時間
優先順序 int 表示預約優先順序的整數。優先順序數字較小表示優先順序較高。定期預約的優先順序永遠高於非定期預約。非定期預約的優先順序僅與非定期預約進行比較。定期預約亦同。

reservation-requests 物件的元素

項目 資料類型 說明
reservation-request-interpreter int 如何詮釋 ReservationRequest 集合的數字選項:0 為任意、1 為全部、2 為順序、3 為無間隙順序
reservation-request 物件 此預約階段/步驟的資源和時間功能說明

reservation-request 物件的元素

項目 資料類型 說明
duration 長整數 ReservationRequeust 的持續時間,以毫秒為單位(此預訂部分的滿意配置應存在的連續毫秒數)。
num-containers int 此預約階段中所需容器的數量(擷取此階段中工作最大並行度)。
min-concurrency int 滿足此配置所必須同時配置的最小容器數量(擷取最小並行度,可用於表示群組語意)。
capability 物件 允許指定每個容器的大小(記憶體、虛擬核心)。

capability 物件的元素

項目 資料類型 說明
memory int 此容器的 MB 記憶體數量
vCores int 此容器的虛擬核心數量

JSON 回應

此範例包含由兩個階段組成的預訂(彼此為備用,因為 reservation-request-interpreter 設為 0),因此第一個較短且「較高」並「群組」有 220 個容器,持續 60 秒,而第二個備用較長,持續 120 秒,且較短,有 110 個容器(以及 1 個容器的最小並行性,因此沒有群組語意)。

HTTP 要求

POST http://rmdns:8088/ws/v1/cluster/reservation/submit
Content-Type: application/json
{
  "queue" : "dedicated",
  "reservation-id":"reservation_1404198295326_0003"
  "reservation-definition" : {
     "arrival" : 1765541532000,
     "deadline" : 1765542252000,
     "reservation-name" : "res_1",
     "reservation-requests" : {
        "reservation-request-interpreter" : 0,
        "reservation-request" : [
           {
             "duration" : 60000,
             "num-containers" : 220,
             "min-concurrency" : 220,
             "capability" : {
               "memory" : 1024,
               "vCores" : 1
             }
           },
           {
             "duration" : 120000,
             "num-containers" : 110,
             "min-concurrency" : 1,
             "capability" : {
               "memory" : 1024,
               "vCores" : 1
             }
           }
        ]
     }
   }
}

回應標頭

200 OK Cache-Control: no-cache Expires: Thu, 17 Dec 2015 23:36:34 GMT, Thu, 17 Dec 2015 23:36:34 GMT Date: Thu, 17 Dec 2015 23:36:34 GMT, Thu, 17 Dec 2015 23:36:34 GMT Pragma: no-cache, no-cache Content-Type: application/xml Content-Encoding: gzip Content-Length: 137 Server: Jetty(6.1.26)

回應本文

  No response body

XML 回應

HTTP 要求

POST http://rmdns:8088/ws/v1/cluster/reservation/submit
Accept: application/xml
Content-Type: application/xml
<reservation-submission-context>
  <queue>dedicated</queue>
  <reservation-id>reservation_1404198295326_0003</reservation-id>
  <reservation-definition>
     <arrival>1765541532000</arrival>
     <deadline>1765542252000</deadline>
     <reservation-name>res_1</reservation-name>
     <reservation-requests>
        <reservation-request-interpreter>0</reservation-request-interpreter>
        <reservation-request>
             <duration>60000</duration>
             <num-containers>220</num-containers>
             <min-concurrency>220</min-concurrency>
             <capability>
               <memory>1024</memory>
               <vCores>1</vCores>
             </capability>
        </reservation-request>
        <reservation-request>
             <duration>120000</duration>
             <num-containers>110</num-containers>
             <min-concurrency>1</min-concurrency>
             <capability>
               <memory>1024</memory>
               <vCores>1</vCores>
             </capability>
        </reservation-request>
     </reservation-requests>
  </reservation-definition>
</reservation-submission-context>

回應標頭

200 OK Cache-Control: no-cache Expires: Thu, 17 Dec 2015 23:49:21 GMT, Thu, 17 Dec 2015 23:49:21 GMT Date: Thu, 17 Dec 2015 23:49:21 GMT, Thu, 17 Dec 2015 23:49:21 GMT Pragma: no-cache, no-cache Content-Type: application/xml Content-Encoding: gzip Content-Length: 137 Server: Jetty(6.1.26)

回應本文

  No response body

叢集預訂 API 更新

叢集預訂 API 更新可用於更新現有預訂。預訂更新的運作方式類似於上述提交,但使用者會提交現有預訂的預訂 ID 以進行更新。語意為嘗試和交換,成功操作會根據請求的更新參數修改現有預訂,而失敗執行則會讓現有預訂保持不變。

URI

支援的 HTTP 作業

  • POST

POST 回應範例

POST 請求可用於將預訂更新至 ResourceManager。成功提交會產生 200 回應,表示現有預訂的原址更新(ID 不會變更)。請注意,若要更新預訂,您必須為 HTTP 介面設定驗證過濾器。此功能需要在 HttpServletRequest 中設定使用者名稱。如果未設定過濾器,回應會是「UNAUTHORIZED」回應。

請注意,此功能目前處於 alpha 階段,未來可能會變更。

POST 要求物件的元素

項目 資料類型 說明
保留 ID 字串 要更新的預約 ID(系統會自動由此尋找正確的佇列)
預約定義 物件 一組限制,表示使用者隨著時間推移對資源的需求。

reservation-definition 物件的元素

項目 資料類型 說明
抵達 長整數 此預約最早可從中配置的 UTC 時間表示。
截止時間 長整數 此預約可在其中配置的最晚 UTC 時間表示。
預約名稱 字串 預約的助記名稱 (不是有效的識別碼)。
預約要求 物件 此預約的「階段」或階段清單,每個階段都描述資源需求和持續時間
優先順序 int 表示預約優先順序的整數。優先順序數字較小表示優先順序較高。定期預約的優先順序永遠高於非定期預約。非定期預約的優先順序僅與非定期預約進行比較。定期預約亦同。

reservation-requests 物件的元素

項目 資料類型 說明
reservation-request-interpreter int 如何詮釋 ReservationRequest 集合的數字選項:0 為任意、1 為全部、2 為順序、3 為無間隙順序
reservation-request 物件 此預約階段/步驟的資源和時間功能說明

reservation-request 物件的元素

項目 資料類型 說明
duration 長整數 ReservationRequeust 的持續時間,以毫秒為單位(此預訂部分的滿意配置應存在的連續毫秒數)。
num-containers int 此預約階段中所需容器的數量(擷取此階段中工作最大並行度)。
min-concurrency int 滿足此配置所必須同時配置的最小容器數量(擷取最小並行度,可用於表示群組語意)。
capability 物件 允許指定每個容器的大小(記憶體、虛擬核心)。

capability 物件的元素

項目 資料類型 說明
memory int 此容器的 MB 記憶體數量
vCores int 此容器的虛擬核心數量

JSON 回應

此範例會更新由 reservation_1449259268893_0005 識別的現有預約,其中包含兩個階段(依序,因為 reservation-request-interpreter 設為 2),第一個階段是一個 10 個容器的「幫派」,持續 5 分鐘(10 個容器的最小並行性),接著是 50 個容器,持續 10 分鐘(1 個容器的最小並行性,因此沒有幫派語意)。

HTTP 要求

POST http://rmdns:8088/ws/v1/cluster/reservation/update
Accept: application/json
Content-Type: application/json
{
  "reservation-id" : "reservation_1449259268893_0005",
  "reservation-definition" : {
     "arrival" : 1765541532000,
     "deadline" : 1765542252000,
     "reservation-name" : "res_1",
     "reservation-requests" : {
        "reservation-request-interpreter" : 2,
        "reservation-request" : [
           {
             "duration" : 300000,
             "num-containers" : 10,
             "min-concurrency" : 10,
             "capability" : {
               "memory" : 1024,
               "vCores" : 1
             }
           },
           {
             "duration" : 60000,
             "num-containers" : 50,
             "min-concurrency" : 1,
             "capability" : {
               "memory" : 1024,
               "vCores" : 1
             }
           }
          ]
     }
   }
}

回應標頭

200 OK Cache-Control: no-cache Expires: Thu, 17 Dec 2015 23:36:34 GMT, Thu, 17 Dec 2015 23:36:34 GMT Date: Thu, 17 Dec 2015 23:36:34 GMT, Thu, 17 Dec 2015 23:36:34 GMT Pragma: no-cache, no-cache Content-Type: application/json Content-Encoding: gzip Content-Length: 137 Server: Jetty(6.1.26)

回應本文

  No response body

XML 回應

HTTP 要求

POST http://rmdns:8088/ws/v1/cluster/reservation/update
Accept: application/xml
Content-Type: application/xml
<reservation-update-context>
  <reservation-id>reservation_1449259268893_0005</reservation-id>
  <reservation-definition>
     <arrival>1765541532000</arrival>
     <deadline>1765542252000</deadline>
     <reservation-name>res_1</reservation-name>
     <reservation-requests>
        <reservation-request-interpreter>2</reservation-request-interpreter>
        <reservation-request>
             <duration>300000</duration>
             <num-containers>10</num-containers>
             <min-concurrency>10</min-concurrency>
             <capability>
               <memory>1024</memory>
               <vCores>1</vCores>
             </capability>
        </reservation-request>
        <reservation-request>
             <duration>60000</duration>
             <num-containers>50</num-containers>
             <min-concurrency>1</min-concurrency>
             <capability>
               <memory>1024</memory>
               <vCores>1</vCores>
             </capability>
        </reservation-request>
     </reservation-requests>
  </reservation-definition>
</reservation-update-context>

回應標頭

200 OK Cache-Control: no-cache Expires: Thu, 17 Dec 2015 23:49:21 GMT, Thu, 17 Dec 2015 23:49:21 GMT Date: Thu, 17 Dec 2015 23:49:21 GMT, Thu, 17 Dec 2015 23:49:21 GMT Pragma: no-cache, no-cache Content-Type: application/xml Content-Encoding: gzip Content-Length: 137 Server: Jetty(6.1.26)

回應本文

  No response body

叢集預約 API 刪除

叢集預約 API 刪除可用於刪除現有預約。刪除的工作方式類似於更新。要求包含預約 ID,如果成功,預約會被取消,否則預約會保留在系統中。

URI

支援的 HTTP 作業

  • POST

POST 回應範例

POST 要求可用於將預約刪除至 ResourceManager。成功提交會產生 200 回應,表示刪除成功。請注意,若要刪除預約,您必須為 HTTP 介面設定驗證過濾器。此功能需要在 HttpServletRequest 中設定使用者名稱。如果未設定過濾器,回應會是「UNAUTHORIZED」回應。

請注意,此功能目前處於 alpha 階段,未來可能會變更。

POST 要求物件的元素

項目 資料類型 說明
保留 ID 字串 要刪除的預約 ID(系統會自動由此尋找正確的佇列)

JSON 回應

此範例會刪除由 reservation_1449259268893_0006 識別的現有預約

HTTP 要求

POST http://10.200.91.98:8088/ws/v1/cluster/reservation/delete
Accept: application/json
Content-Type: application/json
{
  "reservation-id" : "reservation_1449259268893_0006"
}

回應標頭

200 OK Cache-Control: no-cache Expires: Fri, 18 Dec 2015 01:31:05 GMT, Fri, 18 Dec 2015 01:31:05 GMT Date: Fri, 18 Dec 2015 01:31:05 GMT, Fri, 18 Dec 2015 01:31:05 GMT Pragma: no-cache, no-cache Content-Type: application/json Content-Encoding: gzip Transfer-Encoding: chunked Server: Jetty(6.1.26)

回應本文

  No response body

XML 回應

HTTP 要求

POST http://10.200.91.98:8088/ws/v1/cluster/reservation/delete
Accept: application/xml
Content-Type: application/xml
<reservation-delete-context>
<reservation-id>reservation_1449259268893_0006</reservation-id>
</reservation-delete-context>

回應標頭

200 OK Cache-Control: no-cache Expires: Fri, 18 Dec 2015 01:33:23 GMT, Fri, 18 Dec 2015 01:33:23 GMT Date: Fri, 18 Dec 2015 01:33:23 GMT, Fri, 18 Dec 2015 01:33:23 GMT Pragma: no-cache, no-cache Content-Type: application/xml Content-Encoding: gzip Content-Length: 101 Server: Jetty(6.1.26)

回應本文

  No response body

叢集應用程式逾時 API

群集應用程式逾時 API 可用於取得應用程式所有已設定的逾時。當您對此資源執行 GET 作業時,會傳回逾時物件的集合。每個逾時物件都由逾時類型、到期時間和剩餘時間(以秒為單位)組成。

URI

支援的 HTTP 作業

  • GET

逾時(應用程式逾時)物件的元素

當您提出應用程式逾時清單的要求時,資訊會以逾時物件的集合傳回。另請參閱 群集應用程式逾時 API,以取得逾時物件的語法。

項目 資料類型 說明
逾時 逾時物件陣列(JSON)/零個或多個應用程式物件(XML) 應用程式逾時物件的集合

JSON 回應

HTTP 要求

  Accept: application/json
  GET http://rm-http-address:port/ws/v1/cluster/apps/{appid}/timeouts

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

回應本文

{
  "timeouts":
  {
    "timeout":
    [
      {
        "type": "LIFETIME",
        "expiryTime": "2016-12-05T22:51:00.104+0530",
        "remainingTimeInSeconds": 27
      }
    ]
  }
}

XML 回應

HTTP 要求

  Accept: application/xml
  GET http://rm-http-address:port/ws/v1/cluster/apps/{appid}/timeouts

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Content-Length: 712
  Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<timeouts>
    <timeout>
       <type>LIFETIME</type>
       <expiryTime>2016-12-05T22:51:00.104+0530</expiryTime>
       <remainingTimeInSeconds>27</remainingTimeInSeconds>
    </timeout>
</timeouts>

群集應用程式逾時 API

群集應用程式逾時資源包含有關逾時的資訊。

URI

支援的 HTTP 作業

  • GET

逾時(應用程式逾時)物件的元素

項目 資料類型 說明
類型 字串 逾時類型。有效值是 ApplicationTimeoutType 列舉的成員。目前 LIFETIME 是唯一有效的有效值。
到期時間 字串 應用程式會在 ISO8601 yyyy-MM-dd’T’HH:mm:ss.SSSZ 格式到期的時間。如果為 UNLIMITED,則應用程式會永遠執行。
剩餘時間(以秒為單位) 長整數 已設定應用程式逾時的剩餘時間。-1 表示應用程式未設定逾時。零(0)表示應用程式已使用已設定的逾時類型到期。

JSON 回應

HTTP 要求

  Accept: application/json
  GET http://rm-http-address:port/ws/v1/cluster/apps/{appid}/timeouts/LIFETIME

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

回應本文

{
"timeout":
   {
     "type": "LIFETIME",
     "expiryTime": "2016-12-05T22:51:00.104+0530",
     "remainingTimeInSeconds": 27
   }
}

XML 回應

HTTP 要求

  Accept: application/xml
  GET http://rm-http-address:port/ws/v1/cluster/apps/{appid}/timeouts/LIFETIME

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Content-Length: 712
  Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<timeout>
    <type>LIFETIME</type>
    <expiryTime>2016-12-05T22:51:00.104+0530</expiryTime>
    <remainingTimeInSeconds>27</remainingTimeInSeconds>
</timeout>

群集應用程式逾時更新 API

針對已設定的逾時類型更新應用程式的逾時。

URI

支援的 HTTP 作業

  • PUT

逾時物件的元素

項目 資料類型 說明
類型 字串 逾時類型。有效值是 ApplicationTimeoutType 列舉的成員。目前 LIFETIME 是唯一有效的有效值。
到期時間 字串 應用程式會在 ISO8601 yyyy-MM-dd’T’HH:mm:ss.SSSZ 格式到期的時間。

JSON 回應

HTTP 要求

      Accept: application/json
      PUT http://rm-http-address:port/ws/v1/cluster/apps/{appid}/timeout
      Content-Type: application/json
        {
        "timeout":
                   {
                     "type": "LIFETIME",
                     "expiryTime": "2016-11-27T09:36:16.678+05:30"
                   }
        }

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

回應本文

{
"timeout":
   {
     "type": "LIFETIME",
     "expiryTime": "2016-11-27T09:36:16.678+05:30",
     "remainingTimeInSeconds": 90
   }
}

XML 回應

HTTP 要求

      Accept: application/xml
      PUT http://rm-http-address:port/ws/v1/cluster/apps/{appid}/timeout
      Content-Type: application/xml
        <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
        <timeout>
            <type>LIFETIME</type>
            <expiryTime>2016-11-27T09:36:16.678+05:30</expiryTime>
        </timeout>

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Content-Length: 712
  Server: Jetty(6.1.26)

回應本文

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<timeout>
    <type>LIFETIME</type>
    <expiryTime>2016-11-27T09:36:16.678+05:30</expiryTime>
    <remainingTimeInSeconds>90</remainingTimeInSeconds>
</timeout>

排程器設定變更 API

排程器設定變更 API 提供一種修改排程器/佇列設定和佇列階層的方式。

請注意,此功能目前處於 alpha 階段,可能會變更。

URI

支援的 HTTP 作業

  • GET
    • PUT

排程器設定物件的元素

項目 資料類型 說明
更新佇列 物件 應更新其設定的佇列
新增佇列 物件 要新增到排程器的佇列,以及此佇列的設定
移除佇列 字串 要移除的佇列的完整路徑名稱
global-updates map 用於更新排程器全球組態的鍵值對映射

GET 要求範例

GET 要求用於擷取目前載入排程器內容的排程器組態。

XML 回應

HTTP 要求

  Accept: application/xml
  Content-Type: application/xml
  GET http://rm-http-address:port/ws/v1/cluster/scheduler-conf

回應標頭

  TTP/1.1 200 OK
  Content-Type: application/xml; charset=utf-8
  Transfer-Encoding: chunked

回應本文

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <configuration>
        <property>
          <name>yarn.scheduler.capacity.root.queues</name>
          <value>default</value>
        </property>
        <property>
          <name>yarn.scheduler.capacity.maximum-applications</name>
          <value>10000</value>
        </property>
        <property>
          <name>yarn.scheduler.capacity.root.default.capacity</name>
          <value>100</value>
        </property>
      </configuration>

PUT 要求範例

PUT 要求用於修改排程器組態。成功的變更會產生 200 回應。格式錯誤的請求或導致無效排程器組態的請求會產生 400 回應。

更新佇列組態

更新佇列組態的請求。

update-queue 物件的元素

項目 資料類型 說明
queue-name 字串 要更新的佇列完整路徑名稱
params map 用於更新此佇列的鍵值組態對應映射

假設我們使用容量排程器,而目前的佇列組態是單一佇列 root.default,此範例將 root.default 的最大應用程式數設定為 100,而其最小使用者限制百分比設定為 10。

HTTP 要求

      Accept: application/xml
      PUT http://rm-http-address:port/ws/v1/cluster/scheduler-conf
      Content-Type: application/xml
      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <sched-conf>
        <update-queue>
          <queue-name>root.default</queue-name>
          <params>
            <entry>
              <key>maximum-applications</key>
              <value>100</value>
            </entry>
            <entry>
              <key>minimum-user-limit-percent</key>
              <value>10</value>
            </entry>
          </params>
        </update-queue>
      </sched-conf>

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Transfer-Encoding: chunked

新增佇列

新增佇列/更新佇列組態的請求。

add-queue 物件的元素

項目 資料類型 說明
queue-name 字串 要新增的佇列完整路徑名稱
params map 用於設定此佇列的鍵值組態對應映射

假設我們使用容量排程器,而目前的佇列組態是單一佇列 root.default,此範例會新增一個佇列 root.a,其容量/最大容量為 10,並調整 root.default 的容量/最大容量為 90。(較複雜的範例包括新增一個佇列,其父佇列也在同一個請求中新增,或新增多個同層佇列。)

HTTP 要求

      Accept: application/xml
      PUT http://rm-http-address:port/ws/v1/cluster/scheduler-conf
      Content-Type: application/xml
      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <sched-conf>
        <add-queue>
          <queue-name>root.a</queue-name>
          <params>
            <entry>
              <key>capacity</key>
              <value>10</value>
            </entry>
            <entry>
              <key>maximum-capacity</key>
              <value>10</value>
            </entry>
          </params>
        </add-queue>
        <update-queue>
          <queue-name>root.default</queue-name>
          <params>
            <entry>
              <key>capacity</key>
              <value>90</value>
            </entry>
            <entry>
              <key>maximum-capacity</key>
              <value>90</value>
            </entry>
          </params>
        </update-queue>
      </sched-conf>

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Transfer-Encoding: chunked

移除佇列

從佇列階層中移除佇列的請求。

假設我們使用容量排程器,而目前的佇列組態是三個佇列 root.defaultroot.aroot.b,此範例會移除 root.aroot.b。(較複雜的範例包括移除父佇列及其子佇列。)

注意:佇列必須先置於 STOPPED 狀態才能刪除。任何更新的佇列組態都必須是有效的,也就是說每個 層級 的佇列容量都應該等於 100%。

HTTP 要求

      Accept: application/xml
      PUT http://rm-http-address:port/ws/v1/cluster/scheduler-conf
      Content-Type: application/xml
      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <sched-conf>
        <remove-queue>root.a</remove-queue>
        <remove-queue>root.b</remove-queue>
      </sched-conf>

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Transfer-Encoding: chunked

更新全球排程器組態

更新全球排程器組態的請求。假設我們使用容量排程器,此範例會啟用佇列對應。對於全球組態更新,必須指定完整的組態金鑰。

HTTP 要求

      Accept: application/xml
      PUT http://rm-http-address:port/ws/v1/cluster/scheduler-conf
      Content-Type: application/xml
      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <sched-conf>
        <global-updates>
          <entry>
            <key>yarn.scheduler.capacity.queue-mappings-override.enable</key>
            <value>true</value>
          </entry>
        </global-updates>
      </sched-conf>

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Transfer-Encoding: chunked

新增節點標籤至佇列

假設我們使用容量排程器,而目前的佇列組態是兩個佇列 root.default 和 root.a,此範例會新增一個節點標籤 x 至佇列 root.a。建立一個節點標籤 x,並使用下列指令指定節點。

yarn rmadmin -addToClusterNodeLabels "x(exclusive=true)"

yarn rmadmin -replaceLabelsOnNode "<nodeId>=x"

HTTP 要求

      Accept: application/xml
      PUT http://rm-http-address:port/ws/v1/cluster/scheduler-conf
      Content-Type: application/xml
      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <sched-conf>
        <update-queue>
          <queue-name>root.a</queue-name>
          <params>
            <entry>
              <key>accessible-node-labels</key>
              <value>x</value>
            </entry>
            <entry>
              <key>accessible-node-labels.x.capacity</key>
              <value>100</value>
            </entry>
          </params>
        </update-queue>
        <update-queue>
          <queue-name>root</queue-name>
          <params>
            <entry>
              <key>accessible-node-labels.x.capacity</key>
              <value>100</value>
            </entry>
          </params>
        </update-queue>
      </sched-conf>

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Transfer-Encoding: chunked

從佇列中移除節點標籤

假設我們使用容量排程器,目前的佇列組態是兩個佇列 root.default 和 root.a,且節點標籤 x 已指派給佇列 root.a。此範例會取消設定佇列 root.a 的節點標籤 x 並將其移除。

HTTP 要求

      Accept: application/xml
      PUT http://rm-http-address:port/ws/v1/cluster/scheduler-conf
      Content-Type: application/xml
      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <sched-conf>
        <update-queue>
          <queue-name>root.a</queue-name>
          <params>
            <entry>
              <key>accessible-node-labels</key>
              <value></value>
            </entry>
          </params>
        </update-queue>
      </sched-conf>

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Transfer-Encoding: chunked

yarn rmadmin -removeFromClusterNodeLabels x

叢集容器訊號 API

使用容器訊號 API,您可以使用下列其中一個指令傳送訊號給指定的容器:OUTPUT_THREAD_DUMP、GRACEFUL_SHUTDOWN 和 FORCEFUL_SHUTDOWN。

URI

  http://rm-http-address:port/ws/v1/cluster/containers/{containerId}/signal/{command}

支援的 HTTP 作業

  POST

支援的查詢參數

  None

回應範例

JSON 回應

HTTP 要求

  POST http://rm-http-address:port/ws/v1/cluster/containers/container_1531404209605_0008_01_000001/signal/OUTPUT_THREAD_DUMP
  Accept: application/json
  Content-Type: application/json

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

沒有回應主體。

XML 回應

HTTP 要求

  POST http://rm-http-address:port/ws/v1/cluster/containers/container_1531404209605_0008_01_000001/signal/OUTPUT_THREAD_DUMP
  Accept: application/xml
  Content-Type: application/xml

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml
  Content-Length: 552
  Server: Jetty(6.1.26)

沒有回應主體。

排程器活動 API

如果您使用容量排程器,排程器活動 RESTful API 可用,並可擷取排程週期中所記錄的排程器活動資訊。API 會傳回一則訊息,其中包含重要的排程器活動資訊,其具有下列欄位的階層式配置

  • 活動 - 活動是排程器活動的根物件。
  • 配置 - 配置是基於分割或保留的配置嘗試。
  • 階層式佇列 - 排程器已嘗試配置容器的階層式佇列,每個佇列都包含佇列名稱、配置狀態、選用診斷和選用子項。
  • 應用程式 - 應用程式顯示為葉狀佇列的子項,每個應用程式都包含關於應用程式的基本資訊。
  • 要求 - 要求顯示為應用程式的子項,每個要求都包含關於要求的基本資訊。
  • 節點 - 節點顯示為要求的子項,每個節點都包含節點 ID、配置狀態、選用名稱(應在節點上配置或保留容器後出現),以及選用診斷(如果無法配置或保留此節點上的容器時應顯示)。對於依配置狀態和診斷分組的聚合節點,每個節點都包含配置狀態、聚合節點 ID 和選用診斷。

URI

支援的 HTTP 作業

  • GET

支援的查詢參數

可為 GET 作業指定多個參數。

  • nodeId - 指定的節點 ID,如果未指定,排程器會在所有節點上記錄下一個排程週期的排程活動資訊。
    • groupBy - 應用程式活動的彙總類型,目前僅支援「diagnostic」,使用者可以查詢依配置狀態和診斷分組的彙總活動。

活動 物件的元素

項目 資料類型 說明
nodeId 字串 排程器嘗試配置容器的節點 ID。
時間戳記 長整數 活動的時間戳記。
dateTime 字串 活動的日期時間。
diagnostic 字串 關於空白結果、不可用環境或非法輸入參數的活動的頂層診斷,例如「等待顯示」、「等待下一次配置」、「叢集中沒有執行中的節點管理員」、「取得無效的 groupBy:xx,有效的 groupBy 類型:DIAGNOSTICS」
allocations 配置陣列 配置物件的集合。

配置 物件的元素

項目 資料類型 說明
partition 字串 配置的分區。
updatedContainerId 字串 配置中更新(配置或保留)的容器 ID。
finalAllocationState 字串 配置的最終配置狀態,包括 ALLOCATED、ALLOCATED_FROM_RESERVED、RESERVED 和 SKIPPED。
root 佇列 佇列物件

佇列 物件的元素

項目 資料類型 說明
名稱 字串 佇列名稱。
allocationState 字串 佇列的最終配置狀態,包括 ACCEPTED、REJECTED 和 SKIPPED。
diagnostic 字串 佇列的診斷。
children 佇列或應用程式的陣列 佇列物件(對於父佇列)或應用程式物件(對於葉狀佇列)的集合

應用程式 物件的元素

項目 資料類型 說明
名稱 字串 應用程式名稱。
appPriority 字串 應用程式的優先順序。
allocationState 字串 應用程式的最終配置狀態,包括 ALLOCATED、RESERVED、RE_RESERVED 和 SKIPPED。
diagnostic 字串 應用程式的診斷。
children 要求陣列 要求物件的集合

要求 物件的元素

項目 資料類型 說明
名稱 字串 要求的名稱,值格式為「request_<requestPriority>_<allocationRequestId>」,可用於識別不同的要求。
requestPriority 字串 要求的優先順序。
allocationRequestId 字串 要求的配置要求 ID。
allocationState 字串 應用程式的最終配置狀態,包括 ALLOCATED、RESERVED、RE_RESERVED 和 SKIPPED。
diagnostic 字串 要求的診斷。
children 節點陣列 節點物件的集合。

節點 物件的元素

項目 資料類型 說明
名稱 字串 容器資訊,為選用項目,且當配置狀態為 ALLOCATED、RESERVED 或 ALLOCATED_FROM_RESERVED 時可以顯示。
allocationState 字串 應用程式的最終配置狀態,包括 ALLOCATED、RESERVED、RE_RESERVED 和 SKIPPED。
diagnostic 字串 關於一般模式中的節點或彙總模式中的節點的診斷
nodeId 字串 排程程序為基礎的節點 ID,對於具有 groupBy 參數的彙總查詢,不會顯示。
nodeIds 字串陣列 聚合活動的節點 ID 集合,僅顯示 groupBy 參數的聚合查詢。
count int 節點 ID 的數量,僅顯示 groupBy 參數的聚合查詢。

回應範例

JSON 回應

HTTP 要求

  Accept: application/json
  GET http://rm-http-address:port/ws/v1/cluster/scheduler/activities

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

回應本文

以下是在啟用全球排程時輸出的範例,單一要求在節點層級有多個活動。對於單一節點放置,差異在於 nodeId 會顯示為活動的欄位,且每個要求在節點層級上應只有一個活動。

{
  "activities": {
    "timestamp": 1562296830912,
    "dateTime": "Fri Jul 05 11:20:30 CST 2019",
    "allocations": [
      {
        "partition": "",
        "finalAllocationState": "ALLOCATED",
        "root": {
          "name": "root",
          "allocationState": "ACCEPTED",
          "children": [
            {
              "name": "a",
              "allocationState": "SKIPPED",
              "diagnostic": "Queue does not need more resources"
            },
            {
              "name": "b",
              "allocationState": "ACCEPTED",
              "children": [
                {
                  "name": "application_1562296828063_0001",
                  "appPriority": 0,
                  "allocationState": "ALLOCATED",
                  "children": [
                    {
                      "name": "request_1_-1",
                      "requestPriority": 1,
                      "allocationRequestId": -1,
                      "allocationState": "ALLOCATED",
                      "children": [
                        {
                          "allocationState": "SKIPPED",
                          "diagnostic": "Node's total resource is insufficient for request, insufficient resources=[memory-mb]\nrequired=<memory:3072, vCores:1>, available=<memory:2048, vCores:2>",
                          "nodeId": "127.0.0.2:1234"
                        },
                        {
                          "allocationState": "SKIPPED",
                          "diagnostic": "Node's total resource is insufficient for request, insufficient resources=[memory-mb]\nrequired=<memory:3072, vCores:1>, available=<memory:2048, vCores:2>",
                          "nodeId": "127.0.0.3:1234"
                        },
                        {
                          "allocationState": "SKIPPED",
                          "diagnostic": "Node's total resource is insufficient for request, insufficient resources=[memory-mb]\nrequired=<memory:3072, vCores:1>, available=<memory:2048, vCores:2>",
                          "nodeId": "127.0.0.4:1234"
                        },
                        {
                          "name": "Container: [ContainerId: null, AllocationRequestId: -1, Version: 0, NodeId: 127.0.0.1:1234, NodeHttpAddress: 127.0.0.1:2, Resource: <memory:3072, vCores:1>, Priority: 1, Token: null, ExecutionType: GUARANTEED, ]",
                          "allocationState": "ALLOCATED",
                          "nodeId": "127.0.0.1:1234"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      }
    ]
  }
}

當我們使用查詢參數(「groupBy=diagnostic」)查詢排程器活動 REST API 時,4 個節點活動資訊會分組成 2 個群組:具有相同診斷「節點的總資源不足以應付要求,資源不足=[memory-mb]」的 SKIPPED 群組和 ALLOCATED 群組,輸出應如下所示

{
  "activities": {
    "timestamp": 1562297536893,
    "dateTime": "Fri Jul 05 11:32:16 CST 2019",
    "allocations": [
      {
        "partition": "",
        "finalAllocationState": "ALLOCATED",
        "root": {
          "name": "root",
          "allocationState": "ACCEPTED",
          "children": [
            {
              "name": "a",
              "allocationState": "SKIPPED",
              "diagnostic": "Queue does not need more resources"
            },
            {
              "name": "b",
              "allocationState": "ACCEPTED",
              "children": [
                {
                  "name": "application_1562297533892_0001",
                  "appPriority": 0,
                  "allocationState": "ALLOCATED",
                  "children": [
                    {
                      "name": "request_1_-1",
                      "requestPriority": 1,
                      "allocationRequestId": -1,
                      "allocationState": "ALLOCATED",
                      "children": [
                        {
                          "allocationState": "ALLOCATED",
                          "count": 1,
                          "nodeIds": [
                            "127.0.0.1:1234"
                          ]
                        },
                        {
                          "allocationState": "SKIPPED",
                          "diagnostic": "Node's total resource is insufficient for request, insufficient resources=[memory-mb]",
                          "count": 3,
                          "nodeIds": [
                            "127.0.0.2:1234",
                            "127.0.0.3:1234",
                            "127.0.0.4:1234"
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      }
    ]
  }
}

XML 回應

HTTP 要求

  Accept: application/xml
  GET http://rm-http-address:port/ws/v1/cluster/scheduler/activities

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml; charset=utf-8
  Transfer-Encoding: chunked

回應本文

<?xml version="1.0" encoding="utf-8"?>
<activities>
  <timestamp>1562296830912</timestamp>
  <dateTime>Fri Jul 05 11:20:30 CST 2019</dateTime>
  <allocations>
    <partition></partition>
    <finalAllocationState>ALLOCATED</finalAllocationState>
    <root>
      <name>root</name>
      <allocationState>ACCEPTED</allocationState>
      <children>
        <name>a</name>
        <allocationState>SKIPPED</allocationState>
        <diagnostic>Queue does not need more resource</diagnostic>
      </children>
      <children>
        <name>b</name>
        <allocationState>ACCEPTED</allocationState>
        <children>
          <name>application_1562296828063_0001</name>
          <appPriority>0</appPriority>
          <allocationState>ACCEPTED</allocationState>
          <children>
            <name>request_1_-1</name>
            <requestPriority>1</requestPriority>
            <allocationRequestId>-1</allocationRequestId>
            <allocationState>ALLOCATED</allocationState>
            <children>
              <allocationState>SKIPPED</allocationState>
              <diagnostic>Node's total resource is insufficient for request, insufficient resources=[memory-mb]\nrequired=&lt;memory:3072, vCores:1&gt;, available=&lt;memory:2048, vCores:2&gt;</diagnostic>
              <nodeId>127.0.0.2:1234</nodeId>
            </children>
            <children>
              <allocationState>SKIPPED</allocationState>
              <diagnostic>Node's total resource is insufficient for request, insufficient resources=[memory-mb]\nrequired=&lt;memory:3072, vCores:1&gt;, available=&lt;memory:2048, vCores:2&gt;</diagnostic>
              <nodeId>127.0.0.3:1234</nodeId>
            </children>
            <children>
              <allocationState>SKIPPED</allocationState>
              <diagnostic>Node's total resource is insufficient for request, insufficient resources=[memory-mb]\nrequired=&lt;memory:3072, vCores:1&gt;, available=&lt;memory:2048, vCores:2&gt;</diagnostic>
              <nodeId>127.0.0.4:1234</nodeId>
            </children>
            <children>
              <name>Container: [ContainerId: null, AllocationRequestId: -1, Version: 0, NodeId: 127.0.0.1:1234, NodeHttpAddress: 127.0.0.1:2, Resource: &lt;memory:3072, vCores:1&gt;, Priority: 1, Token: null, ExecutionType: GUARANTEED, ]</name>
              <allocationState>ALLOCATED</allocationState>
              <nodeId>127.0.0.1:1234</nodeId>
            </children>
          </children>
        </children>
      </children>
    </root>
  </allocations>
</activities>

應用程式活動 API

如果您使用容量排程器,則可以使用應用程式活動 RESTful API,並可擷取指定應用程式的有用排程資訊,回應具有下列欄位的階層式配置

  • AppActivities - AppActivities 是基本資訊中應用程式活動的根元素。
  • Allocations - Allocations 是從快取中查詢到的應用程式層級配置嘗試。
  • Requests - Requests 顯示為配置的子項,每個子項都包含要求名稱、要求優先順序、配置要求 ID、配置狀態和選用子項。
  • Nodes - Nodes 顯示為要求的子項,每個子項都包含節點 ID、配置狀態、配置或保留節點上容器後應出現的選用名稱,以及配置或保留節點上容器失敗時應出現的選用診斷。對於依配置狀態和診斷分組的聚合節點,每個節點都包含配置狀態、聚合節點 ID 和選用診斷。

URI

支援的 HTTP 作業

  • GET

支援的查詢參數

可為 GET 作業指定多個參數。

  • maxTime - 從現在開始記錄應用程式活動的最大持續時間(秒)。如果未指定,則預設為 3(秒)。
    • requestPriorities - 要求的優先順序,用於過濾應用程式活動,指定為逗號分隔的清單。
    • allocationRequestIds - 要求的配置要求 ID,用於過濾應用程式活動,指定為逗號分隔的清單。
    • groupBy - 應用程式活動的聚合類型,目前僅支援「diagnostic」,使用者可以使用它查詢依配置狀態和診斷分組的聚合活動。
    • limit - 應用程式活動的限制,可以減少伺服器和用戶端雙方的成本。
    • actions - 應用程式活動所需動作,包括「更新」和「取得」,以逗號分隔清單指定。
    • summarize - 是否需要摘要多個排程程序中的應用程式活動,以布林值指定,當多節點配置停用時很有用,因為在單一排程程序中只能考慮一個節點,啟用此功能可提供所有節點的診斷摘要。

AppActivities 物件的元素

項目 資料類型 說明
applicationId 字串 指定的應用程式 ID。
allocations 配置陣列 按時間遞減順序排列的配置物件集合。

配置 物件的元素

項目 資料類型 說明
nodeId 字串 節點 ID。
時間戳記 長整數 配置的時間戳記。
dateTime 字串 配置的日期時間。
佇列名稱 字串 應用程式的佇列名稱。
appPriority int 應用程式的優先順序
allocationState 字串 應用程式的最終配置狀態,包括 ALLOCATED、RESERVED、RE_RESERVED 和 SKIPPED。
diagnostic 字串 應用程式的診斷。
children 要求陣列 要求物件的集合

要求 物件的元素

項目 資料類型 說明
requestPriority 字串 要求的優先順序。
allocationRequestId 字串 要求的配置要求 ID。
allocationState 字串 應用程式的最終配置狀態,包括 ALLOCATED、RESERVED、RE_RESERVED 和 SKIPPED。
diagnostic 字串 要求的診斷。
children 節點陣列 節點物件的集合。

節點 物件的元素

項目 資料類型 說明
名稱 字串 已更新容器的 ID,如果未指定,將顯示「Container-Id-Not-Assigned」。
allocationState 字串 應用程式的最終配置狀態,包括 ALLOCATED、RESERVED、RE_RESERVED 和 SKIPPED。
diagnostic 字串 關於一般模式中的節點或彙總模式中的節點的診斷
nodeId 字串 排程程序為基礎的節點 ID,對於具有 groupBy 參數的彙總查詢,不會顯示。
nodeIds 字串陣列 聚合應用程式活動的節點 ID 集合,僅顯示群組查詢參數的聚合查詢。
count int 節點 ID 的數量,僅顯示 groupBy 參數的聚合查詢。

回應範例

JSON 回應

HTTP 要求

  Accept: application/json
  GET http://rm-http-address:port/ws/v1/cluster/scheduler/app-activities/{appid}

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

回應本文

{
  "appActivities": {
    "applicationId": "application_1562312049195_0001",
    "allocations": [
      {
        "timestamp": 1562312052039,
        "dateTime": "Fri Jul 05 15:34:12 CST 2019",
        "queueName": "b",
        "appPriority": 0,
        "allocationState": "RESERVED",
        "children": [
          {
            "requestPriority": 1,
            "allocationRequestId": -1,
            "allocationState": "RESERVED",
            "children": [
              {
                "name": "Container-Id-Not-Assigned",
                "allocationState": "SKIPPED",
                "diagnostic": "Node's total resource is insufficient for request, insufficient resources=[memory-mb]\nrequired=<memory:4096, vCores:1>, available=<memory:2048, vCores:2>",
                "nodeId": "127.0.0.3:1234"
              },
              {
                "name": "Container-Id-Not-Assigned",
                "allocationState": "SKIPPED",
                "diagnostic": "Node's total resource is insufficient for request, insufficient resources=[memory-mb]\nrequired=<memory:4096, vCores:1>, available=<memory:2048, vCores:2>",
                "nodeId": "127.0.0.4:1234"
              },
              {
                "name": "Container-Id-Not-Assigned",
                "allocationState": "SKIPPED",
                "diagnostic": "Node's total resource is insufficient for request, insufficient resources=[memory-mb]\nrequired=<memory:4096, vCores:1>, available=<memory:2048, vCores:2>",
                "nodeId": "127.0.0.2:1234"
              },
              {
                "name": "Container-Id-Not-Assigned",
                "allocationState": "RESERVED",
                "diagnostic": "Node does not have sufficient resource for request, insufficient resources=[memory-mb]\nrequired=<memory:4096, vCores:1>, available=<memory:1024, vCores:3>",
                "nodeId": "127.0.0.1:1234"
              }
            ]
          }
        ]
      },
      {
        "timestamp": 1562312052031,
        "dateTime": "Fri Jul 05 15:34:12 CST 2019",
        "queueName": "b",
        "appPriority": 0,
        "allocationState": "ALLOCATED",
        "children": [
          {
            "requestPriority": 0,
            "allocationRequestId": -1,
            "allocationState": "ALLOCATED",
            "children": [
              {
                "name": "Container-Id-Not-Assigned",
                "allocationState": "ALLOCATED",
                "nodeId": "127.0.0.2:1234"
              }
            ]
          }
        ]
      }
    ]
  }
}

當我們使用查詢參數(「groupBy=diagnostic」)查詢排程器活動 REST API 時,4 個節點活動將分成兩組:具有相同診斷「節點的總資源不足以進行請求,資源不足=[memory-mb]」的 SKIPPED 群組和 ALLOCATED 群組,輸出應如下所示

{
  "appActivities": {
    "applicationId": "application_1562312658870_0001",
    "allocations": [
      {
        "timestamp": 1562312661536,
        "dateTime": "Fri Jul 05 15:44:21 CST 2019",
        "queueName": "b",
        "appPriority": 0,
        "allocationState": "RESERVED",
        "children": [
          {
            "requestPriority": 1,
            "allocationRequestId": -1,
            "allocationState": "RESERVED",
            "children": [
              {
                "allocationState": "SKIPPED",
                "diagnostic": "Node's total resource is insufficient for request, insufficient resources=[memory-mb]",
                "count": 3,
                "nodeIds": [
                  "127.0.0.3:1234",
                  "127.0.0.4:1234",
                  "127.0.0.2:1234"
                ]
              },
              {
                "allocationState": "RESERVED",
                "diagnostic": "Node does not have sufficient resource for request, insufficient resources=[memory-mb]",
                "count": 1,
                "nodeIds": [
                  "127.0.0.1:1234"
                ]
              }
            ]
          }
        ]
      },
      {
        "timestamp": 1562312661522,
        "dateTime": "Fri Jul 05 15:44:21 CST 2019",
        "queueName": "b",
        "appPriority": 0,
        "allocationState": "ALLOCATED",
        "children": [
          {
            "requestPriority": 0,
            "allocationRequestId": -1,
            "allocationState": "ALLOCATED",
            "children": [
              {
                "allocationState": "ALLOCATED",
                "count": 1,
                "nodeIds": [
                  "127.0.0.2:1234"
                ]
              }
            ]
          }
        ]
      }
    ]
  }
}

XML 回應

HTTP 要求

  Accept: application/xml
  GET http://rm-http-address:port/ws/v1/cluster/scheduler/app-activities/{appid}

回應標頭

  HTTP/1.1 200 OK
  Content-Type: application/xml; charset=utf-8
  Transfer-Encoding: chunked

回應本文

<?xml version="1.0" encoding="utf-8"?>

<appActivities>
  <applicationId>application_1562312049195_0001</applicationId>
  <allocations>
    <timestamp>1562312052039</timestamp>
    <dateTime>Fri Jul 05 15:34:12 CST 2019</dateTime>
    <queueName>b</queueName>
    <appPriority>0</appPriority>
    <allocationState>RESERVED</allocationState>
    <children>
      <requestPriority>1</requestPriority>
      <allocationRequestId>-1</allocationRequestId>
      <allocationState>RESERVED</allocationState>
      <children>
        <name>Container-Id-Not-Assigned</name>
        <allocationState>SKIPPED</allocationState>
        <diagnostic>Node's total resource is insufficient for request, insufficient resources=[memory-mb]\nrequired=&lt;memory:4096, vCores:1&gt;, available=&lt;memory:2048, vCores:2&gt;</diagnostic>
        <nodeId>127.0.0.3:1234</nodeId>
      </children>
      <children>
        <name>Container-Id-Not-Assigned</name>
        <allocationState>SKIPPED</allocationState>
        <diagnostic>Node does not have sufficient resource for request, insufficient resources=[memory-mb]\nrequired=&lt;memory:4096, vCores:1&gt;, available=&lt;memory:2048, vCores:2&gt;</diagnostic>
        <nodeId>127.0.0.4:1234</nodeId>
      </children>
      <children>
        <name>Container-Id-Not-Assigned</name>
        <allocationState>SKIPPED</allocationState>
        <diagnostic>Node does not have sufficient resource for request, insufficient resources=[memory-mb]\nrequired=&lt;memory:4096, vCores:1&gt;, available=&lt;memory:2048, vCores:2&gt;</diagnostic>
        <nodeId>127.0.0.2:1234</nodeId>
      </children>
      <children>
        <name>Container-Id-Not-Assigned</name>
        <allocationState>RESERVED</allocationState>
        <diagnostic>Node does not have sufficient resource for request, insufficient resources=[memory-mb]\nrequired=&lt;memory:4096, vCores:1&gt;, available=&lt;memory:1024, vCores:3&gt;</diagnostic>
        <nodeId>127.0.0.1:1234</nodeId>
      </children>
    </children>
  </allocations>
  <allocations>
    <timestamp>1562312052031</timestamp>
    <dateTime>Fri Jul 05 15:34:12 CST 2019</dateTime>
    <queueName>b</queueName>
    <appPriority>0</appPriority>
    <allocationState>ALLOCATED</allocationState>
    <children>
      <requestPriority>0</requestPriority>
      <allocationRequestId>-1</allocationRequestId>
      <allocationState>ALLOCATED</allocationState>
      <children>
        <name>Container-Id-Not-Assigned</name>
        <allocationState>ALLOCATED</allocationState>
        <nodeId>127.0.0.2:1234</nodeId>
      </children>
    </children>
  </allocations>
</appActivitiesInfo>