these unused includes were identified by clangd. see https://clangd.llvm.org/guides/include-cleaner#unused-include-warning for more details on the "Unused include" warning. because the removal of `#include "unimplemented.hh"`, `service/migration_manager.cc` misses the definition of `unimplemented::cause::VALIDATION`, so include the header where it is used. Signed-off-by: Kefu Chai <kefu.chai@scylladb.com> Closes scylladb/scylladb#16654
36 lines
866 B
C++
36 lines
866 B
C++
/*
|
|
* Copyright 2020-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
#include <cassert>
|
|
#include <chrono>
|
|
#include <utility>
|
|
|
|
#include <fmt/format.h>
|
|
|
|
#include "generation-number.hh"
|
|
|
|
namespace gms {
|
|
|
|
generation_type get_generation_number() {
|
|
using namespace std::chrono;
|
|
auto now = high_resolution_clock::now().time_since_epoch();
|
|
int generation_number = duration_cast<seconds>(now).count();
|
|
auto ret = generation_type(generation_number);
|
|
// Make sure the clock didn't overflow the 32 bits value
|
|
assert(ret.value() == generation_number);
|
|
return ret;
|
|
}
|
|
|
|
void validate_gossip_generation(int64_t generation_number) {
|
|
if (!std::in_range<gms::generation_type::value_type>(generation_number)) {
|
|
throw std::out_of_range(fmt::format("gossip generation {} is out of range", generation_number));
|
|
}
|
|
}
|
|
|
|
}
|