MongoRemoteSnapshotClient
public class MongoRemoteSnapshotClient implements RemoteSnapshotClient
io/agentscope/extensions/mongodb/snapshot/MongoRemoteSnapshotClient.java:55–196Mongo 远程快照客户端,封装与远端服务的连接和调用。位于 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.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
mongoClient | MongoClient | mongo 客户端(类型 `MongoClient`)。The mongo client. |
databaseName | String | 数据库名称(类型 `String`)。The database name. |
collectionName | String | 集合名称(类型 `String`)。The collection name. |
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.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
snapshotId | String | 快照标识(类型 `String`)。The snapshot id. |
data | InputStream | 数据(类型 `InputStream`)。The data. |
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/mongodb/snapshot/MongoRemoteSnapshotClient.java:92–103download
public InputStream download(String snapshotId) throws Exception
设置下载。
Performs the download operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
snapshotId | String | 快照标识(类型 `String`)。The snapshot id. |
InputStreamException可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/mongodb/snapshot/MongoRemoteSnapshotClient.java:105–118exists
public boolean exists(String snapshotId) throws Exception
判断数据是否存在。
Performs the exists operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
snapshotId | String | 快照标识(类型 `String`)。The snapshot id. |
booleanException可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/mongodb/snapshot/MongoRemoteSnapshotClient.java:120–130delete
public boolean delete(String snapshotId) throws Exception
删除数据。
Deletes a snapshot from GridFS.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
snapshotId | String | 快照标识(类型 `String`)。the snapshot identifier (stored as GridFS filename) |
booleanException可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/mongodb/snapshot/MongoRemoteSnapshotClient.java:139–149