Mastering Hadoop 3
上QQ阅读APP看书,第一时间看更新

Node Manager REST API 

The Node Manager is responsible for running containers and executing tasks inside containers. The Node Manager API provides information about particular nodes, applications running on that node, and their containers. Let's look at each API and their uses:

  • Retrieve Node Manager information: YARN exposes the REST API to get information about any particular node. The response contains information such as node ID, node hostname, health report, container memory, and core information, for example:
       curl -X GET http://nodemanagerIP:port/ws/v1/node/info

An example would look like the following: 

        curl -X GET http://10.20.28.19:8042/ws/v1/node/info
  • Application information on Node Manager: We can also get the information about what applications are running on a Node Manager and their containers. Remember, the same application may be running on other Node Managers as well with different containers and tasks. To get the application information, we can use following REST API:
       curl -X GET http://nodemanagerIP:port/ws/v1/node/apps

An example would look like the following:

      curl -X GET http://10.20.28.19:8042/ws/v1/node/apps 

We can also get the information about specific applications running on a Node Manager by providing an application ID to the API. The REST call would look as follows:

      curl -X GET http://nodemanagerIP:port/ws/v1/node/apps/{APP_ID} 

An example would look like the following:

      curl -X GET   
http://10.20.28.19:8042/ws/v1/node/apps/application_1412438797813_001
  • Retrieving container information: The Node Manager launches containers to execute various tasks such as running the application master, map task or reduce task, and so on. The container REST APIs for YARN provide information about all the containers running on a Node Manager. The response contains information about all the containers such as container ID, container log location, memory required by container, container status, user, and so on. The REST call would look like the following:
      curl -X GET http://nodemanagerIP:port/ws/v1/node/containers 

An example would look like the following:

     curl -X GET http://10.20.28.19:8042/ws/v1/node/apps/containers

We can also retrieve information about a specific container by passing a container ID to the REST call mentioned previously, as follows:

  curl -X GET http://nodemanagerIP:port/ws/v1/node/containers/{containerID} 

An example would look like the following:

  curl -X GET http://10.20.28.19:8042/ws/v1/node/apps/containers/
container_1423657897651_0002_01_000020

The REST APIs are currently configured to return responses in either JSON or XML. The default return type is JSON. If you would like to receive response in XML format, you need to mention the content type of XML in the request header, as follows:

      curl-X GET -H "Content-Type: application/xml" RESTURL