Skip to content

Commit

Permalink
Move thread_local declarations out of main.cc
Browse files Browse the repository at this point in the history
Since `disk-error-handler.hh` defines these global variables `extern`,
it makes sense to declare them in the `disk-error-handler.cc` instead of
`main.cc`.

This means that test files don't have to declare them.

Fixes #2735.

Signed-off-by: Jesse Haber-Kucharsky <jhaberku@scylladb.com>
Message-Id: <1eed120bfd9bb3647e03fe05b60c871de2df2a86.1511810004.git.jhaberku@scylladb.com>
  • Loading branch information
Jesse Haber-Kucharsky authored and tgrabiec committed Nov 27, 2017
1 parent 04106b4 commit fb0866c
Show file tree
Hide file tree
Showing 80 changed files with 6 additions and 378 deletions.
3 changes: 3 additions & 0 deletions disk-error-handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

#include "disk-error-handler.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

thread_local io_error_handler commit_error_handler = default_io_error_handler(commit_error);
thread_local io_error_handler general_disk_error_handler = default_io_error_handler(general_disk_error);
thread_local io_error_handler sstable_write_error_handler = default_io_error_handler(sstable_write_error);
Expand Down
2 changes: 0 additions & 2 deletions main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@
#include "sstables/compaction_manager.hh"
#include "sstables/sstables.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;
seastar::metrics::metric_groups app_metrics;

using namespace std::chrono_literals;
Expand Down
5 changes: 0 additions & 5 deletions tests/aggregate_fcts_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,8 @@
#include "core/future-util.hh"
#include "transport/messages/result_message.hh"

#include "disk-error-handler.hh"
#include "db/config.hh"


thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

