@@ -35,15 +35,16 @@ Disk::~Disk() {
3535 metadb_ = NULL ;
3636}
3737
38- bool Disk::LoadStorage (std::function<void (int64_t , Disk*, BlockMeta)> callback) {
38+ void Disk::LoadStorage (std::function<void (int64_t , Disk*, BlockMeta)> callback, int* ret_val ) {
3939 MutexLock lock (&mu_);
4040 int64_t start_load_time = common::timer::get_micros ();
4141 leveldb::Options options;
4242 options.create_if_missing = true ;
4343 leveldb::Status s = leveldb::DB::Open (options, path_ + " meta/" , &metadb_);
4444 if (!s.ok ()) {
4545 LOG (WARNING, " Load blocks fail: %s" , s.ToString ().c_str ());
46- return false ;
46+ *ret_val = -1 ;
47+ return ;
4748 }
4849
4950 std::string version_key (8 , ' \0 ' );
@@ -61,7 +62,8 @@ bool Disk::LoadStorage(std::function<void (int64_t, Disk*, BlockMeta)> callback)
6162 if (1 != sscanf (it->key ().data (), " %ld" , &block_id)) {
6263 LOG (WARNING, " Unknown key: %s\n " , it->key ().ToString ().c_str ());
6364 delete it;
64- return false ;
65+ *ret_val = -1 ;
66+ return ;
6567 }
6668 BlockMeta meta;
6769 if (!meta.ParseFromArray (it->value ().data (), it->value ().size ())) {
@@ -97,13 +99,15 @@ bool Disk::LoadStorage(std::function<void (int64_t, Disk*, BlockMeta)> callback)
9799 }
98100 delete it;
99101 int64_t end_load_time = common::timer::get_micros ();
100- LOG (INFO, " Disk %s Load %ld blocks, use %ld ms, namespace version: %ld" ,
101- path_.c_str (), block_num, (end_load_time - start_load_time) / 1000 , namespace_version_);
102+ LOG (INFO, " Disk %s Load %ld blocks, use %ld ms, namespace version: %ld, size %s" ,
103+ path_.c_str (), block_num, (end_load_time - start_load_time) / 1000 ,
104+ namespace_version_, common::HumanReadableString (counters_.data_size .Get ()).c_str ());
102105 if (namespace_version_ == 0 && block_num > 0 ) {
103106 LOG (WARNING, " Namespace version lost!" );
104107 }
105108 quota_ += counters_.data_size .Get ();
106- return true ;
109+ *ret_val = 1 ;
110+ return ;
107111}
108112
109113std::string Disk::Path () const {
0 commit comments