diff --git a/src/cmd_all/src/bin/risingwave.rs b/src/cmd_all/src/bin/risingwave.rs index e9173abefe1df..56e4ba76c6c3a 100644 --- a/src/cmd_all/src/bin/risingwave.rs +++ b/src/cmd_all/src/bin/risingwave.rs @@ -240,7 +240,7 @@ fn standalone(opts: StandaloneOpts) { /// We will start a standalone instance, with all nodes in the same process. fn single_node(opts: SingleNodeOpts) { opts.create_store_directories().unwrap(); - let opts = risingwave_cmd_all::map_single_node_opts_to_standalone_opts(&opts); + let opts = risingwave_cmd_all::normalized_single_node_opts(&opts); let settings = risingwave_rt::LoggerSettings::from_opts(&opts) .with_target("risingwave_storage", Level::WARN) .with_thread_name(true); diff --git a/src/cmd_all/src/common.rs b/src/cmd_all/src/common.rs index 99da59e22dfc1..68e9090578ab0 100644 --- a/src/cmd_all/src/common.rs +++ b/src/cmd_all/src/common.rs @@ -14,10 +14,6 @@ use std::ffi::OsString; -pub fn osstrs_from_iter>(s: impl IntoIterator) -> Vec { - s.into_iter().map(Into::into).collect() -} - pub fn osstrs + AsRef>(s: impl AsRef<[T]>) -> Vec { s.as_ref().iter().map(OsString::from).collect() } diff --git a/src/cmd_all/src/single_node.rs b/src/cmd_all/src/single_node.rs index f8f15df7fd959..f63c887ea4d16 100644 --- a/src/cmd_all/src/single_node.rs +++ b/src/cmd_all/src/single_node.rs @@ -26,6 +26,7 @@ use risingwave_frontend::FrontendOpts; use risingwave_meta_node::MetaNodeOpts; use shell_words::split; +use crate::common::osstrs; use crate::ParsedStandaloneOpts; pub static DEFAULT_STORE_DIRECTORY: LazyLock = LazyLock::new(|| { @@ -120,10 +121,10 @@ pub struct SingleNodeOpts { } struct NormalizedSingleNodeOpts { - frontend_opts: Option, - meta_opts: Option, - compute_opts: Option, - compactor_opts: Option, + frontend_opts: Option, + meta_opts: Option, + compute_opts: Option, + compactor_opts: Option, } pub fn make_single_node_sql_endpoint(store_directory: &String) -> String { @@ -141,7 +142,7 @@ pub fn map_single_node_opts_to_standalone_opts(opts: &SingleNodeOpts) -> ParsedS todo!() } -pub fn normalized_single_node_opts(opts: &SingleNodeOpts) -> NormalizedSingleNodeOpts { +pub fn normalized_single_node_opts(opts: &SingleNodeOpts) -> ParsedStandaloneOpts { let mut meta_opts = RawOpts::default_meta_opts(); let mut compute_opts = RawOpts::default_compute_opts(); let mut frontend_opts = RawOpts::default_frontend_opts(); @@ -242,26 +243,32 @@ pub fn normalized_single_node_opts(opts: &SingleNodeOpts) -> NormalizedSingleNod let frontend_opts = if opts.disable_frontend { None } else { + let args = frontend_opts.raw_opts_to_args(); + let frontend_opts = FrontendOpts::parse_from(osstrs(args)); Some(frontend_opts) }; let meta_opts = if opts.disable_meta { None } else { - // let mut meta_opts = meta_opts.map(|o| MetaNodeOpts::parse_from(osstrs(o))); - + let args = meta_opts.raw_opts_to_args(); + let meta_opts = MetaNodeOpts::parse_from(osstrs(args)); Some(meta_opts) }; let compute_opts = if opts.disable_compute { None } else { + let args = compute_opts.raw_opts_to_args(); + let compute_opts = ComputeNodeOpts::parse_from(osstrs(args)); Some(compute_opts) }; let compactor_opts = if opts.disable_compactor { None } else { + let args = compactor_opts.raw_opts_to_args(); + let compactor_opts = CompactorOpts::parse_from(osstrs(args)); Some(compactor_opts) }; - NormalizedSingleNodeOpts { + ParsedStandaloneOpts { frontend_opts, meta_opts, compute_opts, @@ -397,6 +404,18 @@ impl RawOpts { opts: inner, } } + + fn raw_opts_to_args(self) -> Vec { + let mut args = vec![]; + for (k, v) in self.opts { + args.push(k.clone()); + args.push(v.clone()); + } + for f in self.flags { + args.push(f.clone()); + } + args + } } // Defaults