Interface InstanceConnectionService
- All Known Implementing Classes:
JeroMQInstanceConnectionService
public interface InstanceConnectionService
The instance connection service handles the dirty details of connecting to a remote Node and keeping track of
nodes connected in the system. It is essentially the communication nexus for the rest of the system and provides
client code the ability to connect and get basic information on remote nodes.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceRepresents a binding.static interfaceRepresents a connection to a remote instance. -
Method Summary
Modifier and TypeMethodDescriptionGets aList<InstanceConnectionService.InstanceConnection>representing all active connections.Gets theInstanceIdfor thisInstanceConnectionService.Returns the local control address.openBinding(NodeId nodeId) Gets anInstanceConnectionService.InstanceBindingwhich a node can then use to receive incoming data.voidrefresh()Forces a refresh from the latest source of data immediately.voidstart()Starts the service.voidstop()Stops the service.Adds aConsumer<InstanceConnectionService.InstanceConnection>that will be called when a new instance has connected to thisInstanceConnectionService.Adds aConsumer<InstanceConnectionService.InstanceConnection>that will be called when a an instance has disconnected from thisInstanceConnectionService.
-
Method Details
-
start
void start()Starts the service. -
stop
void stop()Stops the service. -
refresh
void refresh()Forces a refresh from the latest source of data immediately. This will ensure that newInstanceConnectionService.InstanceConnections are added and stale ones removed immediately. All necessary events will be driven as part of this call. -
getInstanceId
InstanceId getInstanceId()Gets theInstanceIdfor thisInstanceConnectionService.- Returns:
- the
InstanceId
-
openBinding
Gets anInstanceConnectionService.InstanceBindingwhich a node can then use to receive incoming data. If a binding already exists for the suppliedNodeId, then an exception will be thrown.- Parameters:
nodeId- theNodeIdfor which the binding will be used.- Returns:
- the
InstanceConnectionService.InstanceBinding
-
getActiveConnections
List<InstanceConnectionService.InstanceConnection> getActiveConnections()Gets aList<InstanceConnectionService.InstanceConnection>representing all active connections.- Returns:
- the list of all active
InstanceConnectionService.InstanceConnections
-
subscribeToConnect
Adds aConsumer<InstanceConnectionService.InstanceConnection>that will be called when a new instance has connected to thisInstanceConnectionService.- Parameters:
onConnect- theConsumer<InstanceConnectionService.InstanceConnection>- Returns:
- a
Subscriptionthat can be cancled later.
-
subscribeToDisconnect
Subscription subscribeToDisconnect(Consumer<InstanceConnectionService.InstanceConnection> onDisconnect) Adds aConsumer<InstanceConnectionService.InstanceConnection>that will be called when a an instance has disconnected from thisInstanceConnectionService.- Parameters:
onDisconnect- theConsumer<InstanceConnectionService.InstanceConnection>- Returns:
- a
Subscriptionthat can be cancled later.
-
getLocalControlAddress
String getLocalControlAddress()Returns the local control address. This is an address through which the a control client may be used to control the instance from within the local process space.- Returns:
- the local control address.
-