Last active
December 13, 2015 22:08
-
-
Save ericacm/4982036 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def startServer(serverStartFunc: () => Unit) { | |
val serverStarted = new Semaphore(0) | |
var serverStartException: Option[Exception] = None | |
startThread("startZookeeper") { | |
try { | |
log.info("Starting ZooKeeper server. clientPort=" + clientPort + | |
" class=" + zkServer.getClass.getName) | |
serverStartFunc() | |
serverStarted.release() | |
} catch { | |
case ioex: IOException => | |
log.error("ZooKeeper Failed - data directory corruption: " + | |
ioex.getMessage, ioex) | |
serverStartException = Some(ioex) | |
case ex: Exception => | |
log.error("ZooKeeper Failed: " + ex.getMessage, ex) | |
serverStartException = Some(ex) | |
} | |
} | |
if (!serverStarted.tryAcquire(waitingSec, TimeUnit.SECONDS)) { | |
serverStartException match { | |
case Some(ex) => throw new RuntimeException(ex) | |
case None => | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment