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: Implement services webhdfs #1263

Merged
merged 35 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
48d9f01
services: implement webhdfs's builder
ClSlaid Jan 29, 2023
3d41e67
feat: implement webhdfs service
ClSlaid Jan 31, 2023
fdb1c50
Merge remote-tracking branch 'opendal/main' into services/webhdfs
ClSlaid Jan 31, 2023
d2754a4
refactor: fix unit tests
ClSlaid Jan 31, 2023
7857694
refactor: add metadata for webhdfs
ClSlaid Feb 1, 2023
bb3a1ca
refactor: fix webhdfs read/write/delete
ClSlaid Feb 1, 2023
aeec63e
refactor: implement blocking api to make build time checkings
ClSlaid Feb 2, 2023
ccfaade
refactor: make clippy happy
ClSlaid Feb 2, 2023
616a95d
ci: complete webhdfs tests
ClSlaid Feb 3, 2023
661d5c6
fix: correct default webhdfs port
ClSlaid Feb 3, 2023
6549e20
ci: update webhdfs setup
ClSlaid Feb 3, 2023
1d37e98
Merge remote-tracking branch 'opendal/main' into services/webhdfs
ClSlaid Feb 6, 2023
4336578
refactor: webhdfs sync up with 0.27.0
ClSlaid Feb 6, 2023
50bf141
Merge remote-tracking branch 'opendal/main' into services/webhdfs
ClSlaid Feb 6, 2023
22ec89d
refactor: check root in stat
ClSlaid Feb 6, 2023
156e3f6
refactor: make clippy happy
ClSlaid Feb 6, 2023
ab4c14a
fix: fix dead lock in checking root
ClSlaid Feb 6, 2023
f4b1c14
fix: doc test in webhdfs
ClSlaid Feb 6, 2023
5e29445
refactor: make cargo msrv clippy happy
ClSlaid Feb 6, 2023
182f274
Merge branch 'main' into services/webhdfs
ClSlaid Feb 6, 2023
25cec90
ci: fix webhdfs integated test
ClSlaid Feb 6, 2023
ea9f214
Merge remote-tracking branch 'opendal/main' into services/webhdfs
ClSlaid Feb 6, 2023
b9e7cb4
Merge remote-tracking branch 'origin/services/webhdfs' into services/…
ClSlaid Feb 6, 2023
417c67d
ci: recorrect test command line
ClSlaid Feb 6, 2023
4ee0406
Merge branch 'main' into services/webhdfs
Xuanwo Feb 6, 2023
0d436a7
Fix CI
Xuanwo Feb 6, 2023
d9584ce
User runner as webhdfs user
Xuanwo Feb 6, 2023
e4e0616
Merge branch 'main' into services/webhdfs
Xuanwo Feb 6, 2023
c67a5b2
ci: change webhdfs test root
ClSlaid Feb 7, 2023
1665318
typo: fix incorrect documentation
ClSlaid Feb 7, 2023
1b943bf
Merge branch 'main' into services/webhdfs
ClSlaid Feb 7, 2023
522f16b
refactor: remove username and doas
ClSlaid Feb 7, 2023
0183e8f
Merge remote-tracking branch 'origin/services/webhdfs' into services/…
ClSlaid Feb 7, 2023
397a6c8
fix: typo fix
ClSlaid Feb 7, 2023
b0cda76
Merge branch 'main' into services/webhdfs
Xuanwo Feb 7, 2023
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 .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,10 @@ OPENDAL_MEMCACHED_ROOT=/
OPENDAL_WEBDAV_TEST=false
OPENDAL_WEBDAV_ROOT=/tmp/opendal/
OPENDAL_WEBDAV_ENDPOINT=http://127.0.0.1:8080
# webhdfs
OPENDAL_WEBHDFS_TEST=false
OPENDAL_WEBHDFS_ROOT=/tmp/opendal/
OPENDAL_WEBHDFS_ENDPOINT=http://127.0.0.1:9870
OPENDAL_WEBHDFS_DELEGATION=<delegation>
OPENDAL_WEBHDFS_USER=<username>
OPENDAL_WEBHDFS_DOAS=<proxy username>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Service Test HDFS
name: Service Test HDFS and WebHDFS
ClSlaid marked this conversation as resolved.
Show resolved Hide resolved

