Skip to content
Merged
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
7 changes: 7 additions & 0 deletions fluss-dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.alibaba.fluss</groupId>
<artifactId>fluss-fs-obs</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>

<!-- metrics plugin -->
<dependency>
<groupId>com.alibaba.fluss</groupId>
Expand Down
6 changes: 6 additions & 0 deletions fluss-dist/src/main/assemblies/plugins.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
<files>
<!-- filesystem -->
<!-- output directory should correspond to the file system *schema* name, i.e., plugins/<schema>/ -->
<file>
<source>../fluss-filesystems/fluss-fs-obs/target/fluss-fs-obs-${project.version}.jar</source>
<outputDirectory>plugins/obs/</outputDirectory>
<destName>fluss-fs-obs-${project.version}.jar</destName>
<fileMode>0644</fileMode>
</file>
<file>
<source>../fluss-filesystems/fluss-fs-gs/target/fluss-fs-gs-${project.version}.jar</source>
<outputDirectory>plugins/gs/</outputDirectory>
Expand Down
259 changes: 259 additions & 0 deletions fluss-filesystems/fluss-fs-obs/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
<?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>com.alibaba.fluss</groupId>
<artifactId>fluss-filesystems</artifactId>
<version>0.8-SNAPSHOT</version>
</parent>

<artifactId>fluss-fs-obs</artifactId>
<name>Fluss : FileSystems : OBS FS</name>

<properties>
<fs.obs.sdk.version>3.24.12</fs.obs.sdk.version>
<huaweicloud.sdk.iam.version>3.1.87</huaweicloud.sdk.iam.version>
<hadoop.huaweicloud.version>3.4.0</hadoop.huaweicloud.version>
</properties>

<dependencies>
<dependency>
<groupId>com.alibaba.fluss</groupId>
<artifactId>fluss-common</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.alibaba.fluss</groupId>
<artifactId>fluss-fs-hadoop-shaded</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.alibaba.fluss</groupId>
<artifactId>fluss-fs-hadoop</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs-client</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-huaweicloud</artifactId>
<version>${hadoop.huaweicloud.version}</version>
<exclusions>
<exclusion>
<groupId>com.huaweicloud</groupId>
<artifactId>esdk-obs-java-bundle</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.huaweicloud</groupId>
<artifactId>esdk-obs-java</artifactId>
<version>${fs.obs.sdk.version}</version>
<exclusions>
<exclusion>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.huaweicloud.sdk</groupId>
<artifactId>huaweicloud-sdk-iam</artifactId>
<version>${huaweicloud.sdk.iam.version}</version>
<exclusions>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
</exclusion>
<exclusion>
<groupId>org.openeuler</groupId>
<artifactId>bgmprovider</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>com.alibaba.fluss</groupId>
<artifactId>fluss-test-utils</artifactId>
</dependency>
<!-- for the behavior test suite -->
<dependency>
<groupId>com.alibaba.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>
<goals>
<goal>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>

<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>
</filters>
<relocations>
<relocation>
<pattern>org.apache.commons</pattern>
<shadedPattern>com.alibaba.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 com.alibaba.fluss.fs.obs;

import com.alibaba.fluss.fs.hdfs.HadoopFileSystem;
import com.alibaba.fluss.fs.obs.token.OBSSecurityTokenProvider;
import com.alibaba.fluss.fs.token.ObtainedSecurityToken;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;

import java.io.IOException;

/**
* A {@link FileSystem} for HuaweiCloud OBS that wraps an {@link HadoopFileSystem}, but overwrite
* method to generate access security token.
*/
class OBSFileSystem extends HadoopFileSystem {

private final Configuration conf;
private volatile OBSSecurityTokenProvider obsSecurityTokenProvider;
private final String scheme;

OBSFileSystem(FileSystem hadoopFileSystem, String scheme, Configuration conf) {
super(hadoopFileSystem);
this.scheme = scheme;
this.conf = conf;
}

@Override
public ObtainedSecurityToken obtainSecurityToken() throws IOException {
try {
mayCreateSecurityTokenProvider();
return obsSecurityTokenProvider.obtainSecurityToken(scheme);
} catch (Exception e) {
throw new IOException(e);
}
}

private void mayCreateSecurityTokenProvider() throws IOException {
if (obsSecurityTokenProvider == null) {
synchronized (this) {
if (obsSecurityTokenProvider == null) {
obsSecurityTokenProvider = new OBSSecurityTokenProvider(conf);
}
}
}
}
}
Loading