diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /src/crimson/osd/backfill_facades.h | |
parent | Initial commit. (diff) | |
download | ceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/crimson/osd/backfill_facades.h')
-rw-r--r-- | src/crimson/osd/backfill_facades.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/crimson/osd/backfill_facades.h b/src/crimson/osd/backfill_facades.h new file mode 100644 index 000000000..683dc6ea6 --- /dev/null +++ b/src/crimson/osd/backfill_facades.h @@ -0,0 +1,73 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#pragma once + +#include "crimson/osd/backfill_state.h" +#include "crimson/osd/pg.h" +#include "osd/PeeringState.h" + +namespace crimson::osd { + +// PeeringFacade -- main implementation of the BackfillState::PeeringFacade +// interface. We have the abstraction to decuple BackfillState from Peering +// State, and thus cut depedencies in unit testing. The second implemention +// is BackfillFixture::PeeringFacade and sits in test_backfill.cc. +struct PeeringFacade final : BackfillState::PeeringFacade { + PeeringState& peering_state; + + hobject_t earliest_backfill() const override { + return peering_state.earliest_backfill(); + } + + const std::set<pg_shard_t>& get_backfill_targets() const override { + return peering_state.get_backfill_targets(); + } + + const hobject_t& get_peer_last_backfill(pg_shard_t peer) const override { + return peering_state.get_peer_info(peer).last_backfill; + } + + const eversion_t& get_last_update() const override { + return peering_state.get_info().last_update; + } + + const eversion_t& get_log_tail() const override { + return peering_state.get_info().log_tail; + } + + void scan_log_after(eversion_t v, scan_log_func_t f) const override { + peering_state.get_pg_log().get_log().scan_log_after(v, std::move(f)); + } + + bool is_backfill_target(pg_shard_t peer) const override { + return peering_state.is_backfill_target(peer); + } + void update_complete_backfill_object_stats(const hobject_t &hoid, + const pg_stat_t &stats) override { + peering_state.update_complete_backfill_object_stats(hoid, stats); + } + + bool is_backfilling() const override { + return peering_state.is_backfilling(); + } + + PeeringFacade(PeeringState& peering_state) + : peering_state(peering_state) { + } +}; + +// PGFacade -- a facade (in the GoF-defined meaning) simplifying the huge +// interface of crimson's PG class. The motivation is to have an inventory +// of behaviour that must be provided by a unit test's mock. +struct PGFacade final : BackfillState::PGFacade { + PG& pg; + + const eversion_t& get_projected_last_update() const override { + return pg.projected_last_update; + } + + PGFacade(PG& pg) : pg(pg) {} +}; + +} // namespace crimson::osd |