Struct opendal::services::Webhdfs

source ·
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:

  • read
  • write
  • list
  • scan
  • presign
  • blocking

Differences with hdfs

Hdfs is powered by HDFS’s native java client. Users need to setup the hdfs services correctly. But webhdfs can access from HTTP API and no extra setup needed.

Configurations

  • root: The root path of the WebHDFS service.
  • endpoint: The endpoint of the WebHDFS service.
  • delegation: The delegation token for WebHDFS.

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 is not 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 folder, the builder will fail on building backend
    builder.root("/path/to/dir");
    // set the endpoint of webhdfs namenode, controlled by dfs.namenode.http-address
    // default is http://127.0.0.1:9870
    builder.endpoint("http://127.0.0.1:9870");
    // set the delegation_token for builder
    builder.delegation("delegation_token");

    let op: Operator = Operator::new(builder)?.finish();

    Ok(())
}

Implementations§

Set the working directory of this backend

All operations will happen under this root

Note

The root will be automatically created if not exists. If the root is occupied by a file, building of directory will fail

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:9870
  • http://192.168.66.88:9870

If user inputs endpoint without scheme, we will prepend http:// to it.

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.

Trait Implementations§

build the backend

Note:

when building backend, the built backend will check if the root directory exits. if the directory does not exits, the directory will be automatically created if the root path is occupied by a file, a failure will be returned

Associated scheme for this builder.
The accessor that built by this builder.
Construct a builder from given map.
Construct a builder from given iterator.
Construct a builder from envs.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Applies the [Compat] adapter by value. Read more
Applies the [Compat] adapter by shared reference. Read more
Applies the [Compat] adapter by mutable reference. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more