Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thriftmux -> 213 #794

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,8 @@ lazy val finagleThrift = Project(
id = "finagle-thrift",
base = file("finagle-thrift")
).settings(
sharedSettings
sharedSettings,
withTwoThirteen
).settings(
name := "finagle-thrift",
libraryDependencies ++= scroogeLibs
Expand Down Expand Up @@ -670,7 +671,8 @@ lazy val finagleMux = Project(
id = "finagle-mux",
base = file("finagle-mux")
).settings(
sharedSettings
sharedSettings,
withTwoThirteen
).settings(
name := "finagle-mux",
libraryDependencies ++= Seq(
Expand All @@ -687,7 +689,8 @@ lazy val finagleThriftMux = Project(
id = "finagle-thriftmux",
base = file("finagle-thriftmux")
).settings(
sharedSettings
sharedSettings,
withTwoThirteen
).settings(
name := "finagle-thriftmux",
libraryDependencies ++= Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.twitter.finagle.mux

import com.twitter.io.{Buf, ByteReader, ByteWriter}
import scala.collection.mutable.ArrayBuffer
import scala.collection.compat.immutable.ArraySeq

/**
* Encoder and decoder for mux contexts
Expand Down Expand Up @@ -41,7 +42,7 @@ private[mux] object ContextCodec {
// We don't know the precise size and we don't try to guess.
val acc = new ArrayBuffer[(Buf, Buf)]()
decodeToBuffer(br, Int.MaxValue, acc)
acc
ArraySeq.unsafeWrapArray(acc.toArray)
}

/**
Expand All @@ -53,7 +54,7 @@ private[mux] object ContextCodec {
def decode(br: ByteReader, count: Int): Seq[(Buf, Buf)] = {
val acc = new ArrayBuffer[(Buf, Buf)](count)
decodeToBuffer(br, count, acc)
acc
ArraySeq.unsafeWrapArray(acc.toArray)
}

private def decodeToBuffer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.twitter.finagle.{Dentry, Dtab, Failure, NameTree, Path}
import com.twitter.io.{Buf, BufByteWriter, ByteReader}
import com.twitter.util.{Duration, Future, Time}
import java.nio.charset.{StandardCharsets => Charsets}
import scala.collection.compat.immutable.ArraySeq
import scala.collection.mutable.ArrayBuffer

/**
Expand Down Expand Up @@ -140,13 +141,13 @@ private[finagle] object Message {

def decode(br: ByteReader): (Short, Seq[(Buf, Buf)]) = {
val version = br.readShortBE()
val headers = new ArrayBuffer[(Buf, Buf)]
val headers = ArraySeq.newBuilder[(Buf, Buf)]
while (br.remaining > 0) {
val k = br.readBytes(br.readIntBE())
val v = br.readBytes(br.readIntBE())
headers += (k -> v)
}
(version.toShort, headers)
(version.toShort, headers.result())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ abstract class AbstractEndToEndTest
for (n <- 0 until 2) {
val rsp = Await.result(client(Request(Path.empty, Nil, Buf.Empty)), 30.seconds)
val Buf.Utf8(str) = rsp.body
assert(str == "Dtab(2)\n\t/foo => /bar\n\t/web => /$/inet/twitter.com/80\n")
assert(str.replace("\r", "") == "Dtab(2)\n\t/foo => /bar\n\t/web => /$/inet/twitter.com/80\n")
}
}
Await.result(server.close(), 5.seconds)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.twitter.finagle.param.{
import com.twitter.finagle.server.{Listener, StackServer, StdStackServer}
import com.twitter.finagle.service.{ResponseClassifier, RetryBudget}
import com.twitter.finagle.stats.{ExceptionStatsHandler, StatsReceiver}
import com.twitter.finagle.thrift.{ClientId => _, _}
import com.twitter.finagle.thrift.{ClientId => FinagleClientId, _}
import com.twitter.finagle.thrift.service.ThriftResponseClassifier
import com.twitter.finagle.thrift.transport.ThriftClientPreparer
import com.twitter.finagle.thrift.transport.netty4.Netty4Transport
Expand Down Expand Up @@ -137,7 +137,7 @@ object Thrift

val maxThriftBufferSize: Int = 16 * 1024

case class ClientId(clientId: Option[thrift.ClientId])
case class ClientId(clientId: Option[FinagleClientId])
implicit object ClientId extends Stack.Param[ClientId] {
val default = ClientId(None)
}
Expand Down Expand Up @@ -269,7 +269,7 @@ object Thrift
def withProtocolFactory(protocolFactory: TProtocolFactory): Client =
configured(param.ProtocolFactory(protocolFactory))

def withClientId(clientId: thrift.ClientId): Client =
def withClientId(clientId: FinagleClientId): Client =
configured(Thrift.param.ClientId(Some(clientId)))

/**
Expand Down Expand Up @@ -303,7 +303,7 @@ object Thrift
def withPerEndpointStats: Client =
configured(param.PerEndpointStats(true))

def clientId: Option[thrift.ClientId] = params[Thrift.param.ClientId].clientId
def clientId: Option[FinagleClientId] = params[Thrift.param.ClientId].clientId

private[this] def withDeserializingClassifier: Client = {
// Note: what type of deserializer used is important if none is specified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.twitter.finagle.stats.{
}
import com.twitter.finagle.thrift.service.ThriftResponseClassifier
import com.twitter.finagle.thrift.thriftscala._
import com.twitter.finagle.thrift.ClientId
import com.twitter.finagle.tracing.{Annotation, Record, Trace}
import com.twitter.finagle.util.DefaultTimer
import com.twitter.io.TempFile
Expand Down