pub struct Webhdfs { /* private fields */ }Expand description
WebHDFS’s REST API support. There two implementations of WebHDFS REST API:
- Native via HDFS Namenode and Datanode, data are transferred between nodes directly.
- HttpFS is a gateway before hdfs nodes, data are proxied.
§Capabilities
This service can be used to:
- stat
- read
- write
- create_dir
- delete
- copy
- rename
- list
-
presign - blocking
§Differences with HDFS
Hdfs is powered by HDFS’s native java client. Users need to set up the HDFS services correctly. But webhdfs can access from HTTP API and no extra setup needed.
§WebHDFS Compatibility Guidelines
§File Creation and Write
For File creation and write operations,
OpenDAL WebHDFS is optimized for Hadoop Distributed File System (HDFS) versions 2.9 and later.
This involves two API calls in webhdfs, where the initial put call to the namenode is redirected to the datanode handling the file data.
The optional noredirect flag can be set to prevent redirection. If used, the API response body contains the datanode URL, which is then utilized for the subsequent put call with the actual file data.
OpenDAL automatically sets the noredirect flag with the first put call. This feature is supported starting from HDFS version 2.9.
§Multi-Write Support
OpenDAL WebHDFS supports multi-write operations by creating temporary files in the specified atomic_write_dir.
The final concatenation of these temporary files occurs when the writer is closed.
However, it’s essential to be aware of HDFS concat restrictions for earlier versions,
where the target file must not be empty, and its last block must be full. Due to these constraints, the concat operation might fail for HDFS 2.6.
This issue, identified as HDFS-6641, has been addressed in later versions of HDFS.
In summary, OpenDAL WebHDFS is designed for optimal compatibility with HDFS, specifically versions 2.9 and later.
§Configurations
root: The root path of the WebHDFS service.endpoint: The endpoint of the WebHDFS service.delegation: The delegation token for WebHDFS.atomic_write_dir: The tmp write dir of multi write for WebHDFS.Needs to be configured for multi write support.
Refer to Builder’s public API docs for more information.
§Examples
§Via Builder
use std::sync::Arc;
use anyhow::Result;
use opendal::services::Webhdfs;
use opendal::Operator;
#[tokio::main]
async fn main() -> Result<()> {
let mut builder = Webhdfs::default()
// set the root for WebHDFS, all operations will happen under this root
//
// Note:
// if the root exists, the builder will automatically create the
// root directory for you
// if the root exists and is a directory, the builder will continue working
// if the root exists and is a file, the builder will fail on building backend
.root("/path/to/dir")
// set the endpoint of webhdfs namenode, controlled by dfs.namenode.http-address
// default is http://127.0.0.1:9870
.endpoint("http://127.0.0.1:9870")
// set the delegation_token for builder
.delegation("delegation_token")
// set atomic_write_dir for builder
.atomic_write_dir(".opendal_tmp/");
let op: Operator = Operator::new(builder)?.finish();
Ok(())
}Implementations§
Source§impl WebhdfsBuilder
impl WebhdfsBuilder
Sourcepub fn root(self, root: &str) -> Self
Available on crate feature services-webhdfs only.
pub fn root(self, root: &str) -> Self
services-webhdfs only.Set the working directory of this backend
All operations will happen under this root
§Note
The root will be automatically created if not exists.
Sourcepub fn endpoint(self, endpoint: &str) -> Self
Available on crate feature services-webhdfs only.
pub fn endpoint(self, endpoint: &str) -> Self
services-webhdfs only.Set the remote address of this backend
default to http://127.0.0.1:9870
Endpoints should be full uri, e.g.
https://webhdfs.example.com:9870http://192.168.66.88:9870
If user inputs endpoint without scheme, we will
prepend http:// to it.
Sourcepub fn user_name(self, user_name: &str) -> Self
Available on crate feature services-webhdfs only.
pub fn user_name(self, user_name: &str) -> Self
services-webhdfs only.Set the username of this backend, used for authentication
Sourcepub fn delegation(self, delegation: &str) -> Self
Available on crate feature services-webhdfs only.
pub fn delegation(self, delegation: &str) -> Self
services-webhdfs only.Set the delegation token of this backend, used for authentication
§Note
The builder prefers using delegation token over username. If both are set, delegation token will be used.
Sourcepub fn disable_list_batch(self) -> Self
Available on crate feature services-webhdfs only.
pub fn disable_list_batch(self) -> Self
services-webhdfs only.Disable batch listing
§Note
When listing a directory, the backend will default to use batch listing. If disabled, the backend will list all files/directories in one request.
Sourcepub fn atomic_write_dir(self, dir: &str) -> Self
Available on crate feature services-webhdfs only.
pub fn atomic_write_dir(self, dir: &str) -> Self
services-webhdfs only.Trait Implementations§
Source§impl Builder for WebhdfsBuilder
Available on crate feature services-webhdfs only.
impl Builder for WebhdfsBuilder
services-webhdfs only.Source§fn build(self) -> Result<impl Access>
fn build(self) -> Result<impl Access>
build the backend
§Note
when building backend, the built backend will check if the root directory exits. if the directory does not exit, the directory will be automatically created
Source§type Config = WebhdfsConfig
type Config = WebhdfsConfig
Source§impl Clone for WebhdfsBuilder
Available on crate feature services-webhdfs only.
impl Clone for WebhdfsBuilder
services-webhdfs only.Source§fn clone(&self) -> WebhdfsBuilder
fn clone(&self) -> WebhdfsBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WebhdfsBuilder
Available on crate feature services-webhdfs only.
impl Debug for WebhdfsBuilder
services-webhdfs only.Source§impl Default for WebhdfsBuilder
Available on crate feature services-webhdfs only.
impl Default for WebhdfsBuilder
services-webhdfs only.Source§fn default() -> WebhdfsBuilder
fn default() -> WebhdfsBuilder
Auto Trait Implementations§
impl Freeze for WebhdfsBuilder
impl RefUnwindSafe for WebhdfsBuilder
impl Send for WebhdfsBuilder
impl Sync for WebhdfsBuilder
impl Unpin for WebhdfsBuilder
impl UnwindSafe for WebhdfsBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.