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 interface
Represents a binding.static interface
Represents a connection to a remote instance. -
Method Summary
Modifier and TypeMethodDescriptionGets aList<InstanceConnectionService.InstanceConnection>
representing all active connections.Gets theInstanceId
for thisInstanceConnectionService
.Returns the local control address.openBinding
(NodeId nodeId) Gets anInstanceConnectionService.InstanceBinding
which a node can then use to receive incoming data.void
refresh()
Forces a refresh from the latest source of data immediately.void
start()
Starts the service.void
stop()
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.InstanceConnection
s are added and stale ones removed immediately. All necessary events will be driven as part of this call. -
getInstanceId
InstanceId getInstanceId()Gets theInstanceId
for thisInstanceConnectionService
.- Returns:
- the
InstanceId
-
openBinding
Gets anInstanceConnectionService.InstanceBinding
which 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
- theNodeId
for 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.InstanceConnection
s
-
subscribeToConnect
Adds aConsumer<InstanceConnectionService.InstanceConnection>
that will be called when a new instance has connected to thisInstanceConnectionService
.- Parameters:
onConnect
- theConsumer<InstanceConnectionService.InstanceConnection>
- Returns:
- a
Subscription
that 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
Subscription
that 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.
-