16
16
17
17
int main (int argc, char * argv[]) {
18
18
std::string loc =
19
- " /users/jsaber/binHamband /workload/" ;
19
+ " /home/prithviraj/Documents/Hamband/wellcoordination /workload/" ;
20
20
21
21
int nr_procs = static_cast <int >(std::atoi (argv[1 ]));
22
22
int num_ops = static_cast <int >(std::atoi (argv[2 ]));
@@ -44,7 +44,7 @@ int main(int argc, char* argv[]) {
44
44
int queries = num_ops - total_writes;
45
45
46
46
int num_conflicting_write_methods = 2 ;
47
- int num_nonconflicting_write_methods = 2 ;
47
+ int num_nonconflicting_write_methods = 3 ;
48
48
int num_read_methods = 0 ;
49
49
50
50
std::cout << " ops: " << num_ops << std::endl;
@@ -81,6 +81,10 @@ int main(int argc, char* argv[]) {
81
81
expected_nonconflicting_write_calls_per_follower *
82
82
num_nonconflicting_write_methods * (nr_procs - 1 );
83
83
84
+
85
+
86
+ std::vector<std::string>* open = new std::vector<std::string>[nr_procs];
87
+
84
88
// first allocating writes operations to the nodes
85
89
for (int i = 1 ; i <= num_replicas; i++) {
86
90
// first leader
@@ -89,11 +93,12 @@ int main(int argc, char* argv[]) {
89
93
int count = 0 ;
90
94
for (; count < expected_calls_per_update_method;) {
91
95
// storeBuyNow
96
+ // Sell items with id 0 - 99.
92
97
std::string callStr;
93
98
if (type == 0 ) {
94
- std::string b_id = std::to_string (1 + std::rand () % 100 );
99
+ std::string i_id = std::to_string (std::rand () % 100 );
95
100
std::string value = std::to_string (std::rand () % 1000 );
96
- callStr = " 1 " + b_id + " -" + value;
101
+ callStr = " 1 " + i_id + " -" + value;
97
102
}
98
103
MethodCall call = ReplicatedObject::createCall (" id" , callStr);
99
104
if (test->isPermissible (call)) {
@@ -110,9 +115,10 @@ int main(int argc, char* argv[]) {
110
115
int count = 0 ;
111
116
for (; count < expected_calls_per_update_method;) {
112
117
// registerUser
118
+ // add users from 100 - 199.
113
119
std::string callStr;
114
120
if (type == 0 ) {
115
- std::string u_id = std::to_string (1 + std::rand () % 100 );
121
+ std::string u_id = std::to_string (100 + std::rand () % 100 );
116
122
callStr = " 2 " + u_id;
117
123
}
118
124
MethodCall call = ReplicatedObject::createCall (" id" , callStr);
@@ -127,25 +133,38 @@ int main(int argc, char* argv[]) {
127
133
// follower
128
134
else {
129
135
// non-conflicting write method
130
- for (int type = 0 ; type <= 1 ; type++) {
136
+ for (int type = 0 ; type <= 2 ; type++) {
131
137
for (int count = 0 ; count <
132
138
expected_nonconflicting_write_calls_per_follower; count++) {
133
139
std::string callStr;
134
140
if (type == 0 ) {
135
- // sellitem
136
- std::string s_id = std::to_string (1 + std::rand () % 100 );
141
+ // sellitem
142
+ std::string s_id = std::to_string (100 + std::rand () % 100 );
137
143
std::string value = std::to_string (std::rand () % 1000 );
138
144
callStr = " 0 " + s_id+ " -" + value;
139
145
}
140
146
if (type == 1 ) {
141
147
// placeBid
142
- std::string a_id = std::to_string (1 + std::rand () % 100 ); // auction id
143
- std::string u_id = std::to_string (1 + std::rand () % 100 ); // user id
148
+ // Bid with user id 0 - 99 and item id 0 - 99
149
+ std::string a_id = std::to_string (std::rand () % 100 ); // auction id
150
+ std::string u_id = std::to_string (std::rand () % 100 ); // user id
144
151
std::string value = std::to_string (std::rand () % 1000 ); // bid value
145
152
146
153
callStr = " 3 " + a_id + " -" + u_id + " -" + value;
147
154
}
148
155
156
+ if (type == 2 ) {
157
+ // Open Auctions
158
+ // Open 100 - 199, with different stock values
159
+ // Save the opened ids so we can close them after shuffling.
160
+ std::string i_id = std::to_string (100 + std::rand () % 100 ); // auction id
161
+ std::string stock = std::to_string (1 + std::rand () % 1000 ); // stock
162
+
163
+ open [i - 1 ].push_back (i_id);
164
+ callStr = " 4 " + i_id + " -" + stock;
165
+ }
166
+
167
+
149
168
MethodCall call = ReplicatedObject::createCall (" id" , callStr);
150
169
test->execute (call);
151
170
calls[i - 1 ].push_back (callStr);
@@ -170,6 +189,15 @@ int main(int argc, char* argv[]) {
170
189
calls[i].insert (calls[i].begin (),
171
190
std::string (" #" + std::to_string (write_calls)));
172
191
std::random_shuffle (calls[i].begin () + 1 , calls[i].end ());
192
+
193
+ std::string callStr;
194
+ if (i != 0 && i != 1 )
195
+ for (int count = 0 ; count < expected_nonconflicting_write_calls_per_follower; count++) {
196
+ // Close Auction (using the saved values we opened added to the end of the shuffled operations)
197
+ callStr = " 5 " + open [i][count];
198
+ calls[i].push_back (callStr);
199
+ }
200
+
173
201
}
174
202
175
203
for (int i = 0 ; i < nr_procs; i++) {
0 commit comments