1 /*
2   Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3 
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU General Public License, version 2.0,
6   as published by the Free Software Foundation.
7 
8   This program is also distributed with certain software (including
9   but not limited to OpenSSL) that is licensed under separate terms,
10   as designated in a particular file or component or in included license
11   documentation.  The authors of MySQL hereby grant you an additional
12   permission to link the program and your derivative works with the
13   separately licensed software that they have included with MySQL.
14 
15   This program is distributed in the hope that it will be useful,
16   but WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18   GNU General Public License, version 2.0, for more details.
19 
20   You should have received a copy of the GNU General Public License
21   along with this program; if not, write to the Free Software
22   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
23 */
24 
25 #ifndef TwsDriver_hpp
26 #define TwsDriver_hpp
27 
28 #include "Driver.hpp"
29 
30 class TwsDriver : public Driver {
31 protected:
32 
33     // benchmark settings
34     enum LockMode { READ_COMMITTED, SHARED, EXCLUSIVE };
35     static const char* toStr(LockMode mode);
36     enum XMode { BULK, EACH, INDY };
37     static const char* toStr(XMode mode);
38     bool renewConnection;
39     bool renewOperations;
40     bool logSumOfOps;
41     LockMode lockMode;
42     int nOpsStart;
43     int nOpsEnd;
44     int nOpsScale;
45     bool doInsert;
46     bool doLookup;
47     bool doUpdate;
48     bool doDelete;
49     bool doBulk;
50     bool doEach;
51     bool doIndy;
52     bool doVerify;
53 
54     // benchmark intializers/finalizers
55     virtual void initProperties();
56     virtual void printProperties();
57 
58     // benchmark operations
59     virtual void initOperations() = 0;
60     virtual void closeOperations() = 0;
61     virtual void runTests();
62     virtual void runLoads(int nOps);
63     virtual void runOperations(int nOps);
64     virtual void runInserts(XMode mode, int nOps) = 0;
65     virtual void runLookups(XMode mode, int nOps) = 0;
66     virtual void runUpdates(XMode mode, int nOps) = 0;
67     virtual void runDeletes(XMode mode, int nOps) = 0;
68     void verify(int exp, int act);
69     void verify(long exp, long act);
70     void verify(long long exp, long long act);
71     void verify(const char* exp, const char* act);
72 
73     // datastore operations
74     virtual void initConnection() = 0;
75     virtual void closeConnection() = 0;
76     virtual void clearData() = 0;
77 
78     // XXX temp compile fixes
createLoad(const std::string &)79     virtual bool createLoad(const std::string&) { assert(0); return false; }
runLoad(Load &)80     virtual void runLoad(Load&) { assert(0); }
81 };
82 
83 #endif // TwsDriver_hpp
84