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

feat(storage): support azblob #8257

Merged
merged 8 commits into from
Mar 21, 2023
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
27 changes: 21 additions & 6 deletions risedev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ profile:
- use: meta-node
- use: compute-node
- use: frontend
# If you want to use hdfs as storage backend, configure hdfs namenode and root path:
# If you want to use webhdfs as storage backend, configure hdfs namenode and root path:
- use: opendal
engine: webhdfs
namenode: "127.0.0.1:9870"
Expand All @@ -148,7 +148,7 @@ profile:
- use: meta-node
- use: compute-node
- use: frontend
# If you want to use google cloud stoage as storage backend, configure hdfs namenode and root path:
# If you want to use google cloud stoage as storage backend, configure bucket name and root path:
- use: opendal
engine: gcs
bucket: bucket-name
Expand All @@ -163,10 +163,25 @@ profile:
- use: meta-node
- use: compute-node
- use: frontend
# If you want to use google cloud stoage as storage backend, configure hdfs namenode and root path:
# If you want to use oss as storage backend, configure bucket name and root path:
- use: opendal
engine: oss
bucket: "risingwave-oss-wcy"
bucket: test-bucket
root: risingwave
- use: compactor
# - use: prometheus
# - use: grafana

azblob:
steps:
# - use: etcd
- use: meta-node
- use: compute-node
- use: frontend
# If you want to use azblob as storage backend, configure bucket(container) name and root path:
- use: opendal
engine: azblob
bucket: test-bucket
root: risingwave
- use: compactor
# - use: prometheus
Expand Down Expand Up @@ -898,7 +913,7 @@ template:
# Minio instances used by this compute node
provide-minio: "minio*"

# AWS s3 bucket used by this compute node
# OpenDAL storage backend used by this compute node
provide-opendal: "opendal*"
# AWS s3 bucket used by this compute node
provide-aws-s3: "aws-s3*"
Expand Down Expand Up @@ -957,7 +972,7 @@ template:

engine: hdfs

namenode: 127.0.0.1:9000"
namenode: 127.0.0.1:9000

bucket: risingwave-test

Expand Down
9 changes: 9 additions & 0 deletions src/object_store/src/object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,15 @@ pub async fn parse_remote_object_store(
.monitored(metrics),
)
}
azblob if azblob.starts_with("azblob://") => {
let azblob = azblob.strip_prefix("azblob://").unwrap();
let (container_name, root) = azblob.split_once('@').unwrap();
ObjectStoreImpl::Opendal(
OpendalObjectStore::new_azblob_engine(container_name.to_string(), root.to_string())
.unwrap()
.monitored(metrics),
)
}
fs if fs.starts_with("fs://") => {
let fs = fs.strip_prefix("fs://").unwrap();
let (_, root) = fs.split_once('@').unwrap();
Expand Down
44 changes: 44 additions & 0 deletions src/object_store/src/object/opendal_engine/azblob.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2023 RisingWave Labs
//
// 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
//
// 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.

use opendal::services::Azblob;
use opendal::Operator;

use super::{EngineType, OpendalObjectStore};
use crate::object::ObjectResult;
impl OpendalObjectStore {
/// create opendal azblob engine.
pub fn new_azblob_engine(container_name: String, root: String) -> ObjectResult<Self> {
// Create azblob backend builder.
let mut builder = Azblob::default();
builder.root(&root);
builder.container(&container_name);

let endpoint = std::env::var("AZBLOB_ENDPOINT")
.unwrap_or_else(|_| panic!("AZBLOB_ENDPOINT not found from environment variables"));
let account_name = std::env::var("AZBLOB_ACCOUNT_NAME")
.unwrap_or_else(|_| panic!("AZBLOB_ACCOUNT_NAME not found from environment variables"));
let account_key = std::env::var("AZBLOB_ACCOUNT_KEY")
.unwrap_or_else(|_| panic!("AZBLOB_ACCOUNT_KEY not found from environment variables"));

builder.endpoint(&endpoint);
builder.account_name(&account_name);
builder.account_key(&account_key);
let op: Operator = Operator::new(builder)?.finish();
Ok(Self {
op,
engine_type: EngineType::Azblob,
})
}
}
2 changes: 2 additions & 0 deletions src/object_store/src/object/opendal_engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ pub mod gcs;
pub use gcs::*;
pub mod oss;
pub use oss::*;
pub mod azblob;
pub use azblob::*;
pub mod fs;
pub use fs::*;
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub enum EngineType {
Gcs,
Oss,
Webhdfs,
Azblob,
Fs,
}

Expand Down Expand Up @@ -186,6 +187,7 @@ impl ObjectStore for OpendalObjectStore {
EngineType::Gcs => "Gcs",
EngineType::Oss => "Oss",
EngineType::Webhdfs => "Webhdfs",
EngineType::Azblob => "Azblob",
EngineType::Fs => "Fs",
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/risedevtool/src/task/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ pub fn add_storage_backend(
.arg(format!("hummock+webhdfs://{}@{}", opendal.namenode, opendal.root));
true
}
else if opendal.engine == "azblob"{
cmd.arg("--state-store")
.arg(format!("hummock+azblob://{}@{}", opendal.bucket, opendal.root));
true
}
else if opendal.engine == "fs"{
cmd.arg("--state-store")
.arg(format!("hummock+fs://{}@{}", opendal.namenode, opendal.root));
Expand Down