Skip to content

Commit

Permalink
update 'flood' to allow the queue name to be specified
Browse files Browse the repository at this point in the history
  • Loading branch information
Robey Pointer committed Sep 2, 2011
1 parent 192397d commit df29313
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/test/scala/net/lag/kestrel/load/Flood.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ object Flood extends LoadTesting {

var totalItems = 10000
var kilobytes = 1
var queueName = "spam"

def usage() {
Console.println("usage: flood [options]")
Expand All @@ -78,6 +79,8 @@ object Flood extends LoadTesting {
Console.println(" put ITEMS items into the queue (default: %d)".format(totalItems))
Console.println(" -k KILOBYTES")
Console.println(" put KILOBYTES per queue item (default: %d)".format(kilobytes))
Console.println(" -q NAME")
Console.println(" use queue NAME (default: %s)".format(queueName))
}

def parseArgs(args: List[String]): Unit = args match {
Expand All @@ -91,6 +94,9 @@ object Flood extends LoadTesting {
case "-k" :: x :: xs =>
kilobytes = x.toInt
parseArgs(xs)
case "-q" :: x :: xs =>
queueName = x
parseArgs(xs)
case _ =>
usage()
System.exit(1)
Expand All @@ -100,21 +106,19 @@ object Flood extends LoadTesting {
parseArgs(args.toList)
val data = DATA * kilobytes

println("flood: " + totalItems + " items of " + kilobytes + "kB")
println("flood: " + totalItems + " items of " + kilobytes + "kB into " + queueName)

val producerThread = new Thread {
override def run = {
val socket = SocketChannel.open(new InetSocketAddress("localhost", 22133))
val qName = "spam"
put(socket, qName, totalItems, data)
put(socket, queueName, totalItems, data)
}
}
val consumerThread = new Thread {
var misses = 0
override def run = {
val socket = SocketChannel.open(new InetSocketAddress("localhost", 22133))
val qName = "spam"
misses = get(socket, qName, totalItems, data)
misses = get(socket, queueName, totalItems, data)
}
}

Expand Down

0 comments on commit df29313

Please sign in to comment.