Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adapt tencent COS to S3 plugin #59

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/src/main/java/com/dremio/io/file/UriSchemes.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public interface UriSchemes {
String WEBHDFS_SCHEME = "webhdfs";
String FILE_SCHEME = "file";
String S3_SCHEME = "s3";
String COS_SCHEME = "cosn";
String AZURE_SCHEME = "wasbs";
String GCS_SCHEME = "gs";
String ADL_SCHEME = "adl";
Expand Down
8 changes: 8 additions & 0 deletions plugins/s3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>com.qcloud.cos</groupId>
<artifactId>hadoop-cos</artifactId>
</dependency>
<dependency>
<groupId>com.qcloud</groupId>
<artifactId>cos_api-bundle</artifactId>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
Expand Down
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,16 @@ limitations under the License.
</dependency>

<!-- 3rd party dependencies -->
<dependency>
<groupId>com.qcloud.cos</groupId>
<artifactId>hadoop-cos</artifactId>
<version>3.1.0-5.9.3</version>
</dependency>
<dependency>
<groupId>com.qcloud</groupId>
<artifactId>cos_api-bundle</artifactId>
<version>5.6.35</version>
</dependency>
<dependency>
<!-- Address CVE-2019-10086 -->
<groupId>commons-beanutils</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
*/
public class DremioHadoopUtils {

public static final String COS_SCHEME = "cosn";

public static String getHadoopFSScheme(Path path, Configuration conf) {
return Util.getFs(path, conf).getScheme();
}
Expand All @@ -50,6 +52,9 @@ public static Path toHadoopPath(String path) {
* @return container name
*/
public static String getContainerName(Path path) {
if (COS_SCHEME.equalsIgnoreCase(path.toUri().getScheme())) {
return path.toString().split(Path.SEPARATOR)[2];
}
final List<String> pathComponents = Arrays.asList(
removeLeadingSlash(Path.getPathWithoutSchemeAndAuthority(path).toString())
.split(Path.SEPARATOR)
Expand All @@ -59,6 +64,9 @@ public static String getContainerName(Path path) {

public static Path pathWithoutContainer(Path path) {
List<String> pathComponents = Arrays.asList(removeLeadingSlash(Path.getPathWithoutSchemeAndAuthority(path).toString()).split(Path.SEPARATOR));
if (COS_SCHEME.equalsIgnoreCase(path.toUri().getScheme())) {
return new Path("/" + Joiner.on(Path.SEPARATOR).join(pathComponents));
}
return new Path("/" + Joiner.on(Path.SEPARATOR).join(pathComponents.subList(1, pathComponents.size())));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static com.dremio.io.file.Path.SEPARATOR;
import static com.dremio.io.file.UriSchemes.ADL_SCHEME;
import static com.dremio.io.file.UriSchemes.AZURE_SCHEME;
import static com.dremio.io.file.UriSchemes.COS_SCHEME;
import static com.dremio.io.file.UriSchemes.FILE_SCHEME;
import static com.dremio.io.file.UriSchemes.GCS_SCHEME;
import static com.dremio.io.file.UriSchemes.HDFS_SCHEME;
Expand Down Expand Up @@ -385,12 +386,14 @@ public static String getValidIcebergPath(Path path, Configuration conf, String f
urlBuilder.append(SCHEME_SEPARATOR);
urlBuilder.append(getContainerName(path));
urlBuilder.append(CONTAINER_SEPARATOR + accountName + AZURE_AUTHORITY_SUFFIX);
urlBuilder.append(pathWithoutContainer(path).toString());
urlBuilder.append(pathWithoutContainer(path));
return urlBuilder.toString();
} else if (fsScheme.equalsIgnoreCase(FileSystemConf.CloudFileSystemScheme.S3_FILE_SYSTEM_SCHEME.getScheme())) {
return S3_SCHEME + SCHEME_SEPARATOR + modifiedPath;
} else if (fsScheme.equalsIgnoreCase(FileSystemConf.CloudFileSystemScheme.GOOGLE_CLOUD_FILE_SYSTEM.getScheme())) {
return GCS_SCHEME + SCHEME_SEPARATOR + modifiedPath;
} else if (fsScheme.equalsIgnoreCase(COS_SCHEME)) {
return COS_SCHEME + SCHEME_SEPARATOR + modifiedPath;
} else if (fsScheme.equalsIgnoreCase(HDFS_SCHEME)) {
String hdfsEndPoint = conf.get("fs.defaultFS");
if (hdfsEndPoint == null || !hdfsEndPoint.toLowerCase().startsWith(HDFS_SCHEME)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public ParquetSplitReaderCreator(boolean autoCorrectCorruptDates,
this.splitXAttr = splitXAttr;
this.path = Path.of(splitXAttr.getPath());
this.tablePath = tablePath;
if (!fs.supportsPath(path)) {
if (!"cosn".equalsIgnoreCase(path.toURI().getScheme()) && !fs.supportsPath(path)) {
throw UserException.invalidMetadataError()
.addContext(String.format("%s: Invalid FS for file '%s'", fs.getScheme(), path))
.addContext("File", path)
Expand Down