Skip to content

Commit

Permalink
Check namespace exist instead of relying on exception
Browse files Browse the repository at this point in the history
  • Loading branch information
k4hoo committed Sep 11, 2014
1 parent 3324dd6 commit 883a845
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions data/src/main/scala/storage/hbase/HBEvents.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,22 @@ import java.util.UUID

class HBEvents(client: HBClient, namespace: String) extends Events with Logging {

val nameDesc = NamespaceDescriptor.create(namespace).build()

// check namespace exist
val existingNamespace = client.admin.listNamespaceDescriptors().map(_.getName)
if (!existingNamespace.contains(namespace)) {
val nameDesc = NamespaceDescriptor.create(namespace).build()
info(s"The namespace ${namespace} doesn't exist yet. Creating now...")
client.admin.createNamespace(nameDesc)
}
/*
try {
val nameDesc = NamespaceDescriptor.create(namespace).build()
client.admin.createNamespace(nameDesc)
} catch {
case e: NamespaceExistException => ()
case e: NamespaceExistException => info(s"namespace already existed: ${e}")
case e: Exception => throw new RuntimeException(e)
}
*/

implicit val formats = DefaultFormats + new EventJson4sSupport.DBSerializer
//implicit val formats = DefaultFormats.lossless ++ JodaTimeSerializers.all
Expand Down

0 comments on commit 883a845

Please sign in to comment.