diff --git a/fe/fe-core/src/main/java/org/apache/doris/backup/BackupMeta.java b/fe/fe-core/src/main/java/org/apache/doris/backup/BackupMeta.java index e22bb7f33ce9882..c93d40d6625519e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/backup/BackupMeta.java +++ b/fe/fe-core/src/main/java/org/apache/doris/backup/BackupMeta.java @@ -116,6 +116,7 @@ public static BackupMeta read(DataInput in) throws IOException { return backupMeta; } + // We can not change, because backup meta stored in external storage @Override public void write(DataOutput out) throws IOException { out.writeInt(tblNameMap.size()); diff --git a/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java b/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java index 4284e5b3d9981a0..8071fb2cf788fdb 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java +++ b/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java @@ -66,6 +66,7 @@ import org.apache.doris.common.util.PropertyAnalyzer; import org.apache.doris.common.util.TimeUtils; import org.apache.doris.datasource.property.S3ClientBEProperties; +import org.apache.doris.persist.gson.GsonPostProcessable; import org.apache.doris.persist.gson.GsonUtils; import org.apache.doris.resource.Tag; import org.apache.doris.task.AgentBatchTask; @@ -107,7 +108,7 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -public class RestoreJob extends AbstractJob { +public class RestoreJob extends AbstractJob implements GsonPostProcessable { private static final String PROP_RESERVE_REPLICA = "reserve_replica"; private static final String PROP_RESERVE_DYNAMIC_PARTITION_ENABLE = "reserve_dynamic_partition_enable"; private static final String PROP_IS_BEING_SYNCED = PropertyAnalyzer.PROPERTIES_IS_BEING_SYNCED; @@ -2187,6 +2188,13 @@ public void readFields(DataInput in) throws IOException { isBeingSynced = Boolean.parseBoolean(properties.get(PROP_IS_BEING_SYNCED)); } + @Override + public void gsonPostProcess() throws IOException { + reserveReplica = Boolean.parseBoolean(properties.get(PROP_RESERVE_REPLICA)); + reserveDynamicPartitionEnable = Boolean.parseBoolean(properties.get(PROP_RESERVE_DYNAMIC_PARTITION_ENABLE)); + isBeingSynced = Boolean.parseBoolean(properties.get(PROP_IS_BEING_SYNCED)); + } + @Override public String toString() { StringBuilder sb = new StringBuilder(super.toString()); diff --git a/fe/fe-core/src/main/java/org/apache/doris/backup/SnapshotInfo.java b/fe/fe-core/src/main/java/org/apache/doris/backup/SnapshotInfo.java index 38e91c422006332..1d70babb98f69eb 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/backup/SnapshotInfo.java +++ b/fe/fe-core/src/main/java/org/apache/doris/backup/SnapshotInfo.java @@ -17,8 +17,11 @@ package org.apache.doris.backup; +import org.apache.doris.catalog.Env; +import org.apache.doris.common.FeMetaVersion; import org.apache.doris.common.io.Text; import org.apache.doris.common.io.Writable; +import org.apache.doris.persist.gson.GsonUtils; import com.google.common.base.Joiner; import com.google.common.collect.Lists; @@ -117,26 +120,19 @@ public String getTabletPath() { } public static SnapshotInfo read(DataInput in) throws IOException { - SnapshotInfo info = new SnapshotInfo(); - info.readFields(in); - return info; + if (Env.getCurrentEnvJournalVersion() < FeMetaVersion.VERSION_135) { + SnapshotInfo info = new SnapshotInfo(); + info.readFields(in); + return info; + } else { + String json = Text.readString(in); + return GsonUtils.GSON.fromJson(json, SnapshotInfo.class); + } } @Override public void write(DataOutput out) throws IOException { - out.writeLong(dbId); - out.writeLong(tblId); - out.writeLong(partitionId); - out.writeLong(indexId); - out.writeLong(tabletId); - out.writeLong(beId); - out.writeInt(schemaHash); - Text.writeString(out, path); - - out.writeInt(files.size()); - for (String file : files) { - Text.writeString(out, file); - } + Text.writeString(out, GsonUtils.GSON.toJson(this)); } public void readFields(DataInput in) throws IOException {