2014-01-23 06:16:03 +05:30
|
|
|
#include "era/metadata.h"
|
|
|
|
#include "persistent-data/space-maps/core.h"
|
|
|
|
|
|
|
|
using namespace era;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
unsigned const METADATA_CACHE_SIZ = 1024;
|
|
|
|
|
|
|
|
// FIXME: duplication
|
|
|
|
transaction_manager::ptr
|
|
|
|
open_tm(block_manager<>::ptr bm) {
|
|
|
|
space_map::ptr sm(new core_map(bm->get_nr_blocks()));
|
|
|
|
sm->inc(SUPERBLOCK_LOCATION);
|
|
|
|
transaction_manager::ptr tm(new transaction_manager(bm, sm));
|
|
|
|
return tm;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
metadata::metadata(block_manager<>::ptr bm, open_type ot)
|
|
|
|
{
|
|
|
|
switch (ot) {
|
|
|
|
case CREATE:
|
|
|
|
// finish
|
|
|
|
throw runtime_error("not imlemented");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OPEN:
|
|
|
|
open_metadata(bm);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-31 22:01:27 +05:30
|
|
|
metadata::metadata(block_manager<>::ptr bm, block_address metadata_snap)
|
|
|
|
{
|
|
|
|
open_metadata(bm);
|
|
|
|
}
|
|
|
|
|
2014-01-23 06:16:03 +05:30
|
|
|
void
|
2014-01-31 22:01:27 +05:30
|
|
|
metadata::open_metadata(block_manager<>::ptr bm, block_address loc)
|
2014-01-23 06:16:03 +05:30
|
|
|
{
|
|
|
|
tm_ = open_tm(bm);
|
2014-01-31 22:01:27 +05:30
|
|
|
sb_ = read_superblock(tm_->get_bm(), loc);
|
2014-01-23 06:16:03 +05:30
|
|
|
|
2014-01-30 03:07:25 +05:30
|
|
|
writeset_tree_ = writeset_tree::ptr(new writeset_tree(tm_,
|
|
|
|
sb_.writeset_tree_root,
|
|
|
|
era_detail_traits::ref_counter(tm_)));
|
2014-01-23 06:16:03 +05:30
|
|
|
|
|
|
|
era_array_ = era_array::ptr(new era_array(tm_,
|
|
|
|
uint32_traits::ref_counter(),
|
|
|
|
sb_.era_array_root,
|
|
|
|
sb_.nr_blocks));
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------
|