Github user tdas commented on a diff in the pull request:
https://github.com/apache/spark/pull/5473#discussion_r28853207
--- Diff:
streaming/src/main/scala/org/apache/spark/streaming/scheduler/Job.scala ---
@@ -25,15 +25,43 @@ import scala.util.Try
*/
private[streaming]
class Job(val time: Time, func: () => _) {
- var id: String = _
- var result: Try[_] = null
+ private var _id: String = _
+ private var _outputOpId: Int = _
+ private var isSet = false
+ private var _result: Try[_] = null
def run() {
- result = Try(func())
+ _result = Try(func())
}
- def setId(number: Int) {
- id = "streaming job " + time + "." + number
+ def result: Try[_] = {
+ if (_result == null) {
+ throw new IllegalStateException("Cannot access result before job
finishes")
+ }
+ _result
+ }
+
+ def id: String = {
+ if (!isSet) {
+ throw new IllegalStateException("Cannot access id before calling
setId")
+ }
+ _id
+ }
+
+ def outputOpId: Int = {
+ if (!isSet) {
+ throw new IllegalStateException("Cannot access number before calling
setId")
+ }
+ _outputOpId
+ }
+
+ def setOutputOpId(outputOpId: Int) {
+ if (isSet) {
+ throw new IllegalStateException("Cannot call setOutputOpId more than
once")
+ }
+ isSet = true
+ _id = "streaming job " + time + "." + outputOpId
--- End diff --
use string interpolation.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]