Managing Data Operating System
Also available as:
PDF
loading table of contents...

Using the Saved YARN file to Assemble a Complex Service

This is an example of a service file that references the saved simple-httpd-service service specification.

{
  "name": "httpd-proxy-service",
  "version": "1.0.0",
  "lifetime": "3600",
  "components": [
    {
      "name": "simple-httpd-service",
      "artifact": {
        "id": "simple-httpd-service",
        "type": "SERVICE"
      }
    },
    {
      "name": "httpd-proxy",
      "number_of_containers": 1,
      "artifact": {
        "id": "centos/httpd-24-centos7:latest",
        "type": "DOCKER"
      },
      "launch_command": "/usr/bin/run-httpd",
      "resource": {
        "cpus": 1,
        "memory": "1024"
      },
      "configuration": {
        "files": [
          {
            "type": "TEMPLATE",
            "dest_file": "/etc/httpd/conf.d/httpd-proxy.conf",
            "src_file": "httpd-proxy.conf"
          }
        ]
      }
    }
  ],
  "quicklinks": {
    "Apache HTTP Server": "http://httpd-proxy-0.${SERVICE_NAME}.${USER}.${DOMAIN}:8080"
  }
}

This YARN service file specifies one component of artifact type SERVICE and one component of artifact DOCKER. The SERVICE component will be read from the YARN service file we saved as the service named simple-httpd-service. So after the httpd-proxy-service service is launched, it will contain two httpd containers (which were specified by simple-httpd-service) and one httpd-proxy container. In this case, the httpd-proxy container will balance the load between the two httpd containers. Before launching this service, the httpd-proxy.conf template file that is specified as a src_file for the httpd-proxy component must be uploaded to HDFS. This httpd-proxy-service example is similar to the httpd example provided with YARN, so the same file may be used.

hdfs dfs -copyFromLocal /usr/hdp/current/hadoop-yarn-client/yarn-service-examples/httpd/httpd-proxy.conf
yarn app -launch httpd-proxy-service /path/to/httpd-proxy-service.json