pengxiangyu commented on a change in pull request #8532:
URL: https://github.com/apache/incubator-doris/pull/8532#discussion_r834070609



##########
File path: 
fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
##########
@@ -130,22 +139,50 @@ public static DataProperty 
analyzeDataProperty(Map<String, String> properties, D
                 hasCooldown = true;
                 DateLiteral dateLiteral = new DateLiteral(value, 
Type.DATETIME);
                 coolDownTimeStamp = 
dateLiteral.unixTimestamp(TimeUtils.getTimeZone());
+            } else if (!hasColdMedium && 
key.equalsIgnoreCase(PROPERTIES_STORAGE_COLD_MEDIUM)) {
+                hasColdMedium = true;

Review comment:
       coldMedium有可能是HDD。

##########
File path: 
fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
##########
@@ -130,22 +139,50 @@ public static DataProperty 
analyzeDataProperty(Map<String, String> properties, D
                 hasCooldown = true;
                 DateLiteral dateLiteral = new DateLiteral(value, 
Type.DATETIME);
                 coolDownTimeStamp = 
dateLiteral.unixTimestamp(TimeUtils.getTimeZone());
+            } else if (!hasColdMedium && 
key.equalsIgnoreCase(PROPERTIES_STORAGE_COLD_MEDIUM)) {
+                hasColdMedium = true;
+                if (value.equalsIgnoreCase(TStorageMedium.S3.name())) {
+                    coldStorageMedium = TStorageMedium.S3;
+                } else {
+                    throw new AnalysisException("Invalid cold storage medium: 
" + value);
+                }
+            } else if (!hasRemoteStorage && 
key.equalsIgnoreCase(PROPERTIES_REMOTE_STORAGE)) {
+                hasRemoteStorage = true;
+                remoteStorageName = value;
             }
         } // end for properties
 
-        if (!hasCooldown && !hasMedium) {
+        // remote_storage_medium may be empty, when data moves SSD to HDD.
+        if (!hasCooldown && !hasMedium && !hasColdMedium) {
             return oldDataProperty;
         }
 
         properties.remove(PROPERTIES_STORAGE_MEDIUM);
         properties.remove(PROPERTIES_STORAGE_COLDOWN_TIME);
+        properties.remove(PROPERTIES_STORAGE_COLD_MEDIUM);
+        properties.remove(PROPERTIES_REMOTE_STORAGE);
+
+        if (hasRemoteStorage && !hasColdMedium) {
+            throw new AnalysisException("Invalid data property, " +
+                    "`remote_storage` must be used with 
`storage_cold_medium`.");
+        }
+
+        if (hasColdMedium && hasRemoteStorage) {
+            remotestorageProperty = Catalog.getCurrentCatalog()
+                    
.getRemoteStorageMgr().getRemoteStorageByName(remoteStorageName);
+
+            if 
(!coldStorageMedium.name().equalsIgnoreCase(remotestorageProperty.getStorageType().name()))
 {
+                throw new AnalysisException("Invalid data property, " +
+                        "`storage_cold_medium` is inconsistent with 
`remote_storage`.");
+            }
+        }
 
         if (hasCooldown && !hasMedium) {
             throw new AnalysisException("Invalid data property. storage medium 
property is not found");
         }
 
-        if (storageMedium == TStorageMedium.HDD && hasCooldown) {
-            throw new AnalysisException("Can not assign cooldown timestamp to 
HDD storage medium");
+        if ((storageMedium == TStorageMedium.HDD && hasCooldown) && 
!(hasColdMedium && hasRemoteStorage)) {
+            throw new AnalysisException("Can not assign cooldown timestamp to 
HDD storage medium without remote storage");

Review comment:
       if (storageMedium == TStorageMedium.S3 && !(hasColdMedium && 
hasRemoteStorage)) {

##########
File path: 
fe/fe-core/src/main/java/org/apache/doris/catalog/RemoteStorageMgr.java
##########
@@ -0,0 +1,282 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.catalog;
+
+import org.apache.doris.analysis.AddRemoteStorageClause;
+import org.apache.doris.analysis.DropRemoteStorageClause;
+import org.apache.doris.analysis.ModifyRemoteStorageClause;
+import org.apache.doris.common.AnalysisException;
+import org.apache.doris.common.DdlException;
+import org.apache.doris.common.io.Text;
+import org.apache.doris.common.io.Writable;
+import org.apache.doris.common.proc.BaseProcResult;
+import org.apache.doris.common.proc.ProcNodeInterface;
+import org.apache.doris.common.proc.ProcResult;
+import org.apache.doris.common.util.PrintableMap;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.locks.ReentrantLock;
+
+public class RemoteStorageMgr {
+    private static final Logger LOG = 
LogManager.getLogger(RemoteStorageMgr.class);
+
+    public static final ImmutableList<String> 
REMOTE_STORAGE_PROC_NODE_TITLE_NAMES = new ImmutableList.Builder<String>()
+            .add("Name").add("Type").add("Properties")
+            .build();
+    private final Map<String, RemoteStorageInfo> storageInfoMap = 
Maps.newHashMap();
+    private final ReentrantLock lock = new ReentrantLock();
+    private RemoteStorageProcNode procNode = null;
+
+    public RemoteStorageMgr() {
+
+    }
+
+    public Map<String, RemoteStorageInfo> getStorageInfoMap() {
+        return storageInfoMap;
+    }
+
+    public RemoteStorageProperty getRemoteStorageByName(String storageName) 
throws AnalysisException {
+        RemoteStorageInfo info = storageInfoMap.get(storageName);
+        if (info == null) {
+            throw new AnalysisException("Unknown remote storage name: " + 
storageName);
+        }
+        return info.getRemoteStorageProperty();
+    }
+
+    public void addRemoteStorage(AddRemoteStorageClause clause) throws 
DdlException {
+        lock.lock();
+        try {
+            String storageName = clause.getStorageName();

Review comment:
       storage_name是key,不要引入空格,这里和下面的modify需要做一下trim。




-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to