aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/scala/org/apache/spark/SparkContext.scala8
-rw-r--r--python/pyspark/context.py15
2 files changed, 23 insertions, 0 deletions
diff --git a/core/src/main/scala/org/apache/spark/SparkContext.scala b/core/src/main/scala/org/apache/spark/SparkContext.scala
index c7a7436462..b3c3bf3746 100644
--- a/core/src/main/scala/org/apache/spark/SparkContext.scala
+++ b/core/src/main/scala/org/apache/spark/SparkContext.scala
@@ -315,6 +315,14 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli
_dagScheduler = ds
}
+ /**
+ * 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'
+ * )
+ */
def applicationId: String = _applicationId
def applicationAttemptId: Option[String] = _applicationAttemptId
diff --git a/python/pyspark/context.py b/python/pyspark/context.py
index 90b2fffbb9..d7466729b8 100644
--- a/python/pyspark/context.py
+++ b/python/pyspark/context.py
@@ -292,6 +292,21 @@ class SparkContext(object):
return self._jsc.version()
@property
+ @ignore_unicode_prefix
+ def applicationId(self):
+ """
+ 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'
+ )
+ >>> sc.applicationId # doctest: +ELLIPSIS
+ u'local-...'
+ """
+ return self._jsc.sc().applicationId()
+
+ @property
def startTime(self):
"""Return the epoch time when the Spark Context was started."""
return self._jsc.startTime()