- // static void test10() throws ServerException {
-
- // long startTime = 0;
- // long endTime = 0;
- // boolean foundError = false;
-
- // // Setup the 2 clients
- // Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
- // t1.initTable();
- // Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
- // t2.update();
-
- // 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;
- // 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();
- // 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;
- // String valueA = "a" + i;
- // String valueB = "b" + i;
- // String valueC = "c" + i;
- // String valueD = "d" + i;
-
- // 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);
-
- // while (true) {
- // t1.startTransaction();
- // t1.addKV(iKeyA, iValueA);
- // if (t1.commitTransactionLocal()) {
- // break;
- // }
- // }
-
- // while (true) {
- // t1.startTransaction();
- // t1.addKV(iKeyB, iValueB);
- // if (t1.commitTransactionLocal()) {
- // break;
- // }
- // }
-
- // while (true) {
- // t2.startTransaction();
- // t2.addKV(iKeyC, iValueC);
- // if (t2.commitTransactionLocal()) {
- // break;
- // }
- // }
-
- // while (true) {
- // t2.startTransaction();
- // t2.addKV(iKeyD, iValueD);
- // if (t2.commitTransactionLocal()) {
- // break;
- // }
- // }
- // }
- // 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("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;
- // String valueA = "a" + i;
- // String valueB = "b" + i;
- // String valueC = "c" + i;
- // String valueD = "d" + i;
-
- // 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;
- // }
- // }
-
-
- // // System.out.println("Updating Clients...");
- // // t1.update();
- // // t2.update();
- // // t1.update();
- // // t2.update();
-
-
-
- // // 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;
- // // String valueA = "a" + i;
- // // String valueB = "b" + i;
- // // String valueC = "c" + i;
- // // String valueD = "d" + i;
-
- // // 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 (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() {