Permalink
Browse files

try catch around cluster share reporter.

  • Loading branch information...
1 parent 00a6f69 commit 5e478f20ec3c7c1ae468e21bed38241fe7f8a1b5 @marmbrus marmbrus committed Feb 23, 2011
Showing with 19 additions and 15 deletions.
  1. +19 −15 demo/src/main/scala/MesosClusterShare.scala
@@ -22,22 +22,23 @@ object MesosClusterShareReporter {
println("Connected to database!")
val stmt = conn.prepareStatement("""
- insert into mesosStats
- (timestamp, frameworkId, frameworkName, cpus, gbRam,
- cpuShare, memShare, domShare)
- values (?, ?, ?, ?, ?, ?, ?, ?)
- """)
+ insert into mesosStats
+ (timestamp, frameworkId, frameworkName, cpus, gbRam,
+ cpuShare, memShare, domShare)
+ values (?, ?, ?, ?, ?, ?, ?, ?)
+ """)
val in = new BufferedReader(new InputStreamReader(System.in))
while (true) {
- val line = in.readLine()
- if (line == null) {
- println("EOF reached, exiting")
- System.exit(0)
- }
- line.trim.split('\t') match {
- case Array(time, fid, name, cpus, mem, cpuShare, memShare, domShare) =>
- stmt.setString(1, time)
+ try {
+ val line = in.readLine()
+ if (line == null) {
+ println("EOF reached, exiting")
+ System.exit(0)
+ }
+ line.trim.split('\t') match {
+ case Array(time, fid, name, cpus, mem, cpuShare, memShare, domShare) =>
+ stmt.setString(1, time)
stmt.setString(2, fid)
stmt.setString(3, name)
stmt.setInt(4, cpus.toInt)
@@ -46,8 +47,11 @@ object MesosClusterShareReporter {
stmt.setDouble(7, memShare.toDouble)
stmt.setDouble(8, domShare.toDouble)
stmt.executeUpdate()
- case _ =>
- System.err.println("Malformed line: " + line)
+ case _ =>
+ System.err.println("Malformed line: " + line)
+ }
+ } catch {
+ case e => System.err.println("Exeception: " + e)
}
}
}

0 comments on commit 5e478f2

Please sign in to comment.