0
votes

I have a Java application to lunch a flink job to process Kafka streaming.

  1. The application is pending here at the job submission at flinkEnv.execute("flink job name") since the job is running forever for streamings incoming from kafka.

    In this case, how can I get job id returned from the execution? I see the jobid is printing in the console. Just wonder, how to get jobid is this case without flinkEnv.execute returning yet.

  2. How I can cancel a flink job given job name from remote server in Java?

3
The execute is printing the jobID in console. My current workaround is to capture it into files. - Will Du

3 Answers

0
votes

As far as I know there is currently no nice programmatic way to control Flink. But since Flink is written in Java everything you can do with the console can also be done with internal class org.apache.flink.client.CliFrontend which is invoked by the console scripts.

An alternative would be using the REST API of the Flink JobManager.

0
votes
0
votes

maybe you can try to request http://host:port/jobs/overview to get all job's message that contains job's name and job's id. Such as

{"jobs":[{"jid":"d6e7b76f728d6d3715bd1b95883f8465","name":"Flink Streaming Job","state":"RUNNING","start-time":1628502261163,"end-time":-1,"duration":494208,"last-modification":1628502353963,"tasks":{"total":6,"created":0,"scheduled":0,"deploying":0,"running":6,"finished":0,"canceling":0,"canceled":0,"failed":0,"reconciling":0,"initializing":0}}]}

I really hope this will help you.