22#include "data/CassandraBackend.hpp"
23#include "data/cassandra/SettingsProvider.hpp"
24#include "data/cassandra/Types.hpp"
25#include "migration/MigratiorStatus.hpp"
26#include "migration/cassandra/impl/CassandraMigrationSchema.hpp"
27#include "migration/cassandra/impl/Spec.hpp"
28#include "util/log/Logger.hpp"
30#include <boost/asio/spawn.hpp>
36namespace migration::cassandra {
54 :
data::cassandra::CassandraBackend{auto{settingsProvider}, false }
55 , settingsProvider_(std::move(settingsProvider))
56 , migrationSchema_{settingsProvider_}
69 template <impl::TableSpec TableDesc>
72 std::int64_t
const start,
73 std::int64_t
const end,
75 boost::asio::yield_context yield
78 LOG(log_.
debug()) <<
"Travsering token range: " << start <<
" - " << end
79 <<
" ; table: " << TableDesc::kTABLE_NAME;
81 static auto kSTATEMENT_PREPARED =
84 auto const statement = kSTATEMENT_PREPARED.
bind(start, end);
86 auto const res = this->executor_.read(yield, statement);
88 LOG(log_.
error()) <<
"Could not fetch data from table: " << TableDesc::kTABLE_NAME <<
" range: " << start
89 <<
" - " << end <<
";" << res.error();
93 auto const& results = res.value();
94 if (not results.hasRows()) {
95 LOG(log_.
debug()) <<
"No rows returned - table: " << TableDesc::kTABLE_NAME <<
" range: " << start <<
" - "
100 for (
auto const& row : std::apply(
102 typename TableDesc::Row{}
Implements BackendInterface for Cassandra/ScyllaDB.
Definition CassandraBackend.hpp:71
Provides settings for BasicCassandraBackend.
Definition SettingsProvider.hpp:35
Statement bind(Args &&... args) const
Bind the given arguments and produce a ready to execute Statement.
Definition Statement.hpp:171
The backend for the migration. It is a subclass of the CassandraBackend and provides the migration sp...
Definition CassandraMigrationBackend.hpp:42
void migrateInTokenRange(std::int64_t const start, std::int64_t const end, auto const &callback, boost::asio::yield_context yield)
Scan a table in a token range and call the callback for each row.
Definition CassandraMigrationBackend.hpp:71
CassandraMigrationBackend(data::cassandra::SettingsProvider settingsProvider)
Construct a new Cassandra Migration Backend object. The backend is not readonly.
Definition CassandraMigrationBackend.hpp:53
The schema for the migration process. It contains the prepared statements only used for the migration...
Definition CassandraMigrationSchema.hpp:37
data::cassandra::PreparedStatement getPreparedFullScanStatement(data::cassandra::Handle const &handler, std::string const &tableName, std::string const &key)
Get the prepared statement for the full scan of a table.
Definition CassandraMigrationSchema.hpp:60
A simple thread-safe logger for the channel specified in the constructor.
Definition Logger.hpp:110
Pump error(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::ERR severity.
Definition Logger.cpp:215
Pump debug(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::DBG severity.
Definition Logger.cpp:200
impl::ResultExtractor< Types... > extract(Handle::ResultType const &result)
Extracts the results into series of std::tuple<Types...> by creating a simple wrapper with an STL inp...
Definition Handle.hpp:329
This namespace implements the data access layer and related components.
Definition AmendmentCenter.cpp:70