Class TestTransport.AssociationRegistry
- java.lang.Object
-
- org.apache.pekko.remote.transport.TestTransport.AssociationRegistry
-
- Enclosing class:
- TestTransport
public static class TestTransport.AssociationRegistry extends java.lang.Object
Shared state amongpekko.remote.transport.TestTransport
instances. Coordinates the transports and the means of communication between them.
-
-
Constructor Summary
Constructors Constructor Description AssociationRegistry()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearLog()
Clears the activity log.scala.Option<scala.Tuple2<AssociationHandle.HandleEventListener,AssociationHandle.HandleEventListener>>
deregisterAssociation(scala.Tuple2<Address,Address> key)
Removes an association.boolean
existsAssociation(Address initiatorAddress, Address remoteAddress)
Tests if an association was registered.scala.Option<AssociationHandle.HandleEventListener>
getRemoteReadHandlerFor(TestAssociationHandle localHandle)
Returns the event handler corresponding to the remote endpoint of the given local handle.void
logActivity(TestTransport.Activity activity)
Logs a transport activity.scala.collection.immutable.Seq<TestTransport.Activity>
logSnapshot()
Takes a thread-safe snapshot of the current state of the activity log.void
registerListenerPair(scala.Tuple2<Address,Address> key, scala.Tuple2<AssociationHandle.HandleEventListener,AssociationHandle.HandleEventListener> listeners)
Registers a Future of two handle event listeners corresponding to the two endpoints of an association.void
registerTransport(TestTransport transport, scala.concurrent.Future<Transport.AssociationEventListener> associationEventListenerFuture)
Records a mapping between an address and the corresponding (transport, associationEventListener) pair.AssociationHandle.HandleEventListener
remoteListenerRelativeTo(TestAssociationHandle handle, scala.Tuple2<AssociationHandle.HandleEventListener,AssociationHandle.HandleEventListener> listenerPair)
Returns the remote endpoint for a pair of endpoints relative to the owner of the supplied handle.void
reset()
Resets the state of the registry.scala.Option<scala.Tuple2<TestTransport,scala.concurrent.Future<Transport.AssociationEventListener>>>
transportFor(Address address)
Returns the Transport bound to the given address.boolean
transportsReady(scala.collection.immutable.Seq<Address> addresses)
Indicates if all given transports were successfully registered.
-
-
-
Method Detail
-
clearLog
public void clearLog()
Clears the activity log.
-
deregisterAssociation
public scala.Option<scala.Tuple2<AssociationHandle.HandleEventListener,AssociationHandle.HandleEventListener>> deregisterAssociation(scala.Tuple2<Address,Address> key)
Removes an association.- Parameters:
key
- Ordered pair of addresses representing an association. First element is the address of the initiator.- Returns:
- The original entries.
-
existsAssociation
public boolean existsAssociation(Address initiatorAddress, Address remoteAddress)
Tests if an association was registered.- Parameters:
initiatorAddress
- The initiator of the association.remoteAddress
- The other address of the association.- Returns:
- True if there is an association for the given addresses.
-
getRemoteReadHandlerFor
public scala.Option<AssociationHandle.HandleEventListener> getRemoteReadHandlerFor(TestAssociationHandle localHandle)
Returns the event handler corresponding to the remote endpoint of the given local handle. In other words it returns the listener that will receive InboundPayload events when
is called on the given handle. @param localHandle The handle @return The option that contains the Future for the listener if exists.write()
-
logActivity
public void logActivity(TestTransport.Activity activity)
Logs a transport activity.- Parameters:
activity
- Activity to be logged.
-
logSnapshot
public scala.collection.immutable.Seq<TestTransport.Activity> logSnapshot()
Takes a thread-safe snapshot of the current state of the activity log.- Returns:
- Collection containing activities ordered left-to-right according to time (first element is earliest).
-
registerListenerPair
public void registerListenerPair(scala.Tuple2<Address,Address> key, scala.Tuple2<AssociationHandle.HandleEventListener,AssociationHandle.HandleEventListener> listeners)
Registers a Future of two handle event listeners corresponding to the two endpoints of an association.- Parameters:
key
- Ordered pair of addresses representing an association. First element must be the address of the initiator.listeners
- The future containing the listeners that will be responsible for handling the events of the two endpoints of the association. Elements in the pair must be in the same order as the addresses in the key parameter.
-
registerTransport
public void registerTransport(TestTransport transport, scala.concurrent.Future<Transport.AssociationEventListener> associationEventListenerFuture)
Records a mapping between an address and the corresponding (transport, associationEventListener) pair.- Parameters:
transport
- The transport that is to be registered. The address of this transport will be used as key.associationEventListenerFuture
- The future that will be completed with the listener that will handle the events for the given transport.
-
remoteListenerRelativeTo
public AssociationHandle.HandleEventListener remoteListenerRelativeTo(TestAssociationHandle handle, scala.Tuple2<AssociationHandle.HandleEventListener,AssociationHandle.HandleEventListener> listenerPair)
Returns the remote endpoint for a pair of endpoints relative to the owner of the supplied handle.- Parameters:
handle
- the reference handle to determine the remote endpoint relative tolistenerPair
- pair of listeners in initiator, receiver order.- Returns:
-
reset
public void reset()
Resets the state of the registry. ''Warning!'' This method is not atomic.
-
transportFor
public scala.Option<scala.Tuple2<TestTransport,scala.concurrent.Future<Transport.AssociationEventListener>>> transportFor(Address address)
Returns the Transport bound to the given address.- Parameters:
address
- The address bound to the transport.- Returns:
- The transport if exists.
-
transportsReady
public boolean transportsReady(scala.collection.immutable.Seq<Address> addresses)
Indicates if all given transports were successfully registered. No associations can be established between transports that are not yet registered.- Parameters:
addresses
- The listen addresses of transports that participate in the test case.- Returns:
- True if all transports are successfully registered.
-
-