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
Default implementation of NetworkMesh.
Provides a peer-to-peer network with configurable topology, dynamic connections, and message routing through the mesh.
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultNetworkMesh(String id, String name, String description, Topology topology, com.tnsai.agents.groups.GroupPolicy policy) Creates a new DefaultNetworkMesh. -
Method Summary
Modifier and TypeMethodDescriptionbroadcastMessage(String message) Broadcasts a message to all agents in the network.voidconnectPeers(String agentA, String agentB) Connects two peers bidirectionally.voiddisconnectPeers(String agentA, String agentB) Disconnects two peers bidirectionally.findShortestPath(String from, String to) Finds the shortest path between two agents.getConnectedPeers(String agentId) Returns the directly connected peers of an agent.Returns the connection manager.Returns the network topology.voidInitializes connections based on the configured topology.booleanremoveMember(String agentId) routeMessage(String from, String to, String message) Routes a message from one agent to another through the mesh.toString()Methods inherited from class com.tnsai.coordination.groups.DefaultAgentGroup
addLifecycleListener, addMember, addMembershipListener, assignTask, broadcast, dissolve, electLeader, electLeader, findMembers, getDescription, getEventBus, getId, getLeader, getLifecycle, getMember, getMembers, getMembershipManager, getMetrics, getName, getPolicy, hasMember, notifyTaskComplete, notifyTaskFailed, removeLifecycleListener, removeMembershipListener, scatter, scatter, scatterAsync, setPolicy, start, stop, stopNowMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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, removeMembershipListener, scatter, scatter, scatterAsync, setPolicy, start, stop, stopNow
-
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 IDname- mesh namedescription- mesh descriptiontopology- network topologypolicy- group policy
-
-
Method Details
-
getTopology
Description copied from interface:NetworkMeshReturns the network topology.- Specified by:
getTopologyin interfaceNetworkMesh- Returns:
- topology type
-
connectPeers
Description copied from interface:NetworkMeshConnects two peers bidirectionally.- Specified by:
connectPeersin interfaceNetworkMesh- Parameters:
agentA- first agent IDagentB- second agent ID
-
disconnectPeers
Description copied from interface:NetworkMeshDisconnects two peers bidirectionally.- Specified by:
disconnectPeersin interfaceNetworkMesh- Parameters:
agentA- first agent IDagentB- second agent ID
-
getConnectedPeers
Description copied from interface:NetworkMeshReturns the directly connected peers of an agent.- Specified by:
getConnectedPeersin interfaceNetworkMesh- Parameters:
agentId- agent ID- Returns:
- set of connected peer IDs
-
findShortestPath
Description copied from interface:NetworkMeshFinds the shortest path between two agents.- Specified by:
findShortestPathin interfaceNetworkMesh- Parameters:
from- source agent IDto- target agent ID- Returns:
- list of agent IDs forming the path, or empty if no path
-
routeMessage
Description copied from interface:NetworkMeshRoutes a message from one agent to another through the mesh.- Specified by:
routeMessagein interfaceNetworkMesh- Parameters:
from- source agent IDto- target agent IDmessage- message content- Returns:
- routing result
-
broadcastMessage
Description copied from interface:NetworkMeshBroadcasts a message to all agents in the network.- Specified by:
broadcastMessagein interfaceNetworkMesh- Parameters:
message- message content- Returns:
- broadcast result with all responses
-
getConnections
Description copied from interface:NetworkMeshReturns the connection manager.- Specified by:
getConnectionsin interfaceNetworkMesh- Returns:
- dynamic connections
-
initializeTopology
public void initializeTopology()Initializes connections based on the configured topology. Should be called after all members are added. -
removeMember
- Specified by:
removeMemberin interfacecom.tnsai.agents.groups.AgentGroup- Overrides:
removeMemberin classDefaultAgentGroup
-
toString
- Overrides:
toStringin classDefaultAgentGroup
-