Permalink
Browse files

drop Codec

  • Loading branch information...
1 parent 1e405d4 commit 3ab26ebac3535d473d5a1951f59ab0e6348202f6 Josh Hull committed Feb 23, 2011
View
4 src/main/scala/com/twitter/gizzard/config/JobScheduler.scala
@@ -9,7 +9,7 @@ import net.lag.kestrel.config.QueueConfig
import com.twitter.gizzard
import com.twitter.gizzard.scheduler
-import com.twitter.gizzard.scheduler.{JsonJob, Codec, MemoryJobQueue, KestrelJobQueue, JobConsumer}
+import com.twitter.gizzard.scheduler.{JsonJob, JsonCodec, MemoryJobQueue, KestrelJobQueue, JobConsumer}
trait SchedulerType
trait KestrelScheduler extends SchedulerType {
@@ -85,7 +85,7 @@ trait Scheduler {
var badJobQueue: Option[BadJobConsumer] = None
def badJobQueue_=(c: BadJobConsumer) { badJobQueue = Some(c) }
- def apply(codec: Codec): gizzard.scheduler.JobScheduler = {
+ def apply(codec: JsonCodec): gizzard.scheduler.JobScheduler = {
val (jobQueue, errorQueue) = schedulerType match {
case kestrel: KestrelScheduler => {
val persistentJobQueue = kestrel(jobQueueName)
View
9 src/main/scala/com/twitter/gizzard/scheduler/JobQueue.scala
@@ -30,12 +30,3 @@ trait JobQueue extends JobConsumer with Process {
def checkExpiration(flushLimit: Int)
def size: Int
}
-
-/**
- * A mechanism for turning jobs into byte arrays (and vice versa) so that they can be used with
- * journaled queues.
- */
-trait Codec {
- def flatten(job: JsonJob): Array[Byte]
- def inflate(data: Array[Byte]): JsonJob
-}
View
2 src/main/scala/com/twitter/gizzard/scheduler/JsonCodec.scala
@@ -20,7 +20,7 @@ import scala.collection.JavaConversions._
*
* Jobs that can't be parsed by the json library are handed to 'unparsableJobHandler'.
*/
-class JsonCodec(unparsableJobHandler: Array[Byte] => Unit) extends Codec {
+class JsonCodec(unparsableJobHandler: Array[Byte] => Unit) {
private val mapper = new ObjectMapper
protected val log = Logger.get(getClass.getName)
View
2 src/main/scala/com/twitter/gizzard/scheduler/KestrelJobQueue.scala
@@ -12,7 +12,7 @@ import net.lag.logging.Logger
* ticket's 'ack' method is called, so if a job is half-complete when the server dies, it will be
* back in the queue when the server restarts.
*/
-class KestrelJobQueue(queueName: String, val queue: PersistentQueue, codec: Codec)
+class KestrelJobQueue(queueName: String, val queue: PersistentQueue, codec: JsonCodec)
extends JobQueue {
private val log = Logger.get(getClass.getName)
val TIMEOUT = 100
View
2 src/test/scala/com/twitter/gizzard/scheduler_new/JobSchedulerSpec.scala
@@ -14,7 +14,7 @@ class JobSchedulerSpec extends ConfiguredSpecification with JMocker with ClassMo
val badJobQueue = mock[JobConsumer]
val job1 = mock[JsonJob]
val ticket1 = mock[Ticket]
- val codec = mock[Codec]
+ val codec = mock[JsonCodec]
val shardId = ShardId("fake", "shard")
var jobScheduler: JobScheduler = null
View
2 src/test/scala/com/twitter/gizzard/scheduler_new/KestrelJobQueueSpec.scala
@@ -15,7 +15,7 @@ object KestrelJobQueueSpec extends ConfiguredSpecification with JMocker with Cla
"KestrelJobQueue" should {
val queue = mock[PersistentQueue]
val queue2 = mock[PersistentQueue]
- val codec = mock[Codec]
+ val codec = mock[JsonCodec]
val job1 = mock[JsonJob]
val job2 = mock[JsonJob]
val destinationQueue = mock[KestrelJobQueue]

0 comments on commit 3ab26eb

Please sign in to comment.