Class JdbcSandboxExecutionGuard
java.lang.Object
io.agentscope.extensions.mysql.sandbox.JdbcSandboxExecutionGuard
- All Implemented Interfaces:
io.agentscope.harness.agent.sandbox.SandboxExecutionGuard
public final class JdbcSandboxExecutionGuard
extends Object
implements io.agentscope.harness.agent.sandbox.SandboxExecutionGuard
JDBC-backed
SandboxExecutionGuard using MySQL GET_LOCK() / RELEASE_LOCK().
Each lock is identified by a string key derived from the SandboxIsolationKey's scope
and value. GET_LOCK() blocks until the lock is available or the timeout expires.
The lock is tied to the database connection — when the connection closes, the lock is
automatically released.
The returned SandboxLease.close() calls RELEASE_LOCK() and closes the
underlying connection, ensuring the lock is freed even if the caller forgets to release it.
Important: MySQL named locks are server-scoped, not database-scoped. Use a unique
keyPrefix to avoid collisions with other applications sharing the same MySQL server.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface io.agentscope.harness.agent.sandbox.SandboxExecutionGuard
io.agentscope.harness.agent.sandbox.SandboxExecutionGuard.NoopSandboxExecutionGuard -
Method Summary
Modifier and TypeMethodDescriptionbuilder(DataSource dataSource) io.agentscope.harness.agent.sandbox.SandboxLeasetryEnter(io.agentscope.harness.agent.sandbox.SandboxIsolationKey key)
-
Method Details
-
builder
-
tryEnter
public io.agentscope.harness.agent.sandbox.SandboxLease tryEnter(io.agentscope.harness.agent.sandbox.SandboxIsolationKey key) throws InterruptedException - Specified by:
tryEnterin interfaceio.agentscope.harness.agent.sandbox.SandboxExecutionGuard- Throws:
InterruptedException
-