cloud-fan commented on code in PR #44321:
URL: https://github.com/apache/spark/pull/44321#discussion_r1428553296
##########
core/src/main/scala/org/apache/spark/scheduler/TaskInfo.scala:
##########
@@ -75,14 +75,47 @@ class TaskInfo(
* accumulable to be updated multiple times in a single task or for two
accumulables with the
* same name but different IDs to exist in a task.
*/
- def accumulables: Seq[AccumulableInfo] = _accumulables
+ def accumulables: Seq[AccumulableInfo] = {
+ if (throwOnAccumulablesCall) {
+ throw new IllegalStateException("Accumulables for the TaskInfo have been
cleared")
+ } else {
+ _accumulables
+ }
+ }
private[this] var _accumulables: Seq[AccumulableInfo] = Nil
private[spark] def setAccumulables(newAccumulables: Seq[AccumulableInfo]):
Unit = {
_accumulables = newAccumulables
}
+ /**
+ * If true, a call to TaskInfo.accumulables() will throw an exception.
+ */
+ private var throwOnAccumulablesCall: Boolean = false
+
+ override def clone(): TaskInfo = super.clone().asInstanceOf[TaskInfo]
+
+ /**
+ * For testing only. Allows probing accumulables without triggering the
exception when
+ * `throwOnAccumulablesCall` is set.
+ */
+ private[scheduler] def isAccumulablesEmpty(): Boolean = {
+ _accumulables.isEmpty
+ }
+
+ private[scheduler] def resetAccumulables(): Unit = {
+ setAccumulables(Nil)
+ throwOnAccumulablesCall = true
+ }
+
+ private[scheduler] def cloneWithEmptyAccumulables(): TaskInfo = {
+ val cloned = clone()
+ cloned.setAccumulables(Nil)
+ cloned.throwOnAccumulablesCall = true
Review Comment:
is this `cloned.resetAccumulables`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]