Skip to content

Commit

Permalink
update the configs to use the zk client config
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanking committed Jul 6, 2011
1 parent 8cae53c commit 31b3ddf
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
15 changes: 9 additions & 6 deletions config/development.scala
@@ -1,6 +1,7 @@
import com.twitter.service.snowflake.{SnowflakeConfig, ReporterConfig}
import com.twitter.logging.config.{LoggerConfig, FileHandlerConfig}
import com.twitter.logging.Level
import com.twitter.zookeeper.ZookeeperClientConfig

new SnowflakeConfig {
val serverPort = 7609
Expand All @@ -9,11 +10,14 @@ new SnowflakeConfig {
val adminPort = 9990
val adminBacklog = 100
val workerIdZkPath = "/snowflake-servers"
val zkHostlist = "localhost"
val skipSanityChecks = false
val startupSleepMs = 10000
val thriftServerThreads = 2

val zookeeperClientConfig = new ZookeeperClientConfig {
val hostList = "localhost"
}

val reporterConfig = new ReporterConfig {
val scribeCategory = "snowflake"
val scribeHost = "localhost"
Expand All @@ -23,10 +27,9 @@ new SnowflakeConfig {
}

loggers = new LoggerConfig {
level = Level.DEBUG
handlers = new FileHandlerConfig {
level = Level.TRACE
filename = "snowflake.log"
}
handlers = new FileHandlerConfig {
level = Level.TRACE
filename = "snowflake.log"
}
}
}
6 changes: 5 additions & 1 deletion config/development2.scala
@@ -1,6 +1,7 @@
import com.twitter.service.snowflake.{SnowflakeConfig, ReporterConfig}
import com.twitter.logging.config.{LoggerConfig, FileHandlerConfig}
import com.twitter.logging.Logger
import com.twitter.zookeeper.ZookeeperClientConfig

new SnowflakeConfig {
val serverPort = 7610
Expand All @@ -9,11 +10,14 @@ new SnowflakeConfig {
val adminPort = 9991
val adminBacklog = 100
val workerIdZkPath = "/snowflake-servers"
val zkHostlist = "localhost"
val skipSanityChecks = false
val startupSleepMs = 10000
val thriftServerThreads = 2

val zookeeperClientConfig = new ZookeeperClientConfig {
val hostList = "localhost"
}

val reporterConfig = new ReporterConfig {
val scribeCategory = "snowflake"
val scribeHost = "localhost"
Expand Down
Expand Up @@ -2,6 +2,7 @@ package com.twitter.service.snowflake

import com.twitter.ostrich.admin.RuntimeEnvironment
import com.twitter.ostrich.admin.config.ServerConfig
import com.twitter.zookeeper.ZookeeperClientConfig

trait SnowflakeConfig extends ServerConfig[SnowflakeServer] {
val serverPort: Int
Expand All @@ -10,13 +11,14 @@ trait SnowflakeConfig extends ServerConfig[SnowflakeServer] {
val adminPort: Int
val adminBacklog: Int
val workerIdZkPath: String
val zkHostlist: String
val skipSanityChecks: Boolean
val startupSleepMs: Int
val thriftServerThreads: Int

val reporterConfig: ReporterConfig

val zookeeperClientConfig: ZookeeperClientConfig

def apply(runtime: RuntimeEnvironment) = {
new SnowflakeServer(this)
}
Expand Down
Expand Up @@ -44,8 +44,8 @@ class SnowflakeServer(config: SnowflakeConfig) extends Service {
private val log = Logger.get
var server: TServer = null
lazy val zkClient = {
log.info("Creating ZooKeeper client connected to %s", config.zkHostlist)
new ZooKeeperClient(config.zkHostlist)
log.info("Creating ZooKeeper client connected to %s", config.zookeeperClientConfig.hostList)
new ZooKeeperClient(config.zookeeperClientConfig)
}

Stats.addGauge("datacenter_id") { config.datacenterId }
Expand Down

0 comments on commit 31b3ddf

Please sign in to comment.