akka.remote.transport
Interface AssociationHandle

All Known Implementing Classes:
AbstractTransportAdapterHandle, AkkaProtocolHandle, FailureInjectorHandle, TcpAssociationHandle, TestAssociationHandle, ThrottlerHandle, UdpAssociationHandle

public interface AssociationHandle

An SPI layer for abstracting over logical links (associations) created by a Transport. Handles are responsible for providing an API for sending and receiving from the underlying channel.

To register a listener for processing incoming payload data, the listener must be registered by completing the Promise returned by readHandlerPromise(). Incoming data is not processed until this registration takes place.


Nested Class Summary
static class AssociationHandle.ActorHandleEventListener
          Class to convert ordinary ActorRef instances to a HandleEventListener.
static class AssociationHandle.ActorHandleEventListener$
           
static class AssociationHandle.Disassociated
          Message sent to the listener registered to an association
static class AssociationHandle.Disassociated$
           
static interface AssociationHandle.DisassociateInfo
          Supertype of possible disassociation reasons
static interface AssociationHandle.HandleEvent
          Trait for events that the registered listener for an AssociationHandle might receive.
static interface AssociationHandle.HandleEventListener
          An interface that needs to be implemented by the user of an AssociationHandle to listen to association events.
static class AssociationHandle.InboundPayload
          Message sent to the listener registered to an association (via the Promise returned by akka.remote.transport.AssociationHandle.readHandlerPromise) when an inbound payload arrives.
static class AssociationHandle.InboundPayload$
           
static class AssociationHandle.Quarantined$
           
static class AssociationHandle.Shutdown$
           
static class AssociationHandle.Unknown$
           
 
Method Summary
 void disassociate()
          Closes the underlying transport link, if needed.
 Address localAddress()
          Address of the local endpoint.
 scala.concurrent.Promise<AssociationHandle.HandleEventListener> readHandlerPromise()
          The Promise returned by this call must be completed with an AssociationHandle.HandleEventListener to register a listener responsible for handling incoming payload.
 Address remoteAddress()
          Address of the remote endpoint.
 boolean write(ByteString payload)
          Asynchronously sends the specified payload to the remote endpoint.
 

Method Detail

localAddress

Address localAddress()
Address of the local endpoint.

Returns:
Address of the local endpoint.

remoteAddress

Address remoteAddress()
Address of the remote endpoint.

Returns:
Address of the remote endpoint.

readHandlerPromise

scala.concurrent.Promise<AssociationHandle.HandleEventListener> readHandlerPromise()
The Promise returned by this call must be completed with an AssociationHandle.HandleEventListener to register a listener responsible for handling incoming payload. Until the listener is not registered the transport SHOULD buffer incoming messages.

Returns:
Promise that must be completed with the listener responsible for handling incoming data.

write

boolean write(ByteString payload)
Asynchronously sends the specified payload to the remote endpoint. This method MUST be thread-safe as it might be called from different threads. This method MUST NOT block.

Writes guarantee ordering of messages, but not their reception. The call to write returns with a Boolean indicating if the channel was ready for writes or not. A return value of false indicates that the channel is not yet ready for delivery (e.g.: the write buffer is full) and the sender needs to wait until the channel becomes ready again. Returning false also means that the current write was dropped (this MUST be guaranteed to ensure duplication-free delivery).

Parameters:
payload - The payload to be delivered to the remote endpoint.
Returns:
Boolean indicating the availability of the association for subsequent writes.

disassociate

void disassociate()
Closes the underlying transport link, if needed. Some transports might not need an explicit teardown (UDP) and some transports may not support it (hardware connections). Remote endpoint of the channel or connection MAY be notified, but this is not guaranteed. The Transport that provides the handle MUST guarantee that disassociate() could be called arbitrarily many times.