AS AgentScopeAPI 手册 / API Reference

MongoRemoteSnapshotClient

public class MongoRemoteSnapshotClient implements RemoteSnapshotClient
源码Source io/agentscope/extensions/mongodb/snapshot/MongoRemoteSnapshotClient.java:55–196

Mongo 远程快照客户端,封装与远端服务的连接和调用。位于 io.agentscope.extensions.mongodb.snapshot 包,实现 RemoteSnapshotClient。核心成员包括 upload、download、exists、delete、MongoRemoteSnapshotClient。

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 and #exists fall back to reading from the legacy single-document collection if the file is not found in GridFS.

构造器摘要Constructor Summary

构造器Constructor说明Description
public MongoRemoteSnapshotClient(MongoClient mongoClient, String databaseName, String collectionName)
初始化 `MongoRemoteSnapshotClient` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public void upload(String snapshotId, InputStream data) throws Exception
执行上传相关操作。
Performs the upload operation.
public InputStream download(String snapshotId) throws Exception
设置下载。
Performs the download operation.
public boolean exists(String snapshotId) throws Exception
判断数据是否存在。
Performs the exists operation.
public boolean delete(String snapshotId) throws Exception
删除数据。
Deletes a snapshot from GridFS.

构造器详情Constructor Detail

MongoRemoteSnapshotClient

public MongoRemoteSnapshotClient(MongoClient mongoClient, String databaseName, String collectionName)

初始化 MongoRemoteSnapshotClient 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
mongoClientMongoClientmongo 客户端(类型 `MongoClient`)。The mongo client.
databaseNameString数据库名称(类型 `String`)。The database name.
collectionNameString集合名称(类型 `String`)。The collection name.
源码Source io/agentscope/extensions/mongodb/snapshot/MongoRemoteSnapshotClient.java:70–80

方法详情Method Detail

upload

public void upload(String snapshotId, InputStream data) throws Exception

执行上传相关操作。

Performs the upload operation.

参数Parameters
名称Name类型Type说明Description
snapshotIdString快照标识(类型 `String`)。The snapshot id.
dataInputStream数据(类型 `InputStream`)。The data.
抛出Throws
  • Exception 可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source io/agentscope/extensions/mongodb/snapshot/MongoRemoteSnapshotClient.java:92–103

download

public InputStream download(String snapshotId) throws Exception

设置下载。

Performs the download operation.

参数Parameters
名称Name类型Type说明Description
snapshotIdString快照标识(类型 `String`)。The snapshot id.
返回Returns InputStream
返回InputStream。Returns input stream.
抛出Throws
  • Exception 可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source io/agentscope/extensions/mongodb/snapshot/MongoRemoteSnapshotClient.java:105–118

exists

public boolean exists(String snapshotId) throws Exception

判断数据是否存在。

Performs the exists operation.

参数Parameters
名称Name类型Type说明Description
snapshotIdString快照标识(类型 `String`)。The snapshot id.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
抛出Throws
  • Exception 可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source io/agentscope/extensions/mongodb/snapshot/MongoRemoteSnapshotClient.java:120–130

delete

public boolean delete(String snapshotId) throws Exception

删除数据。

Deletes a snapshot from GridFS.

参数Parameters
名称Name类型Type说明Description
snapshotIdString快照标识(类型 `String`)。the snapshot identifier (stored as GridFS filename)
返回Returns boolean
返回布尔值,表示判断结果。`true` if a file was deleted, `false` if no matching snapshot existed
抛出Throws
  • Exception 可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source io/agentscope/extensions/mongodb/snapshot/MongoRemoteSnapshotClient.java:139–149
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.