Skip to content

Commit

Permalink
save storage policy to jobinfo instead of BackupMeta
Browse files Browse the repository at this point in the history
  • Loading branch information
justfortaste committed Dec 11, 2024
1 parent a8ec081 commit 905e601
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,8 @@ public final class FeMetaVersion {
// For AnalysisInfo
public static final int VERSION_123 = 123;

// For BackupMeta storage policy
public static final int VERSION_124 = 124;

// note: when increment meta version, should assign the latest version to VERSION_CURRENT
public static final int VERSION_CURRENT = VERSION_124;
public static final int VERSION_CURRENT = VERSION_123;

// all logs meta version should >= the minimum version, so that we could remove many if clause, for example
// if (FE_METAVERSION < VERSION_94) ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public static class BriefBackupJobInfo {
@SerializedName("s3_resource_list")
public List<BackupS3ResourceInfo> s3ResourceList = Lists.newArrayList();
@SerializedName("storage_policy_list")
public List<BackupStoragePolicyInfo> storagePolicyList = Lists.newArrayList();
public List<StoragePolicy> storagePolicyList = Lists.newArrayList();

public static BriefBackupJobInfo fromBackupJobInfo(BackupJobInfo backupJobInfo) {
BriefBackupJobInfo briefBackupJobInfo = new BriefBackupJobInfo();
Expand Down Expand Up @@ -376,7 +376,7 @@ public static class NewBackupObjects {
@SerializedName("s3_resources")
public List<BackupS3ResourceInfo> s3Resources = Lists.newArrayList();
@SerializedName("storage_policy")
public List<BackupStoragePolicyInfo> storagePolicies = Lists.newArrayList();
public List<StoragePolicy> storagePolicies = Lists.newArrayList();
}

public static class BackupOlapTableInfo {
Expand Down Expand Up @@ -500,11 +500,6 @@ public static class BackupS3ResourceInfo {
public String name;
}

public static class BackupStoragePolicyInfo {
@SerializedName("name")
public String name;
}

// eg: __db_10001/__tbl_10002/__part_10003/__idx_10002/__10004
public String getFilePath(String db, String tbl, String part, String idx, long tabletId) {
if (!db.equalsIgnoreCase(dbName)) {
Expand Down Expand Up @@ -708,9 +703,7 @@ public static BackupJobInfo fromCatalog(long backupTime, String label, String db
// storage policies
Collection<StoragePolicy> storagePolicies = backupMeta.getStoragePolicyNameMap().values();
for (StoragePolicy storagePolicy : storagePolicies) {
BackupStoragePolicyInfo backupStoragePolicyInfo = new BackupStoragePolicyInfo();
backupStoragePolicyInfo.name = storagePolicy.getName();
jobInfo.newBackupObjects.storagePolicies.add(backupStoragePolicyInfo);
jobInfo.newBackupObjects.storagePolicies.add(storagePolicy.clone());
}

return jobInfo;
Expand Down
17 changes: 0 additions & 17 deletions fe/fe-core/src/main/java/org/apache/doris/backup/BackupMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.Resource;
import org.apache.doris.catalog.Table;
import org.apache.doris.common.FeMetaVersion;
import org.apache.doris.common.io.Writable;
import org.apache.doris.meta.MetaContext;
import org.apache.doris.persist.gson.GsonUtils;
Expand Down Expand Up @@ -54,7 +53,6 @@ public class BackupMeta implements Writable {
@SerializedName(value = "resourceNameMap")
private Map<String, Resource> resourceNameMap = Maps.newHashMap();
// storagePolicy name -> resource
@SerializedName(value = "storagePolicyNameMap")
private Map<String, StoragePolicy> storagePolicyNameMap = Maps.newHashMap();

private BackupMeta() {
Expand Down Expand Up @@ -108,10 +106,6 @@ public Resource getResource(String resourceName) {
return resourceNameMap.get(resourceName);
}

public StoragePolicy getStoragePolicy(String policyName) {
return storagePolicyNameMap.get(policyName);
}

public Table getTable(Long tblId) {
return tblIdMap.get(tblId);
}
Expand Down Expand Up @@ -162,10 +156,6 @@ public void write(DataOutput out) throws IOException {
for (Resource resource : resourceNameMap.values()) {
resource.write(out);
}
out.writeInt(storagePolicyNameMap.size());
for (StoragePolicy storagePolicy : storagePolicyNameMap.values()) {
storagePolicy.write(out);
}
}

public void readFields(DataInput in) throws IOException {
Expand All @@ -180,13 +170,6 @@ public void readFields(DataInput in) throws IOException {
Resource resource = Resource.read(in);
resourceNameMap.put(resource.getName(), resource);
}
if (Env.getCurrentEnvJournalVersion() >= FeMetaVersion.VERSION_124) {
size = in.readInt();
for (int i = 0; i < size; i++) {
StoragePolicy policy = StoragePolicy.read(in);
storagePolicyNameMap.put(policy.getName(), policy);
}
}
}

public String toJson() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,8 @@ private void checkAndPrepareMeta() {
}
}

for (BackupJobInfo.BackupStoragePolicyInfo backupStoragePolicyInfo : jobInfo.newBackupObjects.storagePolicies) {
String backupStoragePoliceName = backupStoragePolicyInfo.name;
for (StoragePolicy backupStoargePolicy : jobInfo.newBackupObjects.storagePolicies) {
String backupStoragePoliceName = backupStoargePolicy.getName();
Optional<Policy> localPolicy = Env.getCurrentEnv().getPolicyMgr().findPolicy(backupStoragePoliceName,
PolicyTypeEnum.STORAGE);
if (localPolicy.isPresent() && localPolicy.get().getType() != PolicyTypeEnum.STORAGE) {
Expand Down Expand Up @@ -1343,11 +1343,10 @@ private void checkAndRestoreStoragePolicies() {
return;
}
PolicyMgr policyMgr = Env.getCurrentEnv().getPolicyMgr();
for (BackupJobInfo.BackupStoragePolicyInfo backupStoragePolicyInfo : jobInfo.newBackupObjects.storagePolicies) {
String backupStoragePoliceName = backupStoragePolicyInfo.name;
for (StoragePolicy backupStoargePolicy : jobInfo.newBackupObjects.storagePolicies) {
String backupStoragePoliceName = backupStoargePolicy.getName();
Optional<Policy> localPolicy = policyMgr.findPolicy(backupStoragePoliceName,
PolicyTypeEnum.STORAGE);
StoragePolicy backupStoargePolicy = backupMeta.getStoragePolicy(backupStoragePoliceName);

// use specified storageResource
if (StringUtils.isNotEmpty(storageResource)) {
Expand Down

0 comments on commit 905e601

Please sign in to comment.