Skip to content

Commit

Permalink
use new storage policy id
Browse files Browse the repository at this point in the history
  • Loading branch information
justfortaste committed Nov 18, 2024
1 parent bf7103f commit 2258d89
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1419,10 +1419,9 @@ private void checkAndRestoreStoragePolicies() {
} else {
// restore storage policy
try {
policyMgr.replayCreate(backupStoargePolicy);
Env.getCurrentEnv().getEditLog().logCreatePolicy(backupStoargePolicy);
policyMgr.createStoragePolicy(backupStoargePolicy);
} catch (Exception e) {
LOG.error("restore user property fail should not happen", e);
LOG.error("restore storage policy fail should not happen", e);
}
storagePolicies.add(backupStoargePolicy);
}
Expand Down
18 changes: 18 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/policy/PolicyMgr.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,24 @@ public void createPolicy(CreatePolicyStmt stmt) throws UserException {
}
}

/**
* Create policy through StoragePolicy.
**/
public void createStoragePolicy(StoragePolicy storagePolicy) throws UserException {
Map<String, String> pros = Maps.newConcurrentMap();
if (storagePolicy.getCooldownTimestampMs() != -1) {
pros.put(StoragePolicy.COOLDOWN_DATETIME, String.valueOf(storagePolicy.getCooldownTimestampMs()));
}
if (storagePolicy.getCooldownTtl() != -1) {
pros.put(StoragePolicy.COOLDOWN_TTL, String.valueOf(storagePolicy.getCooldownTtl()));
}
pros.put(StoragePolicy.STORAGE_RESOURCE, storagePolicy.getStorageResource());

CreatePolicyStmt stmt = new CreatePolicyStmt(storagePolicy.getType(), true,
storagePolicy.getPolicyName(), pros);
createPolicy(stmt);
}

/**
* Create policy through http api.
**/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,15 +377,15 @@ suite("test_backup_cooldown_1", "backup_cooldown_data") {
// 1.3 restore 指定 ("reserve_storage_policy"="false"), 预期成功,且不落冷

// 2 删除老表
// 1.1 restore 不指定 预期成功,且落冷
// 1.2 restore 指定 ("reserve_storage_policy"="true")预期成功,且落冷
// 1.3 restore 指定 ("reserve_storage_policy"="false")预期成功,且不落冷
// 2.1 restore 不指定 预期成功,且落冷
// 2.2 restore 指定 ("reserve_storage_policy"="true")预期成功,且落冷
// 2.3 restore 指定 ("reserve_storage_policy"="false")预期成功,且不落冷


// 3 删除resource 和 policy
// 1.1 restore 不指定 预期成功,且落冷
// 1.2 restore 指定 ("reserve_storage_policy"="true")预期成功,且落冷
// 1.3 restore 指定 ("reserve_storage_policy"="false")预期成功,且不落冷
// 2.1 restore 不指定 预期成功,且落冷
// 2.2 restore 指定 ("reserve_storage_policy"="true")预期成功,且落冷
// 2.3 restore 指定 ("reserve_storage_policy"="false")预期成功,且不落冷


// 1. old table exist
Expand Down

0 comments on commit 2258d89

Please sign in to comment.