-
Notifications
You must be signed in to change notification settings - Fork 516
[FLUSS-2686] Add COS filesystem support #2836
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,250 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- | ||
| 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. | ||
| --> | ||
|
|
||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <parent> | ||
| <groupId>org.apache.fluss</groupId> | ||
| <artifactId>fluss-filesystems</artifactId> | ||
| <version>0.10-SNAPSHOT</version> | ||
| </parent> | ||
|
|
||
| <artifactId>fluss-fs-cos</artifactId> | ||
| <name>Fluss : FileSystems : COS FS</name> | ||
|
|
||
| <properties> | ||
| <fs.cosn.sdk.version>3.3.5</fs.cosn.sdk.version> | ||
| <fs.cos.api.version>5.6.139</fs.cos.api.version> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.apache.fluss</groupId> | ||
| <artifactId>fluss-common</artifactId> | ||
| <version>${project.version}</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.apache.fluss</groupId> | ||
| <artifactId>fluss-fs-hadoop-shaded</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.apache.fluss</groupId> | ||
| <artifactId>fluss-fs-hadoop</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.apache.hadoop</groupId> | ||
| <artifactId>hadoop-cos</artifactId> | ||
| <version>${fs.cosn.sdk.version}</version> | ||
| <exclusions> | ||
| <exclusion> | ||
| <groupId>com.qcloud</groupId> | ||
| <artifactId>cos_api</artifactId> | ||
| </exclusion> | ||
| <exclusion> | ||
| <groupId>org.apache.hadoop</groupId> | ||
| <artifactId>hadoop-common</artifactId> | ||
| </exclusion> | ||
| <exclusion> | ||
| <groupId>ch.qos.reload4j</groupId> | ||
| <artifactId>reload4j</artifactId> | ||
| </exclusion> | ||
| <exclusion> | ||
| <groupId>org.slf4j</groupId> | ||
| <artifactId>slf4j-reload4j</artifactId> | ||
| </exclusion> | ||
| </exclusions> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>com.qcloud</groupId> | ||
| <artifactId>cos_api</artifactId> | ||
| <version>${fs.cos.api.version}</version> | ||
| <exclusions> | ||
| <exclusion> | ||
| <groupId>javax.xml.bind</groupId> | ||
| <artifactId>jaxb-api</artifactId> | ||
| </exclusion> | ||
| </exclusions> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <!-- Hadoop requires jaxb-api for javax.xml.bind.JAXBException --> | ||
| <groupId>javax.xml.bind</groupId> | ||
| <artifactId>jaxb-api</artifactId> | ||
| <version>${jaxb.api.version}</version> | ||
| <!-- packaged as an optional dependency that is only accessible on Java 11+ --> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.apache.fluss</groupId> | ||
| <artifactId>fluss-test-utils</artifactId> | ||
| </dependency> | ||
| <!-- for the behavior test suite --> | ||
| <dependency> | ||
| <groupId>org.apache.fluss</groupId> | ||
| <artifactId>fluss-common</artifactId> | ||
| <version>${project.version}</version> | ||
| <scope>test</scope> | ||
| <type>test-jar</type> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-jar-plugin</artifactId> | ||
| <executions> | ||
| <execution> | ||
| <id>default-jar</id> | ||
| <goals> | ||
| <goal>jar</goal> | ||
| </goals> | ||
| </execution> | ||
| <execution> | ||
| <id>test-jar</id> | ||
| <goals> | ||
| <goal>test-jar</goal> | ||
| </goals> | ||
| </execution> | ||
| </executions> | ||
| <configuration> | ||
| <archive> | ||
| <manifestEntries> | ||
| <!-- jaxb-api is packaged as an optional dependency that is only accessible on Java 11 --> | ||
| <Multi-Release>true</Multi-Release> | ||
| </manifestEntries> | ||
| </archive> | ||
| </configuration> | ||
| </plugin> | ||
|
Comment on lines
+119
to
+144
|
||
|
|
||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-dependency-plugin</artifactId> | ||
| <executions> | ||
| <execution> | ||
| <id>copy-javax-jars</id> | ||
| <phase>process-resources</phase> | ||
| <goals> | ||
| <goal>copy</goal> | ||
| </goals> | ||
| </execution> | ||
| </executions> | ||
| <configuration> | ||
| <artifactItems> | ||
| <artifactItem> | ||
| <groupId>javax.xml.bind</groupId> | ||
| <artifactId>jaxb-api</artifactId> | ||
| <version>${jaxb.api.version}</version> | ||
| <type>jar</type> | ||
| <overWrite>true</overWrite> | ||
| </artifactItem> | ||
| </artifactItems> | ||
| <outputDirectory>${project.build.directory}/temporary</outputDirectory> | ||
| </configuration> | ||
| </plugin> | ||
|
|
||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-antrun-plugin</artifactId> | ||
| <executions> | ||
| <execution> | ||
| <id>unpack-javax-libraries</id> | ||
| <phase>process-resources</phase> | ||
| <goals> | ||
| <goal>run</goal> | ||
| </goals> | ||
| <configuration> | ||
| <target> | ||
| <echo message="unpacking javax jars"/> | ||
| <unzip dest="${project.build.directory}/classes/META-INF/versions/11"> | ||
| <fileset dir="${project.build.directory}/temporary"> | ||
| <include name="*"/> | ||
| </fileset> | ||
| </unzip> | ||
| </target> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
|
|
||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-shade-plugin</artifactId> | ||
| <executions> | ||
| <execution> | ||
| <id>shade-fluss</id> | ||
| <phase>package</phase> | ||
| <goals> | ||
| <goal>shade</goal> | ||
| </goals> | ||
| <configuration> | ||
| <artifactSet> | ||
| <includes> | ||
| <include>*:*</include> | ||
| </includes> | ||
| <excludes> | ||
| <exclude>javax.servlet:servlet-api</exclude> | ||
| <exclude>xmlenc:xmlenc</exclude> | ||
| </excludes> | ||
| </artifactSet> | ||
| <filters> | ||
| <filter> | ||
| <artifact>*</artifact> | ||
| <excludes> | ||
| <exclude>.gitkeep</exclude> | ||
| <exclude>mime.types</exclude> | ||
| <exclude>mozilla/**</exclude> | ||
| <exclude>LICENSE.txt</exclude> | ||
| <exclude>license/LICENSE*</exclude> | ||
| <exclude>okhttp3/internal/publicsuffix/NOTICE</exclude> | ||
| <exclude>NOTICE</exclude> | ||
| </excludes> | ||
| </filter> | ||
| <filter> | ||
| <artifact>org.apache.fluss:fluss-fs-hadoop</artifact> | ||
| <excludes> | ||
| <exclude>META-INF/**</exclude> | ||
| </excludes> | ||
| </filter> | ||
| </filters> | ||
| <relocations> | ||
| <relocation> | ||
| <pattern>org.apache.commons</pattern> | ||
| <shadedPattern>org.apache.fluss.shaded.org.apache.commons</shadedPattern> | ||
| </relocation> | ||
| </relocations> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
|
|
||
| </plugins> | ||
| </build> | ||
|
|
||
| </project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /* | ||
| * 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.fluss.fs.cos; | ||
|
|
||
| import org.apache.fluss.fs.cos.token.COSSecurityTokenProvider; | ||
| import org.apache.fluss.fs.hdfs.HadoopFileSystem; | ||
| import org.apache.fluss.fs.token.ObtainedSecurityToken; | ||
|
|
||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.fs.FileSystem; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| /** | ||
| * A {@link FileSystem} for Tencent Cloud COS that wraps an {@link HadoopFileSystem}, but overwrite | ||
| * method to generate access security token. | ||
| */ | ||
| class COSFileSystem extends HadoopFileSystem { | ||
|
|
||
| private final Configuration conf; | ||
| private volatile COSSecurityTokenProvider cosSecurityTokenProvider; | ||
| private final String scheme; | ||
|
|
||
| COSFileSystem(FileSystem hadoopFileSystem, String scheme, Configuration conf) { | ||
| super(hadoopFileSystem); | ||
| this.scheme = scheme; | ||
| this.conf = conf; | ||
| } | ||
|
|
||
| @Override | ||
| public ObtainedSecurityToken obtainSecurityToken() throws IOException { | ||
| try { | ||
| mayCreateSecurityTokenProvider(); | ||
| return cosSecurityTokenProvider.obtainSecurityToken(scheme); | ||
| } catch (Exception e) { | ||
| throw new IOException(e); | ||
| } | ||
| } | ||
|
|
||
| private void mayCreateSecurityTokenProvider() throws IOException { | ||
| if (cosSecurityTokenProvider == null) { | ||
| synchronized (this) { | ||
| if (cosSecurityTokenProvider == null) { | ||
| cosSecurityTokenProvider = new COSSecurityTokenProvider(conf); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be in test scope?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test scope for fluss-test-utils is already defined in the parent pom's dependencyManagement section (line 336 in root pom.xml), so child modules inherit it automatically without needing to declare test explicitly. This is consistent with how other filesystem modules (oss, s3, gs, azure, obs, hdfs) declare this dependency.