]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | /* | |
4 | * Ceph - scalable distributed file system | |
5 | * | |
6 | * Copyright (C) 2012 New Dream Network | |
7 | * | |
8 | * This is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License version 2.1, as published by the Free Software | |
11 | * Foundation. See file COPYING. | |
12 | */ | |
13 | #ifndef FILESTORE_DTRMNSTC_SEQ_OPS_H_ | |
14 | #define FILESTORE_DTRMNSTC_SEQ_OPS_H_ | |
15 | ||
16 | #include <iostream> | |
17 | #include <fstream> | |
18 | #include <set> | |
19 | #include "os/ObjectStore.h" | |
20 | #include <boost/scoped_ptr.hpp> | |
21 | #include <boost/random/mersenne_twister.hpp> | |
22 | #include <boost/random/uniform_int.hpp> | |
23 | ||
24 | #include "TestObjectStoreState.h" | |
25 | ||
26 | typedef boost::mt11213b rngen_t; | |
27 | ||
28 | class DeterministicOpSequence : public TestObjectStoreState { | |
29 | public: | |
11fdf7f2 TL |
30 | DeterministicOpSequence(ObjectStore *store, |
31 | std::string status = std::string()); | |
7c673cae FG |
32 | virtual ~DeterministicOpSequence(); |
33 | ||
34 | virtual void generate(int seed, int num_txs); | |
35 | ||
11fdf7f2 TL |
36 | static ghobject_t get_txn_object(coll_t cid) { |
37 | ghobject_t oid(hobject_t(sobject_t("txn", CEPH_NOSNAP))); | |
38 | spg_t pgid; | |
39 | bool r = cid.is_pg(&pgid); | |
40 | if (r) { | |
41 | oid.hobj.set_hash(pgid.ps()); | |
42 | } | |
43 | return oid; | |
44 | } | |
45 | ||
46 | protected: | |
7c673cae FG |
47 | enum { |
48 | DSOP_TOUCH = 0, | |
49 | DSOP_WRITE = 1, | |
50 | DSOP_CLONE = 2, | |
51 | DSOP_CLONE_RANGE = 3, | |
52 | DSOP_OBJ_REMOVE = 4, | |
28e407b8 AA |
53 | DSOP_COLL_MOVE = 5, |
54 | DSOP_SET_ATTRS = 6, | |
55 | DSOP_COLL_CREATE = 7, | |
7c673cae FG |
56 | |
57 | DSOP_FIRST = DSOP_TOUCH, | |
58 | DSOP_LAST = DSOP_COLL_CREATE, | |
59 | }; | |
60 | ||
61 | int32_t txn; | |
62 | ||
11fdf7f2 | 63 | ObjectStore::CollectionHandle m_ch; |
7c673cae FG |
64 | std::ofstream m_status; |
65 | ||
66 | bool run_one_op(int op, rngen_t& gen); | |
67 | ||
11fdf7f2 | 68 | void note_txn(coll_entry_t *entry, ObjectStore::Transaction *t); |
7c673cae FG |
69 | bool do_touch(rngen_t& gen); |
70 | bool do_remove(rngen_t& gen); | |
71 | bool do_write(rngen_t& gen); | |
72 | bool do_clone(rngen_t& gen); | |
73 | bool do_clone_range(rngen_t& gen); | |
74 | bool do_coll_move(rngen_t& gen); | |
75 | bool do_set_attrs(rngen_t& gen); | |
76 | bool do_coll_create(rngen_t& gen); | |
77 | ||
28e407b8 AA |
78 | virtual void _do_touch(coll_entry_t *entry, hobject_t& obj); |
79 | virtual void _do_remove(coll_entry_t *entry, hobject_t& obj); | |
80 | virtual void _do_write(coll_entry_t *entry, hobject_t& obj, uint64_t off, | |
7c673cae | 81 | uint64_t len, const bufferlist& data); |
28e407b8 | 82 | virtual void _do_set_attrs(coll_entry_t *entry, |
7c673cae | 83 | hobject_t &obj, |
20effc67 | 84 | const std::map<std::string, bufferlist> &attrs); |
28e407b8 AA |
85 | virtual void _do_clone(coll_entry_t *entry, hobject_t& orig_obj, hobject_t& new_obj); |
86 | virtual void _do_clone_range(coll_entry_t *entry, hobject_t& orig_obj, | |
7c673cae | 87 | hobject_t& new_obj, uint64_t srcoff, uint64_t srclen, uint64_t dstoff); |
28e407b8 | 88 | virtual void _do_write_and_clone_range(coll_entry_t *entry, hobject_t& orig_obj, |
7c673cae FG |
89 | hobject_t& new_obj, uint64_t srcoff, uint64_t srclen, |
90 | uint64_t dstoff, bufferlist& bl); | |
28e407b8 AA |
91 | virtual void _do_coll_move(coll_entry_t *entry, hobject_t& orig_obj, hobject_t& new_obj); |
92 | virtual void _do_coll_create(coll_entry_t *entry, uint32_t pg_num, uint64_t num_objs); | |
7c673cae FG |
93 | |
94 | int _gen_coll_id(rngen_t& gen); | |
95 | int _gen_obj_id(rngen_t& gen); | |
96 | void _print_status(int seq, int op); | |
97 | ||
98 | private: | |
28e407b8 AA |
99 | bool _prepare_clone( |
100 | rngen_t& gen, | |
101 | coll_entry_t **entry_ret, | |
102 | int *orig_obj_id, | |
103 | hobject_t *orig_obj_ret, | |
104 | int *new_obj_id, | |
105 | hobject_t *new_obj_ret); | |
7c673cae FG |
106 | }; |
107 | ||
108 | ||
109 | #endif /* FILESTORE_DTRMNSTC_SEQ_OPS_H_ */ |