Class DefaultHubSpoke
java.lang.Object
com.tnsai.coordination.groups.DefaultAgentGroup
com.tnsai.coordination.groups.hubspoke.DefaultHubSpoke
- All Implemented Interfaces:
com.tnsai.agents.groups.AgentGroup,HubSpoke
Default implementation of HubSpoke.
Provides a centralized hub-spoke organization with load-balanced task distribution to spoke agents.
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultHubSpoke(String id, String name, String description, com.tnsai.agents.groups.GroupPolicy policy, LoadBalancer.Strategy loadBalancerStrategy) Creates a new DefaultHubSpoke. -
Method Summary
Modifier and TypeMethodDescriptionOptional<com.tnsai.agents.Agent> getHub()Returns the hub agent.Returns the load balancer.Returns the current load distribution across spokes.List<com.tnsai.agents.Agent> Returns all spoke agents.voidpromoteToHub(String agentId) Promotes a spoke agent to hub, making the current hub a spoke.routeToSpoke(String task) Routes a task to an available spoke via the load balancer.voidsetHub(com.tnsai.agents.Agent agent) Sets the hub agent.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, removeMember, 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, removeMember, removeMembershipListener, scatter, scatter, scatterAsync, setPolicy, start, stop, stopNow
-
Constructor Details
-
DefaultHubSpoke
public DefaultHubSpoke(String id, String name, String description, com.tnsai.agents.groups.GroupPolicy policy, LoadBalancer.Strategy loadBalancerStrategy) Creates a new DefaultHubSpoke.- Parameters:
id- hub-spoke IDname- hub-spoke namedescription- hub-spoke descriptionpolicy- group policyloadBalancerStrategy- load balancing strategy
-
-
Method Details
-
getHub
Description copied from interface:HubSpokeReturns the hub agent. -
getSpokes
Description copied from interface:HubSpokeReturns all spoke agents. -
setHub
public void setHub(com.tnsai.agents.Agent agent) Description copied from interface:HubSpokeSets the hub agent. Agent must already be a member. -
promoteToHub
Description copied from interface:HubSpokePromotes a spoke agent to hub, making the current hub a spoke.- Specified by:
promoteToHubin interfaceHubSpoke- Parameters:
agentId- agent ID to promote
-
routeToSpoke
Description copied from interface:HubSpokeRoutes a task to an available spoke via the load balancer.- Specified by:
routeToSpokein interfaceHubSpoke- Parameters:
task- task to route- Returns:
- routing result
-
getLoadDistribution
Description copied from interface:HubSpokeReturns the current load distribution across spokes.- Specified by:
getLoadDistributionin interfaceHubSpoke- Returns:
- map of spoke ID to current task count
-
getLoadBalancer
Description copied from interface:HubSpokeReturns the load balancer.- Specified by:
getLoadBalancerin interfaceHubSpoke- Returns:
- load balancer
-
toString
- Overrides:
toStringin classDefaultAgentGroup
-