aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/scala/spark/Logging.scala11
-rw-r--r--src/scala/spark/MesosScheduler.scala14
2 files changed, 16 insertions, 9 deletions
diff --git a/src/scala/spark/Logging.scala b/src/scala/spark/Logging.scala
index 35f7382a5f..2d1feebbb1 100644
--- a/src/scala/spark/Logging.scala
+++ b/src/scala/spark/Logging.scala
@@ -13,10 +13,15 @@ trait Logging {
// be serialized and used on another machine
@transient private var log_ : Logger = null
- // Method to get or create the logger
+ // Method to get or create the logger for this object
def log: Logger = {
- if (log_ == null)
- log_ = LoggerFactory.getLogger(this.getClass())
+ if (log_ == null) {
+ var className = this.getClass().getName()
+ // Ignore trailing $'s in the class names for Scala objects
+ if (className.endsWith("$"))
+ className = className.substring(0, className.length - 1)
+ log_ = LoggerFactory.getLogger(className)
+ }
return log_
}
diff --git a/src/scala/spark/MesosScheduler.scala b/src/scala/spark/MesosScheduler.scala
index 38e8ab2cd1..be58957806 100644
--- a/src/scala/spark/MesosScheduler.scala
+++ b/src/scala/spark/MesosScheduler.scala
@@ -137,7 +137,7 @@ extends NScheduler with spark.Scheduler with Logging
case None => {}
}
} catch {
- case e: Exception => e.printStackTrace
+ case e: Exception => logError("Exception in resourceOffer", e)
}
}
}
@@ -161,7 +161,7 @@ extends NScheduler with spark.Scheduler with Logging
}
} catch {
- case e: Exception => e.printStackTrace
+ case e: Exception => logError("Exception in statusUpdate", e)
}
}
}
@@ -173,7 +173,7 @@ extends NScheduler with spark.Scheduler with Logging
try {
activeOp.error(code, message)
} catch {
- case e: Exception => e.printStackTrace
+ case e: Exception => logError("Exception in error callback", e)
}
}
} else {
@@ -260,9 +260,11 @@ extends ParallelOperation with Logging
val taskId = sched.newTaskId()
sched.taskIdToOpId(taskId) = opId
tidToIndex(taskId) = i
- printf("Starting task %d as opId %d, TID %s on slave %s: %s (%s)",
- i, opId, taskId, offer.getSlaveId, offer.getHost,
- if(checkPref) "preferred" else "non-preferred")
+ val preferred = if(checkPref) "preferred" else "non-preferred"
+ val message =
+ "Starting task %d as opId %d, TID %s on slave %s: %s (%s)".format(
+ i, opId, taskId, offer.getSlaveId, offer.getHost, preferred)
+ logInfo(message)
tasks(i).markStarted(offer)
launched(i) = true
tasksLaunched += 1