metadata_dumper

This commit is contained in:
Joe Thornber 2011-10-28 12:13:03 +01:00
parent 925d9d583f
commit 9a4ebc8c25
5 changed files with 28 additions and 16 deletions

View File

@ -10,8 +10,8 @@ SOURCE=\
human_readable_format.cc \ human_readable_format.cc \
metadata.cc \ metadata.cc \
metadata_checker.cc \ metadata_checker.cc \
metadata_dumper.cc \
metadata_ll.cc \ metadata_ll.cc \
metadata_dump.cc \
metadata_disk_structures.cc \ metadata_disk_structures.cc \
space_map_disk.cc \ space_map_disk.cc \
transaction_manager.cc \ transaction_manager.cc \

View File

@ -1,7 +1,6 @@
#ifndef MULTISNAP_METADATA_H #ifndef MULTISNAP_METADATA_H
#define MULTISNAP_METADATA_H #define MULTISNAP_METADATA_H
#include "emitter.h"
#include "metadata_ll.h" #include "metadata_ll.h"
#include <string> #include <string>
@ -60,10 +59,6 @@ namespace thin_provisioning {
thin::ptr open_thin(thin_dev_t); thin::ptr open_thin(thin_dev_t);
// FIXME: split out into a separate interface
// Dumping metadata
void dump(emitter::ptr e);
private: private:
friend class thin; friend class thin;

View File

@ -1,4 +1,4 @@
#include "metadata.h" #include "metadata_dumper.h"
using namespace persistent_data; using namespace persistent_data;
using namespace thin_provisioning; using namespace thin_provisioning;
@ -120,14 +120,16 @@ namespace {
}; };
} }
//----------------------------------------------------------------
void void
metadata::dump(emitter::ptr e) thin_provisioning::metadata_dump(metadata_ll::ptr md, emitter::ptr e)
{ {
e->begin_superblock("", md_->sb_.time_, md_->sb_.trans_id_, md_->sb_.data_block_size_); e->begin_superblock("", md->sb_.time_, md->sb_.trans_id_, md->sb_.data_block_size_);
details_extractor::ptr de(new details_extractor); details_extractor::ptr de(new details_extractor);
md_->details_.visit(de); md->details_.visit(de);
map<uint64_t, device_details> const &devs = de->get_devices(); map<uint64_t, device_details> const &devs = de->get_devices();
map<uint64_t, device_details>::const_iterator it, end = devs.end(); map<uint64_t, device_details>::const_iterator it, end = devs.end();
@ -141,8 +143,8 @@ metadata::dump(emitter::ptr e)
dd.creation_time_, dd.creation_time_,
dd.snapshotted_time_); dd.snapshotted_time_);
mappings_extractor::ptr me(new mappings_extractor(dev_id, e, md_->metadata_sm_, md_->data_sm_)); mappings_extractor::ptr me(new mappings_extractor(dev_id, e, md->metadata_sm_, md->data_sm_));
md_->mappings_.visit(me); md->mappings_.visit(me);
e->end_device(); e->end_device();
} }

15
metadata_dumper.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef METADATA_DUMPER_H
#define METADATA_DUMPER_H
#include "emitter.h"
#include "metadata_ll.h"
//----------------------------------------------------------------
namespace thin_provisioning {
void metadata_dump(metadata_ll::ptr md, emitter::ptr e);
}
//----------------------------------------------------------------
#endif

View File

@ -1,7 +1,8 @@
#include <iostream> #include <iostream>
#include "human_readable_format.h" #include "human_readable_format.h"
#include "metadata.h" #include "metadata_dumper.h"
#include "metadata_ll.h"
#include "xml_format.h" #include "xml_format.h"
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
@ -16,8 +17,7 @@ namespace po = boost::program_options;
namespace { namespace {
void dump(string const &path, string const &format) { void dump(string const &path, string const &format) {
metadata_ll::ptr ll(new metadata_ll(path)); metadata_ll::ptr md(new metadata_ll(path));
metadata md(ll);
emitter::ptr e; emitter::ptr e;
if (format == "xml") if (format == "xml")
@ -29,7 +29,7 @@ namespace {
exit(1); exit(1);
} }
md.dump(e); metadata_dump(md, e);
} }
void usage(po::options_description const &desc) { void usage(po::options_description const &desc) {