Ambari服务通过Rest API检查

时间:2017-09-09 10:28:56

标签: rest service ambari

我已经使用rest api对hadoop集群进行服务检查。在Ambari GUI中,我可以看到请求被触发但API只返回到json输出以下。

" HREF" :" http://:8080 / api / v1 / clusters / DEMO / requests / 11","请求" :{" id" :11,"状态" :"接受"

此输出与运行服务检查状态(通过/失败)无关,只有请求ID更改。

如何解释,从上面的json输出运行服务检查结果?

1 个答案:

答案 0 :(得分:0)

使用REST API发出服务检查请求后,ambari会接受运行,并立即给出json响应(在完成服务检查之前)。因此响应json指示请求id,请求的当前状态和监视请求状态的URL。

{
  "href" : "http://localhost:8080/api/v1/clusters/DEMO/requests/182",
  "Requests" : {
    "id" : 182,
    "status" : "Accepted"
  }

您可以使用json响应中返回的URL监视服务检查状态。示例如下,注意"request_status" : "FAILED"表示服务检查是成功完成还是失败。

$ curl -u admin:admin -XGET http://localhost:8080/api/v1/clusters/DEMO/requests/182
{
  "href" : "http://localhost:8080/api/v1/clusters/DEMO/requests/182",
  "Requests" : {
    "aborted_task_count" : 0,
    "cluster_name" : "DEMO",
    "completed_task_count" : 1,
    "create_time" : 1505153613045,
    "end_time" : 1505153724897,
    "exclusive" : false,
    "failed_task_count" : 1,
    "id" : 182,
    "inputs" : "{}",
    "operation_level" : null,
    "progress_percent" : 100.0,
    "queued_task_count" : 0,
    "request_context" : "HDFS Service Check",
    "request_schedule" : null,
    "request_status" : "FAILED",
    "resource_filters" : [
      {
        "service_name" : "HDFS"
      }
    ],
    "start_time" : 1505153613139,
    "task_count" : 1,
    "timed_out_task_count" : 0,
    "type" : "COMMAND"
  },
  "stages" : [
    {
      "href" : "http://localhost:8080/api/v1/clusters/DEMO/requests/182/stages/0",
      "Stage" : {
        "cluster_name" : "DEMO",
        "request_id" : 182,
        "stage_id" : 0
      }
    }
  ],
  "tasks" : [
    {
      "href" : "http://localhost:8080/api/v1/clusters/DEMO/requests/182/tasks/1314",
      "Tasks" : {
        "cluster_name" : "DEMO",
        "id" : 1314,
        "request_id" : 182,
        "stage_id" : 0
      }
    }
  ]
}