]>
git.proxmox.com Git - ceph.git/blob - ceph/src/test/bench/testfilestore_backend.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
3 #include "testfilestore_backend.h"
4 #include "global/global_init.h"
5 #include "os/ObjectStore.h"
8 TestFileStoreBackend::TestFileStoreBackend(
9 ObjectStore
*os
, bool write_infos
)
10 : os(os
), finisher(g_ceph_context
), write_infos(write_infos
)
15 void TestFileStoreBackend::write(
22 ObjectStore::Transaction
*t
= new ObjectStore::Transaction
;
23 size_t sep
= oid
.find("/");
24 assert(sep
!= string::npos
);
25 assert(sep
+ 1 < oid
.size());
27 bool valid_coll
= c
.parse(oid
.substr(0, sep
));
29 string coll_str
= c
.to_str();
31 if (!osrs
.count(coll_str
))
32 osrs
.insert(make_pair(coll_str
, ObjectStore::Sequencer(coll_str
)));
33 ObjectStore::Sequencer
*osr
= &(osrs
.find(coll_str
)->second
);
35 hobject_t
h(sobject_t(oid
.substr(sep
+1), 0));
37 t
->write(c
, ghobject_t(h
), offset
, bl
.length(), bl
);
41 for (uint64_t j
= 0; j
< 128; ++j
) bl2
.append(0);
43 hobject_t
info(sobject_t(string("info_")+coll_str
, 0));
44 t
->write(meta
, ghobject_t(info
), 0, bl2
.length(), bl2
);
47 os
->queue_transaction(
55 void TestFileStoreBackend::read(
62 size_t sep
= oid
.find("/");
63 assert(sep
!= string::npos
);
64 assert(sep
+ 1 < oid
.size());
66 bool valid_coll
= c
.parse(oid
.substr(0, sep
));
68 hobject_t
h(sobject_t(oid
.substr(sep
+1), 0));
70 os
->read(c
, ghobject_t(h
), offset
, length
, *bl
);
71 finisher
.queue(on_complete
);