com.staros.filestore.AzBlobFileStore Maven / Gradle / Ivy
// 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.staros.filestore;
import com.staros.credential.AzBlobCredential;
import com.staros.proto.AzBlobFileStoreInfo;
import com.staros.proto.FileStoreInfo;
import com.staros.proto.FileStoreType;
public class AzBlobFileStore extends FileStore {
// https://xxx.blob.core.windows.net
private String endpoint;
// blob container + prefix
private String path;
// credential
private AzBlobCredential credential;
@Override
public FileStoreType type() {
return FileStoreType.AZBLOB;
}
@Override
public String rootPath() {
return "azblob://" + path;
}
@Override
public boolean isValid() {
return true;
}
public AzBlobFileStore(FileStoreInfo fsInfo, String endpoint, String path, AzBlobCredential credential) {
super(fsInfo);
this.endpoint = endpoint;
this.path = path;
this.credential = credential;
}
public AzBlobFileStore(String key, String name, String endpoint, String path, AzBlobCredential credential) {
super(key, name);
this.endpoint = endpoint;
this.path = path;
this.credential = credential;
}
@Override
public FileStoreInfo toProtobuf() {
AzBlobFileStoreInfo.Builder azblobBuilder = AzBlobFileStoreInfo.newBuilder();
AzBlobFileStoreInfo azblobInfo =
azblobBuilder.setEndpoint(endpoint)
.setPath(path)
.setCredential(credential.toProtobuf())
.build();
FileStoreInfo fileStoreInfo = super.toProtobuf();
return fileStoreInfo.toBuilder().setFsType(FileStoreType.AZBLOB)
.setAzblobFsInfo(azblobInfo).build();
}
@Override
public void mergeFrom(FileStore fileStore) {
super.mergeFrom(fileStore);
}
public static FileStore fromProtobuf(FileStoreInfo fsInfo) {
AzBlobFileStoreInfo azblobInfo = fsInfo.getAzblobFsInfo();
String endpoint = azblobInfo.getEndpoint();
String path = azblobInfo.getPath();
AzBlobCredential credential = AzBlobCredential.fromProtobuf(azblobInfo.getCredential());
return new AzBlobFileStore(fsInfo, endpoint, path, credential);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy