Permalink
Browse files

slight cleanup.

  • Loading branch information...
1 parent e7b578b commit 963ca55a498548d565f814eafe0e6c1b3b7367e0 Robey Pointer committed Jan 8, 2009
@@ -5,6 +5,7 @@
package net.lag.smile
+import java.io.IOException
import java.net.InetSocketAddress
import scala.actors.{Actor, OutputChannel}
import scala.actors.Actor._
@@ -201,7 +202,7 @@ class MemcacheConnection(val hostname: String, val port: Int, val weight: Int) {
log.error("unsolicited response from server %s: %s", this, message)
case MinaMessage.MessageSent(message) =>
case MinaMessage.ExceptionCaught(cause) =>
- log.error(cause, "unsolicted exception in actor for %s", this)
+ log.error(cause, "unsolicited exception in actor for %s", this)
disconnect
case MinaMessage.SessionIdle(status) =>
// probably leftover from a previous timeout.
@@ -224,12 +225,13 @@ class MemcacheConnection(val hostname: String, val port: Int, val weight: Int) {
handler(message)
case MinaMessage.ExceptionCaught(cause) =>
disconnect
- if (cause.isInstanceOf[java.io.IOException]) {
- log.error(cause, "exception in actor for %s ioexception", this)
- sender ! ConnectionFailed
- } else {
- log.error(cause, "exception in actor for %s", this)
- sender ! Error(cause.toString)
+ cause match {
+ case e: IOException =>
+ log.error(cause, "exception in actor for %s ioexception", this)
+ sender ! ConnectionFailed
+ case e =>
+ log.error(cause, "exception in actor for %s", this)
+ sender ! Error(cause.toString)
}
case MinaMessage.SessionIdle(status) =>
log.error("timeout for %s", this)
@@ -12,11 +12,12 @@ import net.lag.extensions._
import net.lag.logging.{Level, Logger}
import net.lag.smile.MemcacheClient
+
class ManyGetsTest extends StressTest {
// get the same value N times in a row.
def serialGets(count: Int, size: Int) = {
val host = hosts(0)
- println("serialGets: count=%d size=%d host=%s".format(count,size, host))
+ println("serialGets: count=%d size=%d host=%s".format(count, size, host))
val cache = MemcacheClient.create(Array(host), "default", "crc32-itu")
val key = "toasters"
@@ -155,27 +156,27 @@ class ManyGetsTest extends StressTest {
for (t <- threadList) t.join
}
cache.shutdown
-
}
def test() {
- serialGets(1000, 10)
- serialPutAndGet(1000, 10)
- serialPutAndGet(1000, 10)
- serialPuts(1000, 10)
- parallelGets(1000, 10, 10)
- parallelGetsFrom3(1000, 10, 25, 10)
-
- serialGets(10000, 5000)
- serialGets(10000, 5001)
- serialPutAndGet(10000, 5002)
- parallelGets(10000, 100, 5003)
- serialPuts(10000, 5007)
- parallelGetsFrom3(4000, 100, 25, 6004)
- parallelGetsFrom3(4000, 100, 25, 15004)
+ serialGets(1000, 10)
+ serialPutAndGet(1000, 10)
+ serialPutAndGet(1000, 10)
+ serialPuts(1000, 10)
+ parallelGets(1000, 10, 10)
+ parallelGetsFrom3(1000, 10, 25, 10)
+
+ serialGets(10000, 5000)
+ serialGets(10000, 5001)
+ serialPutAndGet(10000, 5002)
+ parallelGets(10000, 100, 5003)
+ serialPuts(10000, 5007)
+ parallelGetsFrom3(4000, 100, 25, 6004)
+ parallelGetsFrom3(4000, 100, 25, 15004)
}
}
+
object ManyGets {
def main(args: Array[String]): Unit = {
if (args.size != 3) {
@@ -10,8 +10,8 @@ import net.lag.extensions._
import net.lag.logging.{Level, Logger}
import java.util.Random
+
trait StressTest {
-// Logger.get("").setLevel(Logger.TRACE)
val rnd = new Random(System.currentTimeMillis)
var hosts: Array[String] = _
@@ -34,6 +34,6 @@ trait StressTest {
}
def generateValues(size: Int, variance: Int, count: Int): List[String] = {
- (for (i <- 1 to count) yield generateValue(size + rnd.nextInt(variance))).toList
+ (for (i <- 1 to count) yield generateValue(size + rnd.nextInt(variance))).toList
}
}
View
@@ -4,6 +4,7 @@
level = "info"
utc = true
</log>
+
<memcache>
servers = ["localhost"]
</memcache>

0 comments on commit 963ca55

Please sign in to comment.