forked from StarRocks/starrocks
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Support aliyun cloud credential (StarRocks#24805)
Signed-off-by: miomiocat <284487410@qq.com>
- Loading branch information
Showing
10 changed files
with
216 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,5 +20,6 @@ public enum CloudType { | |
AWS, | ||
AZURE, | ||
GCP, | ||
HDFS | ||
HDFS, | ||
ALIYUN | ||
} |
70 changes: 70 additions & 0 deletions
70
fe/fe-core/src/main/java/com/starrocks/credential/aliyun/AliyunCloudConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright 2021-present StarRocks, Inc. All rights reserved. | ||
// | ||
// Licensed 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 | ||
// | ||
// https://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.starrocks.credential.aliyun; | ||
|
||
import com.google.common.base.Preconditions; | ||
import com.staros.proto.FileStoreInfo; | ||
import com.starrocks.credential.CloudConfiguration; | ||
import com.starrocks.credential.CloudConfigurationConstants; | ||
import com.starrocks.credential.CloudType; | ||
import com.starrocks.thrift.TCloudConfiguration; | ||
import com.starrocks.thrift.TCloudProperty; | ||
import com.starrocks.thrift.TCloudType; | ||
import org.apache.hadoop.conf.Configuration; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
public class AliyunCloudConfiguration implements CloudConfiguration { | ||
|
||
private final AliyunCloudCredential aliyunCloudCredential; | ||
|
||
public AliyunCloudConfiguration(AliyunCloudCredential aliyunCloudCredential) { | ||
Preconditions.checkNotNull(aliyunCloudCredential); | ||
this.aliyunCloudCredential = aliyunCloudCredential; | ||
} | ||
|
||
// reuse aws client logic of BE | ||
@Override | ||
public void toThrift(TCloudConfiguration tCloudConfiguration) { | ||
tCloudConfiguration.setCloud_type(TCloudType.AWS); | ||
|
||
List<TCloudProperty> properties = new LinkedList<>(); | ||
properties.add(new TCloudProperty(CloudConfigurationConstants.AWS_S3_ENABLE_SSL, String.valueOf(true))); | ||
aliyunCloudCredential.toThrift(properties); | ||
tCloudConfiguration.setCloud_properties(properties); | ||
} | ||
|
||
@Override | ||
public void applyToConfiguration(Configuration configuration) { | ||
aliyunCloudCredential.applyToConfiguration(configuration); | ||
} | ||
|
||
@Override | ||
public CloudType getCloudType() { | ||
return CloudType.ALIYUN; | ||
} | ||
|
||
@Override | ||
public FileStoreInfo toFileStoreInfo() { | ||
// TODO: Support oss credential | ||
return aliyunCloudCredential.toFileStoreInfo(); | ||
} | ||
|
||
@Override | ||
public String getCredentialString() { | ||
return aliyunCloudCredential.getCredentialString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
fe/fe-core/src/main/java/com/starrocks/credential/aliyun/AliyunCloudCredential.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright 2021-present StarRocks, Inc. All rights reserved. | ||
// | ||
// Licensed 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 | ||
// | ||
// https://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.starrocks.credential.aliyun; | ||
|
||
import com.google.common.base.Preconditions; | ||
import com.staros.proto.FileStoreInfo; | ||
import com.starrocks.credential.CloudConfigurationConstants; | ||
import com.starrocks.credential.CloudCredential; | ||
import com.starrocks.thrift.TCloudProperty; | ||
import org.apache.hadoop.conf.Configuration; | ||
|
||
import java.util.List; | ||
|
||
public class AliyunCloudCredential implements CloudCredential { | ||
|
||
private final String accessKey; | ||
private final String secretKey; | ||
private final String endpoint; | ||
|
||
public AliyunCloudCredential(String accessKey, String secretKey, String endpoint) { | ||
Preconditions.checkNotNull(accessKey); | ||
Preconditions.checkNotNull(secretKey); | ||
Preconditions.checkNotNull(endpoint); | ||
this.accessKey = accessKey; | ||
this.secretKey = secretKey; | ||
this.endpoint = endpoint; | ||
} | ||
@Override | ||
public void applyToConfiguration(Configuration configuration) { | ||
configuration.set("fs.oss.impl", "com.aliyun.jindodata.oss.JindoOssFileSystem"); | ||
configuration.set("fs.AbstractFileSystem.oss.impl", "com.aliyun.jindodata.oss.OSS"); | ||
configuration.set("fs.oss.accessKeyId", accessKey); | ||
configuration.set("fs.oss.accessKeySecret", secretKey); | ||
configuration.set("fs.oss.endpoint", endpoint); | ||
} | ||
|
||
@Override | ||
public boolean validate() { | ||
return !this.accessKey.isEmpty() && !this.secretKey.isEmpty() && !this.endpoint.isEmpty(); | ||
} | ||
|
||
// reuse aws client logic of BE | ||
@Override | ||
public void toThrift(List<TCloudProperty> properties) { | ||
properties.add(new TCloudProperty(CloudConfigurationConstants.AWS_S3_ACCESS_KEY, accessKey)); | ||
properties.add(new TCloudProperty(CloudConfigurationConstants.AWS_S3_SECRET_KEY, secretKey)); | ||
properties.add(new TCloudProperty(CloudConfigurationConstants.AWS_S3_ENDPOINT, endpoint)); | ||
} | ||
|
||
@Override | ||
public String getCredentialString() { | ||
return "AliyunCloudCredential{" + | ||
"accessKey=" + accessKey + | ||
", secretKey='" + secretKey + '\'' + | ||
", endpoint='" + endpoint + '\'' + | ||
'}'; | ||
} | ||
|
||
@Override | ||
public FileStoreInfo toFileStoreInfo() { | ||
// TODO: Support oss credential | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,8 @@ enum TCloudType { | |
DEFAULT, | ||
AWS, | ||
AZURE, | ||
GCP | ||
GCP, | ||
ALIYUN | ||
} | ||
|
||
struct TCloudProperty { | ||
|