Package akka.io
Class TcpConnection
- java.lang.Object
-
- akka.io.TcpConnection
-
- All Implemented Interfaces:
Actor
,ActorLogging
,RequiresMessageQueue<UnboundedMessageQueueSemantics>
- Direct Known Subclasses:
TcpIncomingConnection
,TcpOutgoingConnection
public abstract class TcpConnection extends java.lang.Object implements Actor, ActorLogging, RequiresMessageQueue<UnboundedMessageQueueSemantics>
connection established, waiting for registration from user handler
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TcpConnection.AllRead$
static class
TcpConnection.CloseInformation
static class
TcpConnection.CloseInformation$
static class
TcpConnection.ConnectionInfo
static class
TcpConnection.ConnectionInfo$
static class
TcpConnection.EmptyPendingWrite$
static class
TcpConnection.EndOfStream$
static class
TcpConnection.MoreDataWaiting$
class
TcpConnection.PendingBufferWrite
static class
TcpConnection.PendingWrite
class
TcpConnection.PendingWriteFile
static interface
TcpConnection.ReadResult
static class
TcpConnection.Unregistered$
static class
TcpConnection.UpdatePendingWriteAndThen
static class
TcpConnection.UpdatePendingWriteAndThen$
static class
TcpConnection.WriteFileFailed
static class
TcpConnection.WriteFileFailed$
-
Nested classes/interfaces inherited from interface akka.actor.Actor
Actor.emptyBehavior$, Actor.ignoringBehavior$
-
-
Constructor Summary
Constructors Constructor Description TcpConnection(TcpExt tcp, java.nio.channels.SocketChannel channel, boolean pullMode)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
akka$actor$Actor$_setter_$context_$eq(ActorContext x$1)
protected void
akka$actor$Actor$_setter_$self_$eq(ActorRef x$1)
The 'self' field holds the ActorRef for this actor.java.nio.channels.SocketChannel
channel()
Tcp.ConnectionClosed
closeReason()
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit>
closing(TcpConnection.ConnectionInfo info, scala.Option<ActorRef> closeCommander)
connection is closed on our side and we're waiting from confirmation from the other sidescala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit>
closingWithPendingWrite(TcpConnection.ConnectionInfo info, scala.Option<ActorRef> closeCommander, Tcp.ConnectionClosed closedEvent)
connection is closing but a write has to be finished firstvoid
completeConnect(ChannelRegistration registration, ActorRef commander, scala.collection.immutable.Iterable<Inet.SocketOption> options)
used in subclasses to start the common machinery above once a channel is connectedscala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit>
connected(TcpConnection.ConnectionInfo info)
normal connected stateActorContext
context()
Scala API: Stores the context for this actor, including self, and sender.void
doCloseConnection(ActorRef handler, scala.Option<ActorRef> closeCommander, Tcp.ConnectionClosed closedEvent)
static scala.Function0<scala.runtime.BoxedUnit>
doNothing()
void
doRead(TcpConnection.ConnectionInfo info, scala.Option<ActorRef> closeCommander)
Read from the channel and potentially send outReceived
message to handler.void
doWrite(TcpConnection.ConnectionInfo info)
static java.io.IOException
DroppingWriteBecauseQueueIsFullException()
static java.io.IOException
DroppingWriteBecauseWritingIsSuspendedException()
void
handleClose(TcpConnection.ConnectionInfo info, scala.Option<ActorRef> closeCommander, Tcp.ConnectionClosed closedEvent)
void
handleError(ActorRef handler, java.io.IOException exception)
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit>
handleWriteMessages(TcpConnection.ConnectionInfo info)
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit>
peerSentEOF(TcpConnection.ConnectionInfo info)
the peer sent EOF first, but we may still want to sendTcpConnection.PendingBufferWrite
PendingBufferWrite(ActorRef commander, ByteString data, Tcp.Event ack, Tcp.WriteCommand tail)
TcpConnection.PendingWrite
PendingWrite(ActorRef commander, Tcp.WriteCommand write)
TcpConnection.PendingWriteFile
PendingWriteFile(ActorRef commander, java.nio.file.Path filePath, long offset, long count, Tcp.Event ack, Tcp.WriteCommand tail)
void
postRestart(java.lang.Throwable reason)
User overridable callback: By default it callspreStart()
.void
postStop()
User overridable callback.void
prepareAbort()
boolean
pullMode()
void
resumeReading(TcpConnection.ConnectionInfo info)
boolean
safeShutdownOutput()
ActorRef
self()
The 'self' field holds the ActorRef for this actor.void
setRegistration(ChannelRegistration registration)
protected void
signDeathPact(ActorRef actor)
void
stopWith(TcpConnection.CloseInformation closeInfo, boolean shouldAbort)
boolean
stopWith$default$2()
void
suspendReading(TcpConnection.ConnectionInfo info)
TcpExt
tcp()
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit>
unregistering()
stopWith sets this state while waiting for the SelectionHandler to execute the `cancelAndClose` thunkprotected void
unsignDeathPact()
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit>
waitingForRegistration(ChannelRegistration registration, ActorRef commander)
connection established, waiting for registration from user handlerboolean
writePending()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface akka.actor.Actor
aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, preRestart, preStart, receive, sender, supervisorStrategy, unhandled
-
Methods inherited from interface akka.actor.ActorLogging
_log_$eq, log
-
-
-
-
Constructor Detail
-
TcpConnection
public TcpConnection(TcpExt tcp, java.nio.channels.SocketChannel channel, boolean pullMode)
-
-
Method Detail
-
doNothing
public static scala.Function0<scala.runtime.BoxedUnit> doNothing()
-
DroppingWriteBecauseWritingIsSuspendedException
public static java.io.IOException DroppingWriteBecauseWritingIsSuspendedException()
-
DroppingWriteBecauseQueueIsFullException
public static java.io.IOException DroppingWriteBecauseQueueIsFullException()
-
context
public ActorContext context()
Description copied from interface:Actor
Scala API: Stores the context for this actor, including self, and sender. It is implicit to support operations such asforward
.WARNING: Only valid within the Actor itself, so do not close over it and publish it to other threads!
ActorContext
is the Scala API.getContext
returns aAbstractActor.ActorContext
, which is the Java API of the actor context.
-
self
public final ActorRef self()
Description copied from interface:Actor
The 'self' field holds the ActorRef for this actor. Can be used to send messages to itself:self ! message
-
akka$actor$Actor$_setter_$context_$eq
protected void akka$actor$Actor$_setter_$context_$eq(ActorContext x$1)
- Specified by:
akka$actor$Actor$_setter_$context_$eq
in interfaceActor
-
akka$actor$Actor$_setter_$self_$eq
protected final void akka$actor$Actor$_setter_$self_$eq(ActorRef x$1)
Description copied from interface:Actor
The 'self' field holds the ActorRef for this actor. Can be used to send messages to itself:self ! message
- Specified by:
akka$actor$Actor$_setter_$self_$eq
in interfaceActor
- Parameters:
x$1
- (undocumented)
-
tcp
public TcpExt tcp()
-
channel
public java.nio.channels.SocketChannel channel()
-
pullMode
public boolean pullMode()
-
setRegistration
public void setRegistration(ChannelRegistration registration)
-
signDeathPact
protected void signDeathPact(ActorRef actor)
-
unsignDeathPact
protected void unsignDeathPact()
-
writePending
public boolean writePending()
-
waitingForRegistration
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> waitingForRegistration(ChannelRegistration registration, ActorRef commander)
connection established, waiting for registration from user handler
-
connected
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> connected(TcpConnection.ConnectionInfo info)
normal connected state
-
peerSentEOF
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> peerSentEOF(TcpConnection.ConnectionInfo info)
the peer sent EOF first, but we may still want to send
-
closingWithPendingWrite
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> closingWithPendingWrite(TcpConnection.ConnectionInfo info, scala.Option<ActorRef> closeCommander, Tcp.ConnectionClosed closedEvent)
connection is closing but a write has to be finished first
-
closing
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> closing(TcpConnection.ConnectionInfo info, scala.Option<ActorRef> closeCommander)
connection is closed on our side and we're waiting from confirmation from the other side
-
handleWriteMessages
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> handleWriteMessages(TcpConnection.ConnectionInfo info)
-
unregistering
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> unregistering()
stopWith sets this state while waiting for the SelectionHandler to execute the `cancelAndClose` thunk
-
completeConnect
public void completeConnect(ChannelRegistration registration, ActorRef commander, scala.collection.immutable.Iterable<Inet.SocketOption> options)
used in subclasses to start the common machinery above once a channel is connected
-
suspendReading
public void suspendReading(TcpConnection.ConnectionInfo info)
-
resumeReading
public void resumeReading(TcpConnection.ConnectionInfo info)
-
doRead
public void doRead(TcpConnection.ConnectionInfo info, scala.Option<ActorRef> closeCommander)
Read from the channel and potentially send outReceived
message to handler.In some cases, this method will change the state with
context.become
.- Parameters:
info
- (undocumented)closeCommander
- (undocumented)
-
doWrite
public void doWrite(TcpConnection.ConnectionInfo info)
-
closeReason
public Tcp.ConnectionClosed closeReason()
-
handleClose
public void handleClose(TcpConnection.ConnectionInfo info, scala.Option<ActorRef> closeCommander, Tcp.ConnectionClosed closedEvent)
-
doCloseConnection
public void doCloseConnection(ActorRef handler, scala.Option<ActorRef> closeCommander, Tcp.ConnectionClosed closedEvent)
-
handleError
public void handleError(ActorRef handler, java.io.IOException exception)
-
safeShutdownOutput
public boolean safeShutdownOutput()
-
prepareAbort
public void prepareAbort()
-
stopWith
public void stopWith(TcpConnection.CloseInformation closeInfo, boolean shouldAbort)
-
stopWith$default$2
public boolean stopWith$default$2()
-
postStop
public void postStop()
Description copied from interface:Actor
User overridable callback. Is called asynchronously after 'actor.stop()' is invoked. Empty default implementation.
-
postRestart
public void postRestart(java.lang.Throwable reason)
Description copied from interface:Actor
User overridable callback: By default it callspreStart()
.- Specified by:
postRestart
in interfaceActor
- Parameters:
reason
- the Throwable that caused the restart to happen Is called right AFTER restart on the newly created Actor to allow reinitialization after an Actor crash.
-
PendingWrite
public TcpConnection.PendingWrite PendingWrite(ActorRef commander, Tcp.WriteCommand write)
-
PendingBufferWrite
public TcpConnection.PendingBufferWrite PendingBufferWrite(ActorRef commander, ByteString data, Tcp.Event ack, Tcp.WriteCommand tail)
-
PendingWriteFile
public TcpConnection.PendingWriteFile PendingWriteFile(ActorRef commander, java.nio.file.Path filePath, long offset, long count, Tcp.Event ack, Tcp.WriteCommand tail)
-
-