mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-06 05:12:54 +00:00
refactor: remove MixOptions and use StandaloneOptions only (#3893)
* refactor: remove MixOptions and use StandaloneOptions only * refactor: refactor code by code review comments 1. Use '&self' in frontend_options() and datanode_options(); 2. Remove unused 'clone()'; Signed-off-by: zyy17 <zyylsxm@gmail.com> * ci: fix integration error --------- Signed-off-by: zyy17 <zyylsxm@gmail.com>
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use catalog::kvbackend::KvBackendCatalogManager;
|
||||
use cmd::options::MixOptions;
|
||||
use cmd::standalone::StandaloneOptions;
|
||||
use common_base::Plugins;
|
||||
use common_catalog::consts::{MIN_USER_FLOW_ID, MIN_USER_TABLE_ID};
|
||||
use common_config::KvBackendConfig;
|
||||
@@ -32,10 +32,8 @@ use common_meta::sequence::SequenceBuilder;
|
||||
use common_meta::wal_options_allocator::WalOptionsAllocator;
|
||||
use common_procedure::options::ProcedureConfig;
|
||||
use common_procedure::ProcedureManagerRef;
|
||||
use common_telemetry::logging::LoggingOptions;
|
||||
use common_wal::config::{DatanodeWalConfig, MetasrvWalConfig};
|
||||
use datanode::datanode::DatanodeBuilder;
|
||||
use frontend::frontend::FrontendOptions;
|
||||
use frontend::instance::builder::FrontendBuilder;
|
||||
use frontend::instance::{FrontendInstance, Instance, StandaloneDatanodeManager};
|
||||
use meta_srv::metasrv::{FLOW_ID_SEQ, TABLE_ID_SEQ};
|
||||
@@ -45,7 +43,7 @@ use crate::test_util::{self, create_tmp_dir_and_datanode_opts, StorageType, Test
|
||||
|
||||
pub struct GreptimeDbStandalone {
|
||||
pub instance: Arc<Instance>,
|
||||
pub mix_options: MixOptions,
|
||||
pub opts: StandaloneOptions,
|
||||
pub guard: TestGuard,
|
||||
// Used in rebuild.
|
||||
pub kv_backend: KvBackendRef,
|
||||
@@ -115,13 +113,13 @@ impl GreptimeDbStandaloneBuilder {
|
||||
&self,
|
||||
kv_backend: KvBackendRef,
|
||||
guard: TestGuard,
|
||||
mix_options: MixOptions,
|
||||
opts: StandaloneOptions,
|
||||
procedure_manager: ProcedureManagerRef,
|
||||
register_procedure_loaders: bool,
|
||||
) -> GreptimeDbStandalone {
|
||||
let plugins = self.plugin.clone().unwrap_or_default();
|
||||
|
||||
let datanode = DatanodeBuilder::new(mix_options.datanode.clone(), plugins.clone())
|
||||
let datanode = DatanodeBuilder::new(opts.datanode_options(), plugins.clone())
|
||||
.with_kv_backend(kv_backend.clone())
|
||||
.build()
|
||||
.await
|
||||
@@ -154,7 +152,7 @@ impl GreptimeDbStandaloneBuilder {
|
||||
.build(),
|
||||
);
|
||||
let wal_options_allocator = Arc::new(WalOptionsAllocator::new(
|
||||
mix_options.wal_meta.clone(),
|
||||
opts.wal.clone().into(),
|
||||
kv_backend.clone(),
|
||||
));
|
||||
let table_metadata_allocator = Arc::new(TableMetadataAllocator::new(
|
||||
@@ -202,7 +200,7 @@ impl GreptimeDbStandaloneBuilder {
|
||||
|
||||
GreptimeDbStandalone {
|
||||
instance: Arc::new(instance),
|
||||
mix_options,
|
||||
opts,
|
||||
guard,
|
||||
kv_backend,
|
||||
procedure_manager,
|
||||
@@ -231,18 +229,15 @@ impl GreptimeDbStandaloneBuilder {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let wal_meta = self.metasrv_wal_config.clone();
|
||||
let mix_options = MixOptions {
|
||||
data_home: opts.storage.data_home.to_string(),
|
||||
let standalone_opts = StandaloneOptions {
|
||||
storage: opts.storage,
|
||||
procedure: procedure_config,
|
||||
metadata_store: kv_backend_config,
|
||||
frontend: FrontendOptions::default(),
|
||||
datanode: opts,
|
||||
logging: LoggingOptions::default(),
|
||||
wal_meta,
|
||||
wal: self.metasrv_wal_config.clone().into(),
|
||||
..StandaloneOptions::default()
|
||||
};
|
||||
|
||||
self.build_with(kv_backend, guard, mix_options, procedure_manager, true)
|
||||
self.build_with(kv_backend, guard, standalone_opts, procedure_manager, true)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ use datanode::config::{
|
||||
AzblobConfig, DatanodeOptions, FileConfig, GcsConfig, ObjectStoreConfig, OssConfig, S3Config,
|
||||
StorageConfig,
|
||||
};
|
||||
use frontend::frontend::TomlSerializable;
|
||||
use frontend::instance::Instance;
|
||||
use frontend::service_config::{MysqlOptions, PostgresOptions};
|
||||
use futures::future::BoxFuture;
|
||||
@@ -392,7 +391,7 @@ pub async fn setup_test_http_app(store_type: StorageType, name: &str) -> (Router
|
||||
None,
|
||||
)
|
||||
.with_metrics_handler(MetricsHandler)
|
||||
.with_greptime_config_options(instance.mix_options.datanode.to_toml_string())
|
||||
.with_greptime_config_options(instance.opts.datanode_options().to_toml_string())
|
||||
.build();
|
||||
(http_server.build(http_server.make_app()), instance.guard)
|
||||
}
|
||||
@@ -425,7 +424,7 @@ pub async fn setup_test_http_app_with_frontend_and_user_provider(
|
||||
ServerSqlQueryHandlerAdapter::arc(instance.instance.clone()),
|
||||
Some(instance.instance.clone()),
|
||||
)
|
||||
.with_greptime_config_options(instance.mix_options.to_toml().unwrap());
|
||||
.with_greptime_config_options(instance.opts.to_toml().unwrap());
|
||||
|
||||
if let Some(user_provider) = user_provider {
|
||||
http_server = http_server.with_user_provider(user_provider);
|
||||
@@ -464,7 +463,7 @@ pub async fn setup_test_prom_app_with_frontend(
|
||||
)
|
||||
.with_prom_handler(frontend_ref.clone(), true, is_strict_mode)
|
||||
.with_prometheus_handler(frontend_ref)
|
||||
.with_greptime_config_options(instance.mix_options.datanode.to_toml_string())
|
||||
.with_greptime_config_options(instance.opts.datanode_options().to_toml_string())
|
||||
.build();
|
||||
let app = http_server.build(http_server.make_app());
|
||||
(app, instance.guard)
|
||||
|
||||
@@ -106,7 +106,7 @@ impl MockInstanceBuilder {
|
||||
unreachable!()
|
||||
};
|
||||
let GreptimeDbStandalone {
|
||||
mix_options,
|
||||
opts,
|
||||
guard,
|
||||
kv_backend,
|
||||
procedure_manager,
|
||||
@@ -114,7 +114,7 @@ impl MockInstanceBuilder {
|
||||
} = instance;
|
||||
MockInstanceImpl::Standalone(
|
||||
builder
|
||||
.build_with(kv_backend, guard, mix_options, procedure_manager, false)
|
||||
.build_with(kv_backend, guard, opts, procedure_manager, false)
|
||||
.await,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -729,103 +729,54 @@ pub async fn test_config_api(store_type: StorageType) {
|
||||
|
||||
let expected_toml_str = format!(
|
||||
r#"
|
||||
[procedure]
|
||||
max_retry_times = 3
|
||||
retry_delay = "500ms"
|
||||
|
||||
[metadata_store]
|
||||
file_size = "256MiB"
|
||||
purge_threshold = "4GiB"
|
||||
|
||||
[frontend]
|
||||
mode = "standalone"
|
||||
enable_telemetry = true
|
||||
|
||||
[frontend.heartbeat]
|
||||
interval = "18s"
|
||||
retry_interval = "3s"
|
||||
|
||||
[frontend.http]
|
||||
[http]
|
||||
addr = "127.0.0.1:4000"
|
||||
timeout = "30s"
|
||||
body_limit = "64MiB"
|
||||
is_strict_mode = false
|
||||
|
||||
[frontend.grpc]
|
||||
[grpc]
|
||||
addr = "127.0.0.1:4001"
|
||||
runtime_size = 8
|
||||
max_recv_message_size = "512MiB"
|
||||
max_send_message_size = "512MiB"
|
||||
|
||||
[frontend.mysql]
|
||||
[mysql]
|
||||
enable = true
|
||||
addr = "127.0.0.1:4002"
|
||||
runtime_size = 2
|
||||
|
||||
[frontend.mysql.tls]
|
||||
[mysql.tls]
|
||||
mode = "disable"
|
||||
cert_path = ""
|
||||
key_path = ""
|
||||
watch = false
|
||||
|
||||
[frontend.postgres]
|
||||
[postgres]
|
||||
enable = true
|
||||
addr = "127.0.0.1:4003"
|
||||
runtime_size = 2
|
||||
|
||||
[frontend.postgres.tls]
|
||||
[postgres.tls]
|
||||
mode = "disable"
|
||||
cert_path = ""
|
||||
key_path = ""
|
||||
watch = false
|
||||
|
||||
[frontend.opentsdb]
|
||||
[opentsdb]
|
||||
enable = true
|
||||
|
||||
[frontend.influxdb]
|
||||
[influxdb]
|
||||
enable = true
|
||||
|
||||
[frontend.prom_store]
|
||||
[prom_store]
|
||||
enable = true
|
||||
with_metric_engine = true
|
||||
|
||||
[frontend.otlp]
|
||||
enable = true
|
||||
|
||||
[frontend.logging]
|
||||
enable_otlp_tracing = false
|
||||
append_stdout = true
|
||||
|
||||
[frontend.datanode.client]
|
||||
timeout = "10s"
|
||||
connect_timeout = "1s"
|
||||
tcp_nodelay = true
|
||||
|
||||
[frontend.export_metrics]
|
||||
enable = false
|
||||
write_interval = "30s"
|
||||
|
||||
[datanode]
|
||||
mode = "standalone"
|
||||
node_id = 0
|
||||
require_lease_before_startup = true
|
||||
init_regions_in_background = false
|
||||
rpc_addr = "127.0.0.1:3001"
|
||||
rpc_runtime_size = 8
|
||||
rpc_max_recv_message_size = "512MiB"
|
||||
rpc_max_send_message_size = "512MiB"
|
||||
enable_telemetry = true
|
||||
|
||||
[datanode.heartbeat]
|
||||
interval = "3s"
|
||||
retry_interval = "3s"
|
||||
|
||||
[datanode.http]
|
||||
addr = "127.0.0.1:4000"
|
||||
timeout = "30s"
|
||||
body_limit = "64MiB"
|
||||
is_strict_mode = false
|
||||
|
||||
[datanode.wal]
|
||||
[wal]
|
||||
provider = "raft_engine"
|
||||
file_size = "256MiB"
|
||||
purge_threshold = "4GiB"
|
||||
@@ -835,13 +786,25 @@ sync_write = false
|
||||
enable_log_recycle = true
|
||||
prefill_log_files = false
|
||||
|
||||
[datanode.storage]
|
||||
[storage]
|
||||
type = "{}"
|
||||
providers = []
|
||||
|
||||
[[datanode.region_engine]]
|
||||
[metadata_store]
|
||||
file_size = "256MiB"
|
||||
purge_threshold = "4GiB"
|
||||
|
||||
[datanode.region_engine.mito]
|
||||
[procedure]
|
||||
max_retry_times = 3
|
||||
retry_delay = "500ms"
|
||||
|
||||
[logging]
|
||||
enable_otlp_tracing = false
|
||||
append_stdout = true
|
||||
|
||||
[[region_engine]]
|
||||
|
||||
[region_engine.mito]
|
||||
worker_channel_size = 128
|
||||
worker_request_batch_size = 64
|
||||
manifest_checkpoint_distance = 10
|
||||
@@ -855,7 +818,7 @@ sst_write_buffer_size = "8MiB"
|
||||
parallel_scan_channel_size = 32
|
||||
allow_stale_entries = false
|
||||
|
||||
[datanode.region_engine.mito.inverted_index]
|
||||
[region_engine.mito.inverted_index]
|
||||
create_on_flush = "auto"
|
||||
create_on_compaction = "auto"
|
||||
apply_on_query = "auto"
|
||||
@@ -863,29 +826,20 @@ write_buffer_size = "8MiB"
|
||||
mem_threshold_on_create = "64.0MiB"
|
||||
intermediate_path = ""
|
||||
|
||||
[datanode.region_engine.mito.memtable]
|
||||
[region_engine.mito.memtable]
|
||||
type = "time_series"
|
||||
|
||||
[[datanode.region_engine]]
|
||||
[[region_engine]]
|
||||
|
||||
[datanode.region_engine.file]
|
||||
[region_engine.file]
|
||||
|
||||
[datanode.logging]
|
||||
enable_otlp_tracing = false
|
||||
append_stdout = true
|
||||
|
||||
[datanode.export_metrics]
|
||||
[export_metrics]
|
||||
enable = false
|
||||
write_interval = "30s"
|
||||
|
||||
[logging]
|
||||
enable_otlp_tracing = false
|
||||
append_stdout = true
|
||||
|
||||
[wal_meta]
|
||||
provider = "raft_engine""#,
|
||||
store_type,
|
||||
);
|
||||
write_interval = "30s""#,
|
||||
store_type
|
||||
)
|
||||
.trim()
|
||||
.to_string();
|
||||
let body_text = drop_lines_with_inconsistent_results(res_get.text().await);
|
||||
assert_eq!(body_text, expected_toml_str);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user