Search code examples
apache-flink

How to get yarn-session's application id


I kicked off a yarn-session application(a long running application runs on YARN) on machine A using yarn-session command, and I want to submit flink applications using flink run -yid on machine B.

Then how could I automatically pick up the application id that runs the yarn session kicked off from machine A? Especially, the yarn-session may be restarted from period to period(eg, the flink-session has to be restarted due to some reasons, such as machine down,etc)


Solution

  • You can use ./yarn-session.sh -nm ${your-app-name} to name the yarn application. Then you can find the yarn application id by this name. One possible solution is:

    applicationId=$(yarn application -list | awk '{if ($2==${your-app-name}) print $1 }')