Class DefaultNetworkMesh

java.lang.Object
com.tnsai.coordination.groups.DefaultAgentGroup
com.tnsai.coordination.groups.network.DefaultNetworkMesh
All Implemented Interfaces:
com.tnsai.agents.groups.AgentGroup, NetworkMesh

public class DefaultNetworkMesh extends DefaultAgentGroup implements NetworkMesh
Default implementation of NetworkMesh.

Provides a peer-to-peer network with configurable topology, dynamic connections, and message routing through the mesh.

  • Constructor Details

    • DefaultNetworkMesh

      public DefaultNetworkMesh(String id, String name, String description, Topology topology, com.tnsai.agents.groups.GroupPolicy policy)
      Creates a new DefaultNetworkMesh.
      Parameters:
      id - mesh ID
      name - mesh name
      description - mesh description
      topology - network topology
      policy - group policy
  • Method Details

    • getTopology

      public Topology getTopology()
      Description copied from interface: NetworkMesh
      Returns the network topology.
      Specified by:
      getTopology in interface NetworkMesh
      Returns:
      topology type
    • connectPeers

      public void connectPeers(String agentA, String agentB)
      Description copied from interface: NetworkMesh
      Connects two peers bidirectionally.
      Specified by:
      connectPeers in interface NetworkMesh
      Parameters:
      agentA - first agent ID
      agentB - second agent ID
    • disconnectPeers

      public void disconnectPeers(String agentA, String agentB)
      Description copied from interface: NetworkMesh
      Disconnects two peers bidirectionally.
      Specified by:
      disconnectPeers in interface NetworkMesh
      Parameters:
      agentA - first agent ID
      agentB - second agent ID
    • getConnectedPeers

      public Set<String> getConnectedPeers(String agentId)
      Description copied from interface: NetworkMesh
      Returns the directly connected peers of an agent.
      Specified by:
      getConnectedPeers in interface NetworkMesh
      Parameters:
      agentId - agent ID
      Returns:
      set of connected peer IDs
    • findShortestPath

      public List<String> findShortestPath(String from, String to)
      Description copied from interface: NetworkMesh
      Finds the shortest path between two agents.
      Specified by:
      findShortestPath in interface NetworkMesh
      Parameters:
      from - source agent ID
      to - target agent ID
      Returns:
      list of agent IDs forming the path, or empty if no path
    • routeMessage

      public NetworkMeshResult routeMessage(String from, String to, String message)
      Description copied from interface: NetworkMesh
      Routes a message from one agent to another through the mesh.
      Specified by:
      routeMessage in interface NetworkMesh
      Parameters:
      from - source agent ID
      to - target agent ID
      message - message content
      Returns:
      routing result
    • broadcastMessage

      public NetworkMeshResult broadcastMessage(String message)
      Description copied from interface: NetworkMesh
      Broadcasts a message to all agents in the network.
      Specified by:
      broadcastMessage in interface NetworkMesh
      Parameters:
      message - message content
      Returns:
      broadcast result with all responses
    • getConnections

      public DynamicConnections getConnections()
      Description copied from interface: NetworkMesh
      Returns the connection manager.
      Specified by:
      getConnections in interface NetworkMesh
      Returns:
      dynamic connections
    • initializeTopology

      public void initializeTopology()
      Initializes connections based on the configured topology. Should be called after all members are added.
    • removeMember

      public boolean removeMember(String agentId)
      Specified by:
      removeMember in interface com.tnsai.agents.groups.AgentGroup
      Overrides:
      removeMember in class DefaultAgentGroup
    • toString

      public String toString()
      Overrides:
      toString in class DefaultAgentGroup