Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

AMBARI REST API + how to know the status of service on specific host

avatar


hi all


I use the following API , to stop the SPARK2_THRIFTSERVER , on specific node - node2

 curl -u admin:admin -i -H 'X-Requested-By: ambari' -X PUT -d '{"HostRoles": {"state": "INSTALLED"}}' http://node2:8080/api/v1/clusters/HDP/hosts/node1/host_components/SPARK2_THRIFTSERVER


after the API performed


how to know if service stooped ?


Michael-Bronson
1 ACCEPTED SOLUTION

avatar
Master Mentor

@Michael Bronson

If your earlier API command was like below

curl -u admin:admin -i -H 'X-Requested-By: ambari' -X PUT -d '{"HostRoles": {"state": "INSTALLED"}}' http://node2:8080/api/v1/clusters/HDP/hosts/node1/host_components/SPARK2_THRIFTSERVER
HTTP/1.1 202 Accepted
.....
...
{
  "href" : "http://node2:8080/api/v1/clusters/HDP/requests/174",
  "Requests" : {
    "id" : 174,
    "status" : "Accepted"
  }   

Then you should take note of the Request id i.e 174 in the above

curl -u admin:admin -i -H 'X-Requested-By: ambari' -X GET http://node2:8080/api/v1/clusters/HDP/requests/{174}


curl -u admin:admin -i -H 'X-Requested-By: ambari' -X GET http://node2:8080/api/v1/clusters/HDP/requests/{174}
HTTP/1.1 200 OK
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Cache-Control: no-store
Pragma: no-cache
Set-Cookie: AMBARISESSIONID=140pqxfdj6o06egemwmnallrt;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
User: admin
Content-Type: text/plain
Vary: Accept-Encoding, User-Agent
Content-Length: 2301


output

.....
...
"cluster_name" : "HDP",
    "completed_task_count" : 1,
    "create_time" : 1556457466529,
    "end_time" : 1556457510975,
    "exclusive" : false,
    "failed_task_count" : 0,
    "id" : 174,
    "inputs" : null,
    "operation_level" : null,
    "progress_percent" : 100.0,
    "queued_task_count" : 0,
    "request_context" : "",
    "request_schedule" : null,
    "request_status" : "COMPLETED",
    "resource_filters" : [ ],
    "start_time" : 1556457466884,
    "task_count" : 1,
    "timed_out_task_count" : 0,
    "type" : "INTERNAL_REQUEST"
  },
                                                                                                                                                           

View solution in original post

2 REPLIES 2

avatar
Master Mentor

@Michael Bronson

If your earlier API command was like below

curl -u admin:admin -i -H 'X-Requested-By: ambari' -X PUT -d '{"HostRoles": {"state": "INSTALLED"}}' http://node2:8080/api/v1/clusters/HDP/hosts/node1/host_components/SPARK2_THRIFTSERVER
HTTP/1.1 202 Accepted
.....
...
{
  "href" : "http://node2:8080/api/v1/clusters/HDP/requests/174",
  "Requests" : {
    "id" : 174,
    "status" : "Accepted"
  }   

Then you should take note of the Request id i.e 174 in the above

curl -u admin:admin -i -H 'X-Requested-By: ambari' -X GET http://node2:8080/api/v1/clusters/HDP/requests/{174}


curl -u admin:admin -i -H 'X-Requested-By: ambari' -X GET http://node2:8080/api/v1/clusters/HDP/requests/{174}
HTTP/1.1 200 OK
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Cache-Control: no-store
Pragma: no-cache
Set-Cookie: AMBARISESSIONID=140pqxfdj6o06egemwmnallrt;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
User: admin
Content-Type: text/plain
Vary: Accept-Encoding, User-Agent
Content-Length: 2301


output

.....
...
"cluster_name" : "HDP",
    "completed_task_count" : 1,
    "create_time" : 1556457466529,
    "end_time" : 1556457510975,
    "exclusive" : false,
    "failed_task_count" : 0,
    "id" : 174,
    "inputs" : null,
    "operation_level" : null,
    "progress_percent" : 100.0,
    "queued_task_count" : 0,
    "request_context" : "",
    "request_schedule" : null,
    "request_status" : "COMPLETED",
    "resource_filters" : [ ],
    "start_time" : 1556457466884,
    "task_count" : 1,
    "timed_out_task_count" : 0,
    "type" : "INTERNAL_REQUEST"
  },
                                                                                                                                                           

avatar
Master Mentor

@Michael Bronson

Any updates?