'How to start ALL processors

I have NiFi running on a test environment and would like it to automatically start all processors as the last step of deployment.

Do I need to parse all the processor ids and hit the /nifi-api/processors endpoint for each one or is it possible to start all - eg from the /nifi-api/process-groups endpoint ?

My NiFi flow has uuid 66f83c1d-0162-1000-baff-01e60296540a - this GET curl statement returns information successfully:

curl -i -X GET http://localhost:9090/nifi-api/process-groups/66f83c1d-0162-1000-baff-01e60296540a

However trying to PUT a status fails:

curl -i -X PUT -H 'Content-Type: application/json' -d '{"status":"RUNNING"}' http://localhost:9090/nifi-api/process-groups/66f83c1d-0162-1000-baff-01e60296540a
HTTP/1.1 400 Bad Request
Date: Mon, 06 Aug 2018 11:08:15 GMT
X-Frame-Options: SAMEORIGIN
Content-Type: text/plain
Vary: Accept-Encoding
Content-Length: 429
Server: Jetty(9.4.3.v20170317)

Cannot construct instance of `org.apache.nifi.web.api.dto.status.ProcessGroupStatusDTO` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('RUNNING')
 at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 11] (through reference chain: org.apache.nifi.web.api.entity.ProcessGroupEntity["status"])


Solution 1:[1]

Yes by using NiFi RestApi we can start all processors in a processor group.

As you are missing id key value in your json,

{"id":"66f83c1d-0162-1000-baff-01e60296540a","state":"RUNNING"}

we need to mention state not status to run/stop processors in the group

{"id":"66f83c1d-0162-1000-baff-01e60296540a","state":"RUNNING"}

and we need to include flow in the address of the rest api.

http://localhost:9090/nifi-api /flow/ process-groups/66f83c1d-0162-1000-baff-01e60296540a

Try with below Curl command

curl -i -X PUT -H 'Content-Type: application/json' -d '{"id":"66f83c1d-0162-1000-baff-01e60296540a","state":"RUNNING"}' http://localhost:9090/nifi-api/flow/process-groups/66f83c1d-0162-1000-baff-01e60296540a

Refer to this for more details regarding start process group using RestAPI.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1