CalvinKirs commented on code in PR #50849:
URL: https://github.com/apache/doris/pull/50849#discussion_r2092571834


##########
fe/fe-core/src/main/java/org/apache/doris/backup/BackupHandler.java:
##########
@@ -231,9 +237,41 @@ public void createRepository(CreateRepositoryStmt stmt) 
throws DdlException {
     }
 
     public void alterRepository(AlterRepositoryStmt stmt) throws DdlException {
-        alterRepositoryInternal(stmt.getName(), stmt.getProperties());
+        tryLock();
+        try {
+            Repository repo = repoMgr.getRepo(stmt.getName());
+            if (repo == null) {
+                ErrorReport.reportDdlException(ErrorCode.ERR_COMMON_ERROR, 
"Repository does not exist");
+            }
+            Map<String, String> allProperties = new 
HashMap<>(repo.getRemoteFileSystem().getProperties());
+            allProperties.putAll(stmt.getProperties());
+            StorageProperties newStorageProperties = 
StorageProperties.createPrimary(allProperties);
+            RemoteFileSystem fileSystem = 
FileSystemFactory.get(newStorageProperties);
+
+            Repository newRepo = new Repository(repo.getId(), repo.getName(), 
repo.isReadOnly(),
+                    repo.getLocation(), fileSystem);
+            if (!newRepo.ping()) {
+                LOG.warn("Failed to connect repository {}. msg: {}", 
repo.getName(), repo.getErrorMsg());
+                ErrorReport.reportDdlException(ErrorCode.ERR_COMMON_ERROR,
+                        "Repo can not ping with new storage properties");
+            }
+
+            Status st = repoMgr.alterRepo(newRepo, false /* not replay */);
+            if (!st.ok()) {
+                ErrorReport.reportDdlException(ErrorCode.ERR_COMMON_ERROR,
+                        "Failed to alter repository: " + st.getErrMsg());
+            }
+            for (AbstractJob job : getAllCurrentJobs()) {
+                if (!job.isDone() && job.getRepoId() == repo.getId()) {
+                    job.updateRepo(newRepo);
+                }
+            }
+        } finally {
+            seqlock.unlock();
+        }
     }
 
+
     public void alterRepositoryInternal(String repoName, Map<String, String> 
properties) throws DdlException {

Review Comment:
   todo : checklist method



##########
fe/fe-core/src/main/java/org/apache/doris/backup/Repository.java:
##########
@@ -307,62 +344,31 @@ public Status initRepository() {
         }
     }
 
-    public Status alterRepositoryS3Properties(Map<String, String> properties) {

Review Comment:
   todo revert line



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to