Permalink
Browse files

finagle: Decouple finagle-core from Netty 3. Meet finagle-netty3

Summary: !!I will --tbr that on Wednesday, 6/28!!

Finagle was heavily coupled to Netty 3. After an enormous amount of work, we're ready to decouple it
from Netty 3. This change introduces a new package `finagle-netty3` that `finagle-core` **doesn't depend on**.

The following Finagle packages still depend on `finagle-netty3`:

- finagle-http (see CSL-3667)
- finagle-core:tests (tests are still using Netty 3 constructs, this will change with CSL-4755)

JIRA Issues: CSL-4224

TBR=true

Differential Revision: https://phabricator.twitter.biz/D65268
  • Loading branch information...
vkostyukov authored and jenkins committed Jun 28, 2017
1 parent 49c502c commit 49d4d0df6d7e0a5dcac85ca6564efcae101c8e04
Showing with 120 additions and 89 deletions.
  1. +1 −0 .travis.yml
  2. +3 −0 CHANGES
  3. +1 −0 finagle-base-http/src/main/scala/BUILD
  4. +1 −0 finagle-benchmark/src/main/scala/BUILD
  5. +0 −1 finagle-core/src/main/scala/BUILD
  6. +17 −6 finagle-core/src/main/scala/com/twitter/finagle/client/Transporter.scala
  7. +0 −24 finagle-core/src/main/scala/com/twitter/finagle/socks/SocksProxyFlags.scala
  8. +9 −0 finagle-core/src/main/scala/com/twitter/finagle/socks/flags.scala
  9. +0 −14 finagle-core/src/test/java/com/twitter/finagle/MyTestCodec.java
  10. +1 −4 finagle-core/src/test/java/com/twitter/finagle/StackParamCompilationTest.java
  11. +2 −0 finagle-core/src/test/scala/BUILD
  12. +0 −23 finagle-core/src/test/scala/com/twitter/finagle/socks/SocksProxyFlagsTest.scala
  13. +0 −1 finagle-example/src/main/scala/BUILD
  14. +1 −0 finagle-http/src/main/scala/BUILD
  15. +11 −0 finagle-netty3/BUILD
  16. +1 −0 {finagle-core/src/main/scala/com/twitter/finagle/netty3 → finagle-netty3}/OWNERS
  17. +24 −0 finagle-netty3/src/main/scala/BUILD
  18. 0 {finagle-core → finagle-netty3}/src/main/scala/com/twitter/finagle/Codec.scala
  19. 0 ...agle-core → finagle-netty3}/src/main/scala/com/twitter/finagle/httpproxy/HttpConnectHandler.scala
  20. 0 {finagle-core → finagle-netty3}/src/main/scala/com/twitter/finagle/netty3/BufChannelBuffer.scala
  21. 0 {finagle-core → finagle-netty3}/src/main/scala/com/twitter/finagle/netty3/ChannelBufferBuf.scala
  22. 0 {finagle-core → finagle-netty3}/src/main/scala/com/twitter/finagle/netty3/ChannelFuture.scala
  23. 0 {finagle-core → finagle-netty3}/src/main/scala/com/twitter/finagle/netty3/ChannelSnooper.scala
  24. 0 {finagle-core → finagle-netty3}/src/main/scala/com/twitter/finagle/netty3/Netty3Listener.scala
  25. 0 {finagle-core → finagle-netty3}/src/main/scala/com/twitter/finagle/netty3/Netty3Transporter.scala
  26. 0 ...re → finagle-netty3}/src/main/scala/com/twitter/finagle/netty3/channel/BrokerChannelHandler.scala
  27. 0 ...e → finagle-netty3}/src/main/scala/com/twitter/finagle/netty3/channel/ChannelClosingHandler.scala
  28. 0 ...inagle-netty3}/src/main/scala/com/twitter/finagle/netty3/channel/ChannelRequestStatsHandler.scala
  29. 0 ...ore → finagle-netty3}/src/main/scala/com/twitter/finagle/netty3/channel/ChannelStatsHandler.scala
  30. 0 ...core → finagle-netty3}/src/main/scala/com/twitter/finagle/netty3/channel/IdleChannelHandler.scala
  31. 0 ...→ finagle-netty3}/src/main/scala/com/twitter/finagle/netty3/channel/LeftFoldUpstreamHandler.scala
  32. 0 ...gle-netty3}/src/main/scala/com/twitter/finagle/netty3/channel/WriteCompletionTimeoutHandler.scala
  33. 0 {finagle-core → finagle-netty3}/src/main/scala/com/twitter/finagle/netty3/codec/BufCodec.scala
  34. 0 {finagle-core → finagle-netty3}/src/main/scala/com/twitter/finagle/netty3/numWorkers.scala
  35. 0 {finagle-core → finagle-netty3}/src/main/scala/com/twitter/finagle/netty3/package.scala
  36. 0 {finagle-core → finagle-netty3}/src/main/scala/com/twitter/finagle/netty3/param/Params.scala
  37. 0 ...gle → finagle-netty3/src/main/scala/com/twitter/finagle/netty3}/socks/AuthenticationSetting.scala
  38. 0 ...-core → finagle-netty3}/src/main/scala/com/twitter/finagle/netty3/socks/SocksConnectHandler.scala
  39. 0 ...inagle-netty3}/src/main/scala/com/twitter/finagle/netty3/ssl/client/SslClientConnectHandler.scala
  40. 0 ...inagle-netty3}/src/main/scala/com/twitter/finagle/netty3/ssl/server/SslServerConnectHandler.scala
  41. 0 ...core → finagle-netty3}/src/main/scala/com/twitter/finagle/netty3/transport/ChannelTransport.scala
  42. 0 {finagle-core → finagle-netty3}/src/main/scala/com/twitter/finagle/util/HashedWheelTimer.scala
  43. 0 {finagle-core → finagle-netty3}/src/main/scala/com/twitter/finagle/util/TimerStats.scala
  44. +15 −0 finagle-netty3/src/test/scala/BUILD
  45. 0 ...-core → finagle-netty3}/src/test/scala/com/twitter/finagle/httpproxy/HttpConnectHandlerTest.scala
  46. 0 {finagle-core → finagle-netty3}/src/test/scala/com/twitter/finagle/netty3/BufChannelBufferTest.scala
  47. 0 {finagle-core → finagle-netty3}/src/test/scala/com/twitter/finagle/netty3/ChannelBufferBufTest.scala
  48. 0 ...agle-core → finagle-netty3}/src/test/scala/com/twitter/finagle/netty3/Netty3AssumptionsTest.scala
  49. 0 {finagle-core → finagle-netty3}/src/test/scala/com/twitter/finagle/netty3/Netty3ListenerTest.scala
  50. 0 ...agle-core → finagle-netty3}/src/test/scala/com/twitter/finagle/netty3/Netty3TransporterTest.scala
  51. 0 {finagle-core → finagle-netty3}/src/test/scala/com/twitter/finagle/netty3/NumWorkersTest.scala
  52. 0 ...finagle-netty3}/src/test/scala/com/twitter/finagle/netty3/channel/ChannelClosingHandlerTest.scala
  53. 0 ...le-netty3}/src/test/scala/com/twitter/finagle/netty3/channel/ChannelRequestStatsHandlerTest.scala
  54. 0 ...→ finagle-netty3}/src/test/scala/com/twitter/finagle/netty3/channel/ChannelStatsHandlerTest.scala
  55. 0 {finagle-core → finagle-netty3}/src/test/scala/com/twitter/finagle/netty3/codec/BufCodecTest.scala
  56. 0 ...e → finagle-netty3}/src/test/scala/com/twitter/finagle/netty3/socks/SocksConnectHandlerTest.scala
  57. 0 ...le-netty3}/src/test/scala/com/twitter/finagle/netty3/ssl/client/SslClientConnectHandlerTest.scala
  58. 0 ...le-netty3}/src/test/scala/com/twitter/finagle/netty3/ssl/server/SslServerConnectHandlerTest.scala
  59. 0 ... → finagle-netty3}/src/test/scala/com/twitter/finagle/netty3/transport/ChannelTransportTest.scala
  60. 0 {finagle-core → finagle-netty3}/src/test/scala/com/twitter/finagle/util/HashedWheelTimerTest.scala
  61. 0 {finagle-core → finagle-netty3}/src/test/scala/com/twitter/finagle/util/TimerStatsTest.scala
  62. +0 −1 finagle-redis/src/main/scala/BUILD
  63. +0 −1 finagle-serversets/src/main/scala/BUILD
  64. +0 −1 finagle-stats/src/main/scala/BUILD
  65. +2 −2 finagle-thrift/src/test/scala/com/twitter/finagle/thrift/EndToEndTest.scala
  66. +5 −5 finagle-thriftmux/src/test/scala/com/twitter/finagle/thriftmux/EndToEndTest.scala
  67. +26 −6 project/Build.scala
