Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dataroaring committed Jun 20, 2024
1 parent 352c1d2 commit cac806a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 103 deletions.
59 changes: 16 additions & 43 deletions fe/fe-core/src/main/java/org/apache/doris/backup/AbstractJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
import org.apache.doris.common.io.Writable;
import org.apache.doris.persist.gson.GsonUtils;

import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import com.google.gson.JsonObject;
import com.google.gson.annotations.SerializedName;

import java.io.DataInput;
Expand Down Expand Up @@ -172,53 +170,28 @@ public void setTypeRead(boolean isTypeRead) {
public abstract Status updateRepo(Repository repo);

public static AbstractJob read(DataInput in) throws IOException {
AbstractJob job = null;
JobType type = JobType.valueOf(Text.readString(in));
if (type == JobType.BACKUP) {
job = new BackupJob();
} else if (type == JobType.RESTORE) {
job = new RestoreJob();
if (Env.getCurrentEnvJournalVersion() < FeMetaVersion.VERSION_136) {
AbstractJob job = null;
JobType type = JobType.valueOf(Text.readString(in));
if (type == JobType.BACKUP) {
job = new BackupJob();
} else if (type == JobType.RESTORE) {
job = new RestoreJob();
} else {
throw new IOException("Unknown job type: " + type.name());
}

job.setTypeRead(true);
job.readFields(in);
return job;
} else {
throw new IOException("Unknown job type: " + type.name());
return GsonUtils.GSON.fromJson(Text.readString(in), AbstractJob.class);
}

job.setTypeRead(true);
job.readFields(in);
return job;
}

@Override
public void write(DataOutput out) throws IOException {
// ATTN: must write type first
Text.writeString(out, type.name());

out.writeLong(repoId);
Text.writeString(out, label);
out.writeLong(jobId);
out.writeLong(dbId);
Text.writeString(out, dbName);

out.writeLong(createTime);
out.writeLong(finishedTime);
out.writeLong(timeoutMs);

if (!taskErrMsg.isEmpty()) {
out.writeBoolean(true);
// we only save at most 3 err msgs
int savedNum = Math.min(3, taskErrMsg.size());
out.writeInt(savedNum);
for (Map.Entry<Long, String> entry : taskErrMsg.entrySet()) {
if (savedNum == 0) {
break;
}
out.writeLong(entry.getKey());
Text.writeString(out, entry.getValue());
savedNum--;
}
Preconditions.checkState(savedNum == 0, savedNum);
} else {
out.writeBoolean(false);
}
Text.writeString(out, GsonUtils.GSON.toJson(this));
}

@Deprecated
Expand Down
60 changes: 0 additions & 60 deletions fe/fe-core/src/main/java/org/apache/doris/backup/BackupJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@
import org.apache.doris.catalog.Tablet;
import org.apache.doris.catalog.View;
import org.apache.doris.common.Config;
import org.apache.doris.common.FeMetaVersion;
import org.apache.doris.common.io.Text;
import org.apache.doris.common.util.TimeUtils;
import org.apache.doris.datasource.property.S3ClientBEProperties;
import org.apache.doris.persist.BarrierLog;
import org.apache.doris.persist.gson.GsonUtils;
import org.apache.doris.task.AgentBatchTask;
import org.apache.doris.task.AgentTask;
import org.apache.doris.task.AgentTaskExecutor;
Expand All @@ -55,7 +53,6 @@
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicates;
import com.google.common.base.Strings;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
Expand All @@ -65,7 +62,6 @@
import org.apache.logging.log4j.Logger;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.File;
import java.io.IOException;
import java.nio.file.FileVisitOption;
Expand Down Expand Up @@ -984,62 +980,6 @@ public static BackupJob read(DataInput in) throws IOException {
return job;
}

@Override
public void write(DataOutput out) throws IOException {
super.write(out);

// table refs
out.writeInt(tableRefs.size());
for (TableRef tblRef : tableRefs) {
tblRef.write(out);
}

// state
Text.writeString(out, state.name());

// times
out.writeLong(snapshotFinishedTime);
out.writeLong(snapshotUploadFinishedTime);

// snapshot info
out.writeInt(snapshotInfos.size());
for (SnapshotInfo info : snapshotInfos.values()) {
info.write(out);
}

// backup meta
if (backupMeta == null) {
out.writeBoolean(false);
} else {
out.writeBoolean(true);
backupMeta.write(out);
}

// No need to persist job info. It is generated then write to file

// metaInfoFilePath and jobInfoFilePath
if (Strings.isNullOrEmpty(localMetaInfoFilePath)) {
out.writeBoolean(false);
} else {
out.writeBoolean(true);
Text.writeString(out, localMetaInfoFilePath);
}

if (Strings.isNullOrEmpty(localJobInfoFilePath)) {
out.writeBoolean(false);
} else {
out.writeBoolean(true);
Text.writeString(out, localJobInfoFilePath);
}

// write properties
out.writeInt(properties.size());
for (Map.Entry<String, String> entry : properties.entrySet()) {
Text.writeString(out, entry.getKey());
Text.writeString(out, entry.getValue());
}
}

public void readFields(DataInput in) throws IOException {
super.readFields(in);

Expand Down

0 comments on commit cac806a

Please sign in to comment.