Search in sources :

Example 1 with File

use of io.dingodb.raft.entity.LocalStorageOutter.LocalSnapshotPbMeta.File in project dingo by dingodb.

the class LocalSnapshotMetaTable method saveToFile.

/**
 * Save metadata infos into file by path.
 */
public boolean saveToFile(String path) throws IOException {
    LocalSnapshotPbMeta.Builder pbMeta = LocalSnapshotPbMeta.newBuilder();
    if (hasMeta()) {
        pbMeta.setMeta(this.meta);
    }
    for (Map.Entry<String, LocalFileMeta> entry : this.fileMap.entrySet()) {
        File f = File.newBuilder().setName(entry.getKey()).setMeta(entry.getValue()).build();
        pbMeta.addFiles(f);
    }
    ProtoBufFile pbFile = new ProtoBufFile(path);
    return pbFile.save(pbMeta.build(), this.raftOptions.isSyncMeta());
}
Also used : LocalSnapshotPbMeta(io.dingodb.raft.entity.LocalStorageOutter.LocalSnapshotPbMeta) LocalFileMeta(io.dingodb.raft.entity.LocalFileMetaOutter.LocalFileMeta) HashMap(java.util.HashMap) Map(java.util.Map) File(io.dingodb.raft.entity.LocalStorageOutter.LocalSnapshotPbMeta.File) ProtoBufFile(io.dingodb.raft.storage.io.ProtoBufFile) ProtoBufFile(io.dingodb.raft.storage.io.ProtoBufFile)

Aggregations

LocalFileMeta (io.dingodb.raft.entity.LocalFileMetaOutter.LocalFileMeta)1 LocalSnapshotPbMeta (io.dingodb.raft.entity.LocalStorageOutter.LocalSnapshotPbMeta)1 File (io.dingodb.raft.entity.LocalStorageOutter.LocalSnapshotPbMeta.File)1 ProtoBufFile (io.dingodb.raft.storage.io.ProtoBufFile)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1