Skip to content

Commit

Permalink
Merge pull request mesos#295 from airbnb/fix-bad-exception-handling
Browse files Browse the repository at this point in the history
JobStats: catch exception on C* failures.
  • Loading branch information
brndnmtthws committed Oct 31, 2014
2 parents 3721672 + 6918b1f commit a74562e
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/main/scala/com/airbnb/scheduler/jobs/JobStats.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import com.google.inject.Inject
import com.datastax.driver.core._
import com.airbnb.scheduler.config.CassandraConfiguration
import org.apache.mesos.Protos.TaskStatus
import scala.Some
import com.datastax.driver.core.exceptions.{QueryValidationException, QueryExecutionException, NoHostAvailableException}
import com.datastax.driver.core.exceptions.{DriverException, QueryValidationException, QueryExecutionException, NoHostAvailableException}
import java.util.logging.{Level, Logger}
import scala.collection.JavaConverters._
import java.util.concurrent.ConcurrentHashMap
Expand All @@ -22,9 +21,10 @@ class JobStats @Inject() (clusterBuilder: Option[Cluster.Builder], config: Cassa
case None =>
clusterBuilder match {
case Some(c) =>
val session = c.build.connect(config.cassandraKeyspace())
session.execute(new SimpleStatement(
s"CREATE TABLE IF NOT EXISTS ${config.cassandraTable()}" +
try {
val session = c.build.connect(config.cassandraKeyspace())
session.execute(new SimpleStatement(
s"CREATE TABLE IF NOT EXISTS ${config.cassandraTable()}" +
"""
|(
| id VARCHAR,
Expand All @@ -42,9 +42,14 @@ class JobStats @Inject() (clusterBuilder: Option[Cluster.Builder], config: Cassa
| WITH bloom_filter_fp_chance=0.100000 AND
| compaction = {'class':'LeveledCompactionStrategy'}
""".stripMargin
))
_session = Some(session)
_session
))
_session = Some(session)
_session
} catch {
case e: DriverException =>
log.log(Level.WARNING, "Caught exception when creating Cassandra JobStats session", e)
None
}
case None => None
}
}
Expand Down

0 comments on commit a74562e

Please sign in to comment.