pub struct ClientBuilder { /* private fields */ }Expand description
Builds a new Client instance. By default, configs will be loaded from the default config directories with the following precedence:
- If the
HADOOP_CONF_DIRenvironment variable is defined, configs will be loaded from${HADOOP_CONF_DIR}/{core,hdfs}-site.xml - If the
HADOOP_HOMEenvironment variable is defined, configs will be loaded from${HADOOP_HOME}/etc/hadoop/{core,hdfs}-site.xml - Otherwise no default configs are defined
If no URL is defined, the fs.defaultFS config must be defined and is used as the URL.
§Examples
Create a new client using the fs.defaultFS config
let client = ClientBuilder::new()
.with_config(vec![("fs.defaultFS", "hdfs://127.0.0.1:9000")])
.build()
.unwrap();Create a new client connecting to a specific URL:
let client = ClientBuilder::new()
.with_url("hdfs://127.0.0.1:9000")
.build()
.unwrap();Create a new client using a dedicated tokio runtime for spawned tasks and IO operations
let client = ClientBuilder::new()
.with_url("hdfs://127.0.0.1:9000")
.with_io_runtime(tokio::runtime::Runtime::new().unwrap())
.build()
.unwrap();Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new ClientBuilder
Sourcepub fn with_url(self, url: impl Into<String>) -> Self
pub fn with_url(self, url: impl Into<String>) -> Self
Set the URL to connect to. Can be the address of a single NameNode, or a logical NameService
Sourcepub fn with_config(
self,
config: impl IntoIterator<Item = (impl Into<String>, impl Into<String>)>,
) -> Self
pub fn with_config( self, config: impl IntoIterator<Item = (impl Into<String>, impl Into<String>)>, ) -> Self
Set configs to use for the client. The provided configs will override any found in the default config files loaded
Sourcepub fn with_io_runtime(self, runtime: impl Into<IORuntime>) -> Self
pub fn with_io_runtime(self, runtime: impl Into<IORuntime>) -> Self
Trait Implementations§
Source§impl Default for ClientBuilder
impl Default for ClientBuilder
Source§fn default() -> ClientBuilder
fn default() -> ClientBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for ClientBuilder
impl RefUnwindSafe for ClientBuilder
impl Send for ClientBuilder
impl Sync for ClientBuilder
impl Unpin for ClientBuilder
impl UnwindSafe for ClientBuilder
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
Mutably borrows from an owned value. Read more