22#include "data/CassandraBackend.hpp"
23#include "data/LedgerCacheInterface.hpp"
24#include "data/cassandra/SettingsProvider.hpp"
25#include "migration/cassandra/impl/CassandraMigrationSchema.hpp"
26#include "migration/cassandra/impl/Spec.hpp"
27#include "util/log/Logger.hpp"
29#include <boost/asio/spawn.hpp>
35namespace migration::cassandra {
57 :
data::cassandra::CassandraBackend{auto{settingsProvider},
cache, false }
58 , settingsProvider_(std::move(settingsProvider))
59 , migrationSchema_{settingsProvider_}
72 template <impl::TableSpec TableDesc>
75 std::int64_t
const start,
76 std::int64_t
const end,
78 boost::asio::yield_context yield
81 LOG(log_.
debug()) <<
"Travsering token range: " << start <<
" - " << end
82 <<
" ; table: " << TableDesc::kTABLE_NAME;
84 static auto kSTATEMENT_PREPARED =
87 auto const statement = kSTATEMENT_PREPARED.
bind(start, end);
89 auto const res = this->executor_.read(yield, statement);
91 LOG(log_.
error()) <<
"Could not fetch data from table: " << TableDesc::kTABLE_NAME <<
" range: " << start
92 <<
" - " << end <<
";" << res.error();
96 auto const& results = res.value();
97 if (not results.hasRows()) {
98 LOG(log_.
debug()) <<
"No rows returned - table: " << TableDesc::kTABLE_NAME <<
" range: " << start <<
" - "
103 for (
auto const& row : std::apply(
105 typename TableDesc::Row{}
LedgerCacheInterface const & cache() const
Definition BackendInterface.hpp:165
Cache for an entire ledger.
Definition LedgerCacheInterface.hpp:38
Implements BackendInterface for Cassandra/ScyllaDB.
Definition CassandraBackend.hpp:76
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:179
The backend for the migration. It is a subclass of the CassandraBackend and provides the migration sp...
Definition CassandraMigrationBackend.hpp:41
CassandraMigrationBackend(data::cassandra::SettingsProvider settingsProvider, data::LedgerCacheInterface &cache)
Construct a new Cassandra Migration Backend object. The backend is not readonly.
Definition CassandraMigrationBackend.hpp:53
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:74
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:111
Pump error(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::ERR severity.
Definition Logger.cpp:229
Pump debug(SourceLocationType const &loc=CURRENT_SRC_LOCATION) const
Interface for logging at Severity::DBG severity.
Definition Logger.cpp:214
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