Package com.tnsai.coordination.lifecycle
Class GroupRecovery
java.lang.Object
com.tnsai.coordination.lifecycle.GroupRecovery
Restores a group from a previously captured checkpoint.
GroupRecovery works with GroupCheckpoint to provide
checkpoint-based recovery. It verifies that all required agents
are available and then re-adds them to the group.
Usage Example
GroupCheckpoint.Snapshot snapshot = GroupCheckpoint.load(path);
Map<String, Agent> available = Map.of("agent-1", agent1, "agent-2", agent2);
if (GroupRecovery.canRecover(snapshot, available)) {
GroupRecovery.restore(group, snapshot, available);
}
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleancanRecover(GroupCheckpoint.Snapshot snapshot, Map<String, com.tnsai.agents.Agent> availableAgents) Checks whether a snapshot can be fully recovered given the available agents.static voidrestore(DefaultAgentGroup group, GroupCheckpoint.Snapshot snapshot, Map<String, com.tnsai.agents.Agent> availableAgents) Restores a group from a checkpoint by re-adding the agents that were members at the time of the snapshot.
-
Method Details
-
restore
public static void restore(DefaultAgentGroup group, GroupCheckpoint.Snapshot snapshot, Map<String, com.tnsai.agents.Agent> availableAgents) Restores a group from a checkpoint by re-adding the agents that were members at the time of the snapshot.Only agents present in both the snapshot's member list and the available agents map will be re-added. Agents listed in the snapshot but not available will be logged as warnings and skipped.
- Parameters:
group- the group to restore members intosnapshot- the checkpoint snapshot to restore fromavailableAgents- map of agent ID to Agent instances that are available for recovery- Throws:
NullPointerException- if any argument is null
-
canRecover
public static boolean canRecover(GroupCheckpoint.Snapshot snapshot, Map<String, com.tnsai.agents.Agent> availableAgents) Checks whether a snapshot can be fully recovered given the available agents.Returns
trueonly if every member ID in the snapshot is present in the available agents map.- Parameters:
snapshot- the checkpoint snapshot to verifyavailableAgents- map of agent ID to Agent instances- Returns:
- true if all members from the snapshot are available
- Throws:
NullPointerException- if any argument is null
-