[cache_check] mapping damage reporter

This commit is contained in:
Joe Thornber 2013-10-08 09:36:20 +01:00
parent 96143f0bed
commit 81a72c8a35
3 changed files with 66 additions and 10 deletions

View File

@ -87,11 +87,35 @@ namespace {
using reporter_base::get_error; using reporter_base::get_error;
}; };
class mapping_reporter : public reporter_base { class mapping_reporter : public mapping_array_damage::damage_visitor, reporter_base {
public: public:
mapping_reporter(nested_output &o) mapping_reporter(nested_output &o)
: reporter_base(o) { : reporter_base(o) {
} }
virtual void visit(mapping_array_damage::missing_mappings const &d) {
out() << "missing mappings:" << end_message();
{
nested_output::nest _ = push();
out() << d.get_desc() << end_message();
}
mplus_error(FATAL);
}
virtual void visit(mapping_array_damage::invalid_mapping const &d) {
out() << "invalid mapping:" << end_message();
{
nested_output::nest _ = push();
out() << d.get_desc()
<< " [cblock = " << d.cblock_
<< ", oblock = " << d.m_.oblock_
<< ", flags = " << d.m_.flags_
<< "]" << end_message();
}
mplus_error(FATAL);
}
}; };
class hint_reporter : public reporter_base { class hint_reporter : public reporter_base {

View File

@ -28,12 +28,10 @@ mapping_traits::pack(value_type const &value, disk_type &disk)
//---------------------------------------------------------------- //----------------------------------------------------------------
missing_mappings::missing_mappings(run<uint32_t> const &keys, missing_mappings::missing_mappings(std::string const &desc, run<uint32_t> const &keys)
std::string const &desc) : damage(desc),
: keys_(keys), keys_(keys)
desc_(desc)
{ {
} }
void void
@ -42,6 +40,20 @@ missing_mappings::visit(damage_visitor &v) const
v.visit(*this); v.visit(*this);
} }
invalid_mapping::invalid_mapping(std::string const &desc,
block_address cblock, mapping const &m)
: damage(desc),
cblock_(cblock),
m_(m)
{
}
void
invalid_mapping::visit(damage_visitor &v) const
{
v.visit(*this);
}
namespace { namespace {
struct no_op_visitor { struct no_op_visitor {
virtual void visit(uint32_t index, virtual void visit(uint32_t index,
@ -56,7 +68,7 @@ namespace {
} }
virtual void visit(array_detail::damage const &d) { virtual void visit(array_detail::damage const &d) {
v_.visit(missing_mappings(d.lost_keys_, d.desc_)); v_.visit(missing_mappings(d.desc_, d.lost_keys_));
} }
private: private:

View File

@ -28,17 +28,36 @@ namespace caching {
namespace mapping_array_damage { namespace mapping_array_damage {
class damage_visitor; class damage_visitor;
struct damage { class damage {
public:
damage(std::string const &desc)
: desc_(desc) {
}
virtual ~damage() {} virtual ~damage() {}
virtual void visit(damage_visitor &v) const = 0; virtual void visit(damage_visitor &v) const = 0;
std::string get_desc() const {
return desc_;
}
private:
std::string desc_;
}; };
struct missing_mappings : public damage { struct missing_mappings : public damage {
missing_mappings(run<uint32_t> const &keys, std::string const &desc); missing_mappings(std::string const &desc, run<uint32_t> const &keys);
virtual void visit(damage_visitor &v) const; virtual void visit(damage_visitor &v) const;
run<uint32_t> keys_; run<uint32_t> keys_;
std::string desc_; };
struct invalid_mapping : public damage {
invalid_mapping(std::string const &desc, block_address cblock, mapping const &m);
virtual void visit(damage_visitor &v) const;
block_address cblock_;
mapping m_;
}; };
class damage_visitor { class damage_visitor {
@ -50,6 +69,7 @@ namespace caching {
} }
virtual void visit(missing_mappings const &d) = 0; virtual void visit(missing_mappings const &d) = 0;
virtual void visit(invalid_mapping const &d) = 0;
}; };
} }