akka.io
Class TcpConnection

java.lang.Object
  extended by 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>

Base class for TcpIncomingConnection and TcpOutgoingConnection.

INTERNAL API


Nested Class Summary
static class TcpConnection.AllRead$
           
static class TcpConnection.CloseInformation
          Used to transport information to the postStop method to notify interested party about a connection close.
static class TcpConnection.CloseInformation$
           
static class TcpConnection.ConnectionInfo
          Groups required connection-related data that are only available once the connection has been fully established.
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.UpdatePendingWriteAndThen
           
static class TcpConnection.UpdatePendingWriteAndThen$
           
static class TcpConnection.WriteFileFailed
           
static class TcpConnection.WriteFileFailed$
           
 
Nested classes/interfaces inherited from interface akka.actor.Actor
Actor.emptyBehavior$
 
Constructor Summary
TcpConnection(TcpExt tcp, java.nio.channels.SocketChannel channel, boolean pullMode)
           
 
Method Summary
 void abort()
           
 java.nio.channels.SocketChannel channel()
           
 TcpConnection.CloseInformation closedMessage()
           
 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 side
 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
 void completeConnect(ChannelRegistration registration, ActorRef commander, scala.collection.immutable.Traversable<Inet.SocketOption> options)
          used in subclasses to start the common machinery above once a channel is connected
 scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> connected(TcpConnection.ConnectionInfo info)
          normal connected state
 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)
           
 void doWrite(TcpConnection.ConnectionInfo info)
           
 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 send
 TcpConnection.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.lang.String filePath, long offset, long count, Tcp.Event ack, Tcp.WriteCommand tail)
           
 void postRestart(java.lang.Throwable reason)
          User overridable callback: By default it calls preStart().
 void postStop()
          User overridable callback.
 boolean pullMode()
           
 void resumeReading(TcpConnection.ConnectionInfo info)
           
 boolean safeShutdownOutput()
           
 void signDeathPact(ActorRef actor)
           
 void stopWith(TcpConnection.CloseInformation closeInfo)
           
 void suspendReading(TcpConnection.ConnectionInfo info)
           
 TcpExt tcp()
           
 void unsignDeathPact()
           
 scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> waitingForRegistration(ChannelRegistration registration, ActorRef commander)
          connection established, waiting for registration from user handler
 boolean 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, context, preRestart, preStart, receive, self, sender, supervisorStrategy, unhandled
 
Methods inherited from interface akka.actor.ActorLogging
_log, 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()

tcp

public TcpExt tcp()

channel

public java.nio.channels.SocketChannel channel()

pullMode

public boolean pullMode()

closedMessage

public TcpConnection.CloseInformation closedMessage()

signDeathPact

public void signDeathPact(ActorRef actor)

unsignDeathPact

public 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)

completeConnect

public void completeConnect(ChannelRegistration registration,
                            ActorRef commander,
                            scala.collection.immutable.Traversable<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)

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()

abort

public void abort()

stopWith

public void stopWith(TcpConnection.CloseInformation closeInfo)

postStop

public void postStop()
Description copied from interface: Actor
User overridable callback.

Is called asynchronously after 'actor.stop()' is invoked. Empty default implementation.

Specified by:
postStop in interface Actor

postRestart

public void postRestart(java.lang.Throwable reason)
Description copied from interface: Actor
User overridable callback: By default it calls preStart().

Specified by:
postRestart in interface Actor
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.lang.String filePath,
                                                       long offset,
                                                       long count,
                                                       Tcp.Event ack,
                                                       Tcp.WriteCommand tail)