Struct HdfsNative
pub struct HdfsNative { /* private fields */ }services-hdfs-native only.Expand description
Hadoop Distributed File System (HDFS™) support. Using Native Rust HDFS client. A distributed file system that provides high-throughput access to application data. Using Native Rust HDFS client.
§Capabilities
Depending on its configuration and the backing system, this service can expose:
- create_dir
- stat
- read
- write
- write (if_not_exists)
- delete
- list
- copy
- rename
- rename (if_not_exists)
-
presign
Inspect the effective capability set with opendal_core::Operator::info and
opendal_core::OperatorInfo::capability after building an operator.
HDFS Native deletes a directory and its descendants in a single NameNode
request when recursive(true) is set. Deleting a non-empty directory without
this option returns an error. Deleting / targets the configured root. If the
configured root is the HDFS filesystem root, HDFS keeps it intact.
§Configuration
Use crate::HdfsNativeConfig for serializable configuration and this builder’s
methods for direct construction. The field and method documentation defines
accepted values, defaults, and environment interaction.
Each built service owns one hdfs-native client. The service creates the
client when it is built and reuses it for every operation. The client opens
NameNode connections, and authenticates them, on first use.
§Hadoop configuration
The client resolves each Hadoop property from the first of these sources that sets it:
options.- The Hadoop configuration files in
config_dir. - The Hadoop configuration files in
HADOOP_CONF_DIR, whenconfig_diris unset. - The Hadoop configuration files in
$HADOOP_HOME/etc/hadoop, whenconfig_dirandHADOOP_CONF_DIRare unset.
The client reads files from only one directory, so config_dir replaces
HADOOP_CONF_DIR rather than adding to it.
§Identity
hadoop.security.authentication selects how the client authenticates.
| Authentication | NameNode caller |
|---|---|
simple or unset | user, then HADOOP_USER_NAME, then the operating system user. |
kerberos | The principal from kerberos_principal, or the default principal of the default credential cache. With user, or else HADOOP_PROXY_USER, the principal impersonates that user. |
To use Kerberos, set hadoop.security.authentication to kerberos.
kerberos_keytab and kerberos_cache require kerberos_principal. With any
kerberos_* setting, building the service, for example through
Operator::new, fails with ErrorKind::ConfigInvalid when the effective
hadoop.security.authentication is unset or exactly simple. Other values
pass this check, and building does not connect to the cluster, so other
authentication problems surface on the first operation. To check the
authentication setting, building a service with kerberos_* settings reads the
Hadoop configuration files a second time.
With kerberos_keytab, the client requests tickets from the KDC when it first
connects. Without kerberos_cache, it keeps them in an in-memory credential
cache that belongs to this service, so services with different principals in
one process do not share tickets.
The Kerberos library reads KRB5_CONFIG and KRB5CCNAME for the whole
process. Services without kerberos_* settings can also authenticate with the
delegation tokens in HADOOP_TOKEN_FILE_LOCATION.
use opendal_core::Operator;
use opendal_service_hdfs_native::HdfsNative;
let builder = HdfsNative::default()
.name_node("hdfs://namenode.example.com:8020")
.config_dir("/etc/hadoop/conf")
.kerberos_principal("alice@EXAMPLE.COM")
.kerberos_keytab("/etc/security/keytabs/alice.keytab");
let op = Operator::new(builder)?;§Encryption zones
Reading and writing files in HDFS encryption zones requires a Hadoop KMS client.
Enable one of these features on opendal-service-hdfs-native. Applications that
use the opendal facade add it as a direct dependency so Cargo unifies the
features:
| Feature | KMS transport |
|---|---|
kms | http:// only |
kms-rustls-tls | Rustls with its default crypto provider |
kms-rustls-no-provider | Rustls with the crypto provider the application installs |
kms-native-tls | Platform TLS |
cargo add opendal --features services-hdfs-native
cargo add opendal-service-hdfs-native --features kms-rustls-tlsThe KMS endpoint comes from hadoop.security.key.provider.path, set in
core-site.xml or in options.
Implementations§
§impl HdfsNativeBuilder
impl HdfsNativeBuilder
pub fn root(self, root: &str) -> HdfsNativeBuilder
pub fn root(self, root: &str) -> HdfsNativeBuilder
Set root of this backend.
All operations will happen under this root.
pub fn name_node(self, name_node: &str) -> HdfsNativeBuilder
pub fn name_node(self, name_node: &str) -> HdfsNativeBuilder
Set name_node of this backend.
Valid format including:
default: usefs.defaultFSfrom Hadoop configuration or client options.hdfs://mycluster: use a logical nameservice configured in Hadoop.hdfs://127.0.0.1:9000: connect to a single NameNode.hdfs://namenode1:9000,namenode2:9000: connect to an HDFS HA cluster by its addresses.
pub fn enable_append(self, _enable_append: bool) -> HdfsNativeBuilder
👎Deprecated since 0.57.0: HDFS Native append capability is enabled by default and this option is no longer needed.
pub fn enable_append(self, _enable_append: bool) -> HdfsNativeBuilder
HDFS Native append capability is enabled by default and this option is no longer needed.
Deprecated: HDFS Native append capability is enabled by default.
pub fn options(self, options: HashMap<String, String>) -> HdfsNativeBuilder
pub fn options(self, options: HashMap<String, String>) -> HdfsNativeBuilder
Set Hadoop configuration properties for the client.
These properties override the values from the Hadoop configuration
files. See Self::config_dir for the files the client reads, and the
hdfs-native documentation
for the supported properties.
pub fn config_dir(self, config_dir: &str) -> HdfsNativeBuilder
pub fn config_dir(self, config_dir: &str) -> HdfsNativeBuilder
Set the directory that contains the Hadoop configuration files.
The client reads core-site.xml, hdfs-site.xml, yarn-site.xml, and
mapred-site.xml from this directory instead of HADOOP_CONF_DIR or
$HADOOP_HOME/etc/hadoop. Properties set through Self::options
override the values from these files. Building the service fails with
ErrorKind::ConfigInvalid when the path is not a directory.
An empty value leaves the setting unchanged.
pub fn user(self, user: &str) -> HdfsNativeBuilder
pub fn user(self, user: &str) -> HdfsNativeBuilder
Set the HDFS user that the client acts as.
Without Kerberos, the NameNode accepts this name as the caller. When
unset, the client uses HADOOP_USER_NAME, then the operating system
user. With Kerberos, the authenticated principal impersonates this user,
which the cluster must allow through its hadoop.proxyuser.* settings.
When unset, the client uses HADOOP_PROXY_USER, if set.
An empty value leaves the setting unchanged.
pub fn kerberos_principal(self, principal: &str) -> HdfsNativeBuilder
pub fn kerberos_principal(self, principal: &str) -> HdfsNativeBuilder
Set the Kerberos principal that the client authenticates as.
Set hadoop.security.authentication to kerberos in
Self::options or in the Hadoop configuration files. With any
kerberos_* setting, building the service, for example through
Operator::new, fails with ErrorKind::ConfigInvalid when the
effective value is unset or exactly simple. Other values pass this
check, and building does not connect to the cluster, so other
authentication problems surface on the first operation. Without a
keytab or credential cache, the client looks up this principal’s
tickets in the default credential cache.
An empty value leaves the setting unchanged.
pub fn kerberos_keytab(self, keytab: &str) -> HdfsNativeBuilder
pub fn kerberos_keytab(self, keytab: &str) -> HdfsNativeBuilder
Set the keytab that the client obtains Kerberos tickets from.
Requires Self::kerberos_principal. The client keeps the tickets in
an in-memory credential cache that belongs to this service, unless
Self::kerberos_cache is set.
An empty value leaves the setting unchanged.
pub fn kerberos_cache(self, cache: &str) -> HdfsNativeBuilder
pub fn kerberos_cache(self, cache: &str) -> HdfsNativeBuilder
Set the Kerberos credential cache that the client reads tickets from,
such as FILE:/tmp/krb5cc_alice.
Requires Self::kerberos_principal. With Self::kerberos_keytab,
the client also stores the tickets it obtains from the keytab in this
cache.
An empty value leaves the setting unchanged.
Trait Implementations§
§impl Builder for HdfsNativeBuilder
impl Builder for HdfsNativeBuilder
§impl Debug for HdfsNativeBuilder
impl Debug for HdfsNativeBuilder
§impl Default for HdfsNativeBuilder
impl Default for HdfsNativeBuilder
§fn default() -> HdfsNativeBuilder
fn default() -> HdfsNativeBuilder
Auto Trait Implementations§
impl Freeze for HdfsNativeBuilder
impl RefUnwindSafe for HdfsNativeBuilder
impl Send for HdfsNativeBuilder
impl Sync for HdfsNativeBuilder
impl Unpin for HdfsNativeBuilder
impl UnsafeUnpin for HdfsNativeBuilder
impl UnwindSafe for HdfsNativeBuilder
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§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> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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> MaybeSend for Twhere
T: Send,
impl<T> MaybeSend for Twhere
T: Send,
§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> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<E> ResultError for E
§impl<T> Scope for T
impl<T> Scope for T
§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.