Package org.bsc.langgraph4j.checkpoint
Class OracleSaver
java.lang.Object
org.bsc.langgraph4j.checkpoint.AbstractCheckpointSaver
org.bsc.langgraph4j.checkpoint.AbstractOracleSaver
org.bsc.langgraph4j.checkpoint.OracleSaver
- All Implemented Interfaces:
BaseCheckpointSaver,LG4JLoggable
OracleSaver is an extension of MemorySaver that enables persistent, reliable storage of workflow state in an Oracle database.
Two tables are used to store the workflow state:
CREATE TABLE LANGRAPH4J_THREAD (
thread_id VARCHAR2(36) PRIMARY KEY,
thread_name VARCHAR(255),
is_released BOOLEAN DEFAULT FALSE NOT NULL
)
CREATE INDEX IDX_LANGRAPH4J_THREAD_NAME_RELEASED
ON LANGRAPH4J_THREAD(thread_name, is_released)
CREATE TABLE LANGRAPH4J_CHECKPOINT (
checkpoint_id VARCHAR2(36) PRIMARY KEY,
thread_id VARCHAR2(36) NOT NULL,
node_id VARCHAR(255),
next_node_id VARCHAR(255),
state_data JSON NOT NULL,
saved_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT LANGRAPH4J_FK_THREAD
FOREIGN KEY(thread_id)
REFERENCES LANGRAPH4J_THREAD(thread_id)
ON DELETE CASCADE
)
A builder can be use to create an instance or OracleSaver. The builder allows to configure the following options: - DataSource: indicates which data source should be used to connect to the database - CreateOption : indicates whether the tables should be created or existing tables should be used.
Ex:
var saver = OracleSaver.builder()
.createOption(CreateOption.CREATE_OR_REPLACE)
.dataSource(DATA_SOURCE)
.build();
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.bsc.langgraph4j.checkpoint.AbstractOracleSaver
AbstractOracleSaver.AbstractBuilder<B extends AbstractOracleSaver.AbstractBuilder<B>>Nested classes/interfaces inherited from interface org.bsc.langgraph4j.checkpoint.BaseCheckpointSaver
BaseCheckpointSaver.SubGraphSaver, BaseCheckpointSaver.Tag -
Field Summary
Fields inherited from class org.bsc.langgraph4j.checkpoint.AbstractOracleSaver
dataSource, sqlCommands, stateSerializerMapFields inherited from interface org.bsc.langgraph4j.checkpoint.BaseCheckpointSaver
THREAD_ID_DEFAULTFields inherited from interface org.bsc.langgraph4j.LG4JLoggable
log -
Method Summary
Modifier and TypeMethodDescriptionstatic OracleSaver.Builderbuilder()Creates an instance of a builder that allows to configure and create a new instance of OracleSaver.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<State extends AgentState>
CompletableFuture<InterruptionMetadata<State>> registerInterruption(RunnableConfig config, InterruptionMetadata<State> interruptionMetadata) Register Interrupt of the execution for the given config and provide interruption metadata.protected BaseCheckpointSaver.TagreleaseCheckpointsOnError(RunnableConfig config, LinkedList<Checkpoint> checkpoints, Throwable exception) protected Stringprotected Stringtag(RunnableConfig config, Integer version) Methods inherited from class org.bsc.langgraph4j.checkpoint.AbstractOracleSaver
decodeState, encodeState, exec, execTransaction, initTables, insertCheckpoint, insertedCheckpoint, loadCheckpoints, releaseCheckpoints, updatedCheckpointMethods inherited from class org.bsc.langgraph4j.checkpoint.AbstractCheckpointSaver
get, list, listSubGraphSaver, put, putSubGraphSaver, release, release, releaseOnErrorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.bsc.langgraph4j.checkpoint.BaseCheckpointSaver
lastTag, threadId
-
Method Details
-
builder
Creates an instance of a builder that allows to configure and create a new instance of OracleSaver.- Returns:
- a new instance of the builder.
-
sqlCommandsResourcePath
- Specified by:
sqlCommandsResourcePathin classAbstractOracleSaver
-
sqlInitResourcePath
- Specified by:
sqlInitResourcePathin classAbstractOracleSaver
-
releaseCheckpointsOnError
protected BaseCheckpointSaver.Tag releaseCheckpointsOnError(RunnableConfig config, LinkedList<Checkpoint> checkpoints, Throwable exception) throws Exception - Specified by:
releaseCheckpointsOnErrorin classAbstractCheckpointSaver- Throws:
Exception
-
registerInterruption
public <State extends AgentState> CompletableFuture<InterruptionMetadata<State>> registerInterruption(RunnableConfig config, InterruptionMetadata<State> interruptionMetadata) Description copied from interface:BaseCheckpointSaverRegister Interrupt of the execution for the given config and provide interruption metadata. this is used internally and should not be called directly by the user.- Parameters:
config- the RunnableConfig for which to register the interruptioninterruptionMetadata- the metadata associated with the interruption
-
tag
public Optional<BaseCheckpointSaver.Tag> tag(RunnableConfig config, Integer version) throws Exception - Throws:
Exception
-
clearCheckpointsCache
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 anymoreRemoves 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
-