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

public class DefaultHubSpoke extends DefaultAgentGroup implements HubSpoke
Default implementation of HubSpoke.

Provides a centralized hub-spoke organization with load-balanced task distribution to spoke agents.

  • 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 ID
      name - hub-spoke name
      description - hub-spoke description
      policy - group policy
      loadBalancerStrategy - load balancing strategy
  • Method Details

    • getHub

      public Optional<com.tnsai.agents.Agent> getHub()
      Description copied from interface: HubSpoke
      Returns the hub agent.
      Specified by:
      getHub in interface HubSpoke
      Returns:
      hub agent, or empty if not set
    • getSpokes

      public List<com.tnsai.agents.Agent> getSpokes()
      Description copied from interface: HubSpoke
      Returns all spoke agents.
      Specified by:
      getSpokes in interface HubSpoke
      Returns:
      list of spoke agents
    • setHub

      public void setHub(com.tnsai.agents.Agent agent)
      Description copied from interface: HubSpoke
      Sets the hub agent. Agent must already be a member.
      Specified by:
      setHub in interface HubSpoke
      Parameters:
      agent - hub agent
    • promoteToHub

      public void promoteToHub(String agentId)
      Description copied from interface: HubSpoke
      Promotes a spoke agent to hub, making the current hub a spoke.
      Specified by:
      promoteToHub in interface HubSpoke
      Parameters:
      agentId - agent ID to promote
    • routeToSpoke

      public HubSpokeResult routeToSpoke(String task)
      Description copied from interface: HubSpoke
      Routes a task to an available spoke via the load balancer.
      Specified by:
      routeToSpoke in interface HubSpoke
      Parameters:
      task - task to route
      Returns:
      routing result
    • getLoadDistribution

      public Map<String,Integer> getLoadDistribution()
      Description copied from interface: HubSpoke
      Returns the current load distribution across spokes.
      Specified by:
      getLoadDistribution in interface HubSpoke
      Returns:
      map of spoke ID to current task count
    • getLoadBalancer

      public LoadBalancer getLoadBalancer()
      Description copied from interface: HubSpoke
      Returns the load balancer.
      Specified by:
      getLoadBalancer in interface HubSpoke
      Returns:
      load balancer
    • toString

      public String toString()
      Overrides:
      toString in class DefaultAgentGroup