Class MongoRemoteSnapshotClient

java.lang.Object
io.agentscope.extensions.mongodb.snapshot.MongoRemoteSnapshotClient
All Implemented Interfaces:
io.agentscope.harness.agent.sandbox.snapshot.RemoteSnapshotClient

public class MongoRemoteSnapshotClient extends Object implements io.agentscope.harness.agent.sandbox.snapshot.RemoteSnapshotClient
RemoteSnapshotClient backed by MongoDB GridFS.

Stores sandbox workspace tar archives in GridFS, which transparently chunks data into 255 KB segments and supports files up to 16 GB — removing the 16 MB BSON document limit that constrains single-document Binary storage.

Snapshots have no independent TTL — aligned with Postgres/JDBC/Redis which retain snapshots indefinitely. A snapshot is reclaimed only by delete(String) when the owning session is explicitly deleted (cascade cleanup driven by MongoDistributedStore).

For backward compatibility, download(java.lang.String) and exists(java.lang.String) fall back to reading from the legacy single-document collection if the file is not found in GridFS.

  • Constructor Details

    • MongoRemoteSnapshotClient

      public MongoRemoteSnapshotClient(com.mongodb.client.MongoClient mongoClient, String databaseName, String collectionName)
  • Method Details

    • upload

      public void upload(String snapshotId, InputStream data) throws Exception
      Specified by:
      upload in interface io.agentscope.harness.agent.sandbox.snapshot.RemoteSnapshotClient
      Throws:
      Exception
    • download

      public InputStream download(String snapshotId) throws Exception
      Specified by:
      download in interface io.agentscope.harness.agent.sandbox.snapshot.RemoteSnapshotClient
      Throws:
      Exception
    • exists

      public boolean exists(String snapshotId) throws Exception
      Specified by:
      exists in interface io.agentscope.harness.agent.sandbox.snapshot.RemoteSnapshotClient
      Throws:
      Exception
    • delete

      public boolean delete(String snapshotId) throws Exception
      Deletes a snapshot from GridFS.
      Parameters:
      snapshotId - the snapshot identifier (stored as GridFS filename)
      Returns:
      true if a file was deleted, false if no matching snapshot existed
      Throws:
      Exception - if a MongoDB error occurs