JdbcDistributedStore
public class JdbcDistributedStore implements DistributedStore
io/agentscope/extensions/jdbc/JdbcDistributedStore.java:60–155JDBC 分布式存储,负责持久化与读取数据。位于 io.agentscope.extensions.jdbc 包,实现 DistributedStore。核心成员包括 create、agentStateStore、baseStore、sandboxSnapshotSpec、sandboxExecutionGuard。
Multi-database JDBC-backed DistributedStore with automatic dialect detection.
Pass any JDBC DataSource and the store auto-detects the database via
AbstractJdbcDialect#from(DataSource), then assembles all four components:
-
JdbcAgentStateStore— agent session state -
JdbcStore— workspace filesystem KV -
JdbcSnapshotSpec— sandbox snapshots as BLOBs -
JdbcSandboxExecutionGuard— distributed lock via the dialect's lock strategy
Usage
`DataSource dataSource = ... // HikariCP, Druid, etc.
HarnessAgent agent = HarnessAgent.builder()
.name("my-agent")
.model("dashscope:qwen-plus")
.distributedStore(JdbcDistributedStore.create(dataSource))
.filesystem(new DockerFilesystemSpec()
.image("ubuntu:24.04"))
.build();
`
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static JdbcDistributedStore create(DataSource dataSource)static | 创建并返回实例。 Creates a JDBC distributed store with auto-detected dialect and table creation. |
public static JdbcDistributedStore create(DataSource dataSource, AbstractJdbcDialect dialect)static | 创建并返回实例。 Creates a JDBC distributed store with an explicitly provided dialect. |
public AgentStateStore agentStateStore() | 返回智能体状态存储。 Returns the agent state store. |
public BaseStore baseStore() | 返回基类存储。 Returns the base store. |
public SandboxSnapshotSpec sandboxSnapshotSpec() | 返回沙箱快照规格。 Returns the sandbox snapshot spec. |
public SandboxExecutionGuard sandboxExecutionGuard() | 返回沙箱执行守卫。 Returns the sandbox execution guard. |
方法详情Method Detail
create
public static JdbcDistributedStore create(DataSource dataSource)
创建并返回实例。
Creates a JDBC distributed store with auto-detected dialect and table creation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
dataSource | DataSource | 数据来源(类型 `DataSource`)。the JDBC data source for any supported database |
JdbcDistributedStoreio/agentscope/extensions/jdbc/JdbcDistributedStore.java:86–89create
public static JdbcDistributedStore create(DataSource dataSource, AbstractJdbcDialect dialect)
创建并返回实例。
Creates a JDBC distributed store with an explicitly provided dialect.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
dataSource | DataSource | JDBC 数据来源。the JDBC data source |
dialect | AbstractJdbcDialect | dialect(类型 `AbstractJdbcDialect`)。the pre-built dialect (skips auto-detection) |
JdbcDistributedStoreio/agentscope/extensions/jdbc/JdbcDistributedStore.java:98–100agentStateStore
public AgentStateStore agentStateStore()
返回智能体状态存储。
Returns the agent state store.
AgentStateStoreio/agentscope/extensions/jdbc/JdbcDistributedStore.java:102–115baseStore
public BaseStore baseStore()
返回基类存储。
Returns the base store.
BaseStoreio/agentscope/extensions/jdbc/JdbcDistributedStore.java:117–134sandboxSnapshotSpec
public SandboxSnapshotSpec sandboxSnapshotSpec()
返回沙箱快照规格。
Returns the sandbox snapshot spec.
SandboxSnapshotSpecio/agentscope/extensions/jdbc/JdbcDistributedStore.java:136–149sandboxExecutionGuard
public SandboxExecutionGuard sandboxExecutionGuard()
返回沙箱执行守卫。
Returns the sandbox execution guard.
SandboxExecutionGuardio/agentscope/extensions/jdbc/JdbcDistributedStore.java:151–154