Skip to content

Commit

Permalink
Print monitor updates to standard output in order to have them in yar…
Browse files Browse the repository at this point in the history
…n logs as well
  • Loading branch information
xavierguihot committed Nov 13, 2017
1 parent 7e94ae1 commit 39932c4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Overview


Version: 1.0.4
Version: 1.0.5

API Scaladoc: [SparkHelper](http://xavierguihot.github.io/spark_helper/#com.spark_helper.SparkHelper$)

Expand Down Expand Up @@ -112,7 +112,7 @@ for a cool exemple.

With sbt, just add this one line to your build.sbt:

libraryDependencies += "spark_helper" % "spark_helper" % "1.0.4" from "https://github.com/xavierguihot/spark_helper/releases/download/v1.0.4/spark_helper-1.0.4.jar"
libraryDependencies += "spark_helper" % "spark_helper" % "1.0.5" from "https://github.com/xavierguihot/spark_helper/releases/download/v1.0.5/spark_helper-1.0.5.jar"


## Building the project:
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "spark_helper"

version := "1.0.4"
version := "1.0.5"

scalaVersion := "2.10.4"

Expand Down
25 changes: 19 additions & 6 deletions src/main/scala/com/spark_helper/monitoring/Monitor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,12 @@ class Monitor(

lastReportUpdate = now

report += "[" + before + "-" + now + "]" + " " + text + "\n"
val update = "[" + before + "-" + now + "]" + " " + text

// We also print the update to also have them within yarn logs:
println("MONITOR: " + update)

report += update + "\n"
}

/** Updates the report with some text and a success.
Expand Down Expand Up @@ -269,17 +274,21 @@ class Monitor(
// possible diagnostic, we set the monitoring as failed:
success = false

var update = ""

if (taskDescription != "")
updateReport(taskDescription + ": failed")
update += taskDescription + ": failed\n"

if (diagnostic != "")
report += "\tDiagnostic: " + diagnostic + "\n"
update += "\tDiagnostic: " + diagnostic + "\n"

report += (
update += (
"\t\t" + error.toString() + "\n" +
error.getStackTrace.map(line => "\t\t" + line).mkString("\n") + "\n"
)

updateReport(update)

false
}

Expand Down Expand Up @@ -332,14 +341,18 @@ class Monitor(
if (!testsAreValid)
success = false

var update = ""

// A title in the report for the kpi validation:
if (testSuitName != "") {
val validation = if (testsAreValid) "success" else "failed"
updateReport(testSuitName + ": " + validation)
update += testSuitName + ": " + validation + "\n"
}

// The kpi report is added to the report:
report += tests.map(_.stringify).mkString("\n") + "\n"
update += tests.map(_.stringify).mkString("\n")

updateReport(update)

testsAreValid
}
Expand Down

0 comments on commit 39932c4

Please sign in to comment.