namespace {

template <typename Env>
Expand Down
5 changes: 0 additions & 5 deletions tests/auth_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@
#include "db/config.hh"
#include "cql3/query_processor.hh"

#include "disk-error-handler.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

SEASTAR_TEST_CASE(test_data_resource) {
auth::data_resource root, keyspace("fisk"), column_family("fisk", "notter");

Expand Down
4 changes: 0 additions & 4 deletions tests/batchlog_manager_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,8 @@
#include "cql3/untyped_result_set.hh"
#include "db/batchlog_manager.hh"

#include "disk-error-handler.hh"
#include "message/messaging_service.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

static atomic_cell make_atomic_cell(bytes value) {
return atomic_cell::make_live(0, std::move(value));
};
Expand Down
5 changes: 0 additions & 5 deletions tests/big_decimal_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@
#include <boost/test/unit_test.hpp>
#include "utils/big_decimal.hh"

#include "disk-error-handler.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

namespace {

void test_div(const char *r_cstr, const int64_t q, const char *expected_cstr) {
Expand Down
4 changes: 0 additions & 4 deletions tests/cache_streamed_mutation_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,9 @@
#include "cache_streamed_mutation.hh"
#include "row_cache.hh"

#include "disk-error-handler.hh"
#include "memtable_snapshot_source.hh"
#include "mutation_assertions.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

/*
* ===================
* ====== Utils ======
Expand Down
5 changes: 0 additions & 5 deletions tests/canonical_mutation_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@
#include "tests/test_services.hh"
#include "tests/test-utils.hh"

#include "disk-error-handler.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

SEASTAR_TEST_CASE(test_conversion_back_and_forth) {
return seastar::async([] {
storage_service_for_tests ssft;
Expand Down
5 changes: 0 additions & 5 deletions tests/cartesian_product_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@
#include <boost/range/algorithm/copy.hpp>
#include "cartesian_product.hh"

#include "disk-error-handler.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

template<typename Range>
auto to_vec(Range&& r) {
std::vector<typename Range::iterator::value_type> v;
Expand Down
5 changes: 0 additions & 5 deletions tests/castas_fcts_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,8 @@
#include "core/future-util.hh"
#include "transport/messages/result_message.hh"

#include "disk-error-handler.hh"
#include "db/config.hh"


thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

namespace {

template<typename T>
Expand Down
4 changes: 0 additions & 4 deletions tests/cell_locker_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,13 @@
*/

#include "tests/test-utils.hh"
#include "disk-error-handler.hh"

#include <seastar/core/thread.hh>

#include "cell_locking.hh"
#include "mutation.hh"
#include "schema_builder.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

static schema_ptr make_schema()
{
return schema_builder("ks", "cf")
Expand Down
5 changes: 0 additions & 5 deletions tests/chunked_vector_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@
#include <boost/range/algorithm/reverse.hpp>
#include <boost/range/irange.hpp>

#include "disk-error-handler.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

using disk_array = utils::chunked_vector<uint64_t, 1024>;


Expand Down
5 changes: 0 additions & 5 deletions tests/clustering_ranges_walker_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
#include "simple_schema.hh"
#include "clustering_ranges_walker.hh"

#include "disk-error-handler.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

using namespace std::chrono_literals;

struct step {
Expand Down
5 changes: 0 additions & 5 deletions tests/commitlog_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@
#include "db/commitlog/rp_set.hh"
#include "log.hh"

#include "disk-error-handler.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

using namespace db;

template<typename Func>
Expand Down
5 changes: 0 additions & 5 deletions tests/compound_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@
#include "tests/range_assert.hh"
#include "schema_builder.hh"

#include "disk-error-handler.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

static std::vector<bytes> to_bytes_vec(std::vector<sstring> values) {
std::vector<bytes> result;
for (auto&& v : values) {
Expand Down
4 changes: 0 additions & 4 deletions tests/compress_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
#include <boost/test/unit_test.hpp>

#include "sstables/compress.hh"
#include "disk-error-handler.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

BOOST_AUTO_TEST_CASE(segmented_offsets_basic_functionality) {
sstables::compression::segmented_offsets offsets;
Expand Down
5 changes: 0 additions & 5 deletions tests/config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@
#include "core/future-util.hh"
#include "db/config.hh"

#include "disk-error-handler.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

using namespace db;

// stock, default cassandra.yaml
Expand Down
4 changes: 0 additions & 4 deletions tests/counter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,11 @@

#include "tests/test-utils.hh"
#include "tests/test_services.hh"
#include "disk-error-handler.hh"
#include "schema_builder.hh"
#include "keys.hh"
#include "mutation.hh"
#include "frozen_mutation.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

void verify_shard_order(counter_cell_view ccv) {
if (ccv.shards().begin() == ccv.shards().end()) {
return;
Expand Down
5 changes: 0 additions & 5 deletions tests/cql_query_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@
#include "transport/messages/result_message.hh"
#include "utils/big_decimal.hh"

#include "disk-error-handler.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

using namespace std::literals::chrono_literals;

SEASTAR_TEST_CASE(test_create_keyspace_statement) {
Expand Down
5 changes: 0 additions & 5 deletions tests/crc_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@
#include "utils/crc.hh"
#include <seastar/core/print.hh>

#include "disk-error-handler.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

inline
uint32_t
do_compute_crc(utils::crc32& c) {
Expand Down
5 changes: 0 additions & 5 deletions tests/database_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@
#include "partition_slice_builder.hh"
#include "frozen_mutation.hh"

#include "disk-error-handler.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

SEASTAR_TEST_CASE(test_querying_with_limits) {
return do_with_cql_env([](cql_test_env& e) {
return seastar::async([&] {
Expand Down
5 changes: 0 additions & 5 deletions tests/duration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,12 @@

#include "duration.hh"

#include "disk-error-handler.hh"

#include <boost/test/unit_test.hpp>

#include <experimental/string_view>

namespace stdx = std::experimental;

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

namespace {

//
Expand Down
5 changes: 0 additions & 5 deletions tests/dynamic_bitset_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@

#include "utils/dynamic_bitset.hh"

#include "disk-error-handler.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

BOOST_AUTO_TEST_CASE(test_set_clear_test) {
utils::dynamic_bitset bits;
bits.resize(178);
Expand Down
5 changes: 0 additions & 5 deletions tests/ec2_snitch_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@
#include <string>
#include <tuple>

#include "disk-error-handler.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

static boost::filesystem::path test_files_subdir("tests/snitch_property_files");

future<> one_test(const std::string& property_fname, bool exp_result) {
Expand Down
4 changes: 0 additions & 4 deletions tests/flat_mutation_reader_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,10 @@
#include "tmpdir.hh"
#include "sstable_test.hh"

#include "disk-error-handler.hh"
#include "tests/test_services.hh"
#include "tests/simple_schema.hh"
#include "flat_mutation_reader_assertions.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

static void test_double_conversion_through_mutation_reader(const std::vector<mutation>& mutations) {
BOOST_REQUIRE(!mutations.empty());
auto schema = mutations[0].schema();
Expand Down
5 changes: 0 additions & 5 deletions tests/flush_queue_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@
#include "utils/flush_queue.hh"
#include "log.hh"

#include "disk-error-handler.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

std::random_device rd;
std::default_random_engine e1(rd());

Expand Down
5 changes: 0 additions & 5 deletions tests/frozen_mutation_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@
#include "tests/mutation_assertions.hh"
#include "tests/mutation_source_test.hh"

#include "disk-error-handler.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

static schema_builder new_table() {
return { "some_keyspace", "some_table" };
}
Expand Down
5 changes: 0 additions & 5 deletions tests/gossip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@
#include <seastar/core/thread.hh>
#include <chrono>

#include "disk-error-handler.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

namespace bpo = boost::program_options;

// === How to run the test
Expand Down
5 changes: 0 additions & 5 deletions tests/gossip_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
#include "core/distributed.hh"
#include "database.hh"

#include "disk-error-handler.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

SEASTAR_TEST_CASE(test_boot_shutdown){
return seastar::async([] {
distributed<database> db;
Expand Down
5 changes: 0 additions & 5 deletions tests/gossiping_property_file_snitch_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@
#include <string>
#include <tuple>

#include "disk-error-handler.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

static boost::filesystem::path test_files_subdir("tests/snitch_property_files");

future<> one_test(const std::string& property_fname, bool exp_result) {
Expand Down
7 changes: 2 additions & 5 deletions tests/hash_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,12 @@


#include <boost/test/unit_test.hpp>
#include <seastar/core/future.hh>

#include "seastarx.hh"
#include "tests/test-utils.hh"
#include "utils/hash.hh"

#include "disk-error-handler.hh"

thread_local disk_error_signal_type commit_error;
thread_local disk_error_signal_type general_disk_error;

SEASTAR_TEST_CASE(test_pair_hash){
auto hash_compare = [](auto p) {
auto h1 = utils::tuple_hash()(p);
Expand Down
Loading

0 comments on commit fb0866c

Please sign in to comment.