Interface SandboxLockStrategy
- All Known Implementing Classes:
AbstractJdbcDialect,H2Dialect,MysqlDialect,PostgresDialect,SqliteDialect
public interface SandboxLockStrategy
Distributed lock contract implemented by
AbstractJdbcDialect.
The default implementation in AbstractJdbcDialect.tryEnter(java.lang.String, int) 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.
- Author:
- shanhongyu
-
Method Summary
-
Method Details
-
tryEnter
io.agentscope.harness.agent.sandbox.SandboxLease tryEnter(String lockName, int timeoutSeconds) throws InterruptedException Acquires the named lock, blocking until available or timeout expires.- Parameters:
lockName- a unique, validated lock nametimeoutSeconds- maximum wait in seconds- Returns:
- a lease that releases the lock when closed
- Throws:
InterruptedException- if the calling thread is interrupted
-