Last active
December 13, 2015 21:58
-
-
Save ericacm/4981475 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
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