morningman commented on code in PR #14842:
URL: https://github.com/apache/doris/pull/14842#discussion_r1042188903


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/S3Resource.java:
##########
@@ -41,68 +40,92 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
-import java.util.Set;
 
 /**
- * S3 resource for olap table
+ * S3 resource
  *
  * Syntax:
  * CREATE RESOURCE "remote_s3"
  * PROPERTIES
  * (
  *    "type" = "s3",
- *    "s3_endpoint" = "bj",
- *    "s3_region" = "bj",
- *    "s3_root_path" = "/path/to/root",
- *    "s3_access_key" = "bbb",
- *    "s3_secret_key" = "aaaa",
- *    "s3_max_connections" = "50",
- *    "s3_request_timeout_ms" = "3000",
- *    "s3_connection_timeout_ms" = "1000"
+ *    "AWS_ENDPOINT" = "bj",
+ *    "AWS_REGION" = "bj",
+ *    "AWS_ROOT_PATH" = "/path/to/root",
+ *    "AWS_ACCESS_KEY" = "bbb",
+ *    "AWS_SECRET_KEY" = "aaaa",
+ *    "AWS_MAX_CONNECTION" = "50",
+ *    "AWS_REQUEST_TIMEOUT_MS" = "3000",
+ *    "AWS_CONNECTION_TIMEOUT_MS" = "1000"
  * );
  */
 public class S3Resource extends Resource {
+    public enum ReferenceType {
+        TVF, // table valued function
+        LOAD,
+        EXPORT,
+        REPOSITORY,
+        OUTFILE,
+        TABLE,
+        POLICY
+    }
+
     private static final Logger LOG = LogManager.getLogger(S3Resource.class);
+    public static final String S3_PROPERTIES_PREFIX = "AWS";
+    public static final String S3_FS_PREFIX = "fs.s3";
     // required
-    public static final String S3_ENDPOINT = "s3_endpoint";
-    public static final String S3_REGION = "s3_region";
-    public static final String S3_ROOT_PATH = "s3_root_path";
-    public static final String S3_ACCESS_KEY = "s3_access_key";
-    public static final String S3_SECRET_KEY = "s3_secret_key";
-    public static final String S3_BUCKET = "s3_bucket";
+    public static final String S3_ENDPOINT = "AWS_ENDPOINT";
+    public static final String S3_REGION = "AWS_REGION";
+    public static final String S3_ACCESS_KEY = "AWS_ACCESS_KEY";
+    public static final String S3_SECRET_KEY = "AWS_SECRET_KEY";
+    public static final List<String> REQUIRED_FIELDS =
+            Arrays.asList(S3_ENDPOINT, S3_REGION, S3_ACCESS_KEY, 
S3_SECRET_KEY);
+    // required by storage policy
+    public static final String S3_ROOT_PATH = "AWS_ROOT_PATH";
+    public static final String S3_BUCKET = "AWS_BUCKET";
 
     // optional
-    public static final String S3_MAX_CONNECTIONS = "s3_max_connections";
-    public static final String S3_REQUEST_TIMEOUT_MS = "s3_request_timeout_ms";
-    public static final String S3_CONNECTION_TIMEOUT_MS = 
"s3_connection_timeout_ms";
+    public static final String USE_PATH_STYLE = "use_path_style";
+    public static final String S3_MAX_CONNECTIONS = "AWS_MAX_CONNECTIONS";
+    public static final String S3_REQUEST_TIMEOUT_MS = 
"AWS_REQUEST_TIMEOUT_MS";
+    public static final String S3_CONNECTION_TIMEOUT_MS = 
"AWS_CONNECTION_TIMEOUT_MS";
     public static final String DEFAULT_S3_MAX_CONNECTIONS = "50";
     public static final String DEFAULT_S3_REQUEST_TIMEOUT_MS = "3000";
     public static final String DEFAULT_S3_CONNECTION_TIMEOUT_MS = "1000";
 
     @SerializedName(value = "properties")
     private Map<String, String> properties;
 
-    @SerializedName(value = "usedByPolicySet")
-    private Set<String> usedByPolicySet;
+    @SerializedName(value = "referenceSet")
+    private Map<String, ReferenceType> references;

Review Comment:
   I doubt if it is forward-compatible



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/HMSResource.java:
##########
@@ -0,0 +1,84 @@
+// 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.common.DdlException;
+import org.apache.doris.common.proc.BaseProcResult;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.gson.annotations.SerializedName;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * HMS resource
+ * <p>
+ * Syntax:
+ * CREATE RESOURCE "hive"
+ * PROPERTIES
+ * (
+ * "type" = "hms",
+ * "hive.metastore.uris" = "thrift://172.21.0.44:7004"
+ * );
+ */
+public class HMSResource extends Resource {
+    // required
+    public static final String HIVE_METASTORE_URIS = "hive.metastore.uris";

Review Comment:
   Maybe we need to add some `getHiveConfiguration` or `getHdfsConfiguration` 
for HMSResource or HdfsResource. Because some properties are read from 
`hdfs-site.xml` or `hive-site.xml` in `conf/` dir.



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/Resource.java:
##########
@@ -98,6 +100,12 @@ private static Resource getResourceInstance(ResourceType 
type, String name) thro
             case JDBC:
                 resource = new JdbcResource(name);
                 break;
+            case HDFS:
+                resource = new HdfsResource(name);

Review Comment:
   Add new resource class to GsonUtils.java



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/HdfsResource.java:
##########
@@ -0,0 +1,123 @@
+// 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.common.DdlException;
+import org.apache.doris.common.proc.BaseProcResult;
+import org.apache.doris.thrift.THdfsConf;
+import org.apache.doris.thrift.THdfsParams;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.gson.annotations.SerializedName;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * HDFS resource
+ * <p>
+ * Syntax:
+ * CREATE RESOURCE "remote_hdfs"
+ * PROPERTIES
+ * (
+ * "type" = "hdfs",
+ * "fs.defaultFS" = "hdfs://10.220.147.151:8020",
+ * "hadoop.username" = "root"
+ * );
+ */
+public class HdfsResource extends Resource {
+    public static final String HADOOP_FS_PREFIX = "dfs.";
+    public static String HADOOP_FS_NAME = "fs.defaultFS";
+    // simple or kerberos
+    public static String HADOOP_USER_NAME = "hadoop.username";
+    public static String HADOOP_SECURITY_AUTHENTICATION = 
"hadoop.security.authentication";
+    public static String HADOOP_KERBEROS_PRINCIPAL = 
"hadoop.kerberos.principal";
+    public static String HADOOP_KERBEROS_KEYTAB = "hadoop.kerberos.keytab";
+    public static String HADOOP_SHORT_CIRCUIT = "dfs.client.read.shortcircuit";
+    public static String HADOOP_SOCKET_PATH = "dfs.domain.socket.path";
+    public static List<String> REQUIRED_FIELDS = 
Collections.singletonList(HADOOP_FS_NAME);
+
+    @SerializedName(value = "properties")
+    private Map<String, String> properties;
+
+    public HdfsResource(String name) {
+        super(name, Resource.ResourceType.HDFS);
+        properties = Maps.newHashMap();
+    }
+
+    @Override
+    public void modifyProperties(Map<String, String> properties) throws 
DdlException {

Review Comment:
   Most of `override` methods can be moved to the parent class `Resource`, 
since they all have same logic.



-- 
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