Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

pretty formatting

  • Loading branch information...
commit 984a4eedc860f2f57721b92eb5781e0fdf2eb313 1 parent f9f84cd
Nick Kallen authored
View
6 finagle-core/src/main/scala/com/twitter/finagle/builder/ClientBuilder.scala
@@ -267,9 +267,9 @@ case class ClientBuilder(
_statsReceiver.foreach { statsReceiver =>
val hostString = host.toString
- statsReceiver.mkGauge("host" -> hostString, "load" -> "broker", broker.load)
- statsReceiver.mkGauge("host" -> hostString, "weight" -> "broker", broker.weight)
- statsReceiver.mkGauge("host" -> hostString, "available" -> "broker", if (broker.isAvailable) 1 else 0)
+ statsReceiver.mkGauge("host" -> hostString, "name" -> "load", broker.load)
+ statsReceiver.mkGauge("host" -> hostString, "name" -> "weight", broker.weight)
+ statsReceiver.mkGauge("host" -> hostString, "name" -> "available", if (broker.isAvailable) 1 else 0)
}
broker
View
1  finagle-core/src/main/scala/com/twitter/finagle/stats/JavaLoggerStatsReceiver.scala
@@ -23,7 +23,6 @@ class JavaLoggerStatsReceiver(logger: Logger, timer: Timer) extends StatsReceive
def mkGauge(name: Seq[(String, String)], f: => Float) {
timer.schedule(10.seconds) {
logger.info("%s %2f".format(name, f))
- makeGauge(name, f)
}
}
View
2  finagle-stress/src/main/scala/com/twitter/finagle/stress/EmbeddedServer.scala
@@ -1,4 +1,4 @@
-package com.twitter.finagle.integration
+package com.twitter.finagle.stress
import scala.collection.JavaConversions._
View
47 finagle-stress/src/main/scala/com/twitter/finagle/stress/LoadBalancerTest.scala
@@ -1,4 +1,4 @@
-package com.twitter.finagle.integration
+package com.twitter.finagle.stress
import scala.collection.mutable.{ArrayBuffer, HashMap}
@@ -61,7 +61,7 @@ object LoadBalancerTest {
class LoadBalancerTest(
clientBuilder: ClientBuilder,
serverLatency: Duration = 0.seconds,
- numRequests: Int = 100000,
+ numRequests: Int = 10000,
concurrency: Int = 20)(behavior: PartialFunction[(Int, Seq[EmbeddedServer]), Unit])
{
private[this] val requestNumber = new AtomicInteger(0)
@@ -121,18 +121,31 @@ class LoadBalancerTest(
}
// Capture gauges to report them at the end.
- val gauges = new HashMap[String, Function0[Float]]
+ val gauges = new HashMap[Seq[(String, String)], Function0[Float]]
val statsReceiver = new NullStatsRepository {
override def mkGauge(description: Seq[(String, String)], f: => Float) {
- val name = description.map(_._2).mkString("_")
- gauges += name -> (() => f)
+ gauges += description -> (() => f)
}
}
def captureGauges() {
Timer.default.schedule(500.milliseconds) {
val now = requestNumber.get
- val values = gauges map { case (k, v) => (k, v()) }
+ val values = gauges map { case (description, v) =>
+ val options = Map(description: _*)
+ val host = options("host")
+ val serverIndex = servers.findIndexOf { _.addr.toString == host }
+ val shortName = options("name") match {
+ case "load" => "l"
+ case "weight" => "w"
+ case "available" => "a"
+ case _ => "u"
+ }
+
+ val name = "%d/%s".format(serverIndex, shortName)
+
+ (name, v())
+ }
gaugeValues += ((now, Map() ++ values))
}
}
@@ -165,24 +178,14 @@ class LoadBalancerTest(
unique.toList.sorted
}
- val columnNames = allGaugeNames map { gaugeName =>
- // Try to substitute a server.
- val Array(host, name) = gaugeName.split("_")
- val serverIndex = servers.findIndexOf { _.addr.toString == host }
- val shortName = name match {
- case "available" => "a"
- case "load" => "l"
- case "weight" => "w"
- case n => n
- }
-
- "%d/%s".format(serverIndex, shortName)
- }
-
- println("> %5s %s".format("time", columnNames map("%-8s".format(_)) mkString(" ")))
+ println("> %5s %s".format("time", allGaugeNames map("%-8s".format(_)) mkString(" ")))
gaugeValues foreach { case (requestNum, values) =>
- val columns = allGaugeNames map { values.get(_).map("%.2e".format(_)).getOrElse("n/a") }
+ val columns = allGaugeNames map { name =>
+ val value = values.get(name)
+ val formatted = value.map("%.2e".format(_)).getOrElse("n/a")
+ formatted
+ }
println("> %05d %s".format(requestNum, columns.map("%8s".format(_)).mkString(" ")))
}
Please sign in to comment.
Something went wrong with that request. Please try again.