]>
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: | |
30 | DeterministicOpSequence(ObjectStore *store, std::string status = std::string()); | |
31 | virtual ~DeterministicOpSequence(); | |
32 | ||
33 | virtual void generate(int seed, int num_txs); | |
34 | ||
35 | protected: | |
36 | enum { | |
37 | DSOP_TOUCH = 0, | |
38 | DSOP_WRITE = 1, | |
39 | DSOP_CLONE = 2, | |
40 | DSOP_CLONE_RANGE = 3, | |
41 | DSOP_OBJ_REMOVE = 4, | |
28e407b8 AA |
42 | DSOP_COLL_MOVE = 5, |
43 | DSOP_SET_ATTRS = 6, | |
44 | DSOP_COLL_CREATE = 7, | |
7c673cae FG |
45 | |
46 | DSOP_FIRST = DSOP_TOUCH, | |
47 | DSOP_LAST = DSOP_COLL_CREATE, | |
48 | }; | |
49 | ||
50 | int32_t txn; | |
51 | ||
52 | coll_t txn_coll; | |
53 | hobject_t txn_object; | |
54 | ||
55 | ObjectStore::Sequencer m_osr; | |
56 | std::ofstream m_status; | |
57 | ||
58 | bool run_one_op(int op, rngen_t& gen); | |
59 | ||
60 | void note_txn(ObjectStore::Transaction *t); | |
61 | bool do_touch(rngen_t& gen); | |
62 | bool do_remove(rngen_t& gen); | |
63 | bool do_write(rngen_t& gen); | |
64 | bool do_clone(rngen_t& gen); | |
65 | bool do_clone_range(rngen_t& gen); | |
66 | bool do_coll_move(rngen_t& gen); | |
67 | bool do_set_attrs(rngen_t& gen); | |
68 | bool do_coll_create(rngen_t& gen); | |
69 | ||
28e407b8 AA |
70 | virtual void _do_touch(coll_entry_t *entry, hobject_t& obj); |
71 | virtual void _do_remove(coll_entry_t *entry, hobject_t& obj); | |
72 | virtual void _do_write(coll_entry_t *entry, hobject_t& obj, uint64_t off, | |
7c673cae | 73 | uint64_t len, const bufferlist& data); |
28e407b8 | 74 | virtual void _do_set_attrs(coll_entry_t *entry, |
7c673cae FG |
75 | hobject_t &obj, |
76 | const map<string, bufferlist> &attrs); | |
28e407b8 AA |
77 | virtual void _do_clone(coll_entry_t *entry, hobject_t& orig_obj, hobject_t& new_obj); |
78 | virtual void _do_clone_range(coll_entry_t *entry, hobject_t& orig_obj, | |
7c673cae | 79 | hobject_t& new_obj, uint64_t srcoff, uint64_t srclen, uint64_t dstoff); |
28e407b8 | 80 | virtual void _do_write_and_clone_range(coll_entry_t *entry, hobject_t& orig_obj, |
7c673cae FG |
81 | hobject_t& new_obj, uint64_t srcoff, uint64_t srclen, |
82 | uint64_t dstoff, bufferlist& bl); | |
28e407b8 AA |
83 | virtual void _do_coll_move(coll_entry_t *entry, hobject_t& orig_obj, hobject_t& new_obj); |
84 | virtual void _do_coll_create(coll_entry_t *entry, uint32_t pg_num, uint64_t num_objs); | |
7c673cae FG |
85 | |
86 | int _gen_coll_id(rngen_t& gen); | |
87 | int _gen_obj_id(rngen_t& gen); | |
88 | void _print_status(int seq, int op); | |
89 | ||
90 | private: | |
28e407b8 AA |
91 | bool _prepare_clone( |
92 | rngen_t& gen, | |
93 | coll_entry_t **entry_ret, | |
94 | int *orig_obj_id, | |
95 | hobject_t *orig_obj_ret, | |
96 | int *new_obj_id, | |
97 | hobject_t *new_obj_ret); | |
7c673cae FG |
98 | }; |
99 | ||
100 | ||
101 | #endif /* FILESTORE_DTRMNSTC_SEQ_OPS_H_ */ |