View
@@ -18,6 +18,7 @@ env:
- PROJECT=finagle-mysql
- PROJECT=finagle-netty4
- PROJECT=finagle-netty4-http
- PROJECT=finagle-netty3
- PROJECT=finagle-redis
- PROJECT=finagle-serversets
- PROJECT=finagle-stats
View
@@ -24,6 +24,9 @@ New Features
Breaking API Changes
~~~~~~~~~~~~~~~~~~~~
* finagle: Finagle is now decoupled from Netty 3. Depend on `finagle-netty3`
explicitly if needed. ``PHAB_ID=D65268``
* finagle-core: The Framer type has been transformed into a specialized version of a
more generic abstraction, Decoder[T]. ``PHAB_ID=D59495``
@@ -10,6 +10,7 @@ scala_library(
'3rdparty/jvm/commons-lang',
'3rdparty/jvm/io/netty',
'finagle/finagle-core',
'finagle/finagle-netty3',
'util/util-codec',
'util/util-collection',
'util/util-core',
@@ -12,6 +12,7 @@ scala_library(
'finagle/finagle-exp/src/main/scala',
'finagle/finagle-memcached/src/main/scala',
'finagle/finagle-mux/src/main/scala',
'finagle/finagle-netty3/src/main/scala',
'finagle/finagle-netty4/src/main/scala',
'finagle/finagle-serversets/src/main/scala',
'finagle/finagle-stats/src/main/scala',
@@ -7,7 +7,6 @@ scala_library(
dependencies=[
'3rdparty/jvm/com/github/ben-manes/caffeine',
'3rdparty/jvm/com/google/code/findbugs:jsr305',
'3rdparty/jvm/io/netty',
'finagle/finagle-core/src/main/resources',
'finagle/finagle-toggle',
'util/util-app',
@@ -1,10 +1,10 @@
package com.twitter.finagle.client
import com.twitter.finagle.socks._
import com.twitter.finagle.{Address, Stack}
import com.twitter.finagle.socks.SocksProxyFlags
import com.twitter.finagle.transport.Transport
import com.twitter.util.{Duration, Future}
import java.net.SocketAddress
import java.net.{InetSocketAddress, SocketAddress}
/**
* Transporters construct a `Future[Transport[In, Out]]`.
@@ -68,10 +68,21 @@ object Transporter {
(this, SocksProxy.param)
}
object SocksProxy {
implicit val param = Stack.Param(SocksProxy(
SocksProxyFlags.socksProxy,
SocksProxyFlags.socksUsernameAndPassword
))
private[this] def socksProxy: Option[SocketAddress] =
(socksProxyHost.get, socksProxyPort.get) match {
case (Some(host), Some(port)) => Some(new InetSocketAddress(host, port))
case _ => None
}
private[this] def socksUsernameAndPassword: Option[(String, String)] =
(socksUsernameFlag.get, socksPasswordFlag.get) match {
case (Some(username), Some(password)) => Some((username,password))
case _ => None
}
implicit val param = Stack.Param(SocksProxy(socksProxy, socksUsernameAndPassword))
}
/**

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,9 @@
package com.twitter.finagle.socks
import com.twitter.app.GlobalFlag
private[finagle] object socksProxyHost extends GlobalFlag("", "SOCKS proxy host") { override val name = "socksProxyHost" }
private[finagle] object socksProxyPort extends GlobalFlag(0, "SOCKS proxy port") { override val name = "socksProxyPort" }
private[finagle] object socksUsernameFlag extends GlobalFlag("", "SOCKS username") { override val name = "socksUsername" }
private[finagle] object socksPasswordFlag extends GlobalFlag("", "SOCKS password") { override val name = "socksPassword" }

This file was deleted.

Oops, something went wrong.
@@ -36,7 +36,6 @@
import com.twitter.finagle.service.RetryBudgets;
import com.twitter.finagle.service.RetryPolicy;
import com.twitter.finagle.service.TimeoutFilter;
import com.twitter.finagle.socks.SocksProxyFlags;
import com.twitter.finagle.ssl.client.SslClientConfiguration;
import com.twitter.finagle.ssl.server.SslServerConfiguration;
import com.twitter.finagle.stats.NullStatsReceiver;
@@ -70,9 +69,7 @@ public void testParams() {
new DefaultPool.Param(0, Integer.MAX_VALUE, 0, Duration.Top(), Integer.MAX_VALUE).mk())
.configured(new Transporter.ConnectTimeout(Duration.Top()).mk())
.configured(
new Transporter.SocksProxy(
SocksProxyFlags.socksProxy(),
SocksProxyFlags.socksUsernameAndPassword()).mk())
new Transporter.SocksProxy(Option.empty(), Option.empty()).mk())
.configured(
new Transporter.HttpProxy(
Option.<SocketAddress>empty(),
@@ -5,6 +5,7 @@ scala_library(
dependencies=[
'3rdparty/jvm/io/netty:netty',
'finagle/finagle-core',
'finagle/finagle-netty3',
'util/util-core',
'util/util-stats',
],
@@ -27,6 +28,7 @@ junit_tests(
'3rdparty/jvm/io/netty:netty',
'finagle/finagle-core/src/main/scala:scala',
'finagle/finagle-core/src/test/resources',
'finagle/finagle-netty3',
'util/util-app/src/main/scala:scala',
'util/util-core/src/main/scala:scala',
'util/util-hashing/src/main/scala:scala',

This file was deleted.

Oops, something went wrong.
@@ -7,7 +7,6 @@ scala_library(
dependencies=[
'3rdparty/jvm/com/google/guava:guava',
'3rdparty/jvm/com/google/inject:guice',
'3rdparty/jvm/io/netty:netty',
'3rdparty/jvm/org/apache/thrift:libthrift-0.5.0',
'finagle/finagle-base-http/src/main/scala:scala',
'finagle/finagle-example/src/main/thrift:thrift-scala',
@@ -12,6 +12,7 @@ scala_library(
'finagle/finagle-core',
'finagle/finagle-http/src/main/resources',
'finagle/finagle-http2',
'finagle/finagle-netty3',
'finagle/finagle-netty4',
'finagle/finagle-base-http',
'finagle/finagle-netty4-http',
View
@@ -0,0 +1,11 @@
target(
dependencies=[
'finagle/finagle-netty3/src/main/scala'
]
)
target(name='tests',
dependencies=[
'finagle/finagle-netty3/src/test/scala'
]
)
@@ -4,3 +4,4 @@ koliver
mnakamura
roanta
ryano
vkostyukov
@@ -0,0 +1,24 @@
scala_library(
provides = scala_artifact(
org = 'com.twitter',
name = 'finagle-netty3',
repo = artifactory,
),
dependencies=[
'3rdparty/jvm/io/netty',
'finagle/finagle-core/src/main/scala:scala',
'util/util-app/src/main/scala:scala',
'util/util-codec/src/main/scala:scala',
'util/util-core/src/main/scala:scala',
'util/util-jvm/src/main/scala:scala',
'util/util-lint/src/main/scala:scala',
'util/util-security/src/main/scala:scala',
'util/util-stats/src/main/scala:scala',
],
strict_deps=True,
exports=[
'3rdparty/jvm/io/netty',
],
fatal_warnings=True,
sources=rglobs('*.scala'),
)
@@ -0,0 +1,15 @@
junit_tests(
dependencies=[
'3rdparty/jvm/io/netty',
'3rdparty/jvm/junit',
'3rdparty/jvm/org/mockito:mockito-all',
'3rdparty/jvm/org/scalacheck',
'3rdparty/jvm/org/scalatest',
'finagle/finagle-core/src/main/scala:scala',
'finagle/finagle-netty3',
'util/util-core/src/main/scala:scala',
'util/util-stats/src/main/scala:scala'
],
sources=rglobs('*.scala'),
fatal_warnings=True
)
@@ -6,7 +6,6 @@ scala_library(
),
dependencies=[
'util/util-logging',
'3rdparty/jvm/io/netty:netty',
'finagle/finagle-core',
'finagle/finagle-netty4',
'util/util-core',
@@ -9,7 +9,6 @@ scala_library(
'3rdparty/jvm/com/github/ben-manes/caffeine',
'3rdparty/jvm/com/google/guava:guava',
'3rdparty/jvm/com/google/inject:guice',
'3rdparty/jvm/io/netty:netty',
'3rdparty/jvm/org/apache/thrift:libthrift-0.5.0',
'3rdparty/jvm/org/apache/zookeeper:zookeeper-client',
'finagle/finagle-core/src/main/scala:scala',
@@ -9,7 +9,6 @@ scala_library(
'3rdparty/jvm/com/fasterxml/jackson/core:jackson-core',
'3rdparty/jvm/com/fasterxml/jackson/core:jackson-databind',
'3rdparty/jvm/com/fasterxml/jackson/module:jackson-module-scala',
'3rdparty/jvm/io/netty:netty',
'finagle/finagle-base-http/src/main/scala:scala',
'finagle/finagle-core/src/main/scala:scala',
'finagle/finagle-http/src/main/scala:scala',
@@ -12,7 +12,7 @@ import com.twitter.finagle.stats.{InMemoryStatsReceiver, LoadedStatsReceiver, Nu
import com.twitter.finagle.thrift.service.ThriftResponseClassifier
import com.twitter.finagle.thrift.thriftscala._
import com.twitter.finagle.tracing.{Annotation, Record, Trace}
import com.twitter.finagle.util.HashedWheelTimer
import com.twitter.finagle.util.DefaultTimer
import com.twitter.io.TempFile
import com.twitter.test._
import com.twitter.util._
@@ -380,7 +380,7 @@ class EndToEndTest extends FunSuite with ThriftTest with BeforeAndAfter {
if (x == "safe")
Future.value("safe")
else if (x == "slow")
Future.sleep(1.second)(HashedWheelTimer.Default).before(Future.value("slow"))
Future.sleep(1.second)(DefaultTimer).before(Future.value("slow"))
else
Future.exception(new InvalidQueryException(x.length))
}
@@ -16,7 +16,7 @@ import com.twitter.finagle.thriftmux.thriftscala._
import com.twitter.finagle.tracing.Annotation.{ClientSend, ServerRecv}
import com.twitter.finagle.tracing._
import com.twitter.finagle.transport.Transport
import com.twitter.finagle.util.{DefaultTimer, HashedWheelTimer}
import com.twitter.finagle.util.DefaultTimer
import com.twitter.io.Buf
import com.twitter.util._
import java.net.{InetAddress, InetSocketAddress, SocketAddress}
@@ -516,7 +516,7 @@ class EndToEndTest extends FunSuite
if (x == "safe")
Future.value("safe")
else if (x == "slow")
Future.sleep(1.second)(HashedWheelTimer.Default).before(Future.value("slow"))
Future.sleep(1.second)(DefaultTimer).before(Future.value("slow"))
else
Future.exception(new InvalidQueryException(x.length))
}
@@ -1314,7 +1314,7 @@ class EndToEndTest extends FunSuite
}
test("methodBuilder timeouts from Stack") {
implicit val timer = HashedWheelTimer.Default
implicit val timer = DefaultTimer
val service = new TestService.FutureIface {
def query(x: String): Future[String] = {
Future.sleep(50.millis).before { Future.value(x) }
@@ -1335,7 +1335,7 @@ class EndToEndTest extends FunSuite
}
test("methodBuilder timeouts from ClientBuilder") {
implicit val timer = HashedWheelTimer.Default
implicit val timer = DefaultTimer
val service = new TestService.FutureIface {
def query(x: String): Future[String] = {
Future.sleep(50.millis).before { Future.value(x) }
@@ -1359,7 +1359,7 @@ class EndToEndTest extends FunSuite
}
test("methodBuilder timeouts from configured ClientBuilder") {
implicit val timer = HashedWheelTimer.Default
implicit val timer = DefaultTimer
val service = new TestService.FutureIface {
def query(x: String): Future[String] = {
Future.sleep(50.millis).before { Future.value(x) }
Oops, something went wrong.

0 comments on commit 49d4d0d

Please sign in to comment.