Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixes connection establishment timeout issue.

  • Loading branch information...
commit f8e7bd88be558afb6fd5623dba7578e2e8a01fbc 1 parent 33ff293
James Waldrop authored
View
2  src/main/scala/com/twitter/parrot/config/ParrotServerConfig.scala
@@ -57,6 +57,8 @@ trait ParrotServerConfig[Req <: ParrotRequest, Rep] extends Config[RuntimeEnviro
var hostConnectionLimit = Integer.MAX_VALUE
var hostConnectionMaxIdleTimeInMs = 5000
var hostConnectionMaxLifeTimeInMs = Integer.MAX_VALUE
+ var requestTimeoutInMs = Integer.MAX_VALUE
+ var tcpConnectTimeoutInMs = Integer.MAX_VALUE
var idleTimeoutInSec = 300
var reuseConnections = true
var thriftClientId = ""
View
4 src/main/scala/com/twitter/parrot/processor/SimpleRecordProcessor.scala
@@ -32,13 +32,15 @@ import org.jboss.netty.handler.codec.http.HttpResponse
class SimpleRecordProcessor(service: ParrotService[ParrotRequest, HttpResponse],
config: ParrotServerConfig[ParrotRequest, HttpResponse])
extends RecordProcessor {
+
def processLines(job: ParrotJob, lines: Seq[String]) {
lines flatMap { line =>
val target = job.victims.get(config.randomizer.nextInt(job.victims.size))
UriParser(line) match {
case Return(uri) =>
if (!uri.path.isEmpty && !line.startsWith("#")) {
- Some(service(new ParrotRequest(target, None, Nil, uri, line)))
+ val request = new ParrotRequest(target, None, Nil, uri, line)
+ Some(service(request))
}
else
None
View
7 src/main/scala/com/twitter/parrot/server/FinagleTransport.scala
@@ -25,6 +25,7 @@ import com.twitter.parrot.thrift.TargetHost
import com.twitter.util.{Promise, Duration, Future}
import java.nio.ByteOrder.BIG_ENDIAN
import java.util.concurrent.TimeUnit
+import java.util.logging.{Logger => JLogger}
import org.jboss.netty.buffer.ChannelBuffers
import org.jboss.netty.handler.codec.http.HttpHeaders.Names.CONTENT_LENGTH
import org.jboss.netty.handler.codec.http._
@@ -43,7 +44,10 @@ class FinagleTransport(config: ParrotServerConfig[ParrotRequest, HttpResponse])
.hostConnectionLimit(config.hostConnectionLimit)
.hostConnectionMaxIdleTime(Duration(config.hostConnectionMaxIdleTimeInMs, TimeUnit.MILLISECONDS))
.hostConnectionMaxLifeTime(Duration(config.hostConnectionMaxLifeTimeInMs, TimeUnit.MILLISECONDS))
+ .requestTimeout(Duration(config.requestTimeoutInMs, TimeUnit.MILLISECONDS))
+ .tcpConnectTimeout(Duration(config.tcpConnectTimeoutInMs, TimeUnit.MILLISECONDS))
.keepAlive(true)
+// .logger(JLogger.getLogger("com.twitter.finagle")) // enable for extreme debugging
.reportTo(new OstrichStatsReceiver)
var allRequests = 0
@@ -78,8 +82,9 @@ class FinagleTransport(config: ParrotServerConfig[ParrotRequest, HttpResponse])
"""
===================== HttpRequest ======================
%s
+%s
========================================================"""
- .format(httpRequest.toString)
+ .format(request.target, httpRequest.toString)
)
client flatMap { service: Service[HttpRequest, HttpResponse] =>
Please sign in to comment.
Something went wrong with that request. Please try again.