Class AbstractMysqlServer

java.lang.Object
org.bsc.langgraph4j.checkpoint.AbstractCheckpointSaver
org.bsc.langgraph4j.checkpoint.AbstractMysqlServer
All Implemented Interfaces:
BaseCheckpointSaver
Direct Known Subclasses:
MysqlSaver

public abstract class AbstractMysqlServer extends AbstractCheckpointSaver
  • Field Details

    • dataSource

      protected final DataSource dataSource
    • createOption

      protected final CreateOption createOption
    • objectMapper

      protected final com.fasterxml.jackson.databind.ObjectMapper objectMapper
  • Constructor Details

    • AbstractMysqlServer

      protected AbstractMysqlServer(AbstractMysqlServer.AbstractBuilder<?> builder)
      protected constructor used by the builder to create a new instance of MysqlSaver.
      Parameters:
      builder - Builder instance
  • Method Details

    • loadCheckpoints

      protected LinkedList<Checkpoint> loadCheckpoints(RunnableConfig config) throws Exception
      If the list of checkpoints is empty, loads the checkpoints from the database.
      Specified by:
      loadCheckpoints in class AbstractCheckpointSaver
      Parameters:
      config - the configuration
      Returns:
      a list of checkpoints
      Throws:
      Exception - if an error occurs while the checkpoints are being loaded from the database.
    • insertedCheckpoint

      protected void insertedCheckpoint(RunnableConfig config, LinkedList<Checkpoint> checkpoints, Checkpoint checkpoint) throws Exception
      Inserts a checkpoint to the database
      Specified by:
      insertedCheckpoint in class AbstractCheckpointSaver
      Parameters:
      config - the configuration
      checkpoints - the list of checkpoints
      checkpoint - the checkpoint to insert
      Throws:
      Exception - if an error occurs while inserting the checkpoint in the database.
    • releaseCheckpoints

      protected BaseCheckpointSaver.Tag releaseCheckpoints(RunnableConfig config, LinkedList<Checkpoint> checkpoints) throws Exception
      Marks the checkpoints as released
      Specified by:
      releaseCheckpoints in class AbstractCheckpointSaver
      Parameters:
      config - the configuration
      checkpoints - the checkpoints
      Throws:
      Exception - if an error occurs while marking the checkpoints as released
    • updatedCheckpoint

      protected void updatedCheckpoint(RunnableConfig config, LinkedList<Checkpoint> checkpoints, Checkpoint checkpoint) throws Exception
      If the checkpoint exists, updates the checkpoint, otherwise it inserts it.
      Specified by:
      updatedCheckpoint in class AbstractCheckpointSaver
      Parameters:
      config - the configuration
      checkpoints - the list of checkpoints
      checkpoint - the checkpoint
      Throws:
      Exception - if an error occurs while inserting or updating the checkpoint.
    • initTables

      protected void initTables()
      Initializes the database according the create options.
    • clearCheckpointsCache

      @Deprecated(forRemoval=true) public Collection<Checkpoint> clearCheckpointsCache(String threadId)
      Deprecated, for removal: This API element is subject to removal in a future version.
      this method do nothing because currently this saver don't use cache anymore
      Removes the cached checkpoints associated with the given thread identifier from the in-memory cache.
      Parameters:
      threadId - the thread identifier whose cached checkpoints must be cleared
      Returns:
      the checkpoints removed from the cache, or an empty collection if no cached checkpoints exist