Skip to content

Commit

Permalink
kafka: delete unused config code
Browse files Browse the repository at this point in the history
This removes somee methods in the kafka config handling code that have
either now become unused or have already been unused even before the
changes in this PR.
  • Loading branch information
pgellert committed Mar 13, 2024
1 parent 50f1813 commit f6e1088
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 166 deletions.
18 changes: 0 additions & 18 deletions src/v/kafka/server/handlers/create_topics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,24 +92,6 @@ using validators = make_validator_types<
vcluster_id_validator,
write_caching_configs_validator>;

static std::vector<creatable_topic_configs>
properties_to_result_configs(config_map_t config_map) {
std::vector<creatable_topic_configs> configs;
configs.reserve(config_map.size());
std::transform(
config_map.begin(),
config_map.end(),
std::back_inserter(configs),
[](auto& cfg) {
return creatable_topic_configs{
.name = cfg.first,
.value = {std::move(cfg.second)},
.config_source = kafka::describe_configs_source::default_config,
};
});
return configs;
}

static void
append_topic_configs(request_context& ctx, create_topics_response& response) {
for (auto& ct_result : response.data.topics) {
Expand Down
147 changes: 0 additions & 147 deletions src/v/kafka/server/handlers/topics/types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,151 +229,4 @@ to_cluster_type(const creatable_topic& t) {
return ret;
}

template<typename T>
static ss::sstring from_config_type(const T& v) {
if constexpr (std::is_enum_v<T>) {
return ssx::sformat("{}", v);
} else if constexpr (std::is_same_v<bool, T>) {
return v ? "true" : "false";
} else if constexpr (std::is_same_v<T, std::chrono::milliseconds>) {
return ss::to_sstring(
std::chrono::duration_cast<std::chrono::milliseconds>(v).count());
} else {
return ss::to_sstring(v);
}
}

config_map_t from_cluster_type(const cluster::topic_properties& properties) {
config_map_t config_entries;
if (properties.compression) {
config_entries[topic_property_compression] = from_config_type(
*properties.compression);
}
if (properties.cleanup_policy_bitflags) {
config_entries[topic_property_cleanup_policy] = from_config_type(
*properties.cleanup_policy_bitflags);
}
if (properties.compaction_strategy) {
config_entries[topic_property_compaction_strategy] = from_config_type(
*properties.compaction_strategy);
}
if (properties.timestamp_type) {
config_entries[topic_property_timestamp_type] = from_config_type(
*properties.timestamp_type);
}
if (properties.segment_size) {
config_entries[topic_property_segment_size] = from_config_type(
*properties.segment_size);
}
if (properties.retention_bytes.has_optional_value()) {
config_entries[topic_property_retention_bytes] = from_config_type(
properties.retention_bytes.value());
}
if (properties.retention_duration.has_optional_value()) {
config_entries[topic_property_retention_duration] = from_config_type(
*properties.retention_duration);
}
if (properties.recovery) {
config_entries[topic_property_recovery] = from_config_type(
*properties.recovery);
}
if (properties.batch_max_bytes) {
config_entries[topic_property_max_message_bytes] = from_config_type(
*properties.batch_max_bytes);
}
if (properties.shadow_indexing) {
config_entries[topic_property_remote_write] = "false";
config_entries[topic_property_remote_read] = "false";

switch (*properties.shadow_indexing) {
case model::shadow_indexing_mode::archival:
config_entries[topic_property_remote_write] = "true";
break;
case model::shadow_indexing_mode::fetch:
config_entries[topic_property_remote_read] = "true";
break;
case model::shadow_indexing_mode::full:
config_entries[topic_property_remote_write] = "true";
config_entries[topic_property_remote_read] = "true";
break;
default:
break;
}
}
if (properties.read_replica_bucket) {
config_entries[topic_property_read_replica] = from_config_type(
*properties.read_replica_bucket);
}

if (properties.retention_local_target_bytes.has_optional_value()) {
config_entries[topic_property_retention_local_target_bytes]
= from_config_type(*properties.retention_local_target_bytes);
}

if (properties.retention_local_target_ms.has_optional_value()) {
config_entries[topic_property_retention_local_target_ms]
= from_config_type(*properties.retention_local_target_ms);
}

config_entries[topic_property_remote_delete] = from_config_type(
properties.remote_delete);

if (properties.segment_ms.has_optional_value()) {
config_entries[topic_property_segment_ms] = from_config_type(
properties.segment_ms.value());
}

if (properties.record_key_schema_id_validation) {
config_entries[topic_property_record_key_schema_id_validation]
= from_config_type(properties.record_key_schema_id_validation);
}
if (properties.record_key_schema_id_validation_compat) {
config_entries[topic_property_record_key_schema_id_validation_compat]
= from_config_type(properties.record_key_schema_id_validation_compat);
}
if (properties.record_key_subject_name_strategy) {
config_entries[topic_property_record_key_subject_name_strategy]
= from_config_type(properties.record_key_subject_name_strategy);
}
if (properties.record_key_subject_name_strategy_compat) {
config_entries[topic_property_record_key_subject_name_strategy_compat]
= from_config_type(
properties.record_key_subject_name_strategy_compat);
}
if (properties.record_value_schema_id_validation) {
config_entries[topic_property_record_value_schema_id_validation]
= from_config_type(properties.record_value_schema_id_validation);
}
if (properties.record_value_schema_id_validation_compat) {
config_entries[topic_property_record_value_schema_id_validation_compat]
= from_config_type(
properties.record_value_schema_id_validation_compat);
}
if (properties.record_value_subject_name_strategy) {
config_entries[topic_property_record_value_subject_name_strategy]
= from_config_type(properties.record_value_subject_name_strategy);
}
if (properties.record_value_subject_name_strategy_compat) {
config_entries[topic_property_record_value_subject_name_strategy_compat]
= from_config_type(
properties.record_value_subject_name_strategy_compat);
}
if (properties.initial_retention_local_target_bytes.has_optional_value()) {
config_entries[topic_property_initial_retention_local_target_bytes]
= from_config_type(*properties.initial_retention_local_target_bytes);
}
if (properties.initial_retention_local_target_ms.has_optional_value()) {
config_entries[topic_property_initial_retention_local_target_ms]
= from_config_type(*properties.initial_retention_local_target_ms);
}

if (properties.mpx_virtual_cluster_id.has_value()) {
config_entries[topic_property_mpx_virtual_cluster_id]
= from_config_type(properties.mpx_virtual_cluster_id.value());
}
/// Final topic_property not encoded here is \ref remote_topic_properties,
/// is more of an implementation detail no need to ever show user
return config_entries;
}

} // namespace kafka
1 change: 0 additions & 1 deletion src/v/kafka/server/handlers/topics/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,4 @@ config_map_t config_map(const std::vector<creatable_topic_configs>& config);
cluster::custom_assignable_topic_configuration
to_cluster_type(const creatable_topic& t);

config_map_t from_cluster_type(const cluster::topic_properties&);
} // namespace kafka

0 comments on commit f6e1088

Please sign in to comment.