https://spark.apache.org/docs/2.3.0/api/java/org/apache/spark/SparkContext.html
applicationId
public String applicationId()
A unique identifier for the Spark application. Its format depends on the scheduler implementation. (i.e. in case of local spark app something like 'local-1433865536131' in case of YARN something like 'application_1433865536131_34483' in case of MESOS something like 'driver-20170926223339-0001' )
val appId = spark.sparkContext.applicationId