Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Commit

Permalink
Update for gizzard-3.0.0-beta29
Browse files Browse the repository at this point in the history
  • Loading branch information
Stu Hood committed Jan 12, 2012
1 parent 134549d commit 959957c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion test/test_server/project/build/Project.scala
Expand Up @@ -7,7 +7,7 @@ class GizzmoServerProject(info: ProjectInfo) extends StandardProject(info) {
override def filterScalaJars = false

val scalaTools = "org.scala-lang" % "scala-compiler" % "2.7.7"
val gizzard = "com.twitter" % "gizzard" % "3.0.0-beta28"
val gizzard = "com.twitter" % "gizzard" % "3.0.0-beta29"
val querulous = "com.twitter" % "querulous" % "2.6.5"

val specs = "org.scala-tools.testing" % "specs" % "1.6.2.1" % "test"
Expand Down
20 changes: 12 additions & 8 deletions test/test_server/src/main/scala/TestServer.scala
Expand Up @@ -223,35 +223,39 @@ class PutJob(key: Int, value: String, forwarding: Long => RoutingNode[TestShard]

class TestCopyFactory(ns: NameServer, s: JobScheduler)
extends CopyJobFactory[TestShard] {
def apply(src: ShardId, dest: ShardId) = new TestCopy(src, dest, 0, 500, ns, s)
def apply(shardIds: Seq[ShardId]) = new TestCopy(shardIds, 0, 500, ns, s)
}

class TestCopyParser(ns: NameServer, s: JobScheduler)
extends CopyJobParser[TestShard] {
def deserialize(m: Map[String, Any], src: ShardId, dest: ShardId, count: Int) = {
def deserialize(m: Map[String, Any], shardIds: Seq[ShardId], count: Int) = {
val cursor = m("cursor").asInstanceOf[Int]
val count = m("count").asInstanceOf[Int]
new TestCopy(src, dest, cursor, count, ns, s)
new TestCopy(shardIds, cursor, count, ns, s)
}
}

class TestCopy(
srcId: ShardId,
destId: ShardId,
shardIds: Seq[ShardId],
cursor: Int,
count: Int,
ns: NameServer,
s: JobScheduler)
extends CopyJob[TestShard](srcId, destId, count, ns, s) {
extends CopyJob[TestShard](shardIds, count, ns, s) {

def copyPage(nodes: Seq[RoutingNode[TestShard]], count: Int) = {
val (src, dest) = nodes match {
case Seq(src, dest) => (src, dest)
case _ => throw new AssertionError("Server does not support complex copies (yet): " + nodes)
}

def copyPage(src: RoutingNode[TestShard], dest: RoutingNode[TestShard], count: Int) = {
val rows = src.read.any(_.getAll(cursor, count)) map { case (k,v,c) => (k,v) }

if (rows.isEmpty) {
None
} else {
dest.write.foreach(_.putAll(rows))
Some(new TestCopy(srcId, destId, rows.last._1, count, ns, s))
Some(new TestCopy(nodes.map(_.shardInfo.id), rows.last._1, count, ns, s))
}
}

Expand Down

0 comments on commit 959957c

Please sign in to comment.