【问题标题】:Ambari service checks Through Rest APIAmbari 服务通过 Rest API 检查
【发布时间】:2018-02-18 03:51:38
【问题描述】:

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

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

无论运行服务检查状态如何(通过/失败),此输出都是相同的,只是请求 id 发生变化。

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

【问题讨论】:

  • 您能否提供您使用的 API(完整的 REST 调用)?
  • CURL 命令 :curl -ivk -H "X-Requested-By: ambari" -u : -X POST -d @payload http:// :8080/api/v1/clusters//requests
  • Payload :{ "RequestInfo":{ "context":"HDFS Service Check", "command":"HDFS_SERVICE_CHECK" }, "Requests/resource_filters":[ { "service_name":"HDFS" } ]

标签: rest service ambari


【解决方案1】:

一旦您使用 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
      }
    }
  ]
}

【讨论】:

  • 谢谢 Subhangi :)
猜你喜欢
  • 1970-01-01
  • 2014-11-05
  • 1970-01-01
  • 2020-01-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-05
  • 1970-01-01
相关资源
最近更新 更多