Class GroupRecovery

java.lang.Object
com.tnsai.coordination.lifecycle.GroupRecovery

public final class GroupRecovery extends Object
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 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 into
      snapshot - the checkpoint snapshot to restore from
      availableAgents - 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 true only if every member ID in the snapshot is present in the available agents map.

      Parameters:
      snapshot - the checkpoint snapshot to verify
      availableAgents - map of agent ID to Agent instances
      Returns:
      true if all members from the snapshot are available
      Throws:
      NullPointerException - if any argument is null