!str #17031 Rename StreamTcp to Tcp

This commit is contained in:
Patrik Nordwall 2015-04-24 13:15:02 +02:00
parent 07f299a1e0
commit 1595a8a911
9 changed files with 72 additions and 72 deletions

View file

@ -7,7 +7,7 @@ import java.net.InetSocketAddress
import java.util.concurrent.atomic.AtomicReference import java.util.concurrent.atomic.AtomicReference
import akka.stream._ import akka.stream._
import akka.stream.scaladsl.StreamTcp._ import akka.stream.scaladsl.Tcp._
import akka.stream.scaladsl._ import akka.stream.scaladsl._
import akka.stream.stage.Context import akka.stream.stage.Context
import akka.stream.stage.PushStage import akka.stream.stage.PushStage
@ -32,13 +32,13 @@ class StreamTcpDocSpec extends AkkaSpec {
{ {
//#echo-server-simple-bind //#echo-server-simple-bind
val connections: Source[IncomingConnection, Future[ServerBinding]] = val connections: Source[IncomingConnection, Future[ServerBinding]] =
StreamTcp().bind("127.0.0.1", 8888) Tcp().bind("127.0.0.1", 8888)
//#echo-server-simple-bind //#echo-server-simple-bind
} }
{ {
val localhost = TestUtils.temporaryServerAddress() val localhost = TestUtils.temporaryServerAddress()
val connections: Source[IncomingConnection, Future[ServerBinding]] = val connections: Source[IncomingConnection, Future[ServerBinding]] =
StreamTcp().bind(localhost.getHostName, localhost.getPort) // TODO getHostString in Java7 Tcp().bind(localhost.getHostName, localhost.getPort) // TODO getHostString in Java7
//#echo-server-simple-handle //#echo-server-simple-handle
connections runForeach { connection => connections runForeach { connection =>
@ -57,7 +57,7 @@ class StreamTcpDocSpec extends AkkaSpec {
"initial server banner echo server" in { "initial server banner echo server" in {
val localhost = TestUtils.temporaryServerAddress() val localhost = TestUtils.temporaryServerAddress()
val connections = StreamTcp().bind(localhost.getHostName, localhost.getPort) // TODO getHostString in Java7 val connections = Tcp().bind(localhost.getHostName, localhost.getPort) // TODO getHostString in Java7
val serverProbe = TestProbe() val serverProbe = TestProbe()
//#welcome-banner-chat-server //#welcome-banner-chat-server
@ -113,12 +113,12 @@ class StreamTcpDocSpec extends AkkaSpec {
{ {
//#repl-client //#repl-client
val connection = StreamTcp().outgoingConnection("127.0.0.1", 8888) val connection = Tcp().outgoingConnection("127.0.0.1", 8888)
//#repl-client //#repl-client
} }
{ {
val connection = StreamTcp().outgoingConnection(localhost) val connection = Tcp().outgoingConnection(localhost)
//#repl-client //#repl-client
val replParser = new PushStage[String, ByteString] { val replParser = new PushStage[String, ByteString] {

View file

@ -260,7 +260,7 @@ class ConnectionPoolSpec extends AkkaSpec("akka.loggers = []\n akka.loglevel = O
} }
val sink = if (autoAccept) Sink.foreach[Http.IncomingConnection](handleConnection) else Sink(incomingConnections) val sink = if (autoAccept) Sink.foreach[Http.IncomingConnection](handleConnection) else Sink(incomingConnections)
// TODO getHostString in Java7 // TODO getHostString in Java7
StreamTcp().bind(serverEndpoint.getHostName, serverEndpoint.getPort, idleTimeout = serverSettings.timeouts.idleTimeout) Tcp().bind(serverEndpoint.getHostName, serverEndpoint.getPort, idleTimeout = serverSettings.timeouts.idleTimeout)
.map { c .map { c
val layer = Http().serverLayer(serverSettings, log) val layer = Http().serverLayer(serverSettings, log)
Http.IncomingConnection(c.localAddress, c.remoteAddress, layer atop rawBytesInjection join c.flow) Http.IncomingConnection(c.localAddress, c.remoteAddress, layer atop rawBytesInjection join c.flow)

View file

@ -17,19 +17,19 @@ import scala.concurrent.duration.FiniteDuration;
import scala.runtime.BoxedUnit; import scala.runtime.BoxedUnit;
import akka.stream.*; import akka.stream.*;
import akka.stream.javadsl.StreamTcp.*; import akka.stream.javadsl.Tcp.*;
import akka.japi.function.*; import akka.japi.function.*;
import akka.stream.testkit.AkkaSpec; import akka.stream.testkit.AkkaSpec;
import akka.stream.testkit.TestUtils; import akka.stream.testkit.TestUtils;
import akka.util.ByteString; import akka.util.ByteString;
public class StreamTcpTest extends StreamTest { public class TcpTest extends StreamTest {
public StreamTcpTest() { public TcpTest() {
super(actorSystemResource); super(actorSystemResource);
} }
@ClassRule @ClassRule
public static AkkaJUnitActorSystemResource actorSystemResource = new AkkaJUnitActorSystemResource("StreamTcpTest", public static AkkaJUnitActorSystemResource actorSystemResource = new AkkaJUnitActorSystemResource("TcpTest",
AkkaSpec.testConf()); AkkaSpec.testConf());
final Sink<IncomingConnection, Future<BoxedUnit>> echoHandler = final Sink<IncomingConnection, Future<BoxedUnit>> echoHandler =
@ -49,7 +49,7 @@ public class StreamTcpTest extends StreamTest {
@Test @Test
public void mustWorkInHappyCase() throws Exception { public void mustWorkInHappyCase() throws Exception {
final InetSocketAddress serverAddress = TestUtils.temporaryServerAddress("127.0.0.1", false); final InetSocketAddress serverAddress = TestUtils.temporaryServerAddress("127.0.0.1", false);
final Source<IncomingConnection, Future<ServerBinding>> binding = StreamTcp.get(system) final Source<IncomingConnection, Future<ServerBinding>> binding = Tcp.get(system)
.bind(serverAddress.getHostName(), serverAddress.getPort()); // TODO getHostString in Java7 .bind(serverAddress.getHostName(), serverAddress.getPort()); // TODO getHostString in Java7
final Future<ServerBinding> future = binding.to(echoHandler).run(materializer); final Future<ServerBinding> future = binding.to(echoHandler).run(materializer);
@ -59,7 +59,7 @@ public class StreamTcpTest extends StreamTest {
final Future<ByteString> resultFuture = Source final Future<ByteString> resultFuture = Source
.from(testInput) .from(testInput)
// TODO getHostString in Java7 // TODO getHostString in Java7
.via(StreamTcp.get(system).outgoingConnection(serverAddress.getHostName(), serverAddress.getPort())) .via(Tcp.get(system).outgoingConnection(serverAddress.getHostName(), serverAddress.getPort()))
.runFold(ByteString.empty(), .runFold(ByteString.empty(),
new Function2<ByteString, ByteString, ByteString>() { new Function2<ByteString, ByteString, ByteString>() {
public ByteString apply(ByteString acc, ByteString elem) { public ByteString apply(ByteString acc, ByteString elem) {
@ -76,7 +76,7 @@ public class StreamTcpTest extends StreamTest {
@Test @Test
public void mustReportServerBindFailure() throws Exception { public void mustReportServerBindFailure() throws Exception {
final InetSocketAddress serverAddress = TestUtils.temporaryServerAddress("127.0.0.1", false); final InetSocketAddress serverAddress = TestUtils.temporaryServerAddress("127.0.0.1", false);
final Source<IncomingConnection, Future<ServerBinding>> binding = StreamTcp.get(system) final Source<IncomingConnection, Future<ServerBinding>> binding = Tcp.get(system)
.bind(serverAddress.getHostName(), serverAddress.getPort()); // TODO getHostString in Java7 .bind(serverAddress.getHostName(), serverAddress.getPort()); // TODO getHostString in Java7
final Future<ServerBinding> future = binding.to(echoHandler).run(materializer); final Future<ServerBinding> future = binding.to(echoHandler).run(materializer);
@ -99,7 +99,7 @@ public class StreamTcpTest extends StreamTest {
Await.result( Await.result(
Source.from(testInput) Source.from(testInput)
// TODO getHostString in Java7 // TODO getHostString in Java7
.via(StreamTcp.get(system).outgoingConnection(serverAddress.getHostName(), serverAddress.getPort()), .via(Tcp.get(system).outgoingConnection(serverAddress.getHostName(), serverAddress.getPort()),
Keep.<BoxedUnit, Future<OutgoingConnection>> right()) Keep.<BoxedUnit, Future<OutgoingConnection>> right())
.to(Sink.<ByteString> ignore()) .to(Sink.<ByteString> ignore())
.run(materializer), .run(materializer),

View file

@ -3,7 +3,7 @@
*/ */
package akka.stream.io package akka.stream.io
import akka.stream.scaladsl.StreamTcp.OutgoingConnection import akka.stream.scaladsl.Tcp.OutgoingConnection
import scala.concurrent.{ Future, Await } import scala.concurrent.{ Future, Await }
import akka.io.Tcp._ import akka.io.Tcp._
@ -19,7 +19,7 @@ import akka.stream.testkit.Utils._
import akka.stream.scaladsl._ import akka.stream.scaladsl._
import akka.stream.testkit.TestUtils.temporaryServerAddress import akka.stream.testkit.TestUtils.temporaryServerAddress
class StreamTcpSpec extends AkkaSpec with TcpHelper { class TcpSpec extends AkkaSpec with TcpHelper {
import akka.stream.io.TcpHelper._ import akka.stream.io.TcpHelper._
var demand = 0L var demand = 0L
@ -32,7 +32,7 @@ class StreamTcpSpec extends AkkaSpec with TcpHelper {
val tcpReadProbe = new TcpReadProbe() val tcpReadProbe = new TcpReadProbe()
val tcpWriteProbe = new TcpWriteProbe() val tcpWriteProbe = new TcpWriteProbe()
Source(tcpWriteProbe.publisherProbe).via(StreamTcp().outgoingConnection(server.address)).to(Sink(tcpReadProbe.subscriberProbe)).run() Source(tcpWriteProbe.publisherProbe).via(Tcp().outgoingConnection(server.address)).to(Sink(tcpReadProbe.subscriberProbe)).run()
val serverConnection = server.waitAccept() val serverConnection = server.waitAccept()
validateServerClientCommunication(testData, serverConnection, tcpReadProbe, tcpWriteProbe) validateServerClientCommunication(testData, serverConnection, tcpReadProbe, tcpWriteProbe)
@ -48,7 +48,7 @@ class StreamTcpSpec extends AkkaSpec with TcpHelper {
val testInput = (0 to 255).map(ByteString(_)) val testInput = (0 to 255).map(ByteString(_))
val expectedOutput = ByteString(Array.tabulate(256)(_.asInstanceOf[Byte])) val expectedOutput = ByteString(Array.tabulate(256)(_.asInstanceOf[Byte]))
Source(testInput).via(StreamTcp().outgoingConnection(server.address)).to(Sink.ignore).run() Source(testInput).via(Tcp().outgoingConnection(server.address)).to(Sink.ignore).run()
val serverConnection = server.waitAccept() val serverConnection = server.waitAccept()
serverConnection.read(256) serverConnection.read(256)
@ -63,7 +63,7 @@ class StreamTcpSpec extends AkkaSpec with TcpHelper {
val idle = new TcpWriteProbe() // Just register an idle upstream val idle = new TcpWriteProbe() // Just register an idle upstream
val resultFuture = val resultFuture =
Source(idle.publisherProbe) Source(idle.publisherProbe)
.via(StreamTcp().outgoingConnection(server.address)) .via(Tcp().outgoingConnection(server.address))
.runFold(ByteString.empty)((acc, in) acc ++ in) .runFold(ByteString.empty)((acc, in) acc ++ in)
val serverConnection = server.waitAccept() val serverConnection = server.waitAccept()
@ -82,7 +82,7 @@ class StreamTcpSpec extends AkkaSpec with TcpHelper {
val tcpWriteProbe = new TcpWriteProbe() val tcpWriteProbe = new TcpWriteProbe()
val tcpReadProbe = new TcpReadProbe() val tcpReadProbe = new TcpReadProbe()
Source(tcpWriteProbe.publisherProbe).via(StreamTcp().outgoingConnection(server.address)).to(Sink(tcpReadProbe.subscriberProbe)).run() Source(tcpWriteProbe.publisherProbe).via(Tcp().outgoingConnection(server.address)).to(Sink(tcpReadProbe.subscriberProbe)).run()
val serverConnection = server.waitAccept() val serverConnection = server.waitAccept()
// Client can still write // Client can still write
@ -112,7 +112,7 @@ class StreamTcpSpec extends AkkaSpec with TcpHelper {
val tcpWriteProbe = new TcpWriteProbe() val tcpWriteProbe = new TcpWriteProbe()
val tcpReadProbe = new TcpReadProbe() val tcpReadProbe = new TcpReadProbe()
Source(tcpWriteProbe.publisherProbe).via(StreamTcp().outgoingConnection(server.address)).to(Sink(tcpReadProbe.subscriberProbe)).run() Source(tcpWriteProbe.publisherProbe).via(Tcp().outgoingConnection(server.address)).to(Sink(tcpReadProbe.subscriberProbe)).run()
val serverConnection = server.waitAccept() val serverConnection = server.waitAccept()
// Server can still write // Server can still write
@ -140,7 +140,7 @@ class StreamTcpSpec extends AkkaSpec with TcpHelper {
val tcpWriteProbe = new TcpWriteProbe() val tcpWriteProbe = new TcpWriteProbe()
val tcpReadProbe = new TcpReadProbe() val tcpReadProbe = new TcpReadProbe()
Source(tcpWriteProbe.publisherProbe).via(StreamTcp().outgoingConnection(server.address)).to(Sink(tcpReadProbe.subscriberProbe)).run() Source(tcpWriteProbe.publisherProbe).via(Tcp().outgoingConnection(server.address)).to(Sink(tcpReadProbe.subscriberProbe)).run()
val serverConnection = server.waitAccept() val serverConnection = server.waitAccept()
// Server can still write // Server can still write
@ -172,7 +172,7 @@ class StreamTcpSpec extends AkkaSpec with TcpHelper {
val tcpWriteProbe = new TcpWriteProbe() val tcpWriteProbe = new TcpWriteProbe()
val tcpReadProbe = new TcpReadProbe() val tcpReadProbe = new TcpReadProbe()
Source(tcpWriteProbe.publisherProbe).via(StreamTcp().outgoingConnection(server.address)).to(Sink(tcpReadProbe.subscriberProbe)).run() Source(tcpWriteProbe.publisherProbe).via(Tcp().outgoingConnection(server.address)).to(Sink(tcpReadProbe.subscriberProbe)).run()
val serverConnection = server.waitAccept() val serverConnection = server.waitAccept()
// Client can still write // Client can still write
@ -205,7 +205,7 @@ class StreamTcpSpec extends AkkaSpec with TcpHelper {
val tcpWriteProbe = new TcpWriteProbe() val tcpWriteProbe = new TcpWriteProbe()
val tcpReadProbe = new TcpReadProbe() val tcpReadProbe = new TcpReadProbe()
Source(tcpWriteProbe.publisherProbe).via(StreamTcp().outgoingConnection(server.address)).to(Sink(tcpReadProbe.subscriberProbe)).run() Source(tcpWriteProbe.publisherProbe).via(Tcp().outgoingConnection(server.address)).to(Sink(tcpReadProbe.subscriberProbe)).run()
val serverConnection = server.waitAccept() val serverConnection = server.waitAccept()
// Server can still write // Server can still write
@ -235,7 +235,7 @@ class StreamTcpSpec extends AkkaSpec with TcpHelper {
val tcpWriteProbe = new TcpWriteProbe() val tcpWriteProbe = new TcpWriteProbe()
val tcpReadProbe = new TcpReadProbe() val tcpReadProbe = new TcpReadProbe()
Source(tcpWriteProbe.publisherProbe).via(StreamTcp().outgoingConnection(server.address)).to(Sink(tcpReadProbe.subscriberProbe)).run() Source(tcpWriteProbe.publisherProbe).via(Tcp().outgoingConnection(server.address)).to(Sink(tcpReadProbe.subscriberProbe)).run()
val serverConnection = server.waitAccept() val serverConnection = server.waitAccept()
// Server can still write // Server can still write
@ -262,7 +262,7 @@ class StreamTcpSpec extends AkkaSpec with TcpHelper {
val tcpWriteProbe = new TcpWriteProbe() val tcpWriteProbe = new TcpWriteProbe()
val tcpReadProbe = new TcpReadProbe() val tcpReadProbe = new TcpReadProbe()
Source(tcpWriteProbe.publisherProbe).via(StreamTcp().outgoingConnection(server.address)).to(Sink(tcpReadProbe.subscriberProbe)).run() Source(tcpWriteProbe.publisherProbe).via(Tcp().outgoingConnection(server.address)).to(Sink(tcpReadProbe.subscriberProbe)).run()
val serverConnection = server.waitAccept() val serverConnection = server.waitAccept()
// Server can still write // Server can still write
@ -291,7 +291,7 @@ class StreamTcpSpec extends AkkaSpec with TcpHelper {
val tcpWriteProbe = new TcpWriteProbe() val tcpWriteProbe = new TcpWriteProbe()
val tcpReadProbe = new TcpReadProbe() val tcpReadProbe = new TcpReadProbe()
Source(tcpWriteProbe.publisherProbe).via(StreamTcp().outgoingConnection(server.address)).to(Sink(tcpReadProbe.subscriberProbe)).run() Source(tcpWriteProbe.publisherProbe).via(Tcp().outgoingConnection(server.address)).to(Sink(tcpReadProbe.subscriberProbe)).run()
val serverConnection = server.waitAccept() val serverConnection = server.waitAccept()
serverConnection.abort() serverConnection.abort()
@ -310,7 +310,7 @@ class StreamTcpSpec extends AkkaSpec with TcpHelper {
val tcpWriteProbe1 = new TcpWriteProbe() val tcpWriteProbe1 = new TcpWriteProbe()
val tcpReadProbe2 = new TcpReadProbe() val tcpReadProbe2 = new TcpReadProbe()
val tcpWriteProbe2 = new TcpWriteProbe() val tcpWriteProbe2 = new TcpWriteProbe()
val outgoingConnection = StreamTcp().outgoingConnection(server.address) val outgoingConnection = Tcp().outgoingConnection(server.address)
val conn1F = val conn1F =
Source(tcpWriteProbe1.publisherProbe) Source(tcpWriteProbe1.publisherProbe)
@ -346,12 +346,12 @@ class StreamTcpSpec extends AkkaSpec with TcpHelper {
"TCP listen stream" must { "TCP listen stream" must {
// Reusing handler // Reusing handler
val echoHandler = Sink.foreach[StreamTcp.IncomingConnection] { _.flow.join(Flow[ByteString]).run() } val echoHandler = Sink.foreach[Tcp.IncomingConnection] { _.flow.join(Flow[ByteString]).run() }
"be able to implement echo" in { "be able to implement echo" in {
val serverAddress = temporaryServerAddress() val serverAddress = temporaryServerAddress()
val (bindingFuture, echoServerFinish) = val (bindingFuture, echoServerFinish) =
StreamTcp() Tcp()
.bind(serverAddress.getHostName, serverAddress.getPort) // TODO getHostString in Java7 .bind(serverAddress.getHostName, serverAddress.getPort) // TODO getHostString in Java7
.toMat(echoHandler)(Keep.both) .toMat(echoHandler)(Keep.both)
.run() .run()
@ -362,7 +362,7 @@ class StreamTcpSpec extends AkkaSpec with TcpHelper {
val testInput = (0 to 255).map(ByteString(_)) val testInput = (0 to 255).map(ByteString(_))
val expectedOutput = ByteString(Array.tabulate(256)(_.asInstanceOf[Byte])) val expectedOutput = ByteString(Array.tabulate(256)(_.asInstanceOf[Byte]))
val resultFuture = val resultFuture =
Source(testInput).via(StreamTcp().outgoingConnection(serverAddress)).runFold(ByteString.empty)((acc, in) acc ++ in) Source(testInput).via(Tcp().outgoingConnection(serverAddress)).runFold(ByteString.empty)((acc, in) acc ++ in)
Await.result(resultFuture, 3.seconds) should be(expectedOutput) Await.result(resultFuture, 3.seconds) should be(expectedOutput)
Await.result(binding.unbind(), 3.seconds) Await.result(binding.unbind(), 3.seconds)
@ -372,7 +372,7 @@ class StreamTcpSpec extends AkkaSpec with TcpHelper {
"work with a chain of echoes" in { "work with a chain of echoes" in {
val serverAddress = temporaryServerAddress() val serverAddress = temporaryServerAddress()
val (bindingFuture, echoServerFinish) = val (bindingFuture, echoServerFinish) =
StreamTcp() Tcp()
.bind(serverAddress.getHostName, serverAddress.getPort) // TODO getHostString in Java7 .bind(serverAddress.getHostName, serverAddress.getPort) // TODO getHostString in Java7
.toMat(echoHandler)(Keep.both) .toMat(echoHandler)(Keep.both)
.run() .run()
@ -380,7 +380,7 @@ class StreamTcpSpec extends AkkaSpec with TcpHelper {
// make sure that the server has bound to the socket // make sure that the server has bound to the socket
val binding = Await.result(bindingFuture, 100.millis) val binding = Await.result(bindingFuture, 100.millis)
val echoConnection = StreamTcp().outgoingConnection(serverAddress) val echoConnection = Tcp().outgoingConnection(serverAddress)
val testInput = (0 to 255).map(ByteString(_)) val testInput = (0 to 255).map(ByteString(_))
val expectedOutput = ByteString(Array.tabulate(256)(_.asInstanceOf[Byte])) val expectedOutput = ByteString(Array.tabulate(256)(_.asInstanceOf[Byte]))
@ -400,18 +400,18 @@ class StreamTcpSpec extends AkkaSpec with TcpHelper {
"bind and unbind correctly" in { "bind and unbind correctly" in {
val address = temporaryServerAddress() val address = temporaryServerAddress()
val probe1 = TestSubscriber.manualProbe[StreamTcp.IncomingConnection]() val probe1 = TestSubscriber.manualProbe[Tcp.IncomingConnection]()
val bind = StreamTcp(system).bind(address.getHostName, address.getPort) // TODO getHostString in Java7 val bind = Tcp(system).bind(address.getHostName, address.getPort) // TODO getHostString in Java7
// Bind succeeded, we have a local address // Bind succeeded, we have a local address
val binding1 = Await.result(bind.to(Sink(probe1)).run(), 3.second) val binding1 = Await.result(bind.to(Sink(probe1)).run(), 3.second)
probe1.expectSubscription() probe1.expectSubscription()
val probe2 = TestSubscriber.manualProbe[StreamTcp.IncomingConnection]() val probe2 = TestSubscriber.manualProbe[Tcp.IncomingConnection]()
val binding2F = bind.to(Sink(probe2)).run() val binding2F = bind.to(Sink(probe2)).run()
probe2.expectSubscriptionAndError(BindFailedException) probe2.expectSubscriptionAndError(BindFailedException)
val probe3 = TestSubscriber.manualProbe[StreamTcp.IncomingConnection]() val probe3 = TestSubscriber.manualProbe[Tcp.IncomingConnection]()
val binding3F = bind.to(Sink(probe3)).run() val binding3F = bind.to(Sink(probe3)).run()
probe3.expectSubscriptionAndError() probe3.expectSubscriptionAndError()
@ -422,7 +422,7 @@ class StreamTcpSpec extends AkkaSpec with TcpHelper {
Await.result(binding1.unbind(), 1.second) Await.result(binding1.unbind(), 1.second)
probe1.expectComplete() probe1.expectComplete()
val probe4 = TestSubscriber.manualProbe[StreamTcp.IncomingConnection]() val probe4 = TestSubscriber.manualProbe[Tcp.IncomingConnection]()
// Bind succeeded, we have a local address // Bind succeeded, we have a local address
val binding4 = Await.result(bind.to(Sink(probe4)).run(), 3.second) val binding4 = Await.result(bind.to(Sink(probe4)).run(), 3.second)
probe4.expectSubscription() probe4.expectSubscription()

View file

@ -154,7 +154,7 @@ class TlsSpec extends AkkaSpec("akka.loglevel=INFO\nakka.actor.debug.receive=off
} }
def server(flow: Flow[ByteString, ByteString, Any]) = { def server(flow: Flow[ByteString, ByteString, Any]) = {
val server = StreamTcp() val server = Tcp()
.bind("localhost", 0) .bind("localhost", 0)
.to(Sink.foreach(c c.flow.join(flow).run())) .to(Sink.foreach(c c.flow.join(flow).run()))
.run() .run()
@ -162,21 +162,21 @@ class TlsSpec extends AkkaSpec("akka.loglevel=INFO\nakka.actor.debug.receive=off
} }
object ClientInitiatesViaTcp extends CommunicationSetup { object ClientInitiatesViaTcp extends CommunicationSetup {
var binding: StreamTcp.ServerBinding = null var binding: Tcp.ServerBinding = null
def decorateFlow(leftClosing: Closing, rightClosing: Closing, def decorateFlow(leftClosing: Closing, rightClosing: Closing,
rhs: Flow[SslTlsInbound, SslTlsOutbound, Any]) = { rhs: Flow[SslTlsInbound, SslTlsOutbound, Any]) = {
binding = server(serverTls(rightClosing).reversed join rhs) binding = server(serverTls(rightClosing).reversed join rhs)
clientTls(leftClosing) join StreamTcp().outgoingConnection(binding.localAddress) clientTls(leftClosing) join Tcp().outgoingConnection(binding.localAddress)
} }
override def cleanup(): Unit = binding.unbind() override def cleanup(): Unit = binding.unbind()
} }
object ServerInitiatesViaTcp extends CommunicationSetup { object ServerInitiatesViaTcp extends CommunicationSetup {
var binding: StreamTcp.ServerBinding = null var binding: Tcp.ServerBinding = null
def decorateFlow(leftClosing: Closing, rightClosing: Closing, def decorateFlow(leftClosing: Closing, rightClosing: Closing,
rhs: Flow[SslTlsInbound, SslTlsOutbound, Any]) = { rhs: Flow[SslTlsInbound, SslTlsOutbound, Any]) = {
binding = server(clientTls(rightClosing).reversed join rhs) binding = server(clientTls(rightClosing).reversed join rhs)
serverTls(leftClosing) join StreamTcp().outgoingConnection(binding.localAddress) serverTls(leftClosing) join Tcp().outgoingConnection(binding.localAddress)
} }
override def cleanup(): Unit = binding.unbind() override def cleanup(): Unit = binding.unbind()
} }

View file

@ -16,7 +16,7 @@ import akka.io.Tcp
import akka.stream.ActorFlowMaterializerSettings import akka.stream.ActorFlowMaterializerSettings
import akka.stream.impl.ActorProcessor import akka.stream.impl.ActorProcessor
import akka.stream.impl.ActorPublisher import akka.stream.impl.ActorPublisher
import akka.stream.scaladsl.StreamTcp import akka.stream.scaladsl.{ Tcp StreamTcp }
import akka.util.ByteString import akka.util.ByteString
import org.reactivestreams.Processor import org.reactivestreams.Processor
import org.reactivestreams.Subscriber import org.reactivestreams.Subscriber

View file

@ -13,7 +13,7 @@ import akka.io.Tcp._
import akka.stream.{ FlowMaterializer, ActorFlowMaterializerSettings } import akka.stream.{ FlowMaterializer, ActorFlowMaterializerSettings }
import akka.stream.impl._ import akka.stream.impl._
import akka.stream.scaladsl.Flow import akka.stream.scaladsl.Flow
import akka.stream.scaladsl.StreamTcp import akka.stream.scaladsl.{ Tcp StreamTcp }
import akka.util.ByteString import akka.util.ByteString
import org.reactivestreams.Subscriber import org.reactivestreams.Subscriber
import akka.stream.ConnectionException import akka.stream.ConnectionException

View file

@ -19,12 +19,12 @@ import akka.util.ByteString
import akka.japi.Util.immutableSeq import akka.japi.Util.immutableSeq
import akka.io.Inet.SocketOption import akka.io.Inet.SocketOption
object StreamTcp extends ExtensionId[StreamTcp] with ExtensionIdProvider { object Tcp extends ExtensionId[Tcp] with ExtensionIdProvider {
/** /**
* Represents a prospective TCP server binding. * Represents a prospective TCP server binding.
*/ */
class ServerBinding private[akka] (delegate: scaladsl.StreamTcp.ServerBinding) { class ServerBinding private[akka] (delegate: scaladsl.Tcp.ServerBinding) {
/** /**
* The local address of the endpoint bound by the materialization of the `connections` [[Source]]. * The local address of the endpoint bound by the materialization of the `connections` [[Source]].
*/ */
@ -42,7 +42,7 @@ object StreamTcp extends ExtensionId[StreamTcp] with ExtensionIdProvider {
/** /**
* Represents an accepted incoming TCP connection. * Represents an accepted incoming TCP connection.
*/ */
class IncomingConnection private[akka] (delegate: scaladsl.StreamTcp.IncomingConnection) { class IncomingConnection private[akka] (delegate: scaladsl.Tcp.IncomingConnection) {
/** /**
* The local address this connection is bound to. * The local address this connection is bound to.
*/ */
@ -72,7 +72,7 @@ object StreamTcp extends ExtensionId[StreamTcp] with ExtensionIdProvider {
/** /**
* Represents a prospective outgoing TCP connection. * Represents a prospective outgoing TCP connection.
*/ */
class OutgoingConnection private[akka] (delegate: scaladsl.StreamTcp.OutgoingConnection) { class OutgoingConnection private[akka] (delegate: scaladsl.Tcp.OutgoingConnection) {
/** /**
* The remote address this connection is or will be bound to. * The remote address this connection is or will be bound to.
*/ */
@ -84,21 +84,21 @@ object StreamTcp extends ExtensionId[StreamTcp] with ExtensionIdProvider {
def localAddress: InetSocketAddress = delegate.localAddress def localAddress: InetSocketAddress = delegate.localAddress
} }
override def get(system: ActorSystem): StreamTcp = super.get(system) override def get(system: ActorSystem): Tcp = super.get(system)
def lookup() = StreamTcp def lookup() = Tcp
def createExtension(system: ExtendedActorSystem): StreamTcp = new StreamTcp(system) def createExtension(system: ExtendedActorSystem): Tcp = new Tcp(system)
} }
class StreamTcp(system: ExtendedActorSystem) extends akka.actor.Extension { class Tcp(system: ExtendedActorSystem) extends akka.actor.Extension {
import StreamTcp._ import Tcp._
import akka.dispatch.ExecutionContexts.{ sameThreadExecutionContext ec } import akka.dispatch.ExecutionContexts.{ sameThreadExecutionContext ec }
private lazy val delegate: scaladsl.StreamTcp = scaladsl.StreamTcp(system) private lazy val delegate: scaladsl.Tcp = scaladsl.Tcp(system)
/** /**
* Creates a [[StreamTcp.ServerBinding]] instance which represents a prospective TCP server binding on the given `endpoint`. * Creates a [[Tcp.ServerBinding]] instance which represents a prospective TCP server binding on the given `endpoint`.
*/ */
def bind(interface: String, def bind(interface: String,
port: Int, port: Int,
@ -110,7 +110,7 @@ class StreamTcp(system: ExtendedActorSystem) extends akka.actor.Extension {
.mapMaterialized(_.map(new ServerBinding(_))(ec))) .mapMaterialized(_.map(new ServerBinding(_))(ec)))
/** /**
* Creates a [[StreamTcp.ServerBinding]] without specifying options. * Creates a [[Tcp.ServerBinding]] without specifying options.
* It represents a prospective TCP server binding on the given `endpoint`. * It represents a prospective TCP server binding on the given `endpoint`.
*/ */
def bind(interface: String, port: Int): Source[IncomingConnection, Future[ServerBinding]] = def bind(interface: String, port: Int): Source[IncomingConnection, Future[ServerBinding]] =
@ -119,7 +119,7 @@ class StreamTcp(system: ExtendedActorSystem) extends akka.actor.Extension {
.mapMaterialized(_.map(new ServerBinding(_))(ec))) .mapMaterialized(_.map(new ServerBinding(_))(ec)))
/** /**
* Creates an [[StreamTcp.OutgoingConnection]] instance representing a prospective TCP client connection to the given endpoint. * Creates an [[Tcp.OutgoingConnection]] instance representing a prospective TCP client connection to the given endpoint.
*/ */
def outgoingConnection(remoteAddress: InetSocketAddress, def outgoingConnection(remoteAddress: InetSocketAddress,
localAddress: Option[InetSocketAddress], localAddress: Option[InetSocketAddress],
@ -130,7 +130,7 @@ class StreamTcp(system: ExtendedActorSystem) extends akka.actor.Extension {
.mapMaterialized(_.map(new OutgoingConnection(_))(ec))) .mapMaterialized(_.map(new OutgoingConnection(_))(ec)))
/** /**
* Creates an [[StreamTcp.OutgoingConnection]] without specifying options. * Creates an [[Tcp.OutgoingConnection]] without specifying options.
* It represents a prospective TCP client connection to the given endpoint. * It represents a prospective TCP client connection to the given endpoint.
*/ */
def outgoingConnection(host: String, port: Int): Flow[ByteString, ByteString, Future[OutgoingConnection]] = def outgoingConnection(host: String, port: Int): Flow[ByteString, ByteString, Future[OutgoingConnection]] =

View file

@ -18,7 +18,7 @@ import akka.actor.ExtensionId
import akka.actor.ExtensionIdProvider import akka.actor.ExtensionIdProvider
import akka.actor.Props import akka.actor.Props
import akka.io.Inet.SocketOption import akka.io.Inet.SocketOption
import akka.io.Tcp import akka.io.{ Tcp IoTcp }
import akka.stream._ import akka.stream._
import akka.stream.impl._ import akka.stream.impl._
import akka.stream.impl.ReactiveStreamsCompliance._ import akka.stream.impl.ReactiveStreamsCompliance._
@ -31,7 +31,7 @@ import akka.stream.impl.io.TcpListenStreamActor
import akka.stream.impl.io.DelayedInitProcessor import akka.stream.impl.io.DelayedInitProcessor
import akka.stream.impl.io.StreamTcpManager import akka.stream.impl.io.StreamTcpManager
object StreamTcp extends ExtensionId[StreamTcp] with ExtensionIdProvider { object Tcp extends ExtensionId[Tcp] with ExtensionIdProvider {
/** /**
* * Represents a succdessful TCP server binding. * * Represents a succdessful TCP server binding.
@ -64,20 +64,20 @@ object StreamTcp extends ExtensionId[StreamTcp] with ExtensionIdProvider {
*/ */
case class OutgoingConnection(remoteAddress: InetSocketAddress, localAddress: InetSocketAddress) case class OutgoingConnection(remoteAddress: InetSocketAddress, localAddress: InetSocketAddress)
def apply()(implicit system: ActorSystem): StreamTcp = super.apply(system) def apply()(implicit system: ActorSystem): Tcp = super.apply(system)
override def get(system: ActorSystem): StreamTcp = super.get(system) override def get(system: ActorSystem): Tcp = super.get(system)
def lookup() = StreamTcp def lookup() = Tcp
def createExtension(system: ExtendedActorSystem): StreamTcp = new StreamTcp(system) def createExtension(system: ExtendedActorSystem): Tcp = new Tcp(system)
} }
class StreamTcp(system: ExtendedActorSystem) extends akka.actor.Extension { class Tcp(system: ExtendedActorSystem) extends akka.actor.Extension {
import StreamTcp._ import Tcp._
private val manager: ActorRef = system.systemActorOf(Props[StreamTcpManager] private val manager: ActorRef = system.systemActorOf(Props[StreamTcpManager]
.withDispatcher(Tcp(system).Settings.ManagementDispatcher), name = "IO-TCP-STREAM") .withDispatcher(IoTcp(system).Settings.ManagementDispatcher), name = "IO-TCP-STREAM")
private class BindSource( private class BindSource(
val endpoint: InetSocketAddress, val endpoint: InetSocketAddress,
@ -122,7 +122,7 @@ class StreamTcp(system: ExtendedActorSystem) extends akka.actor.Extension {
} }
/** /**
* Creates a [[StreamTcp.ServerBinding]] instance which represents a prospective TCP server binding on the given `endpoint`. * Creates a [[Tcp.ServerBinding]] instance which represents a prospective TCP server binding on the given `endpoint`.
*/ */
def bind(interface: String, def bind(interface: String,
port: Int, port: Int,
@ -146,7 +146,7 @@ class StreamTcp(system: ExtendedActorSystem) extends akka.actor.Extension {
} }
/** /**
* Creates an [[StreamTcp.OutgoingConnection]] instance representing a prospective TCP client connection to the given endpoint. * Creates an [[Tcp.OutgoingConnection]] instance representing a prospective TCP client connection to the given endpoint.
*/ */
def outgoingConnection(remoteAddress: InetSocketAddress, def outgoingConnection(remoteAddress: InetSocketAddress,
localAddress: Option[InetSocketAddress] = None, localAddress: Option[InetSocketAddress] = None,
@ -169,7 +169,7 @@ class StreamTcp(system: ExtendedActorSystem) extends akka.actor.Extension {
} }
/** /**
* Creates an [[StreamTcp.OutgoingConnection]] without specifying options. * Creates an [[Tcp.OutgoingConnection]] without specifying options.
* It represents a prospective TCP client connection to the given endpoint. * It represents a prospective TCP client connection to the given endpoint.
*/ */
def outgoingConnection(host: String, port: Int): Flow[ByteString, ByteString, Future[OutgoingConnection]] = def outgoingConnection(host: String, port: Int): Flow[ByteString, ByteString, Future[OutgoingConnection]] =