github-actions[bot] commented on code in PR #64695:
URL: https://github.com/apache/doris/pull/64695#discussion_r3586086490
##########
fe/fe-filesystem/fe-filesystem-spi/src/main/java/org/apache/doris/filesystem/spi/ObjectStorageUri.java:
##########
@@ -59,6 +66,45 @@ private ObjectStorageUri(String bucket, String key) {
* original (escaped) form.
*/
public static ObjectStorageUri parse(String path, boolean pathStyleAccess)
{
+ return parse(path, pathStyleAccess, null);
+ }
+
+ /**
+ * Same as {@link #parse(String, boolean)} but validates the URI scheme
against the set of
+ * schemes the calling provider accepts. A scheme not in {@code
supportedSchemes} (matched
+ * case-insensitively) is rejected, so e.g. a COS provider refuses an
{@code oss://} URI.
+ * Passing {@code null} or an empty set skips scheme validation.
+ *
+ * <p>{@code http}/{@code https} are always accepted regardless of {@code
supportedSchemes}:
+ * they are the endpoint-URL form (e.g. a TVF such as {@code s3()} pointed
at a path-style
+ * endpoint), not a provider-identity scheme. {@code supportedSchemes}
therefore stays explicit
+ * (e.g. {@code s3}/{@code oss}/{@code cos}) for catalog scheme-to-storage
routing and omits
+ * {@code http}/{@code https} on purpose.
+ */
+ public static ObjectStorageUri parse(String path, boolean pathStyleAccess,
Set<String> supportedSchemes) {
+ if (path == null) {
+ throw new IllegalArgumentException("Object storage path must not
be null");
+ }
+ if (supportedSchemes != null && !supportedSchemes.isEmpty()) {
+ int schemeEnd = path.indexOf("://");
+ if (schemeEnd < 0) {
+ throw new IllegalArgumentException("Cannot parse object
storage URI without scheme: " + path);
+ }
+ String scheme = path.substring(0, schemeEnd).toLowerCase();
+ // http/https is the endpoint-URL form (e.g. TVF s3() with a
path-style endpoint),
+ // not a provider-identity scheme, so it bypasses the
supportedSchemes check. The set
+ // stays explicit (s3/oss/cos/...) for catalog scheme-to-storage
routing; the actual
+ // bucket/key extraction for http(s) is handled by the path-style
branch in doParse.
+ boolean httpEndpoint = scheme.equals("http") ||
scheme.equals("https");
+ if (!httpEndpoint && !supportedSchemes.contains(scheme)) {
+ throw new IllegalArgumentException("Unsupported scheme '" +
scheme
Review Comment:
This still leaves direct concrete-filesystem callers outside the new
normalization boundary. `LoadCommand` normalizes the Nereids broker-load path,
and the OUTFILE/EXPORT/import-preview callers are now fixed, but several other
direct paths still pass raw compatibility URIs after selecting a concrete
object-store filesystem: legacy `BrokerLoadPendingTask` lists
`BrokerFileGroup.getFilePaths()` directly;
`InsertIntoTVFCommand.deleteExistingFilesInFE()` deletes the raw `file_path`
parent; `Repository.ping()` rebuilds the check path from the raw `location`
field even though repository init used normalized `getLocation()`; and Hive
ACID scanning selects the filesystem from normalized `LocationPath` but
`AcidUtil.getAcidState()` then calls `FileSystemTransferUtil.globList()` on raw
`partition.getPath()` / base / delta paths. With S3 properties and a
compatibility URI such as `cos://bucket/key`, these paths now reach the S3
filesystem and fail this guard with `Unsupported scheme 'cos'`,
whereas the old parser accepted them. Please normalize these remaining direct
paths as well, and add coverage for the non-Nereids broker-load, TVF-delete,
repository-ping, and Hive transactional-partition paths.
##########
fe/fe-filesystem/fe-filesystem-oss-hdfs/src/main/java/org/apache/doris/filesystem/hdfs/properties/OssHdfsProperties.java:
##########
@@ -0,0 +1,175 @@
+// 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.filesystem.hdfs.properties;
+
+import org.apache.doris.foundation.property.ConnectorProperty;
+
+import com.google.common.collect.ImmutableSet;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Aliyun OSS-HDFS (JindoFS) storage properties for fe-filesystem.
+ *
+ * <p>OSS-HDFS is an HDFS-compatible service over OSS, addressed with {@code
oss://} URIs and
+ * served by the JindoFS Hadoop FileSystem ({@code
com.aliyun.jindodata.oss.JindoOssFileSystem}).
+ * It therefore sits on the shared {@link HdfsCompatibleProperties} base
alongside plain
+ * {@link HdfsProperties} and produces a backend config map for {@code
DFSFileSystem}; the only
+ * delta is the Jindo {@code fs.oss.*} wiring plus oss-dls endpoint/region
handling.</p>
+ *
+ * <p>Self-contained port of the kernel {@code OSSHdfsProperties}, with zero
fe-core / fe-common
+ * dependency. The Jindo impl class names are kept as string constants (loaded
reflectively by the
+ * backend), so no compile dependency on the Jindo SDK is introduced.</p>
+ *
+ * <p>The normalized {@code fs.oss.*} backend keys are accepted as aliases so
the binder is a
+ * fixpoint for converter-produced maps: fe-core's StoragePropertiesConverter
hands the plugin
+ * {@code getBackendConfigProperties()} output (plus the {@code
_STORAGE_TYPE_} marker), not the
+ * raw user keys, and rebinding that map must yield the same configuration.</p>
+ */
+public class OssHdfsProperties extends HdfsCompatibleProperties {
+
+ private static final String JINDO_OSS_FILE_SYSTEM_IMPL =
+ "com.aliyun.jindodata.oss.JindoOssFileSystem";
+ private static final String JINDO_OSS_ABSTRACT_FILE_SYSTEM_IMPL =
+ "com.aliyun.jindodata.oss.JindoOSS";
+
+ private static final String OSS_HDFS_PREFIX_KEY = "oss.hdfs.";
+ private static final String OSS_HDFS_ENDPOINT_SUFFIX =
".oss-dls.aliyuncs.com";
+
+ private static final Set<String> OSS_ENDPOINT_KEY_NAME =
ImmutableSet.of("oss.hdfs.endpoint",
+ "oss.endpoint", "dlf.endpoint", "dlf.catalog.endpoint");
+
+ private static final Set<Pattern> ENDPOINT_PATTERN = ImmutableSet.of(
+
Pattern.compile("(?:https?://)?([a-z]{2}-[a-z0-9-]+)\\.oss-dls\\.aliyuncs\\.com"),
+
Pattern.compile("^(?:https?://)?dlf(?:-vpc)?\\.([a-z0-9-]+)\\.aliyuncs\\.com(?:/.*)?$"));
+
+ private static final Set<String> SUPPORT_SCHEMA = ImmutableSet.of("oss",
"hdfs");
+
+ @ConnectorProperty(names = {"oss.hdfs.endpoint", "oss.endpoint",
"dlf.endpoint", "dlf.catalog.endpoint",
+ "fs.oss.endpoint"},
+ description = "The endpoint of OSS.")
+ private String endpoint = "";
+
+ @ConnectorProperty(names = {"oss.hdfs.access_key", "oss.access_key",
"dlf.access_key", "dlf.catalog.accessKeyId",
+ "fs.oss.accessKeyId"},
+ sensitive = true,
+ description = "The access key of OSS.")
+ private String accessKey = "";
+
+ @ConnectorProperty(names = {"oss.hdfs.secret_key", "oss.secret_key",
"dlf.secret_key", "dlf.catalog.secret_key",
+ "fs.oss.accessKeySecret"},
+ sensitive = true,
+ description = "The secret key of OSS.")
+ private String secretKey = "";
+
+ @ConnectorProperty(names = {"oss.hdfs.region", "oss.region", "dlf.region",
"fs.oss.region"},
+ required = false,
+ description = "The region of OSS.")
+ private String region = "";
+
+ @ConnectorProperty(names = {"oss.hdfs.fs.defaultFS"}, required = false,
description = "")
+ private String fsDefaultFS = "";
+
+ @ConnectorProperty(names = {"oss.hdfs.hadoop.config.resources"},
+ required = false,
+ description = "The xml files of Hadoop configuration.")
+ private String hadoopConfigResources = "";
+
+ @ConnectorProperty(names = {"oss.hdfs.security_token",
"oss.security_token", "fs.oss.securityToken"},
+ required = false,
+ sensitive = true,
+ description = "The security token of OSS.")
+ private String securityToken = "";
+
+ public OssHdfsProperties(Map<String, String> origProps) {
+ super(origProps);
+ }
+
+ /**
+ * Cheap, deterministic detection of an OSS-HDFS configuration: an
explicit {@code oss.hdfs.}
+ * enable flag, or any endpoint key pointing at an {@code
*.oss-dls.aliyuncs.com} host.
+ */
+ public static boolean guessIsMe(Map<String, String> props) {
+ boolean enable = props.entrySet().stream()
+ .anyMatch(e -> e.getKey().equalsIgnoreCase(OSS_HDFS_PREFIX_KEY)
+ && Boolean.parseBoolean(e.getValue()));
+ if (enable) {
+ return true;
+ }
+ return OSS_ENDPOINT_KEY_NAME.stream()
+ .map(props::get)
+ .anyMatch(ep -> StringUtils.isNotBlank(ep) &&
ep.endsWith(OSS_HDFS_ENDPOINT_SUFFIX));
+ }
+
+ static Optional<String> extractRegion(String endpoint) {
+ for (Pattern pattern : ENDPOINT_PATTERN) {
+ Matcher matcher = pattern.matcher(endpoint.toLowerCase());
+ if (matcher.matches()) {
+ return Optional.ofNullable(matcher.group(1));
+ }
+ }
+ return Optional.empty();
+ }
+
+ private void convertDlfToOssEndpointIfNeeded() {
+ if (this.endpoint.contains("dlf")) {
+ this.endpoint = this.region + ".oss-dls.aliyuncs.com";
+ }
+ }
+
+ @Override
+ protected void doInitNormalizeAndCheckProps() {
+ // Derive region from the endpoint when not explicitly set, e.g.
+ // "cn-shanghai.oss-dls.aliyuncs.com" -> "cn-shanghai".
+ if (StringUtils.isBlank(this.region)) {
+ Optional<String> regionOptional = extractRegion(endpoint);
+ if (!regionOptional.isPresent()) {
+ throw new IllegalArgumentException("The region extracted from
the endpoint is empty. "
+ + "Please check the endpoint format: " + endpoint + "
or set oss.hdfs.region");
+ }
+ this.region = regionOptional.get();
+ }
+ convertDlfToOssEndpointIfNeeded();
+ if (StringUtils.isBlank(fsDefaultFS)) {
+ this.fsDefaultFS =
HdfsPropertiesUtils.extractDefaultFsFromUri(origProps, SUPPORT_SCHEMA);
+ }
+ initConfigurationParams();
+ }
+
+ private void initConfigurationParams() {
+ Map<String, String> config = loadConfigFromFile(hadoopConfigResources);
+ config.put("fs.oss.endpoint", endpoint);
Review Comment:
`StoragePropertiesConverter.toMap()` passes the plugin a converted backend
map, not the original OSS-HDFS catalog properties: it starts from
`props.getBackendConfigProperties()` and adds `_STORAGE_TYPE_=OSS_HDFS`. That
backend map can already include XML-loaded Hadoop/OSS keys and `fs.defaultFS`,
but when `OssHdfsFileSystemProvider` rebinds it here, `hadoopConfigResources`
is no longer present and `initConfigurationParams()` starts from an empty
`loadConfigFromFile(...)` result. The method only writes the fixed
credential/endpoint fields, so existing backend entries such as XML-loaded
`fs.oss.*` keys, Hadoop configs, and converted `fs.defaultFS` are dropped
before constructing `DFSFileSystem`. HDFS and JFS preserve pass-through
`fs.*`/`dfs.*`/`hadoop.*` entries in their plugin property classes; OSS-HDFS
needs the same fixpoint behavior, plus a round-trip test that feeds
`StoragePropertiesConverter.toMap(...)` output into the plugin properties.
--
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]