Skip to content

feat(services/hdfs-native): add configs for other settings like hdfs namenode ha #6085

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 17 additions & 2 deletions core/src/services/hdfs_native/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use crate::*;
use hdfs_native::HdfsError;
use hdfs_native::WriteOptions;
use log::debug;
use std::collections::HashMap;
use std::fmt::Debug;
use std::fmt::Formatter;
use std::sync::Arc;
Expand Down Expand Up @@ -89,6 +90,13 @@ impl HdfsNativeBuilder {
self.config.enable_append = enable_append;
self
}
/// Set other configs of this backend.
///
/// This is a map of key-value pairs.
pub fn configs(mut self, configs: Option<HashMap<String, String>>) -> Self {
self.config.configs = configs;
self
}
}

impl Builder for HdfsNativeBuilder {
Expand All @@ -109,8 +117,15 @@ impl Builder for HdfsNativeBuilder {
let root = normalize_root(&self.config.root.unwrap_or_default());
debug!("backend use root {}", root);

let client = hdfs_native::Client::new(name_node).map_err(parse_hdfs_error)?;

let client = {
match self.config.configs {
None => hdfs_native::Client::new(name_node).map_err(parse_hdfs_error)?,
Some(ref configs) => {
hdfs_native::Client::new_with_config(name_node, configs.clone())
.map_err(parse_hdfs_error)?
}
}
};
// need to check if root dir exists, create if not
Ok(HdfsNativeBackend {
root,
Expand Down
6 changes: 6 additions & 0 deletions core/src/services/hdfs_native/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ use std::fmt::Formatter;
use serde::Deserialize;
use serde::Serialize;

use std::collections::HashMap;

/// Config for HdfsNative services support.
#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
#[serde(default)]
Expand All @@ -32,6 +34,9 @@ pub struct HdfsNativeConfig {
pub name_node: Option<String>,
/// enable the append capacity
pub enable_append: bool,
/// other configs
#[serde(skip_serializing_if = "Option::is_none")]
pub configs: Option<HashMap<String, String>>,
}

impl Debug for HdfsNativeConfig {
Expand All @@ -40,6 +45,7 @@ impl Debug for HdfsNativeConfig {
.field("root", &self.root)
.field("name_node", &self.name_node)
.field("enable_append", &self.enable_append)
.field("configs", &self.configs)
.finish_non_exhaustive()
}
}
Loading