on:
push:
Expand Down Expand Up @@ -41,11 +41,16 @@ jobs:
- name: Test
shell: bash
continue-on-error: true
run: cargo test hdfs --features compress,services-hdfs -- --show-output
run:
# this command will test both hdfs and webhdfs, make use of it
cargo test hdfs --features compress,services-hdfs -- --show-output
env:
RUST_BACKTRACE: full
RUST_LOG: debug
OPENDAL_HDFS_TEST: on
OPENDAL_HDFS_ROOT: /
OPENDAL_HDFS_NAME_NODE: hdfs://${{ env.HDFS_NAMENODE_ADDR }}
LD_LIBRARY_PATH: ${{ env.JAVA_HOME }}/lib/server:${{ env.LD_LIBRARY_PATH }}
OPENDAL_WEBHDFS_TEST: on
OPENDAL_WEBHDFS_ROOT: /
OPENDAL_WEBHDFS_ENDPOINT: http://${{ env.WEBHDFS_NAMENODE_ADDR }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- [rocksdb](https://opendal.databend.rs/opendal/services/rocksdb/index.html): [RocksDB](http://rocksdb.org/) services support.
- [s3](https://opendal.databend.rs/opendal/services/s3/index.html): [AWS S3](https://aws.amazon.com/s3/) alike services.
- [webdav](https://opendal.databend.rs/opendal/services/webdav/index.html): [WebDAV](https://datatracker.ietf.org/doc/html/rfc4918) Service Support.
- [webhdfs](https://opendal.databend.rs/opendal/services/webhdfs/index.html): [WebHDFS](https://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-hdfs/WebHDFS.html) Service Support.
Xuanwo marked this conversation as resolved.
Show resolved Hide resolved

## Features

Expand Down
1 change: 1 addition & 0 deletions src/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ impl Operator {
let op = match scheme {
Scheme::Azblob => services::azblob::Builder::from_iter(it).build()?.into(),
Scheme::Azdfs => services::azdfs::Builder::from_iter(it).build()?.into(),
Scheme::WebHdfs => services::webhdfs::Builder::from_iter(it).build()?.into(),
Scheme::Fs => services::fs::Builder::from_iter(it).build()?.into(),
#[cfg(feature = "services-ftp")]
Scheme::Ftp => services::ftp::Builder::from_iter(it).build()?.into(),
Expand Down
4 changes: 2 additions & 2 deletions src/raw/rps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ use http::Request;

use crate::*;

/// Reply fro `create` operation
/// Reply for `create` operation
#[derive(Debug, Clone, Default)]
pub struct RpCreate {}

/// Reply fro `delete` operation
/// Reply for `delete` operation
#[derive(Debug, Clone, Default)]
pub struct RpDelete {}

Expand Down
4 changes: 4 additions & 0 deletions src/scheme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ pub enum Scheme {
S3,
/// [oss][crate::services::oss]: Aliyun Object Storage Services
Oss,
/// [webhdfs][crate::services::webhdfs]: WebHDFS RESTful API Services
WebHdfs,
ClSlaid marked this conversation as resolved.
Show resolved Hide resolved
/// [webdav][crate::services::webdav]: WebDAV support.
Webdav,
/// Custom that allow users to implement services outside of OpenDAL.
Expand Down Expand Up @@ -132,6 +134,7 @@ impl FromStr for Scheme {
"rocksdb" => Ok(Scheme::Rocksdb),
"s3" => Ok(Scheme::S3),
"oss" => Ok(Scheme::Oss),
"webhdfs" => Ok(Scheme::WebHdfs),
"webdav" => Ok(Scheme::Webdav),
_ => Ok(Scheme::Custom(Box::leak(s.into_boxed_str()))),
}
Expand Down Expand Up @@ -166,6 +169,7 @@ impl From<Scheme> for &'static str {
Scheme::Rocksdb => "service-rocksdb",
Scheme::S3 => "s3",
Scheme::Oss => "oss",
Scheme::WebHdfs => "webhdfs",
Scheme::Webdav => "webdav",
Scheme::Custom(v) => v,
}
Expand Down
1 change: 1 addition & 0 deletions src/services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ pub mod redis;
pub mod rocksdb;
pub mod s3;
pub mod webdav;
pub mod webhdfs;
63 changes: 63 additions & 0 deletions src/services/webhdfs/auth.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright 2022 Datafuse 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.

//! This module contains some naive utilities
//! for WebHDFS authentication.

/// a naive WebHDFS auth implementation
/// # Note
/// WebHDFS supports using delegation token, or user and proxy user, for authentication.
/// So we use an enum to represent the signer.
#[derive(Clone, Debug)]
pub(super) enum WebHdfsAuth {
/// Delegation token authentication
Token(String),
/// User name and proxy user authentication
User(String, String),
}

impl WebHdfsAuth {
/// create a new signer with delegation token
pub fn new_delegation(delegation_token: &str) -> Self {
Self::Token(delegation_token.to_string())
}
/// create a new signer with user name and proxy user
///
/// # example
///
/// Signer::new_user("user", "proxy_user") will make us login
/// with identity of "user" but do as "proxy_user".
///
/// Signer::new_user("user", "") will make us login with identity
/// and on behave of nobody.
pub fn new_user(username: &str, doas: &str) -> Self {
Self::User(username.to_string(), doas.to_string())
}

/// sign a request
pub fn auth_str(&self) -> String {
ClSlaid marked this conversation as resolved.
Show resolved Hide resolved
match self {
Self::Token(token) => {
format!("delegation={token}")
}
Self::User(username, doas) => {
if !doas.is_empty() {
format!("user.name={username}&doas={doas}")
} else {
format!("user.name={username}")
}
}
}
}
}
Loading