Skip to content

Commit

Permalink
Merge branch 'scala_28'
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanking committed Jan 3, 2011
2 parents 634a01d + 66c5b0c commit f1d91ae
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 17 deletions.
1 change: 1 addition & 0 deletions config/development.conf
Expand Up @@ -4,6 +4,7 @@ log {
}

admin_http_port = 9990
admin_http_backlog = 100

zookeeper-client {
hostlist = "localhost:2181"
Expand Down
1 change: 1 addition & 0 deletions config/test.conf
Expand Up @@ -4,6 +4,7 @@ log {
}

admin_http_port = 9990
admin_http_backlog = 100

zookeeper-client {
hostlist = "localhost:2181"
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Expand Up @@ -5,5 +5,5 @@ project.organization=com.twitter
project.version=1.0
sbt.version=0.7.4
def.scala.version=2.7.7
build.scala.versions=2.7.7
build.scala.versions=2.8.1
project.initialize=false
11 changes: 6 additions & 5 deletions project/build/Snowflake.scala
Expand Up @@ -2,22 +2,23 @@ import sbt._
import com.twitter.sbt._
import Process._


class SnowflakeProject(info: ProjectInfo) extends StandardProject(info) {
val mavenTwttr = "twitter" at "http://maven.twttr.com/"
val mavenDotOrg = "repo1" at "http://repo1.maven.org/maven2/"
val jBoss = "jboss-repo" at "http://repository.jboss.org/maven2/"

val slf4jApi = "org.slf4j" % "slf4j-api" % "1.5.8"
val slf4jLog = "org.slf4j" % "slf4j-log4j12" % "1.5.8"
val log4j = "apache-log4j" % "log4j" % "1.2.15"
val configgy = "net.lag" % "configgy" % "1.6.8"
val configgy = "net.lag" % "configgy" % "2.0.1"
val commonsPool = "commons-pool" % "commons-pool" % "1.5.4"
val ostrich = "com.twitter" % "ostrich" % "1.1.24"
val ostrich = "com.twitter" % "ostrich" % "2.3.3"
val hamcrest = "org.hamcrest" % "hamcrest-all" % "1.1"
val sp = "org.scala-tools.testing" % "specs" % "1.6.2.2"
val sp = "org.scala-tools.testing" % "specs_2.8.0" % "1.6.5"
val thrift = "thrift" % "libthrift" % "0.5.0"
val commonsCodec = "commons-codec" % "commons-codec" % "1.4"
val zookeeperClient = "com.twitter" % "zookeeper-client" % "1.5.1"

val zookeeperClient = "com.twitter" % "zookeeper-client" % "2.0.0"

override def mainClass = Some("com.twitter.service.snowflake.SnowflakeServer")
override def releaseBuild = true
Expand Down
2 changes: 1 addition & 1 deletion project/plugins/Plugins.scala
Expand Up @@ -3,5 +3,5 @@ import sbt._

class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
val twitterMaven = "twitter.com" at "http://maven.twttr.com/"
val defaultProject = "com.twitter" % "standard-project" % "0.7.11"
val defaultProject = "com.twitter" % "standard-project" % "0.7.17"
}
2 changes: 1 addition & 1 deletion project/plugins/project/build.properties
@@ -1,3 +1,3 @@
#Project properties
#Tue Nov 09 11:32:16 PST 2010
#Mon Dec 13 16:42:54 PST 2010
plugin.uptodate=true
@@ -1,8 +1,8 @@
package com.twitter.service.snowflake

import com.sun.net.httpserver.HttpExchange
import com.twitter.ostrich.{AdminHttpService, CustomHttpHandler}
import net.lag.configgy.{ConfigMap, RuntimeEnvironment}
import com.twitter.ostrich.{AdminHttpService, CustomHttpHandler, RuntimeEnvironment}
import net.lag.configgy.ConfigMap
import java.text.SimpleDateFormat
import java.util.Date
import com.twitter.ostrich.Stats
Expand All @@ -29,8 +29,8 @@ class StatusHandler extends CustomHttpHandler {
}
}

class AdminService(config: ConfigMap, runtime: RuntimeEnvironment) {
val adminHttp = new AdminHttpService(config, runtime)
class AdminService(port: Int, backlog: Int, runtime: RuntimeEnvironment) {
val adminHttp = new AdminHttpService(port, backlog, runtime)
adminHttp.addContext("/status/", new StatusHandler())
adminHttp.start()
}
Expand Up @@ -17,6 +17,7 @@ import org.apache.zookeeper.{KeeperException, CreateMode, Watcher, WatchedEvent}
import org.apache.zookeeper.KeeperException.NodeExistsException
import scala.collection.mutable
import java.net.InetAddress
import com.twitter.ostrich
import com.twitter.ostrich.Stats

case class Peer(hostname: String, port: Int)
Expand Down Expand Up @@ -53,7 +54,9 @@ object SnowflakeServer {
}

registerWorkerId(workerId)
val admin = new AdminService(Configgy.config, runtime)
val port = Configgy.config("admin_http_port").toInt
val backlog = Configgy.config("admin_http_backlog").toInt
val admin = new AdminService(port, backlog, new ostrich.RuntimeEnvironment(getClass))

Thread.sleep(Configgy.config("snowflake.startup_sleep_ms").toLong)

Expand Down Expand Up @@ -154,7 +157,7 @@ object SnowflakeServer {

if (timestamps.toSeq.size > 0) {
val avg = timestamps.foldLeft(0L)(_ + _) / peerCount
if (Math.abs(System.currentTimeMillis - avg) > 10000) {
if (math.abs(System.currentTimeMillis - avg) > 10000) {
log.error("Timestamp sanity check failed. Mean timestamp is %d, but mine is %d, " +
"so I'm more than 10s away from the mean", avg, System.currentTimeMillis)
throw new IllegalStateException("timestamp sanity check failed")
Expand Down
@@ -1,8 +1,8 @@
/** Copyright 2010 Twitter, Inc. */
package com.twitter.service.snowflake.client

import gen.Snowflake
import gen.Snowflake.Client
import com.twitter.service.snowflake.gen.Snowflake
import com.twitter.service.snowflake.gen.Snowflake.Client
import net.lag.configgy.{Config, Configgy}
import net.lag.logging.Logger
import org.apache.commons.pool.impl.{GenericObjectPool, StackKeyedObjectPoolFactory}
Expand Down
Expand Up @@ -116,7 +116,7 @@ class IdWorkerSpec extends Specification {
"sleep if we would rollover twice in the same millisecond" in {
var queue = new scala.collection.mutable.Queue[Long]()
val worker = new WakingIdWorker(1, 1)
val iter = List(2L, 2L, 3L).elements
val iter = List(2L, 2L, 3L).iterator
worker.timeMaker = (() => iter.next)
worker.sequence = 4095
worker.nextId
Expand Down

0 comments on commit f1d91ae

Please sign in to comment.