diff --git a/config/metasrv.example.toml b/config/metasrv.example.toml index abb2e42ec081..704dd90784a0 100644 --- a/config/metasrv.example.toml +++ b/config/metasrv.example.toml @@ -51,18 +51,19 @@ provider = "raft_engine" # There're none raft-engine wal config since meta srv only involves in remote wal currently. +# Uncomment the following lines if switching provider to "kafka". # Kafka wal config. # The broker endpoints of the Kafka cluster. ["127.0.0.1:9090"] by default. -broker_endpoints = ["127.0.0.1:9090"] -# Number of topics to be created upon start. -num_topics = 64 -# Topic selector type. -# Available selector types: -# - "round_robin" (default) -selector_type = "round_robin" -# A Kafka topic is constructed by concatenating `topic_name_prefix` and `topic_id`. -topic_name_prefix = "greptimedb_kafka_wal" -# Number of partitions per topic. -num_partitions = 1 -# Expected number of replicas of each partition. -replication_factor = 3 +# broker_endpoints = ["127.0.0.1:9090"] +# # Number of topics to be created upon start. +# num_topics = 64 +# # Topic selector type. +# # Available selector types: +# # - "round_robin" (default) +# selector_type = "round_robin" +# # A Kafka topic is constructed by concatenating `topic_name_prefix` and `topic_id`. +# topic_name_prefix = "greptimedb_kafka_wal" +# # Number of partitions per topic. +# num_partitions = 1 +# # Expected number of replicas of each partition. +# replication_factor = 3 diff --git a/src/cmd/src/cli/bench/metadata.rs b/src/cmd/src/cli/bench/metadata.rs index fa1b88a76664..4298798e9733 100644 --- a/src/cmd/src/cli/bench/metadata.rs +++ b/src/cmd/src/cli/bench/metadata.rs @@ -17,9 +17,7 @@ use std::time::Instant; use common_meta::key::TableMetadataManagerRef; use common_meta::table_name::TableName; -use super::{ - bench_self_recorded, create_region_routes, create_region_wal_options, create_table_info, -}; +use crate::cli::bench::*; pub struct TableMetadataBencher { table_metadata_manager: TableMetadataManagerRef, diff --git a/src/common/meta/src/key/datanode_table.rs b/src/common/meta/src/key/datanode_table.rs index 431b0c20c0e5..bf2428deb3c4 100644 --- a/src/common/meta/src/key/datanode_table.rs +++ b/src/common/meta/src/key/datanode_table.rs @@ -303,7 +303,7 @@ mod tests { } // This test intends to ensure both the `serde_json::to_string` + `serde_json::from_str` - // and `serde_json::to_vec` + `serde_json::from_slice` works for `DatanodeTableValue`. + // and `serde_json::to_vec` + `serde_json::from_slice` work for `DatanodeTableValue`. // Warning: if the key of `region_wal_options` is of type non-String, this test would fail. #[test] fn test_serde_with_region_info() { diff --git a/src/common/meta/src/wal.rs b/src/common/meta/src/wal.rs index a881d7c77889..8e7d550bc07c 100644 --- a/src/common/meta/src/wal.rs +++ b/src/common/meta/src/wal.rs @@ -25,8 +25,8 @@ use crate::wal::kafka::KafkaConfig; pub use crate::wal::kafka::{KafkaOptions as KafkaWalOptions, Topic as KafkaWalTopic}; pub use crate::wal::options_allocator::WalOptionsAllocator; -// An encoded wal options will be wrapped into a (WAL_OPTIONS_KEY, encoded wal options) key-value pair -// and inserted into the options of a `RegionCreateRequest`. +/// An encoded wal options will be wrapped into a (WAL_OPTIONS_KEY, encoded wal options) key-value pair +/// and inserted into the options of a `RegionCreateRequest`. pub const WAL_OPTIONS_KEY: &str = "wal_options"; /// Wal configurations for bootstrapping meta srv. @@ -41,9 +41,9 @@ pub enum WalConfig { } /// Wal options allocated to a region. -// A wal options is encoded by meta srv into a `String` with `serde_json::to_string`. -// It's then decoded by datanode to a `HashMap` with `serde_json::from_str`. -// Such a encoding/decoding scheme is inspired by the encoding/decoding of `RegionOptions`. +/// A wal options is encoded by meta srv into a `String` with `serde_json::to_string`. +/// It's then decoded by datanode to a `HashMap` with `serde_json::from_str`. +/// Such a encoding/decoding scheme is inspired by the encoding/decoding of `RegionOptions`. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)] #[serde(tag = "wal.provider")] pub enum WalOptions { diff --git a/src/common/meta/src/wal/kafka.rs b/src/common/meta/src/wal/kafka.rs index 189a4190ae9b..b24d14453186 100644 --- a/src/common/meta/src/wal/kafka.rs +++ b/src/common/meta/src/wal/kafka.rs @@ -54,17 +54,7 @@ impl Default for KafkaConfig { /// Kafka wal options allocated to a region. #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] -#[serde(default)] pub struct KafkaOptions { /// Kafka wal topic. pub topic: Topic, } - -impl Default for KafkaOptions { - fn default() -> Self { - Self { - // To indicates a default deserialized topic is invalid. - topic: "invalid_topic".to_string(), - } - } -} diff --git a/src/common/meta/src/wal/kafka/topic.rs b/src/common/meta/src/wal/kafka/topic.rs index 76d7c0c98b69..67223637f1ae 100644 --- a/src/common/meta/src/wal/kafka/topic.rs +++ b/src/common/meta/src/wal/kafka/topic.rs @@ -14,5 +14,5 @@ /// Kafka wal topic. /// Publishers publish log entries to the topic while subscribers pull log entries from the topic. -// A topic is simply a string right now. But it may be more complex in the future. +/// A topic is simply a string right now. But it may be more complex in the future. pub type Topic = String; diff --git a/src/common/meta/src/wal/kafka/topic_selector.rs b/src/common/meta/src/wal/kafka/topic_selector.rs index f29ac55b6ba8..169edc6e70b5 100644 --- a/src/common/meta/src/wal/kafka/topic_selector.rs +++ b/src/common/meta/src/wal/kafka/topic_selector.rs @@ -20,9 +20,9 @@ use crate::wal::kafka::topic::Topic; /// The type of the topic selector, i.e. with which strategy to select a topic. #[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)] +#[serde(rename_all = "snake_case")] pub enum SelectorType { #[default] - #[serde(rename = "round_robin")] RoundRobin, }