]>
git.proxmox.com Git - ceph.git/blob - ceph/src/test/objectstore/FileStoreTracker.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
3 #ifndef FILESTORE_TRACKER_H
4 #define FILESTORE_TRACKER_H
5 #include "test/common/ObjectContents.h"
6 #include "os/filestore/FileStore.h"
7 #include "kv/KeyValueDB.h"
8 #include <boost/scoped_ptr.hpp>
11 #include "common/Mutex.h"
13 class FileStoreTracker
{
14 const static uint64_t SIZE
= 4 * 1024;
20 struct OutTransaction
{
21 list
<pair
<pair
<coll_t
, string
>, uint64_t> > *in_flight
;
22 ObjectStore::Transaction
*t
;
25 FileStoreTracker(ObjectStore
*store
, KeyValueDB
*db
)
26 : store(store
), db(db
),
27 lock("Tracker Lock"), restart_seq(0) {}
32 virtual void operator()(FileStoreTracker
*harness
,
33 OutTransaction
*out
) = 0;
37 class Write
: public Op
{
41 Write(const coll_t
&coll
,
43 : coll(coll
), oid(oid
) {}
44 void operator()(FileStoreTracker
*harness
,
45 OutTransaction
*out
) override
{
46 harness
->write(make_pair(coll
, oid
), out
);
49 class CloneRange
: public Op
{
54 CloneRange(const coll_t
&coll
,
57 : coll(coll
), from(from
), to(to
) {}
58 void operator()(FileStoreTracker
*harness
,
59 OutTransaction
*out
) override
{
60 harness
->clone_range(make_pair(coll
, from
), make_pair(coll
, to
),
64 class Clone
: public Op
{
69 Clone(const coll_t
&coll
,
72 : coll(coll
), from(from
), to(to
) {}
73 void operator()(FileStoreTracker
*harness
,
74 OutTransaction
*out
) override
{
75 harness
->clone(make_pair(coll
, from
), make_pair(coll
, to
),
79 class Remove
: public Op
{
83 Remove(const coll_t
&coll
,
85 : coll(coll
), obj(obj
) {}
86 void operator()(FileStoreTracker
*harness
,
87 OutTransaction
*out
) override
{
88 harness
->remove(make_pair(coll
, obj
),
93 void write(const coll_t
&coll
, const string
&oid
) {
94 ops
.push_back(new Write(coll
, oid
));
96 void clone_range(const coll_t
&coll
, const string
&from
,
98 ops
.push_back(new CloneRange(coll
, from
, to
));
100 void clone(const coll_t
&coll
, const string
&from
,
102 ops
.push_back(new Clone(coll
, from
, to
));
104 void remove(const coll_t
&coll
, const string
&oid
) {
105 ops
.push_back(new Remove(coll
, oid
));
107 friend class FileStoreTracker
;
111 void submit_transaction(Transaction
&t
);
112 void verify(const coll_t
&coll
,
114 bool on_start
= false);
117 ObjectContents
get_current_content(const pair
<coll_t
, string
> &obj
);
118 pair
<uint64_t, uint64_t> get_valid_reads(const pair
<coll_t
, string
> &obj
);
119 ObjectContents
get_content(const pair
<coll_t
, string
> &obj
, uint64_t version
);
121 void committed(const pair
<coll_t
, string
> &obj
, uint64_t seq
);
122 void applied(const pair
<coll_t
, string
> &obj
, uint64_t seq
);
123 uint64_t set_content(const pair
<coll_t
, string
> &obj
, ObjectContents
&content
);
125 // ObjectContents Operations
126 void write(const pair
<coll_t
, string
> &obj
, OutTransaction
*out
);
127 void remove(const pair
<coll_t
, string
> &obj
, OutTransaction
*out
);
128 void clone_range(const pair
<coll_t
, string
> &from
,
129 const pair
<coll_t
, string
> &to
,
130 OutTransaction
*out
);
131 void clone(const pair
<coll_t
, string
> &from
,
132 const pair
<coll_t
, string
> &to
,
133 OutTransaction
*out
);
134 friend class OnApplied
;
135 friend class OnCommitted
;