Skip to content

Commit 83057e5

Browse files
authored
feat(storage): support azblob (risingwavelabs#8257)
1 parent dd34989 commit 83057e5

File tree

6 files changed

+83
-6
lines changed

6 files changed

+83
-6
lines changed

risedev.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ profile:
133133
- use: meta-node
134134
- use: compute-node
135135
- use: frontend
136-
# If you want to use hdfs as storage backend, configure hdfs namenode and root path:
136+
# If you want to use webhdfs as storage backend, configure hdfs namenode and root path:
137137
- use: opendal
138138
engine: webhdfs
139139
namenode: "127.0.0.1:9870"
@@ -148,7 +148,7 @@ profile:
148148
- use: meta-node
149149
- use: compute-node
150150
- use: frontend
151-
# If you want to use google cloud stoage as storage backend, configure hdfs namenode and root path:
151+
# If you want to use google cloud stoage as storage backend, configure bucket name and root path:
152152
- use: opendal
153153
engine: gcs
154154
bucket: bucket-name
@@ -163,10 +163,25 @@ profile:
163163
- use: meta-node
164164
- use: compute-node
165165
- use: frontend
166-
# If you want to use google cloud stoage as storage backend, configure hdfs namenode and root path:
166+
# If you want to use oss as storage backend, configure bucket name and root path:
167167
- use: opendal
168168
engine: oss
169-
bucket: "risingwave-oss-wcy"
169+
bucket: test-bucket
170+
root: risingwave
171+
- use: compactor
172+
# - use: prometheus
173+
# - use: grafana
174+
175+
azblob:
176+
steps:
177+
# - use: etcd
178+
- use: meta-node
179+
- use: compute-node
180+
- use: frontend
181+
# If you want to use azblob as storage backend, configure bucket(container) name and root path:
182+
- use: opendal
183+
engine: azblob
184+
bucket: test-bucket
170185
root: risingwave
171186
- use: compactor
172187
# - use: prometheus
@@ -898,7 +913,7 @@ template:
898913
# Minio instances used by this compute node
899914
provide-minio: "minio*"
900915

901-
# AWS s3 bucket used by this compute node
916+
# OpenDAL storage backend used by this compute node
902917
provide-opendal: "opendal*"
903918
# AWS s3 bucket used by this compute node
904919
provide-aws-s3: "aws-s3*"
@@ -957,7 +972,7 @@ template:
957972

958973
engine: hdfs
959974

960-
namenode: 127.0.0.1:9000"
975+
namenode: 127.0.0.1:9000
961976

962977
bucket: risingwave-test
963978

src/object_store/src/object/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,15 @@ pub async fn parse_remote_object_store(
857857
.monitored(metrics),
858858
)
859859
}
860+
azblob if azblob.starts_with("azblob://") => {
861+
let azblob = azblob.strip_prefix("azblob://").unwrap();
862+
let (container_name, root) = azblob.split_once('@').unwrap();
863+
ObjectStoreImpl::Opendal(
864+
OpendalObjectStore::new_azblob_engine(container_name.to_string(), root.to_string())
865+
.unwrap()
866+
.monitored(metrics),
867+
)
868+
}
860869
fs if fs.starts_with("fs://") => {
861870
let fs = fs.strip_prefix("fs://").unwrap();
862871
let (_, root) = fs.split_once('@').unwrap();
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright 2023 RisingWave Labs
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
use opendal::services::Azblob;
16+
use opendal::Operator;
17+
18+
use super::{EngineType, OpendalObjectStore};
19+
use crate::object::ObjectResult;
20+
impl OpendalObjectStore {
21+
/// create opendal azblob engine.
22+
pub fn new_azblob_engine(container_name: String, root: String) -> ObjectResult<Self> {
23+
// Create azblob backend builder.
24+
let mut builder = Azblob::default();
25+
builder.root(&root);
26+
builder.container(&container_name);
27+
28+
let endpoint = std::env::var("AZBLOB_ENDPOINT")
29+
.unwrap_or_else(|_| panic!("AZBLOB_ENDPOINT not found from environment variables"));
30+
let account_name = std::env::var("AZBLOB_ACCOUNT_NAME")
31+
.unwrap_or_else(|_| panic!("AZBLOB_ACCOUNT_NAME not found from environment variables"));
32+
let account_key = std::env::var("AZBLOB_ACCOUNT_KEY")
33+
.unwrap_or_else(|_| panic!("AZBLOB_ACCOUNT_KEY not found from environment variables"));
34+
35+
builder.endpoint(&endpoint);
36+
builder.account_name(&account_name);
37+
builder.account_key(&account_key);
38+
let op: Operator = Operator::new(builder)?.finish();
39+
Ok(Self {
40+
op,
41+
engine_type: EngineType::Azblob,
42+
})
43+
}
44+
}

src/object_store/src/object/opendal_engine/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,7 @@ pub mod gcs;
2626
pub use gcs::*;
2727
pub mod oss;
2828
pub use oss::*;
29+
pub mod azblob;
30+
pub use azblob::*;
2931
pub mod fs;
3032
pub use fs::*;

src/object_store/src/object/opendal_engine/opendal_object_store.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ pub enum EngineType {
3939
Gcs,
4040
Oss,
4141
Webhdfs,
42+
Azblob,
4243
Fs,
4344
}
4445

@@ -186,6 +187,7 @@ impl ObjectStore for OpendalObjectStore {
186187
EngineType::Gcs => "Gcs",
187188
EngineType::Oss => "Oss",
188189
EngineType::Webhdfs => "Webhdfs",
190+
EngineType::Azblob => "Azblob",
189191
EngineType::Fs => "Fs",
190192
}
191193
}

src/risedevtool/src/task/utils.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ pub fn add_storage_backend(
117117
.arg(format!("hummock+webhdfs://{}@{}", opendal.namenode, opendal.root));
118118
true
119119
}
120+
else if opendal.engine == "azblob"{
121+
cmd.arg("--state-store")
122+
.arg(format!("hummock+azblob://{}@{}", opendal.bucket, opendal.root));
123+
true
124+
}
120125
else if opendal.engine == "fs"{
121126
cmd.arg("--state-store")
122127
.arg(format!("hummock+fs://{}@{}", opendal.namenode, opendal.root));

0 commit comments

Comments
 (0)