SandboxLockStrategy
public interface SandboxLockStrategy
源码Source
io/agentscope/extensions/jdbc/dialect/SandboxLockStrategy.java:33–44定义沙箱锁 Strategy契约的接口。位于 io.agentscope.extensions.jdbc.dialect 包。核心成员包括 tryEnter。
Distributed lock contract implemented by AbstractJdbcDialect.
The default implementation in AbstractJdbcDialect#tryEnter uses a portable
table-based lock (INSERT/DELETE with polling). Vendor dialects with native advisory
locks override tryEnter — e.g. MysqlDialect uses GET_LOCK and
PostgresDialect uses pg_try_advisory_lock.
Adding a new database with native lock support requires only overriding
tryEnter() in the vendor dialect class — no separate strategy class needed.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public SandboxLease tryEnter(String lockName, int timeoutSeconds) throws InterruptedException | 执行 `tryEnter` 方法。 Acquires the named lock, blocking until available or timeout expires. |
方法详情Method Detail
tryEnter
public SandboxLease tryEnter(String lockName, int timeoutSeconds) throws InterruptedException
执行 tryEnter 方法。
Acquires the named lock, blocking until available or timeout expires.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
lockName | String | 锁名称(类型 `String`)。a unique, validated lock name |
timeoutSeconds | int | 超时秒(类型 `int`)。maximum wait in seconds |
SandboxLease返回SandboxLease。a lease that releases the lock when closed
InterruptedException可能抛出 `InterruptedException`。Thrown when the operation cannot be completed.
源码Source
io/agentscope/extensions/jdbc/dialect/SandboxLockStrategy.java:43