From b4f875f08e7ea31ca88d1fbb3d8b059f7e9494f1 Mon Sep 17 00:00:00 2001 From: Konstantin Osipov Date: Wed, 27 Jan 2021 20:31:12 +0300 Subject: [PATCH] uuid: reduce code dependency on UUID_gen.hh Do not include UUID_gen.hh in trace_state.hh and lists.hh to reduce header level dependency on it. Message-Id: <20210127173114.725761-2-kostja@scylladb.com> --- cdc/log.cc | 1 + cql3/lists.cc | 1 + cql3/lists.hh | 1 - database.hh | 1 - schema_mutations.cc | 1 + test/perf/perf_row_cache_update.cc | 1 + tracing/trace_keyspace_helper.cc | 1 + tracing/trace_state.cc | 27 +++++++++++++++++++++++++++ tracing/trace_state.hh | 23 +++-------------------- 9 files changed, 35 insertions(+), 22 deletions(-) diff --git a/cdc/log.cc b/cdc/log.cc index d9666f65d1..a5e7a388b2 100644 --- a/cdc/log.cc +++ b/cdc/log.cc @@ -48,6 +48,7 @@ #include "cql3/untyped_result_set.hh" #include "log.hh" #include "utils/rjson.hh" +#include "utils/UUID_gen.hh" #include "types.hh" #include "concrete_types.hh" #include "types/listlike_partial_deserializing_iterator.hh" diff --git a/cql3/lists.cc b/cql3/lists.cc index ef6f2a13e4..e8011c61bb 100644 --- a/cql3/lists.cc +++ b/cql3/lists.cc @@ -26,6 +26,7 @@ #include "constants.hh" #include #include "types/list.hh" +#include "utils/UUID_gen.hh" namespace cql3 { diff --git a/cql3/lists.hh b/cql3/lists.hh index 340ecbc37f..f9f288b10a 100644 --- a/cql3/lists.hh +++ b/cql3/lists.hh @@ -43,7 +43,6 @@ #include "cql3/abstract_marker.hh" #include "to_string.hh" -#include "utils/UUID_gen.hh" #include "operation.hh" namespace cql3 { diff --git a/database.hh b/database.hh index dc1a108cb9..b1682074c1 100644 --- a/database.hh +++ b/database.hh @@ -29,7 +29,6 @@ #include #include #include -#include "utils/UUID_gen.hh" #include "utils/UUID.hh" #include "utils/hash.hh" #include "db_clock.hh" diff --git a/schema_mutations.cc b/schema_mutations.cc index d826d12e64..95cbae00f6 100644 --- a/schema_mutations.cc +++ b/schema_mutations.cc @@ -23,6 +23,7 @@ #include "canonical_mutation.hh" #include "db/schema_tables.hh" #include "hashers.hh" +#include "utils/UUID_gen.hh" schema_mutations::schema_mutations(canonical_mutation columnfamilies, canonical_mutation columns, diff --git a/test/perf/perf_row_cache_update.cc b/test/perf/perf_row_cache_update.cc index 17ebf058c7..5af930b264 100644 --- a/test/perf/perf_row_cache_update.cc +++ b/test/perf/perf_row_cache_update.cc @@ -27,6 +27,7 @@ #include "utils/managed_bytes.hh" #include "utils/logalloc.hh" +#include "utils/UUID_gen.hh" #include "row_cache.hh" #include "log.hh" #include "schema_builder.hh" diff --git a/tracing/trace_keyspace_helper.cc b/tracing/trace_keyspace_helper.cc index ef8499a18d..f7c323df4f 100644 --- a/tracing/trace_keyspace_helper.cc +++ b/tracing/trace_keyspace_helper.cc @@ -48,6 +48,7 @@ #include "cql3/cql_config.hh" #include "types/set.hh" #include "types/map.hh" +#include "utils/UUID_gen.hh" namespace tracing { diff --git a/tracing/trace_state.cc b/tracing/trace_state.cc index 01ec0098a6..8d7894010e 100644 --- a/tracing/trace_state.cc +++ b/tracing/trace_state.cc @@ -48,6 +48,7 @@ #include "cql3/values.hh" #include "cql3/query_options.hh" +#include "utils/UUID_gen.hh" namespace tracing { @@ -76,6 +77,32 @@ void trace_state::params_values_deleter::operator()(params_values* pv) { delete pv; } +void trace_state::init_session_records( + trace_type type, + std::chrono::seconds slow_query_ttl, + std::optional session_id, + span_id parent_id) { + + _records = make_lw_shared(); + _records->session_id = session_id ? *session_id : utils::UUID_gen::get_time_UUID(); + + if (full_tracing()) { + if (!log_slow_query()) { + _records->ttl = ttl_by_type(type); + } else { + _records->ttl = std::max(ttl_by_type(type), slow_query_ttl); + } + } else { + _records->ttl = slow_query_ttl; + } + + _records->session_rec.command = type; + _records->session_rec.slow_query_record_ttl = slow_query_ttl; + _records->my_span_id = span_id::make_span_id(); + _records->parent_id = parent_id; +} + + void trace_state::set_batchlog_endpoints(const std::unordered_set& val) { _params_ptr->batchlog_endpoints.emplace(val); } diff --git a/tracing/trace_state.hh b/tracing/trace_state.hh index c0876a7a77..c6af17414a 100644 --- a/tracing/trace_state.hh +++ b/tracing/trace_state.hh @@ -45,7 +45,6 @@ #include #include #include -#include "utils/UUID_gen.hh" #include "tracing/tracing.hh" #include "gms/inet_address.hh" #include "auth/authenticated_user.hh" @@ -235,25 +234,9 @@ private: return log_slow_query() && e > _slow_query_threshold; } - void init_session_records(trace_type type, std::chrono::seconds slow_query_ttl, std::optional session_id = std::nullopt, span_id parent_id = span_id::illegal_id) { - _records = make_lw_shared(); - _records->session_id = session_id ? *session_id : utils::UUID_gen::get_time_UUID(); - - if (full_tracing()) { - if (!log_slow_query()) { - _records->ttl = ttl_by_type(type); - } else { - _records->ttl = std::max(ttl_by_type(type), slow_query_ttl); - } - } else { - _records->ttl = slow_query_ttl; - } - - _records->session_rec.command = type; - _records->session_rec.slow_query_record_ttl = slow_query_ttl; - _records->my_span_id = span_id::make_span_id(); - _records->parent_id = parent_id; - } + void init_session_records(trace_type type, std::chrono::seconds slow_query_ttl, + std::optional session_id = std::nullopt, + span_id parent_id = span_id::illegal_id); bool should_write_records() const { return full_tracing() || _records->do_log_slow_query;