]>
git.proxmox.com Git - ceph.git/blob - ceph/src/test/objectstore/DeterministicOpSequence.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2012 New Dream Network
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.
13 #ifndef FILESTORE_DTRMNSTC_SEQ_OPS_H_
14 #define FILESTORE_DTRMNSTC_SEQ_OPS_H_
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>
24 #include "TestObjectStoreState.h"
26 typedef boost::mt11213b rngen_t
;
28 class DeterministicOpSequence
: public TestObjectStoreState
{
30 DeterministicOpSequence(ObjectStore
*store
,
31 std::string status
= std::string());
32 virtual ~DeterministicOpSequence();
34 virtual void generate(int seed
, int num_txs
);
36 static ghobject_t
get_txn_object(coll_t cid
) {
37 ghobject_t
oid(hobject_t(sobject_t("txn", CEPH_NOSNAP
)));
39 bool r
= cid
.is_pg(&pgid
);
41 oid
.hobj
.set_hash(pgid
.ps());
57 DSOP_FIRST
= DSOP_TOUCH
,
58 DSOP_LAST
= DSOP_COLL_CREATE
,
63 ObjectStore::CollectionHandle m_ch
;
64 std::ofstream m_status
;
66 bool run_one_op(int op
, rngen_t
& gen
);
68 void note_txn(coll_entry_t
*entry
, ObjectStore::Transaction
*t
);
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
);
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
,
81 uint64_t len
, const bufferlist
& data
);
82 virtual void _do_set_attrs(coll_entry_t
*entry
,
84 const std::map
<std::string
, bufferlist
> &attrs
);
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
,
87 hobject_t
& new_obj
, uint64_t srcoff
, uint64_t srclen
, uint64_t dstoff
);
88 virtual void _do_write_and_clone_range(coll_entry_t
*entry
, hobject_t
& orig_obj
,
89 hobject_t
& new_obj
, uint64_t srcoff
, uint64_t srclen
,
90 uint64_t dstoff
, bufferlist
& bl
);
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
);
94 int _gen_coll_id(rngen_t
& gen
);
95 int _gen_obj_id(rngen_t
& gen
);
96 void _print_status(int seq
, int op
);
101 coll_entry_t
**entry_ret
,
103 hobject_t
*orig_obj_ret
,
105 hobject_t
*new_obj_ret
);
109 #endif /* FILESTORE_DTRMNSTC_SEQ_OPS_H_ */