Instantly share code, notes, and snippets.

Embed
What would you like to do?
import org.apache.zookeeper.server.quorum.{QuorumPeerMain => ApacheQuorumPeerMain}
import org.apache.zookeeper.server.{ZooKeeperServerMain => ApacheZookeeperServerMain}
trait EmbeddedZookeeper {
this: ClusterService with Logging =>
@Value("${zookeeperService.server.enabled:false}")
var isServerEnabled: Boolean = _
// Location of server data directory
@Value("${zookeeperService.server.dataDir:}")
var dataDir: String = _
// How long to wait for server to start
@Value("${zookeeperService.server.waitingSec:5}")
var waitingSec: Int = _
private var zkServer: Option[Stoppable] = None
trait Stoppable { def stop() }
// Standalone Zookeeper
class ZooKeeperServerMain extends ApacheZookeeperServerMain with Stoppable {
def stop() = super.shutdown()
}
// Replicated Zookeeper
class QuorumPeerMain extends ApacheQuorumPeerMain with Stoppable {
def stop() = quorumPeer.shutdown()
}
// ZK server client port
def clientPort: Int
def genServerNames(): ServerNames = // See below
def configureServer(servers: ServerNames): () => Unit = // See below
def startServer(serverStartFunc: () => Unit) // See below
def serverShutdown() {
zkServer.foreach(_.stop())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment