1 | /* |
2 | * Legal Notice |
3 | * |
4 | * This document and associated source code (the "Work") is a part of a |
5 | * benchmark specification maintained by the TPC. |
6 | * |
7 | * The TPC reserves all right, title, and interest to the Work as provided |
8 | * under U.S. and international laws, including without limitation all patent |
9 | * and trademark rights therein. |
10 | * |
11 | * No Warranty |
12 | * |
13 | * 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION |
14 | * CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE |
15 | * AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER |
16 | * WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY, |
17 | * INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES, |
18 | * DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR |
19 | * PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF |
20 | * WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE. |
21 | * ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT, |
22 | * QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT |
23 | * WITH REGARD TO THE WORK. |
24 | * 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO |
25 | * ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE |
26 | * COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS |
27 | * OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT, |
28 | * INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY, |
29 | * OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT |
30 | * RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD |
31 | * ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. |
32 | * |
33 | * Contributors |
34 | * - Doug Johnson |
35 | */ |
36 | |
37 | /****************************************************************************** |
38 | * Description: This class provides Customer Emulator functionality. |
39 | * It controls the mix of customer-initiated transactions |
40 | * and generates all required inputs for each of these |
41 | * transactions. These inputs are then made available to |
42 | * a sponsor provided callback interface to the SUT (see |
43 | * CESUTInterface.h). In addition, a set of constants used |
44 | * to uniquely identify each transaction type is exposed. |
45 | * |
46 | * The constructor for this class is overloaded. The first |
47 | * form of the constructor accepts 7 inputs, the last one |
48 | * of which is optional (i.e. it has a default value). |
49 | * - pSUT: a pointer to an instance of a sponsor provided |
50 | * subclassing of the CCESUTInterface class. |
51 | * - pLogger: a pointer to an |
52 | *instance of CEGenLogger or a sponsor provided subclassing of the CBaseLogger |
53 | *class. |
54 | * - inputFiles: a reference to an instance of the |
55 | * CInputFiles class containing all input files loaded |
56 | * into memory. |
57 | * - iCustomerCount: the total number of customers to |
58 | * emulate. C_IDs will be generated in the range of |
59 | * 1 to iCustomerCount. |
60 | * - iScaleFactor: the number of customers per tpsE. This |
61 | * should match the scale factor used at load time. |
62 | * - iDaysOfInitialTrades: the number of days of initial |
63 | * trades that was populated during load time. |
64 | * - RandomSeed: seed to be used for the RNG. |
65 | * - pTxnTunables: (optional). a pointer to a tuning |
66 | * structure used to configure the behavior of the CE |
67 | * class. |
68 | * |
69 | * The second form of the constructor accepts all of the |
70 | * same inputs as the first form. In addition, however, |
71 | * it accepts 3 additional inputs between iCustomerCount |
72 | * and iScaleFacto that facilitate partitioning by C_ID |
73 | * during runtime. |
74 | * - iMyStartingCustomerId: the starting customer ID for |
75 | * this instance's partition of C_IDs. This ID must be |
76 | * the first ID in a load unit. |
77 | * - iMyCustomerCount: the number of customers in this |
78 | * instance's partition. The number of customers specified |
79 | * must be an integral multiple of the load unit size. |
80 | * - iPartitionPercent: the percentage of C_IDs |
81 | * that should be generated within this instance's |
82 | * partition. 100-iParititionPercent percent of the C_IDs |
83 | * will be generated across the full range of C_IDs. |
84 | * |
85 | * Paritioning Example. |
86 | * Based on a load unit size of 1000, assume the following |
87 | * valid inputs. |
88 | * - iCustomerCount = 5000 |
89 | * - iMyStartingCustomerID = 2001 |
90 | * - iMyCustomerCount = 2000 |
91 | * - iPartitionPercent = 40 |
92 | * These setting will configure the CE to generated C_IDs |
93 | * as follows. |
94 | * - 40% of the time in the range [2001 - 4000] |
95 | * - 60% of the time in the range [1-5000] |
96 | * |
97 | * The CE provides the following entry point. |
98 | * |
99 | * - DoTxn: this entry point will select the next |
100 | * transaction type based on the mix settings, generate |
101 | * all required inputs for the selected transaction type, |
102 | * and provide those inputs to sponsor code at the |
103 | * appropriate callback interface. |
104 | * |
105 | ******************************************************************************/ |
106 | |
107 | #ifndef CE_H |
108 | #define CE_H |
109 | |
110 | #include "utilities/EGenUtilities_stdafx.h" |
111 | #include "CETxnInputGenerator.h" |
112 | #include "CETxnMixGenerator.h" |
113 | #include "CESUTInterface.h" |
114 | #include "BaseLogger.h" |
115 | #include "DriverParamSettings.h" |
116 | |
117 | #include "input/DataFileManager.h" |
118 | |
119 | namespace TPCE { |
120 | |
121 | class CCE { |
122 | private: |
123 | CDriverGlobalSettings m_DriverGlobalSettings; |
124 | CDriverCESettings m_DriverCESettings; |
125 | CDriverCEPartitionSettings m_DriverCEPartitionSettings; |
126 | TDriverCETxnSettings m_DriverCETxnSettings; |
127 | |
128 | CCESUTInterface *m_pSUT; |
129 | CBaseLogger *m_pLogger; |
130 | CCETxnMixGenerator m_TxnMixGenerator; |
131 | CCETxnInputGenerator m_TxnInputGenerator; |
132 | |
133 | TBrokerVolumeTxnInput m_BrokerVolumeTxnInput; |
134 | TCustomerPositionTxnInput m_CustomerPositionTxnInput; |
135 | TMarketWatchTxnInput m_MarketWatchTxnInput; |
136 | TSecurityDetailTxnInput m_SecurityDetailTxnInput; |
137 | TTradeLookupTxnInput m_TradeLookupTxnInput; |
138 | TTradeOrderTxnInput m_TradeOrderTxnInput; |
139 | TTradeStatusTxnInput m_TradeStatusTxnInput; |
140 | TTradeUpdateTxnInput m_TradeUpdateTxnInput; |
141 | |
142 | // Initialization that is common for all constructors. |
143 | void Initialize(PDriverCETxnSettings pTxnParamSettings); |
144 | |
145 | // Automatically generate unique RNG seeds |
146 | void AutoSetRNGSeeds(UINT32 UniqueId); |
147 | |
148 | /* |
149 | * Zero transaction input buffer. |
150 | * |
151 | * PARAMETERS: |
152 | * IN iTxnType - what transaction to zero the buffer for. |
153 | * |
154 | * RETURNS: |
155 | * none. |
156 | */ |
157 | void ZeroInputBuffer(int iTxnType); |
158 | |
159 | public: |
160 | static const INT32 INVALID_TRANSACTION_TYPE = CCETxnMixGenerator::INVALID_TRANSACTION_TYPE; |
161 | static const INT32 SECURITY_DETAIL = CCETxnMixGenerator::SECURITY_DETAIL; |
162 | static const INT32 BROKER_VOLUME = CCETxnMixGenerator::BROKER_VOLUME; |
163 | static const INT32 CUSTOMER_POSITION = CCETxnMixGenerator::CUSTOMER_POSITION; |
164 | static const INT32 MARKET_WATCH = CCETxnMixGenerator::MARKET_WATCH; |
165 | static const INT32 TRADE_STATUS = CCETxnMixGenerator::TRADE_STATUS; |
166 | static const INT32 TRADE_LOOKUP = CCETxnMixGenerator::TRADE_LOOKUP; |
167 | static const INT32 TRADE_ORDER = CCETxnMixGenerator::TRADE_ORDER; |
168 | static const INT32 TRADE_UPDATE = CCETxnMixGenerator::TRADE_UPDATE; |
169 | // Trade-Result and Market-Feed are included for completness. |
170 | static const INT32 MARKET_FEED = CCETxnMixGenerator::MARKET_FEED; |
171 | static const INT32 TRADE_RESULT = CCETxnMixGenerator::TRADE_RESULT; |
172 | |
173 | // Constructor - no partitioning by C_ID, automatic RNG seed generation |
174 | // (requires unique input) |
175 | CCE(CCESUTInterface *pSUT, CBaseLogger *pLogger, const DataFileManager &dfm, TIdent iConfiguredCustomerCount, |
176 | TIdent iActiveCustomerCount, INT32 iScaleFactor, INT32 iDaysOfInitialTrades, UINT32 UniqueId, |
177 | const PDriverCETxnSettings pParameterSettings = NULL); |
178 | |
179 | // Constructor - no partitioning by C_ID, RNG seeds provided |
180 | CCE(CCESUTInterface *pSUT, CBaseLogger *pLogger, const DataFileManager &dfm, TIdent iConfiguredCustomerCount, |
181 | TIdent iActiveCustomerCount, INT32 iScaleFactor, INT32 iDaysOfInitialTrades, UINT32 UniqueId, |
182 | RNGSEED TxnMixRNGSeed, RNGSEED TxnInputRNGSeed, const PDriverCETxnSettings pParameterSettings = NULL); |
183 | |
184 | // Constructor - partitioning by C_ID, automatic RNG seed generation |
185 | // (requires unique input) |
186 | CCE(CCESUTInterface *pSUT, CBaseLogger *pLogger, const DataFileManager &dfm, TIdent iConfiguredCustomerCount, |
187 | TIdent iActiveCustomerCount, TIdent iMyStartingCustomerId, TIdent iMyCustomerCount, INT32 iPartitionPercent, |
188 | INT32 iScaleFactor, INT32 iDaysOfInitialTrades, UINT32 UniqueId, |
189 | const PDriverCETxnSettings pParameterSettings = NULL); |
190 | |
191 | // Constructor - partitioning by C_ID, RNG seeds provided |
192 | CCE(CCESUTInterface *pSUT, CBaseLogger *pLogger, const DataFileManager &dfm, TIdent iConfiguredCustomerCount, |
193 | TIdent iActiveCustomerCount, TIdent iMyStartingCustomerId, TIdent iMyCustomerCount, INT32 iPartitionPercent, |
194 | INT32 iScaleFactor, INT32 iDaysOfInitialTrades, UINT32 UniqueId, RNGSEED TxnMixRNGSeed, RNGSEED TxnInputRNGSeed, |
195 | const PDriverCETxnSettings pParameterSettings = NULL); |
196 | |
197 | ~CCE(void); |
198 | |
199 | RNGSEED GetTxnInputGeneratorRNGSeed(void); |
200 | RNGSEED GetTxnMixGeneratorRNGSeed(void); |
201 | void SetTxnTunables(const PDriverCETxnSettings pTxnParamSettings); |
202 | |
203 | void DoTxn(void); |
204 | }; |
205 | |
206 | } // namespace TPCE |
207 | |
208 | #endif // CE_H |
209 | |