Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

think we can do migrations this way :/

  • Loading branch information...
commit 9106fb74224edf40651b8dd0c3a38723a59f9617 1 parent 30ba228
Nick Kallen authored
View
BIN  libs/gizzard-1.0.jar
Binary file not shown
View
5 src/main/scala/com/twitter/rowz/Main.scala
@@ -2,7 +2,8 @@ package com.twitter.rowz
import net.lag.configgy.Configgy
import net.lag.logging.Logger
-import com.twitter.gizzard.nameserver.{NameServer, Copier}
+import com.twitter.gizzard.jobs.CopyFactory
+import com.twitter.gizzard.nameserver.NameServer
import com.twitter.gizzard.scheduler.PrioritizingJobScheduler
import com.twitter.gizzard.thrift.{TSelectorServer, JobManager, JobManagerService, ShardManager, ShardManagerService}
import com.facebook.thrift.server.{TServer, TThreadPoolServer}
@@ -16,7 +17,7 @@ object Main {
var rowzService: RowzService = null
var nameServer: NameServer[Shard] = null
var scheduler: PrioritizingJobScheduler = null
- var copier: Copier[Shard] = null
+ var copier: CopyFactory[Shard] = null
var rowzServer: TSelectorServer = null
var jobServer: TSelectorServer = null
View
2  src/main/scala/com/twitter/rowz/Rowz.scala
@@ -75,6 +75,6 @@ object Rowz {
nameServer.reload()
prioritizingScheduler.start()
- (rowzService, nameServer, prioritizingScheduler, new jobs.Copy(_, _, Shard.CursorStart))
+ (rowzService, nameServer, prioritizingScheduler, jobs.CopyFactory)
}
}
View
2  src/main/scala/com/twitter/rowz/SqlShard.scala
@@ -64,6 +64,8 @@ class SqlShard(private val queryEvaluator: QueryEvaluator, val shardInfo: shards
def selectAll(cursor: Cursor, count: Int) = null
+ def write(rows: Seq[Row]) = rows.foreach(write(_))
+
def write(row: Row) = {
val Row(id, name, createdAt, updatedAt, state) = row
insertOrUpdate {
View
8 src/main/scala/com/twitter/rowz/jobs/Copy.scala
@@ -8,8 +8,12 @@ object Copy {
val COUNT = 500
}
-case class Copy(sourceShardId: Int, destinationShardId: Int, cursor: Cursor) extends gizzard.jobs.Copy[Shard](sourceShardId, destinationShardId, Copy.COUNT) {
- protected def copyPage(sourceShard: Shard, destinationShard: Shard, count: Int) = {
+object CopyFactory extends gizzard.jobs.CopyFactory[Shard] {
+ def apply(sourceShardId: Int, destinationShardId: Int) = new Copy(sourceShardId, destinationShardId, Shard.CursorStart)
+}
+
+class Copy(sourceShardId: Int, destinationShardId: Int, cursor: Cursor) extends gizzard.jobs.Copy[Shard](sourceShardId, destinationShardId, Copy.COUNT) {
+ def copyPage(sourceShard: Shard, destinationShard: Shard, count: Int) = {
val (items, nextCursor) = sourceShard.selectAll(cursor, count)
destinationShard.write(items)
nextCursor.map(new Copy(sourceShardId, destinationShardId, _))
View
2  src/test/scala/com/twitter/rowz/SqlShardSpec.scala
@@ -16,7 +16,7 @@ object SqlShard extends Specification with JMocker with ClassMocker {
"table_001", "localhost", "INT UNSIGNED", "INT UNSIGNED", Busy.Normal, 1)
val sqlShard = shardFactory.instantiate(shardInfo, 1, List[Shard]())
val queryEvaluator = queryEvaluatorFactory(shardInfo.hostname, null, config("rowz.db.username"), config("rowz.db.password"))
- val row = new Row(1, "a row", Time.now, Time.now, State.Normal.id)
+ val row = new Row(1, "a row", Time.now, Time.now, State.Normal)
doBefore {
queryEvaluator.execute("DROP DATABASE IF EXISTS " + config("rowz.db.name"))
Please sign in to comment.
Something went wrong with that request. Please try again.