Interface NetworkMesh

All Superinterfaces:
com.tnsai.agents.groups.AgentGroup
All Known Implementing Classes:
DefaultNetworkMesh

public interface NetworkMesh extends com.tnsai.agents.groups.AgentGroup
A mesh network organization with peer-to-peer agent connections.

NetworkMesh extends AgentGroup with peer connection management, message routing through the mesh, and topology-based communication.

Key Features

  • Peer connections: Dynamic connect/disconnect between agents
  • Message routing: Route messages via shortest path
  • Topology: Support for full mesh, partial mesh, ring, and star
  • Broadcast: Send messages to all connected peers

Usage Example


 NetworkMesh mesh = NetworkMesh.builder()
     .name("Agent Network")
     .topology(Topology.FULL_MESH)
     .add(agent1, agent2, agent3)
     .build();

 mesh.start();
 mesh.routeMessage("agent1", "agent3", "Hello!");
 
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Broadcasts a message to all agents in the network.
    Creates a new NetworkMesh builder.
    void
    connectPeers(String agentA, String agentB)
    Connects two peers bidirectionally.
    void
    disconnectPeers(String agentA, String agentB)
    Disconnects two peers bidirectionally.
    Finds the shortest path between two agents.
    Returns the directly connected peers of an agent.
    Returns the connection manager.
    Returns the network topology.
    routeMessage(String from, String to, String message)
    Routes a message from one agent to another through the mesh.

    Methods inherited from interface com.tnsai.agents.groups.AgentGroup

    addLifecycleListener, addMember, addMembershipListener, assignTask, broadcast, broadcast, dissolve, electLeader, electLeader, findMembers, getDescription, getEventBus, getId, getLeader, getLifecycle, getMember, getMemberCount, getMembers, getMembershipManager, getMetrics, getName, getPolicy, hasMember, isActive, isDissolved, removeLifecycleListener, removeMember, removeMembershipListener, scatter, scatter, scatterAsync, setPolicy, start, stop, stopNow
  • Method Details

    • getTopology

      Topology getTopology()
      Returns the network topology.
      Returns:
      topology type
    • connectPeers

      void connectPeers(String agentA, String agentB)
      Connects two peers bidirectionally.
      Parameters:
      agentA - first agent ID
      agentB - second agent ID
      Throws:
      IllegalArgumentException - if either agent is not a member
    • disconnectPeers

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

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

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

      NetworkMeshResult routeMessage(String from, String to, String message)
      Routes a message from one agent to another through the mesh.
      Parameters:
      from - source agent ID
      to - target agent ID
      message - message content
      Returns:
      routing result
    • broadcastMessage

      NetworkMeshResult broadcastMessage(String message)
      Broadcasts a message to all agents in the network.
      Parameters:
      message - message content
      Returns:
      broadcast result with all responses
    • getConnections

      DynamicConnections getConnections()
      Returns the connection manager.
      Returns:
      dynamic connections
    • builder

      static NetworkMeshBuilder builder()
      Creates a new NetworkMesh builder.
      Returns:
      builder