Package com.tnsai.agents.groups
Record Class MembershipManager.MemberInfo
java.lang.Object
java.lang.Record
com.tnsai.agents.groups.MembershipManager.MemberInfo
- Enclosing interface:
MembershipManager
public static record MembershipManager.MemberInfo(String agentId, String agentName, List<String> capabilities, Instant joinedAt, Instant lastHeartbeat, MembershipManager.MemberHealth health, Map<String,Object> metadata, int priority, int maxConcurrentTasks, int activeTasks, String role)
extends Record
Information about a group member.
-
Constructor Summary
ConstructorsConstructorDescriptionMemberInfo(String agentId, String agentName, List<String> capabilities, Instant joinedAt, Instant lastHeartbeat, MembershipManager.MemberHealth health, Map<String, Object> metadata) Creates MemberInfo with defaults for priority/concurrency.MemberInfo(String agentId, String agentName, List<String> capabilities, Instant joinedAt, Instant lastHeartbeat, MembershipManager.MemberHealth health, Map<String, Object> metadata, int priority, int maxConcurrentTasks, int activeTasks, String role) Creates an instance of aMemberInforecord class. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of theactiveTasksrecord component.agentId()Returns the value of theagentIdrecord component.Returns the value of theagentNamerecord component.booleanChecks if this member can accept more tasks.Returns the value of thecapabilitiesrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.health()Returns the value of thehealthrecord component.booleanjoinedAt()Returns the value of thejoinedAtrecord component.Returns the value of thelastHeartbeatrecord component.intReturns the value of themaxConcurrentTasksrecord component.metadata()Returns the value of themetadatarecord component.intpriority()Returns the value of thepriorityrecord component.role()Returns the value of therolerecord component.final StringtoString()Returns a string representation of this record class.withHealth(MembershipManager.MemberHealth newHealth) Returns a new MemberInfo with updated health.withHeartbeat(Instant newHeartbeat) Returns a new MemberInfo with updated heartbeat.Returns a new MemberInfo with decremented active tasks.Returns a new MemberInfo with incremented active tasks.
-
Constructor Details
-
MemberInfo
public MemberInfo(String agentId, String agentName, List<String> capabilities, Instant joinedAt, Instant lastHeartbeat, MembershipManager.MemberHealth health, Map<String, Object> metadata) Creates MemberInfo with defaults for priority/concurrency. -
MemberInfo
public MemberInfo(String agentId, String agentName, List<String> capabilities, Instant joinedAt, Instant lastHeartbeat, MembershipManager.MemberHealth health, Map<String, Object> metadata, int priority, int maxConcurrentTasks, int activeTasks, String role) Creates an instance of aMemberInforecord class.- Parameters:
agentId- the value for theagentIdrecord componentagentName- the value for theagentNamerecord componentcapabilities- the value for thecapabilitiesrecord componentjoinedAt- the value for thejoinedAtrecord componentlastHeartbeat- the value for thelastHeartbeatrecord componenthealth- the value for thehealthrecord componentmetadata- the value for themetadatarecord componentpriority- the value for thepriorityrecord componentmaxConcurrentTasks- the value for themaxConcurrentTasksrecord componentactiveTasks- the value for theactiveTasksrecord componentrole- the value for therolerecord component
-
-
Method Details
-
isHealthy
public boolean isHealthy() -
getMembershipDuration
-
canAcceptTask
public boolean canAcceptTask()Checks if this member can accept more tasks.- Returns:
- true if activeTasks invalid input: '<' maxConcurrentTasks
-
withTaskStarted
Returns a new MemberInfo with incremented active tasks.- Returns:
- new MemberInfo with activeTasks + 1
-
withTaskCompleted
Returns a new MemberInfo with decremented active tasks.- Returns:
- new MemberInfo with activeTasks - 1
-
withHeartbeat
Returns a new MemberInfo with updated heartbeat.- Parameters:
newHeartbeat- new heartbeat time- Returns:
- new MemberInfo
-
withHealth
Returns a new MemberInfo with updated health.- Parameters:
newHealth- new health status- Returns:
- new MemberInfo
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
agentId
Returns the value of theagentIdrecord component.- Returns:
- the value of the
agentIdrecord component
-
agentName
Returns the value of theagentNamerecord component.- Returns:
- the value of the
agentNamerecord component
-
capabilities
Returns the value of thecapabilitiesrecord component.- Returns:
- the value of the
capabilitiesrecord component
-
joinedAt
Returns the value of thejoinedAtrecord component.- Returns:
- the value of the
joinedAtrecord component
-
lastHeartbeat
Returns the value of thelastHeartbeatrecord component.- Returns:
- the value of the
lastHeartbeatrecord component
-
health
Returns the value of thehealthrecord component.- Returns:
- the value of the
healthrecord component
-
metadata
Returns the value of themetadatarecord component.- Returns:
- the value of the
metadatarecord component
-
priority
public int priority()Returns the value of thepriorityrecord component.- Returns:
- the value of the
priorityrecord component
-
maxConcurrentTasks
public int maxConcurrentTasks()Returns the value of themaxConcurrentTasksrecord component.- Returns:
- the value of the
maxConcurrentTasksrecord component
-
activeTasks
public int activeTasks()Returns the value of theactiveTasksrecord component.- Returns:
- the value of the
activeTasksrecord component
-
role
Returns the value of therolerecord component.- Returns:
- the value of the
rolerecord component
-