package iotcloud;
+import java.util.List;
+import java.util.ArrayList;
+
/**
* Test cases.
* @author Brian Demsky
public class Test {
- public static final int NUMBER_OF_TESTS = 15;
+ public static final int NUMBER_OF_TESTS = 100;
public static void main(String[] args) throws ServerException {
if (args[0].equals("2")) {
} else if (args[0].equals("9")) {
test9();
}
+ // else if (args[0].equals("10")) {
+ // test10();
+ // }
}
- // static void test9() throws ServerException {
- // // Setup the 2 clients
- // Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
- // t1.initTable();
- // Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
- // t2.update();
-
-
- // // Make the Keys
- // System.out.println("Setting up keys");
- // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
- // String a = "a" + i;
- // String b = "b" + i;
- // String c = "c" + i;
- // String d = "d" + i;
- // IoTString ia = new IoTString(a);
- // IoTString ib = new IoTString(b);
- // IoTString ic = new IoTString(c);
- // IoTString id = new IoTString(d);
- // t1.createNewKey(ia, 321);
- // t1.createNewKey(ib, 351);
- // t2.createNewKey(ic, 321);
- // t2.createNewKey(id, 351);
- // }
-
- // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
- // String a = "a" + i;
- // String b = "b" + i;
- // String c = "c" + i;
- // String d = "d" + i;
- // IoTString ia = new IoTString(a);
- // IoTString ib = new IoTString(b);
- // IoTString ic = new IoTString(c);
- // IoTString id = new IoTString(d);
- // t1.createNewKey(ia, 1000);
- // t1.createNewKey(ib, 1000);
- // t2.createNewKey(ic, 1000);
- // t2.createNewKey(id, 1000);
- // }
-
- // System.out.println("Updating Clients...");
- // t1.update();
- // t2.update();
- // t1.update();
- // t2.update();
- // boolean foundError = false;
-
- // System.out.println("Checking Key-Values...");
- // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
-
- // String keyA = "a" + i;
- // String keyB = "b" + i;
- // String keyC = "c" + i;
- // String keyD = "d" + i;
-
- // IoTString iKeyA = new IoTString(keyA);
- // IoTString iKeyB = new IoTString(keyB);
- // IoTString iKeyC = new IoTString(keyC);
- // IoTString iKeyD = new IoTString(keyD);
-
-
- // Long testValA1 = t1.getArbitrator(iKeyA);
- // Long testValB1 = t1.getArbitrator(iKeyB);
- // Long testValC1 = t1.getArbitrator(iKeyC);
- // Long testValD1 = t1.getArbitrator(iKeyD);
-
- // Long testValA2 = t2.getArbitrator(iKeyA);
- // Long testValB2 = t2.getArbitrator(iKeyB);
- // Long testValC2 = t2.getArbitrator(iKeyC);
- // Long testValD2 = t2.getArbitrator(iKeyD);
-
- // if ((testValA1 == null) || (testValA1 != 321)) {
- // System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
- // foundError = true;
- // }
-
- // if ((testValB1 == null) || (testValB1 != 351)) {
- // System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
- // foundError = true;
- // }
-
- // if ((testValC1 == null) || (testValC1 != 321)) {
- // System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
- // foundError = true;
- // }
-
- // if ((testValD1 == null) || (testValD1 != 351)) {
- // System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
- // foundError = true;
- // }
-
- // if ((testValA2 == null) || (testValA2 != 321)) {
- // System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
- // foundError = true;
- // }
-
- // if ((testValB2 == null) || (testValB2 != 351)) {
- // System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
- // foundError = true;
- // }
-
- // if ((testValC2 == null) || (testValC2 != 321)) {
- // System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
- // foundError = true;
- // }
-
- // if ((testValD2 == null) || (testValD2 != 351)) {
- // System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
- // foundError = true;
- // }
- // }
-
- // if (foundError) {
- // System.out.println("Found Errors...");
- // } else {
- // System.out.println("No Errors Found...");
- // }
- // }
-
- // static void test8() throws ServerException {
+ // static void test10() throws ServerException {
+ // long startTime = 0;
+ // long endTime = 0;
// boolean foundError = false;
// // Setup the 2 clients
- // Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+ // Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
// t1.initTable();
- // Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+ // Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
// t2.update();
- // // t1.rebuild();
- // // t2.rebuild();
+ // if (t1.hasConnection()) {
+ // System.out.println("Can see server");
+ // }
+
+ // LocalComm lc = new LocalComm(t1, t2);
+ // t1.addLocalComm(t2.getId(), lc);
+ // t2.addLocalComm(t1.getId(), lc);
// // Make the Keys
// System.out.println("Setting up keys");
+ // startTime = System.currentTimeMillis();
// for (int i = 0; i < NUMBER_OF_TESTS; i++) {
// String a = "a" + i;
// String b = "b" + i;
// t2.createNewKey(ic, 321);
// t2.createNewKey(id, 351);
// }
+ // endTime = System.currentTimeMillis();
+ // System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
+ // System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
+ // System.out.println();
// // Do Updates for the keys
// System.out.println("Setting Key-Values...");
-
-
- // String keyA0 = "a0";
- // String keyB0 = "b0";
- // String keyC0 = "c0";
- // String keyD0 = "d0";
- // String valueA0 = "a0";
- // String valueB0 = "b0";
- // String valueC0 = "c0";
- // String valueD0 = "d0";
-
- // IoTString iKeyA0 = new IoTString(keyA0);
- // IoTString iKeyB0 = new IoTString(keyB0);
- // IoTString iKeyC0 = new IoTString(keyC0);
- // IoTString iKeyD0 = new IoTString(keyD0);
- // IoTString iValueA0 = new IoTString(valueA0);
- // IoTString iValueB0 = new IoTString(valueB0);
- // IoTString iValueC0 = new IoTString(valueC0);
- // IoTString iValueD0 = new IoTString(valueD0);
-
- // t1.startTransaction();
- // t1.addKV( iKeyA0, iValueA0);
- // t1.commitTransaction();
-
- // t1.startTransaction();
- // t1.addKV(iKeyB0, iValueB0);
- // t1.commitTransaction();
-
- // t2.startTransaction();
- // t2.addKV(iKeyC0, iValueC0);
- // t2.commitTransaction();
-
- // t2.startTransaction();
- // t2.addKV(iKeyD0, iValueD0);
- // t2.commitTransaction();
-
- // for (int i = 1; i < NUMBER_OF_TESTS; i++) {
- // String keyB = "b" + i;
- // String valueB = "b" + i;
- // IoTString iKeyB = new IoTString(keyB);
- // IoTString iValueB = new IoTString(valueB);
-
- // String keyBOld = "b" + (i - 1);
- // String valueBOld = "b" + (i - 1);
- // IoTString iKeyBOld = new IoTString(keyBOld);
- // IoTString iValueBOld = new IoTString(valueBOld);
-
-
- // t1.startTransaction();
- // t1.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyBOld, iValueBOld, Guard.Equal))));
- // t1.addKV(iKeyB, iValueB);
- // t1.commitTransaction();
- // }
-
- // System.out.println("Checking Key-Values...");
- // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
-
- // String keyB = "b" + i;
- // String valueB = "b" + i;
-
- // IoTString iKeyB = new IoTString(keyB);
- // IoTString iValueB = new IoTString(valueB);
-
- // IoTString testValB1 = t1.getSpeculative(iKeyB);
-
- // if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
- // System.out.println("Key-Value t1 incorrect: " + keyB);
- // foundError = true;
-
- // }
- // }
-
-
- // System.out.println("Updating Clients...");
- // t1.update();
- // t2.update();
- // t1.update();
- // t2.update();
-
- // System.out.println("Checking Key-Values...");
+ // startTime = System.currentTimeMillis();
// for (int i = 0; i < NUMBER_OF_TESTS; i++) {
-
// String keyA = "a" + i;
// String keyB = "b" + i;
// String keyC = "c" + i;
// IoTString iValueC = new IoTString(valueC);
// IoTString iValueD = new IoTString(valueD);
-
- // IoTString testValA1 = t1.getCommitted(iKeyA);
- // IoTString testValB1 = t1.getCommitted(iKeyB);
- // IoTString testValC1 = t1.getCommitted(iKeyC);
- // IoTString testValD1 = t1.getCommitted(iKeyD);
-
- // IoTString testValA2 = t2.getCommitted(iKeyA);
- // IoTString testValB2 = t2.getCommitted(iKeyB);
- // IoTString testValC2 = t2.getCommitted(iKeyC);
- // IoTString testValD2 = t2.getCommitted(iKeyD);
-
-
- // if (i == 0) {
- // if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
- // System.out.println("Key-Value t1 incorrect: " + keyA);
- // foundError = true;
- // }
-
- // if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
- // System.out.println("Key-Value t1 incorrect: " + keyB);
- // foundError = true;
- // }
-
- // if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
- // System.out.println("Key-Value t1 incorrect: " + keyC);
- // foundError = true;
- // }
-
- // if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
- // System.out.println("Key-Value t1 incorrect: " + keyD);
- // foundError = true;
- // }
-
-
- // if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
- // System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
- // foundError = true;
- // }
-
- // if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
- // System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
- // foundError = true;
- // }
-
- // if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
- // System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
- // foundError = true;
- // }
-
- // if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
- // System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
- // foundError = true;
- // }
- // } else {
- // if (testValA1 != null) {
- // System.out.println("Key-Value t1 incorrect: " + keyA);
- // foundError = true;
- // }
-
- // if (testValB1 != null) {
- // System.out.println("Key-Value t1 incorrect: " + keyB);
- // foundError = true;
- // }
-
- // if (testValC1 != null) {
- // System.out.println("Key-Value t1 incorrect: " + keyC);
- // foundError = true;
- // }
-
- // if (testValD1 != null) {
- // System.out.println("Key-Value t1 incorrect: " + keyD);
- // foundError = true;
- // }
-
- // if (testValA2 != null) {
- // System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
- // foundError = true;
+ // while (true) {
+ // t1.startTransaction();
+ // t1.addKV(iKeyA, iValueA);
+ // if (t1.commitTransactionLocal()) {
+ // break;
// }
+ // }
- // if (testValB2 != null) {
- // System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
- // foundError = true;
+ // while (true) {
+ // t1.startTransaction();
+ // t1.addKV(iKeyB, iValueB);
+ // if (t1.commitTransactionLocal()) {
+ // break;
// }
+ // }
- // if (testValC2 != null) {
- // System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
- // foundError = true;
+ // while (true) {
+ // t2.startTransaction();
+ // t2.addKV(iKeyC, iValueC);
+ // if (t2.commitTransactionLocal()) {
+ // break;
// }
+ // }
- // if (testValD2 != null) {
- // System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
- // foundError = true;
+ // while (true) {
+ // t2.startTransaction();
+ // t2.addKV(iKeyD, iValueD);
+ // if (t2.commitTransactionLocal()) {
+ // break;
// }
// }
// }
-
- // if (foundError) {
- // System.out.println("Found Errors...");
- // } else {
- // System.out.println("No Errors Found...");
- // }
- // }
-
- // static void test7() throws ServerException {
-
- // long startTime = 0;
- // long endTime = 0;
-
- // // Setup the 2 clients
- // Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
- // t1.initTable();
- // Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
- // t2.update();
-
- // // t1.rebuild();
- // // t2.rebuild();
-
- // // Make the Keys
- // System.out.println("Setting up keys");
- // startTime = System.currentTimeMillis();
- // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
- // String a = "a" + i;
- // String b = "b" + i;
- // String c = "c" + i;
- // String d = "d" + i;
- // IoTString ia = new IoTString(a);
- // IoTString ib = new IoTString(b);
- // IoTString ic = new IoTString(c);
- // IoTString id = new IoTString(d);
- // t1.createNewKey(ia, 321);
- // t1.createNewKey(ib, 351);
- // t2.createNewKey(ic, 321);
- // t2.createNewKey(id, 351);
- // }
// endTime = System.currentTimeMillis();
-
- // System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
- // System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
- // System.out.println();
-
-
- // // Do Updates for the keys
- // System.out.println("Setting Key-Values...");
- // startTime = System.currentTimeMillis();
-
-
-
- // String keyA0 = "a0";
- // String keyB0 = "b0";
- // String keyC0 = "c0";
- // String keyD0 = "d0";
- // String valueA0 = "a0";
- // String valueB0 = "b0";
- // String valueC0 = "c0";
- // String valueD0 = "d0";
-
- // IoTString iKeyA0 = new IoTString(keyA0);
- // IoTString iKeyB0 = new IoTString(keyB0);
- // IoTString iKeyC0 = new IoTString(keyC0);
- // IoTString iKeyD0 = new IoTString(keyD0);
- // IoTString iValueA0 = new IoTString(valueA0);
- // IoTString iValueB0 = new IoTString(valueB0);
- // IoTString iValueC0 = new IoTString(valueC0);
- // IoTString iValueD0 = new IoTString(valueD0);
-
- // t1.startTransaction();
- // t1.addKV( iKeyA0, iValueA0);
- // t1.commitTransaction();
-
- // t1.startTransaction();
- // t1.addKV(iKeyB0, iValueB0);
- // t1.commitTransaction();
-
- // t2.startTransaction();
- // t2.addKV(iKeyC0, iValueC0);
- // t2.commitTransaction();
-
- // t2.startTransaction();
- // t2.addKV(iKeyD0, iValueD0);
- // t2.commitTransaction();
-
- // for (int i = 1; i < NUMBER_OF_TESTS; i++) {
- // String keyB = "b" + i;
- // String valueB = "b" + i;
- // IoTString iKeyB = new IoTString(keyB);
- // IoTString iValueB = new IoTString(valueB);
-
- // String keyBOld = "b" + (i - 1);
- // String valueBOld = "b" + (i - 2);
- // IoTString iKeyBOld = new IoTString(keyBOld);
- // IoTString iValueBOld = new IoTString(valueBOld);
-
-
- // t1.startTransaction();
- // t1.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyBOld, iValueBOld, Guard.Equal))));
- // t1.addKV(iKeyB, iValueB);
- // t1.commitTransaction();
- // }
-
- // for (int i = 1; i < NUMBER_OF_TESTS; i++) {
- // String keyC = "c" + i;
- // String valueC = "c" + i;
- // IoTString iKeyC = new IoTString(keyC);
- // IoTString iValueC = new IoTString(valueC);
-
- // String keyCOld = "c" + (i - 1);
- // String valueCOld = "c" + (i - 2);
- // IoTString iKeyCOld = new IoTString(keyCOld);
- // IoTString iValueCOld = new IoTString(valueCOld);
-
-
- // t2.startTransaction();
- // t2.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyCOld, iValueCOld, Guard.Equal))));
- // t2.addKV(iKeyC, iValueC);
- // t2.commitTransaction();
- // }
-
- // for (int i = 1; i < NUMBER_OF_TESTS; i++) {
- // String keyA = "a" + i;
- // String keyD = "d" + i;
- // String valueA = "a" + i;
- // String valueD = "d" + i;
-
- // IoTString iKeyA = new IoTString(keyA);
- // IoTString iKeyD = new IoTString(keyD);
- // IoTString iValueA = new IoTString(valueA);
- // IoTString iValueD = new IoTString(valueD);
-
-
- // String keyAOld = "a" + (i - 1);
- // String keyDOld = "d" + (i - 1);
- // String valueAOld = "a" + (i - 2);
- // String valueDOld = "d" + (i - 2);
- // IoTString iKeyAOld = new IoTString(keyAOld);
- // IoTString iKeyDOld = new IoTString(keyDOld);
- // IoTString iValueAOld = new IoTString(valueAOld);
- // IoTString iValueDOld = new IoTString(valueDOld);
-
-
- // t1.startTransaction();
- // t1.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyAOld, iValueAOld, Guard.Equal))));
- // t1.addKV(iKeyA, iValueA);
- // t1.commitTransaction();
-
- // t2.startTransaction();
- // t2.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyDOld, iValueDOld, Guard.Equal))));
- // t2.addKV(iKeyD, iValueD);
- // t2.commitTransaction();
- // }
-
- // endTime = System.currentTimeMillis();
-
// System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
// System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
// System.out.println();
- // System.out.println("Updating Clients...");
- // t1.update();
- // t2.update();
- // t1.update();
- // t2.update();
-
- // boolean foundError = false;
-
// System.out.println("Checking Key-Values...");
// for (int i = 0; i < NUMBER_OF_TESTS; i++) {
// IoTString testValC2 = t2.getCommitted(iKeyC);
// IoTString testValD2 = t2.getCommitted(iKeyD);
+ // if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
+ // System.out.println("Key-Value t1 incorrect: " + keyA);
+ // foundError = true;
+ // }
- // if (i == 0) {
- // if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
- // System.out.println("Key-Value t1 incorrect: " + keyA);
- // foundError = true;
- // }
+ // if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
+ // System.out.println("Key-Value t1 incorrect: " + keyB);
+ // foundError = true;
+ // }
- // if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
- // System.out.println("Key-Value t1 incorrect: " + keyB);
- // foundError = true;
- // }
+ // if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
+ // System.out.println("Key-Value t1 incorrect: " + keyC);
+ // foundError = true;
+ // }
- // if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
- // System.out.println("Key-Value t1 incorrect: " + keyC);
- // foundError = true;
- // }
+ // if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
+ // System.out.println("Key-Value t1 incorrect: " + keyD);
+ // foundError = true;
+ // }
- // if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
- // System.out.println("Key-Value t1 incorrect: " + keyD);
- // foundError = true;
- // }
+ // if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
+ // System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
+ // foundError = true;
+ // }
- // if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
- // System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
- // foundError = true;
- // }
+ // if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
+ // System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
+ // foundError = true;
+ // }
- // if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
- // System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
- // foundError = true;
- // }
+ // if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
+ // System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
+ // foundError = true;
+ // }
- // if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
- // System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
- // foundError = true;
- // }
+ // if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
+ // System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
+ // foundError = true;
+ // }
+ // }
- // if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
- // System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
- // foundError = true;
- // }
- // } else {
- // if (testValA1 != null) {
- // System.out.println("Key-Value t1 incorrect: " + keyA);
- // foundError = true;
- // }
- // if (testValB1 != null) {
- // System.out.println("Key-Value t1 incorrect: " + keyB);
- // foundError = true;
- // }
+ // // System.out.println("Updating Clients...");
+ // // t1.update();
+ // // t2.update();
+ // // t1.update();
+ // // t2.update();
- // if (testValC1 != null) {
- // System.out.println("Key-Value t1 incorrect: " + keyC);
- // foundError = true;
- // }
- // if (testValD1 != null) {
- // System.out.println("Key-Value t1 incorrect: " + keyD);
- // foundError = true;
- // }
- // if (testValA2 != null) {
- // System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
- // foundError = true;
- // }
+ // // System.out.println("Checking Key-Values...");
+ // // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
- // if (testValB2 != null) {
- // System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
- // foundError = true;
- // }
+ // // String keyA = "a" + i;
+ // // String keyB = "b" + i;
+ // // String keyC = "c" + i;
+ // // String keyD = "d" + i;
+ // // String valueA = "a" + i;
+ // // String valueB = "b" + i;
+ // // String valueC = "c" + i;
+ // // String valueD = "d" + i;
- // if (testValC2 != null) {
- // System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
- // foundError = true;
- // }
+ // // IoTString iKeyA = new IoTString(keyA);
+ // // IoTString iKeyB = new IoTString(keyB);
+ // // IoTString iKeyC = new IoTString(keyC);
+ // // IoTString iKeyD = new IoTString(keyD);
+ // // IoTString iValueA = new IoTString(valueA);
+ // // IoTString iValueB = new IoTString(valueB);
+ // // IoTString iValueC = new IoTString(valueC);
+ // // IoTString iValueD = new IoTString(valueD);
+
+
+ // // IoTString testValA1 = t1.getCommitted(iKeyA);
+ // // IoTString testValB1 = t1.getCommitted(iKeyB);
+ // // IoTString testValC1 = t1.getCommitted(iKeyC);
+ // // IoTString testValD1 = t1.getCommitted(iKeyD);
+
+ // // IoTString testValA2 = t2.getCommitted(iKeyA);
+ // // IoTString testValB2 = t2.getCommitted(iKeyB);
+ // // IoTString testValC2 = t2.getCommitted(iKeyC);
+ // // IoTString testValD2 = t2.getCommitted(iKeyD);
+
+ // // if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
+ // // System.out.println("Key-Value t1 incorrect: " + keyA);
+ // // foundError = true;
+ // // }
+
+ // // if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
+ // // System.out.println("Key-Value t1 incorrect: " + keyB);
+ // // foundError = true;
+ // // }
+
+ // // if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
+ // // System.out.println("Key-Value t1 incorrect: " + keyC);
+ // // foundError = true;
+ // // }
+
+ // // if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
+ // // System.out.println("Key-Value t1 incorrect: " + keyD);
+ // // foundError = true;
+ // // }
+
+
+ // // if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
+ // // System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
+ // // foundError = true;
+ // // }
+
+ // // if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
+ // // System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
+ // // foundError = true;
+ // // }
+
+ // // if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
+ // // System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
+ // // foundError = true;
+ // // }
+
+ // // if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
+ // // System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
+ // // foundError = true;
+ // // }
+ // // }
- // if (testValD2 != null) {
- // System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
- // foundError = true;
- // }
- // }
- // }
// if (foundError) {
// System.out.println("Found Errors...");
// } else {
// System.out.println("No Errors Found...");
// }
+
+
+ // System.out.println();
+ // System.out.println();
+ // System.out.println();
+ // t1.printSlots();
+ // System.out.println();
+ // System.out.println();
+ // t2.printSlots();
// }
static void test9() {
boolean foundError = false;
// Setup the 2 clients
- Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+ Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
while (true) {
try {
} catch (Exception e) {}
}
- Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+ Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
while (true) {
try {
// Setup the 2 clients
- Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+ Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
while (true) {
try {
t1.initTable();
} catch (Exception e) {}
}
- Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+ Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
while (true) {
try {
t2.update();
boolean foundError = false;
// Setup the 2 clients
- Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+ Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
t1.initTable();
- Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+ Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
t2.update();
startTime = System.currentTimeMillis();
long endTime = 0;
// Setup the 2 clients
- Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+ Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
t1.initTable();
- Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+ Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
t2.update();
boolean foundError = false;
// Setup the 2 clients
- Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+ Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
t1.initTable();
- Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+ Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
t2.update();
long endTime = 0;
// Setup the 2 clients
- Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+ Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
t1.initTable();
- Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+ Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
t2.update();
boolean foundError = false;
// Setup the 2 clients
- Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+ Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
t1.initTable();
- Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+ Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
t2.update();
long endTime = 0;
// Setup the 2 clients
- Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+ Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
t1.initTable();
- Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+ Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
t2.update();
+ List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
+
// Make the Keys
System.out.println("Setting up keys");
startTime = System.currentTimeMillis();
t2.createNewKey(id, 351);
}
endTime = System.currentTimeMillis();
-
-
-
System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
System.out.println();
t1.startTransaction();
t1.addKV(iKeyA, iValueA);
- t1.commitTransaction();
+ transStatusList.add(t1.commitTransaction());
t1.startTransaction();
t1.addKV(iKeyB, iValueB);
- t1.commitTransaction();
+ transStatusList.add(t1.commitTransaction());
t2.startTransaction();
t2.addKV(iKeyC, iValueC);
- t2.commitTransaction();
+ transStatusList.add(t2.commitTransaction());
t2.startTransaction();
t2.addKV(iKeyD, iValueD);
- t2.commitTransaction();
+ transStatusList.add(t2.commitTransaction());
}
endTime = System.currentTimeMillis();
-
System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
System.out.println();
}
}
+ for (TransactionStatus status : transStatusList) {
+ if (status.getStatus() != TransactionStatus.StatusCommitted) {
+ foundError = true;
+ }
+ }
+
if (foundError) {
System.out.println("Found Errors...");
} else {
System.out.println("No Errors Found...");
}
+
+
+ System.out.println();
+ System.out.println();
+ System.out.println();
+ t1.printSlots();
+ System.out.println();
+ System.out.println();
+ t2.printSlots();
}
}