Support Questions

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

start/stop processor via nifi api

avatar
Rising Star

Hi,

I'm trying to start and stop processors via the nifi api version 1.0.0. I'm getting status code 409 returned and the message is "afb7dcf1-0157-1000-9450-ea0931a67e0f is not stopped."

I have read previous articles about the optimistic locking and I am supplying the version and client id but I'm still getting this error. Any ideas? Here is a snippet of my python code:

process_group = nifiapi.find_process_group(process_group_name)
if process_group is None:
    return None
processors = nifiapi.get_processors_by_pg(process_group["id"])
if processors is None:
    return None
for processor in processors['processors']:
    processor["revision"]["clientId"] = str(uuid.uuid4())
    processor["status"]["runStatus"] = "STOPPED"
    logging.debug("Updating processor: {}".format(json.dumps(processor)))
    nifiapi.update_processor(processor) # this makes the put request
1 ACCEPTED SOLUTION

avatar
Rising Star
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login
17 REPLIES 17

avatar

@Frank Maritato Thanks for the response

Here is my api call, I have updated my call like the above format. Even i am facing the same issue

curl -i -X PUT -H 'Content-Type:application/json' -H 'Accept: application/json' -d '{"status": {"runStatus": "RUNNING"},"component":{"state":"RUNNING","id":"<processorgroup_id>"},"id": "<processorgroup_id>", "revision": {"version": 2,"clientId":"<client_id>"}}' http://host:port/nifi-api/process-groups/>

HTTP/1.1 400 Bad Request Date: Wed, 21 Dec 2016 11:08:27 GMT Content-Type: text/plain Transfer-Encoding: chunked Server: Jetty(9.3.9.v20160517) Message body is malformed. Unable to map into expected format

avatar
Contributor

is there a way to start stop processors group?

avatar
Rising Star

No, not from what I was able to find. If you want to start all processors in a processor group, you need to get the list of all processors in that group by calling

GET /process-groups/{id}/processors

and then one by one set them to RUNNING or STOPPED by doing

PUT /processors/{id}

Hope this helps!

avatar
Super Collaborator

avatar
Rising Star

Hi all,

any new ? somebody has the correct syntax of json for running a processor ?

i've used this json with HTTP CODE 405

# more startListHDFS_1.json
{
  "status": {
    "runStatus": "RUNNING"
  },
  "component": {
    "state": "RUNNING",
    "id": "b0c63454-89a8-15ef-be22-959bd4a72e5a"
  },
  "id": "b0c63454-89a8-15ef-be22-959bd4a72e5a",
  "revision": {
    "version": 1,
    "clientId": "test"
  }
}
# curl -H "Content-type: application/json" --cacert nifi-cert.pem --cert ./client.p12 -XPOST https://localhost:9443/nifi-api/processors/b0c63454-89a8-15ef-be22-959bd4a72e5a -d @startListHDFS_1.json -vv

help appreciate. thanks

avatar

Hi all,

for me it is working fine :

HTTP method : PUT

{ "status": { "runStatus": "STOPPED" }, "component": { "state": "STOPPED", "id": "b2e9b4eb-015b-1000-765d-c01c0a2fa6ce" //processor id }, "id": "b2e9b4eb-015b-1000-765d-c01c0a2fa6ce", //processor id "revision": { "clientId": "b2e5a8bb-015b-1000-31c1-0ee3b952dcbe", "version": 8 } }

avatar

in which processor we need to use? how to specify property of that processor?

avatar

@Frank Maritato Can i run your python code in ExecuteScript processor - which means i am stopping an processor from another one within nifi. If yes? will your code work if security for nifi is enabled like LDAP authentication. Can you show light on "nifiapi" is it an api provided by nifi.