Class DynamicConnections

java.lang.Object
com.tnsai.coordination.groups.network.DynamicConnections

public class DynamicConnections extends Object
Manages dynamic peer-to-peer connections in a network mesh.

Thread-safe connection management with shortest path finding.

  • Constructor Details

    • DynamicConnections

      public DynamicConnections()
  • Method Details

    • connect

      public void connect(String agentA, String agentB)
      Connects two peers bidirectionally.
      Parameters:
      agentA - first agent ID
      agentB - second agent ID
    • disconnect

      public void disconnect(String agentA, String agentB)
      Disconnects two peers bidirectionally.
      Parameters:
      agentA - first agent ID
      agentB - second agent ID
    • getConnectedPeers

      public Set<String> getConnectedPeers(String agentId)
      Returns the connected peers of an agent.
      Parameters:
      agentId - agent ID
      Returns:
      set of connected peer IDs
    • isConnected

      public boolean isConnected(String agentA, String agentB)
      Checks if two agents are directly connected.
      Parameters:
      agentA - first agent
      agentB - second agent
      Returns:
      true if directly connected
    • findShortestPath

      public List<String> findShortestPath(String from, String to)
      Finds the shortest path between two agents using BFS.
      Parameters:
      from - source agent ID
      to - target agent ID
      Returns:
      list of agent IDs forming the path, or empty if no path exists
    • removeAgent

      public void removeAgent(String agentId)
      Removes an agent and all its connections.
      Parameters:
      agentId - agent to remove
    • getConnectionCount

      public int getConnectionCount()
      Returns the total number of connections.
      Returns:
      connection count (each bidirectional connection counted once)