11 public static final int NUMBER_OF_TESTS = 20000; //66
13 public static void main(String[] args) {
14 if (args[0].equals("2")) {
16 } else if (args[0].equals("3")) {
18 } else if (args[0].equals("4")) {
26 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
28 System.out.println(t1);
30 // // Print the results
31 // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
32 // String a = "a" + i;
33 // String b = "b" + i;
34 // IoTString ia = new IoTString(a);
35 // IoTString ib = new IoTString(b);
37 // System.out.println(ib + " -> " + t1.getCommitted(ib));
38 // System.out.println(ia + " -> " + t2.getCommitted(ia));
39 // System.out.println();
43 static Thread buildThreadTest4(String prefix, Table t) {
46 for (int i = 0; i < (NUMBER_OF_TESTS * 3); i++) {
48 int num = i % NUMBER_OF_TESTS;
49 String key = prefix + num;
50 String value = prefix + (num + 2000);
51 IoTString iKey = new IoTString(key);
52 IoTString iValue = new IoTString(value);
55 t.addKV(iKey, iValue);
56 t.commitTransaction();
63 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
64 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
68 Thread thr1 = buildThreadTest4("b", t1);
69 Thread thr2 = buildThreadTest4("a", t2);
75 } catch (Exception e) {
84 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
87 IoTString ia = new IoTString(a);
88 IoTString ib = new IoTString(b);
90 System.out.println(ib + " -> " + t1.getCommitted(ib));
91 System.out.println(ia + " -> " + t2.getCommitted(ia));
97 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
98 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
103 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
104 String key = "a" + i;
105 String value = "a" + (i + 1000);
106 IoTString iKey = new IoTString(key);
107 IoTString iValue = new IoTString(value);
109 t1.startTransaction();
110 t1.addKV(iKey, iValue);
111 t1.commitTransaction();
114 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
115 String key = "b" + i;
116 String value = "b" + (i + 1000);
117 IoTString iKey = new IoTString(key);
118 IoTString iValue = new IoTString(value);
120 t2.startTransaction();
121 t2.addKV(iKey, iValue);
122 t2.commitTransaction();
125 // Make sure t1 sees the new updates from t2
129 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
132 IoTString ia = new IoTString(a);
133 IoTString ib = new IoTString(b);
135 System.out.println(ib + " -> " + t1.getCommitted(ib));
136 System.out.println(ia + " -> " + t2.getCommitted(ia));
137 System.out.println();
141 static void test2() {
142 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
144 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
149 System.out.println("Setting up keys");
150 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
153 IoTString ia = new IoTString(a);
154 IoTString ib = new IoTString(b);
155 t1.createNewKey(ia, 321);
156 t1.createNewKey(ib, 321);
159 // System.out.println("=========t1 live" + t1.liveslotcount + " thresh: " + t1.resizethreshold);
160 // System.out.println("=========t2 live" + t2.liveslotcount + " thresh: " + t2.resizethreshold);
161 // System.out.println();
165 // Do Updates for the keys
166 System.out.println("Writing Keys a...");
167 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
168 System.out.println(i);
170 String key = "a" + i;
171 String value = "a" + (i + 10000);
172 IoTString iKey = new IoTString(key);
173 IoTString iValue = new IoTString(value);
176 t1.startTransaction();
177 t1.addKV(iKey, iValue);
178 t1.commitTransaction();
181 // Do Updates for the keys
182 System.out.println("Writing Keys a...");
183 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
184 System.out.println(i);
186 String key = "a" + i;
187 String value = "a" + (i + 10000);
188 IoTString iKey = new IoTString(key);
189 IoTString iValue = new IoTString(value);
191 t1.startTransaction();
192 t1.addKV(iKey, iValue);
193 t1.commitTransaction();
198 System.out.println("Writing Keys b...");
199 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
200 System.out.println(i);
202 String key = "b" + i;
203 String value = "b" + (i + 10000);
204 IoTString iKey = new IoTString(key);
205 IoTString iValue = new IoTString(value);
208 t2.startTransaction();
209 t2.addKV(iKey, iValue);
210 t2.commitTransaction();
214 // Do Updates for the keys
215 System.out.println("Writing Keys a...");
216 for (int i = 0; i < NUMBER_OF_TESTS; i += 2) {
217 System.out.println(i);
219 String key = "a" + i;
220 String value = "a" + (i + 10000);
221 IoTString iKey = new IoTString(key);
222 IoTString iValue = new IoTString(value);
224 t1.startTransaction();
225 t1.addKV(iKey, iValue);
226 t1.commitTransaction();
233 System.out.println("Checking a keys...");
234 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
236 String key = "a" + i;
237 String value = "a" + (i + 10000);
238 IoTString iKey = new IoTString(key);
239 IoTString iValue = new IoTString(value);
241 IoTString testVal = t1.getCommitted(iKey);
243 if ((testVal == null) || (testVal.equals(iValue) == false)) {
244 System.out.println("Key val incorrect: " + key);
248 value = "b" + (i + 10000);
249 iKey = new IoTString(key);
250 iValue = new IoTString(value);
252 testVal = t1.getCommitted(iKey);
254 if ((testVal == null) || (testVal.equals(iValue) == false)) {
255 System.out.println("Key val incorrect: " + key);
259 System.out.println("Checking b keys...");
260 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
262 String key = "a" + i;
263 String value = "a" + (i + 10000);
264 IoTString iKey = new IoTString(key);
265 IoTString iValue = new IoTString(value);
267 IoTString testVal = t2.getCommitted(iKey);
269 if ((testVal == null) || (testVal.equals(iValue) == false)) {
270 System.out.println("Key val incorrect: " + key);
274 value = "b" + (i + 10000);
275 iKey = new IoTString(key);
276 iValue = new IoTString(value);
278 testVal = t2.getCommitted(iKey);
280 if ((testVal == null) || (testVal.equals(iValue) == false)) {
281 System.out.println("Key val incorrect: " + key);
288 System.out.println();
289 System.out.println();
290 System.out.println("Update");
291 // Make sure t1 sees the new updates from t2
295 System.out.println();
296 System.out.println();
297 System.out.println();
298 System.out.println();
299 System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
300 System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
301 System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
303 System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
304 System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
305 System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
308 // System.out.println("=========t1 live" + t1.liveslotcount + " thresh: " + t1.resizethreshold + " commits: " + t1.commitedTable.size() + " uncommits: " + t1.uncommittedTransactionsList.size());
309 // System.out.println("=========t2 live" + t2.liveslotcount + " thresh: " + t2.resizethreshold + " commits: " + t2.commitedTable.size() + " uncommits: " + t2.uncommittedTransactionsList.size() );
310 System.out.println();
313 System.out.println();
314 System.out.println();
315 System.out.println();
316 System.out.println();
318 System.out.println();
322 // // Do Updates for the keys
323 // System.out.println("Writing Keys a (actual)");
324 // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
325 // String key = "a" + i;
326 // String value = "a" + i;
327 // IoTString iKey = new IoTString(key);
328 // IoTString iValue = new IoTString(value);
330 // t1.startTransaction();
331 // t1.addKV(iKey, iValue);
332 // t1.commitTransaction();
335 // System.out.println("=========t1 live" + t1.liveslotcount + " thresh: " + t1.resizethreshold + " commits: " + t1.commitedTable.size() + " uncommits: " + t1.uncommittedTransactionsList.size());
336 // System.out.println("=========t2 live" + t2.liveslotcount + " thresh: " + t2.resizethreshold + " commits: " + t2.commitedTable.size() + " uncommits: " + t2.uncommittedTransactionsList.size());
337 // System.out.println();
341 // System.out.println("Writing Keys b (actual)");
342 // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
343 // String key = "b" + i;
344 // String value = "b" + i;
345 // IoTString iKey = new IoTString(key);
346 // IoTString iValue = new IoTString(value);
348 // t2.startTransaction();
349 // t2.addKV(iKey, iValue);
350 // t2.commitTransaction();
353 // System.out.println("=========t1 live" + t1.liveslotcount + " thresh: " + t1.resizethreshold + " commits: " + t1.commitedTable.size() + " uncommits: " + t1.uncommittedTransactionsList.size() );
354 // System.out.println("=========t2 live" + t2.liveslotcount + " thresh: " + t2.resizethreshold + " commits: " + t2.commitedTable.size() + " uncommits: " + t2.uncommittedTransactionsList.size() );
355 // System.out.println();
358 // // Do Updates for the keys
359 // System.out.println("Writing Keys a (actual)");
360 // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
361 // String key = "a" + i;
362 // String value = "a" + i;
363 // IoTString iKey = new IoTString(key);
364 // IoTString iValue = new IoTString(value);
366 // t1.startTransaction();
367 // t1.addKV(iKey, iValue);
368 // t1.commitTransaction();
371 // System.out.println("=========t1 live" + t1.liveslotcount + " thresh: " + t1.resizethreshold + " commits: " + t1.commitedTable.size() + " uncommits: " + t1.uncommittedTransactionsList.size());
372 // System.out.println("=========t2 live" + t2.liveslotcount + " thresh: " + t2.resizethreshold + " commits: " + t2.commitedTable.size() + " uncommits: " + t2.uncommittedTransactionsList.size());
373 // System.out.println();
377 // System.out.println("Writing Keys b (actual)");
378 // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
379 // String key = "b" + i;
380 // String value = "b" + i;
381 // IoTString iKey = new IoTString(key);
382 // IoTString iValue = new IoTString(value);
384 // t2.startTransaction();
385 // t2.addKV(iKey, iValue);
386 // t2.commitTransaction();
389 // System.out.println("=========t1 live" + t1.liveslotcount + " thresh: " + t1.resizethreshold + " commits: " + t1.commitedTable.size() + " uncommits: " + t1.uncommittedTransactionsList.size() );
390 // System.out.println("=========t2 live" + t2.liveslotcount + " thresh: " + t2.resizethreshold + " commits: " + t2.commitedTable.size() + " uncommits: " + t2.uncommittedTransactionsList.size() );
391 // System.out.println();
394 // System.out.println();
399 // Make sure t1 sees the new updates from t2
402 // // Print the results
403 // for (int i = NUMBER_OF_TESTS - 10; i < NUMBER_OF_TESTS; i++) {
404 // String a = "a" + i;
405 // String b = "b" + i;
406 // IoTString ia = new IoTString(a);
407 // IoTString ib = new IoTString(b);
409 // System.out.println(ib + " -> " + t1.getCommitted(ib));
410 // System.out.println(ia + " -> " + t2.getCommitted(ia));
411 // System.out.println();