JdbcCoordinationStore
public class JdbcCoordinationStore implements CoordinationStore
io/agentscope/builder/web/coord/JdbcCoordinationStore.java:45–762JDBC Coordination 存储,负责持久化与读取数据。位于 io.agentscope.builder.web.coord 包,实现 CoordinationStore。核心成员包括 tryAcquireTurnLease、heartbeatTurnLease、releaseTurnLease、getTurnLease、listExpiredTurnLeases、requestTurnInterrupt。
JDBC-backed CoordinationStore using the builder catalog DataSource / JPA schema.
Registered as the default bean from BuilderConfig; operators can replace it by
declaring another CoordinationStore bean (e.g. Redis).
构造器摘要Constructor Summary
方法摘要Method Summary
构造器详情Constructor Detail
JdbcCoordinationStore
public JdbcCoordinationStore(CoordLeaseEntityRepository leaseRepository, CoordHitlTicketEntityRepository hitlRepository, CoordWorkItemEntityRepository workRepository, CoordWorkerHeartbeatEntityRepository workerRepository, TransactionTemplate transactionTemplate)
初始化 JdbcCoordinationStore 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
leaseRepository | CoordLeaseEntityRepository | lease 仓库(类型 `CoordLeaseEntityRepository`)。The lease repository. |
hitlRepository | CoordHitlTicketEntityRepository | hitl 仓库(类型 `CoordHitlTicketEntityRepository`)。The hitl repository. |
workRepository | CoordWorkItemEntityRepository | work 仓库(类型 `CoordWorkItemEntityRepository`)。The work repository. |
workerRepository | CoordWorkerHeartbeatEntityRepository | 工作进程仓库(类型 `CoordWorkerHeartbeatEntityRepository`)。The worker repository. |
transactionTemplate | TransactionTemplate | 事务模板(类型 `TransactionTemplate`)。The transaction template. |
io/agentscope/builder/web/coord/JdbcCoordinationStore.java:55–66方法详情Method Detail
tryAcquireTurnLease
public Optional<LeaseHandle> tryAcquireTurnLease(String sessionId, String ownerId, String instanceId, Duration ttl)
执行 tryAcquireTurnLease 方法。
Performs the try acquire turn lease operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
ownerId | String | 所有者标识(类型 `String`)。The owner id. |
instanceId | String | 实例标识(类型 `String`)。The instance id. |
ttl | Duration | 存活时间(类型 `Duration`)。The ttl. |
Optional<LeaseHandle>io/agentscope/builder/web/coord/JdbcCoordinationStore.java:68–103heartbeatTurnLease
public boolean heartbeatTurnLease(String sessionId, String instanceId, Duration ttl)
执行 heartbeatTurnLease 方法。
Performs the heartbeat turn lease operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
instanceId | String | 实例标识(类型 `String`)。The instance id. |
ttl | Duration | 存活时间(类型 `Duration`)。The ttl. |
booleanio/agentscope/builder/web/coord/JdbcCoordinationStore.java:105–114releaseTurnLease
public boolean releaseTurnLease(String sessionId, String instanceId)
执行 releaseTurnLease 方法。
Performs the release turn lease operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
instanceId | String | 实例标识(类型 `String`)。The instance id. |
booleanio/agentscope/builder/web/coord/JdbcCoordinationStore.java:116–122getTurnLease
public Optional<LeaseHandle> getTurnLease(String sessionId)
获取 getTurnLease。
Returns the turn lease.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
Optional<LeaseHandle>io/agentscope/builder/web/coord/JdbcCoordinationStore.java:124–131listExpiredTurnLeases
public List<LeaseHandle> listExpiredTurnLeases(long nowMillis)
列出 listExpiredTurnLeases。
Lists the expired turn leases.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
nowMillis | long | 当前时间毫秒(类型 `long`)。The now millis. |
List<LeaseHandle>io/agentscope/builder/web/coord/JdbcCoordinationStore.java:133–141requestTurnInterrupt
public void requestTurnInterrupt(String sessionId, String reason)
执行请求轮次中断相关操作。
Performs the request turn interrupt operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
reason | String | 原因(类型 `String`)。The reason. |
io/agentscope/builder/web/coord/JdbcCoordinationStore.java:143–147requestFencedTurnInterrupt
public void requestFencedTurnInterrupt(String sessionId, String reason, String fenceToken)
执行 requestFencedTurnInterrupt 方法。
Performs the request fenced turn interrupt operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
reason | String | 原因(类型 `String`)。The reason. |
fenceToken | String | fence 令牌(类型 `String`)。The fence token. |
io/agentscope/builder/web/coord/JdbcCoordinationStore.java:149–156consumeTurnInterrupt
public Optional<String> consumeTurnInterrupt(String sessionId)
设置消费轮次中断。
Performs the consume turn interrupt operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
Optional<String>io/agentscope/builder/web/coord/JdbcCoordinationStore.java:200–204consumeTurnInterruptRequest
public Optional<TurnInterruptRequest> consumeTurnInterruptRequest(String sessionId)
设置消费轮次中断请求。
Performs the consume turn interrupt request operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
Optional<TurnInterruptRequest>io/agentscope/builder/web/coord/JdbcCoordinationStore.java:206–237tryAcquireFireLease
public boolean tryAcquireFireLease(String deploymentId, String fireWindow, String instanceId, Duration ttl)
执行 tryAcquireFireLease 方法。
Performs the try acquire fire lease operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
deploymentId | String | 部署标识(类型 `String`)。The deployment id. |
fireWindow | String | fire Window(类型 `String`)。The fire window. |
instanceId | String | 实例标识(类型 `String`)。The instance id. |
ttl | Duration | 存活时间(类型 `Duration`)。The ttl. |
booleanio/agentscope/builder/web/coord/JdbcCoordinationStore.java:264–295putHitlTicket
public HitlTicket putHitlTicket(HitlTicket ticket)
设置该参数。
Performs the put hitl ticket operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
ticket | HitlTicket | ticket(类型 `HitlTicket`)。The ticket. |
HitlTicketio/agentscope/builder/web/coord/JdbcCoordinationStore.java:297–340getHitlTicket
public Optional<HitlTicket> getHitlTicket(String sessionId, String toolUseId)
获取 getHitlTicket。
Returns the hitl ticket.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
toolUseId | String | 工具使用标识(类型 `String`)。The tool use id. |
Optional<HitlTicket>io/agentscope/builder/web/coord/JdbcCoordinationStore.java:342–350getHitlTicket
public Optional<HitlTicket> getHitlTicket(HitlDecisionFence fence)
获取 getHitlTicket。
Returns the hitl ticket.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
fence | HitlDecisionFence | fence(类型 `HitlDecisionFence`)。The fence. |
Optional<HitlTicket>io/agentscope/builder/web/coord/JdbcCoordinationStore.java:352–365resolveHitlTicket
public Optional<HitlResolution> resolveHitlTicket(HitlDecisionFence fence, String resolutionStatus, long decisionVersion, boolean allow, String denyMessage, long resolvedAt)
解析 resolveHitlTicket。
Performs the resolve hitl ticket operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
fence | HitlDecisionFence | fence(类型 `HitlDecisionFence`)。The fence. |
resolutionStatus | String | resolution 状态(类型 `String`)。The resolution status. |
decisionVersion | long | 决策版本(类型 `long`)。The decision version. |
allow | boolean | allow(类型 `boolean`)。The allow. |
denyMessage | String | 拒绝消息(类型 `String`)。The deny message. |
resolvedAt | long | 已解析 At(类型 `long`)。The resolved at. |
Optional<HitlResolution>io/agentscope/builder/web/coord/JdbcCoordinationStore.java:367–409expireHitlTicket
public Optional<HitlResolution> expireHitlTicket(String sessionId, String toolUseId, long expiredAt)
执行 expireHitlTicket 方法。
Performs the expire hitl ticket operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
toolUseId | String | 工具使用标识(类型 `String`)。The tool use id. |
expiredAt | long | 已过期 At(类型 `long`)。The expired at. |
Optional<HitlResolution>io/agentscope/builder/web/coord/JdbcCoordinationStore.java:411–434markHitlContinuationReady
public boolean markHitlContinuationReady(HitlDecisionFence fence)
设置该参数。
Performs the mark hitl continuation ready operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
fence | HitlDecisionFence | fence(类型 `HitlDecisionFence`)。The fence. |
booleanio/agentscope/builder/web/coord/JdbcCoordinationStore.java:436–455deleteHitlTicket
public void deleteHitlTicket(String sessionId, String toolUseId)
删除 deleteHitlTicket。
Deletes the hitl ticket.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
toolUseId | String | 工具使用标识(类型 `String`)。The tool use id. |
io/agentscope/builder/web/coord/JdbcCoordinationStore.java:457–461deleteHitlTicketsBySession
public void deleteHitlTicketsBySession(String sessionId)
删除 deleteHitlTicketsBySession。
Deletes the hitl tickets by session.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
io/agentscope/builder/web/coord/JdbcCoordinationStore.java:463–467deleteResolvedHitlTicketsBefore
public long deleteResolvedHitlTicketsBefore(long expiresAtCutoff)
删除 deleteResolvedHitlTicketsBefore。
Deletes the resolved hitl tickets before.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
expiresAtCutoff | long | 过期 At Cutoff(类型 `long`)。The expires at cutoff. |
longio/agentscope/builder/web/coord/JdbcCoordinationStore.java:469–473listExpiredHitlTickets
public List<HitlTicket> listExpiredHitlTickets(long nowMillis)
列出 listExpiredHitlTickets。
Lists the expired hitl tickets.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
nowMillis | long | 当前时间毫秒(类型 `long`)。The now millis. |
List<HitlTicket>io/agentscope/builder/web/coord/JdbcCoordinationStore.java:475–481enqueueWork
public WorkItemRecord enqueueWork(String sessionId, String environmentId, String ownerId)
执行 enqueueWork 方法。
Performs the enqueue work operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
environmentId | String | 环境标识(类型 `String`)。The environment id. |
ownerId | String | 所有者标识(类型 `String`)。The owner id. |
WorkItemRecordio/agentscope/builder/web/coord/JdbcCoordinationStore.java:483–497claimWork
public Optional<WorkItemRecord> claimWork(String environmentId, String workerId, long timeoutMs) throws InterruptedException
执行 claimWork 方法。
Performs the claim work operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
environmentId | String | 环境标识(类型 `String`)。The environment id. |
workerId | String | 工作进程标识(类型 `String`)。The worker id. |
timeoutMs | long | 超时 Ms(类型 `long`)。The timeout ms. |
Optional<WorkItemRecord>InterruptedException可能抛出 `InterruptedException`。Thrown when the operation cannot be completed.
io/agentscope/builder/web/coord/JdbcCoordinationStore.java:499–519ackWork
public void ackWork(String leaseId, String workerId, String workDir)
执行 ackWork 方法。
Performs the ack work operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
leaseId | String | lease 标识(类型 `String`)。The lease id. |
workerId | String | 工作进程标识(类型 `String`)。The worker id. |
workDir | String | work 目录(类型 `String`)。The work dir. |
io/agentscope/builder/web/coord/JdbcCoordinationStore.java:542–559stopWork
public void stopWork(String leaseId)
停止 stopWork。
Stops the work.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
leaseId | String | lease 标识(类型 `String`)。The lease id. |
io/agentscope/builder/web/coord/JdbcCoordinationStore.java:561–572heartbeatWork
public void heartbeatWork(String leaseId)
设置该参数。
Performs the heartbeat work operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
leaseId | String | lease 标识(类型 `String`)。The lease id. |
io/agentscope/builder/web/coord/JdbcCoordinationStore.java:574–584getWork
public Optional<WorkItemRecord> getWork(String leaseId)
获取 getWork。
Returns the work.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
leaseId | String | lease 标识(类型 `String`)。The lease id. |
Optional<WorkItemRecord>io/agentscope/builder/web/coord/JdbcCoordinationStore.java:586–590listWork
public List<WorkItemRecord> listWork(String environmentId, String statusFilter)
列出 listWork。
Lists the work.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
environmentId | String | 环境标识(类型 `String`)。The environment id. |
statusFilter | String | 状态过滤器(类型 `String`)。The status filter. |
List<WorkItemRecord>io/agentscope/builder/web/coord/JdbcCoordinationStore.java:592–601workStats
public WorkStats workStats(String environmentId)
设置该参数。
Performs the work stats operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
environmentId | String | 环境标识(类型 `String`)。The environment id. |
WorkStatsio/agentscope/builder/web/coord/JdbcCoordinationStore.java:603–624workerHeartbeat
public void workerHeartbeat(String workerId, String capabilitiesJson)
执行工作进程心跳相关操作。
Performs the worker heartbeat operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
workerId | String | 工作进程标识(类型 `String`)。The worker id. |
capabilitiesJson | String | 能力 JSON(类型 `String`)。The capabilities json. |
io/agentscope/builder/web/coord/JdbcCoordinationStore.java:626–642workerHeartbeats
public Map<String, Long> workerHeartbeats()
返回 workerHeartbeats 结果。
Returns the worker heartbeats.
Map<String, Long>io/agentscope/builder/web/coord/JdbcCoordinationStore.java:644–652pendingWorkCount
public int pendingWorkCount()
返回 pendingWorkCount 结果。
Returns the pending work count.
intio/agentscope/builder/web/coord/JdbcCoordinationStore.java:654–658getSandboxReady
public Optional<SandboxReadyMeta> getSandboxReady(String sessionId)
获取沙箱就绪。
Returns the sandbox ready.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
Optional<SandboxReadyMeta>io/agentscope/builder/web/coord/JdbcCoordinationStore.java:660–678clearSandboxReady
public void clearSandboxReady(String sessionId)
清空沙箱就绪。
Clears the sandbox ready.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
io/agentscope/builder/web/coord/JdbcCoordinationStore.java:680–684