Fixing initialization to just create a table on the cloud side.
authorrtrimana <rtrimana@uci.edu>
Tue, 17 Apr 2018 16:38:06 +0000 (09:38 -0700)
committerrtrimana <rtrimana@uci.edu>
Tue, 17 Apr 2018 16:38:06 +0000 (09:38 -0700)
version2/src/C/Init.C
version2/src/C/Read.C
version2/src/C/Update.C
version2/src/java/simple_test/Read.java

index 55cd2c6..7a8649c 100644 (file)
@@ -9,9 +9,6 @@
 int main(int numargs, char ** args) {
        TimingSingleton * timer = TimingSingleton_getInstance();
 
-       bool foundError = false;
-       Vector<TransactionStatus *> * transStatusList = new Vector<TransactionStatus *>();
-
        // Setup the 2 clients
        IoTString *baseurl = new IoTString("http://dc-6.calit2.uci.edu/test.iotcloud/");
        IoTString * password = new IoTString("reallysecret");
@@ -23,36 +20,6 @@ int main(int numargs, char ** args) {
        baseurl->releaseRef();
        password->releaseRef();
 
-       // Make the Keys
-       printf("Setting up keys\n");
-       for (int i = 0; i < NUMBER_OF_SENSORS; i++) {
-               printf("%d\n",i);
-               char buffer[80];
-               sprintf(buffer, "sensor%d", i);
-               IoTString *ia = new IoTString(buffer);
-               t1->createNewKey(ia, MACHINE_ID);
-               ia->releaseRef();
-       }
-
-       t1->update();
-       printf("Updating table\n");
-
-       for (uint i = 0; i < transStatusList->size(); i++) {
-               TransactionStatus * status = transStatusList->get(i);
-               if (status->getStatus() != TransactionStatus_StatusCommitted) {
-                       foundError = true;
-                       printf("Status error\n");
-               }
-               delete status;
-       }
-       
-       if (foundError) {
-               printf("Found Errors...\n");
-       } else {
-               printf("No Errors Found...\n");
-       }
-
-       delete transStatusList;
        delete t1;
 }
 
index eff53aa..c0071ca 100644 (file)
@@ -25,7 +25,7 @@ int main(int numargs, char ** args) {
 
        printf("Checking Key-Values...\n");
        char buffer[80];
-       sprintf(buffer, "sensor0");
+       sprintf(buffer, "humid0");
        IoTString * iKeyA = new IoTString(buffer);
        IoTString *testValA1 = t1->getCommitted(iKeyA);
        
@@ -37,9 +37,23 @@ int main(int numargs, char ** args) {
                testValA1->print();
                printf("\n\n");
        }
+       sprintf(buffer, "tempF0");
+       IoTString * iKeyB = new IoTString(buffer);
+       IoTString * testValB1 = t1->getCommitted(iKeyB);
+       
+       if (testValA1 == NULL) {
+               printf("\n\nKEY-VALUE B is NULL!\n\n");
+               foundError = true;
+       } else {
+               printf("Printing value... ");
+               testValB1->print();
+               printf("\n\n");
+       }
 
        iKeyA->releaseRef();
        testValA1->releaseRef();
+       iKeyB->releaseRef();
+       testValB1->releaseRef();
 
        for (uint i = 0; i < transStatusList->size(); i++) {
                TransactionStatus * status = transStatusList->get(i);
index 805cc8b..a3613e2 100644 (file)
@@ -4,7 +4,7 @@
 #include "TransactionStatus.h"
 
 #define NUMBER_OF_SENSORS 1
-#define MACHINE_ID 260
+#define MACHINE_ID 15512
 
 int main(int numargs, char ** args) {
        TimingSingleton * timer = TimingSingleton_getInstance();
@@ -22,20 +22,32 @@ int main(int numargs, char ** args) {
        baseurl->releaseRef();
        password->releaseRef();
 
-       /*char keyBuffer[80];
+       char keyBuffer[80];
        char dataBuffer[80];
 
-       sprintf(keyBuffer, "sensor0");
+       sprintf(keyBuffer, "tempF0");
        IoTString * iKeyA = new IoTString(keyBuffer);
-       sprintf(dataBuffer, "data1");
+       sprintf(dataBuffer, "data4");
        IoTString * iValueA = new IoTString(dataBuffer);
+       t1->createNewKey(iKeyA, MACHINE_ID);
        t1->startTransaction();
        t1->put(iKeyA, iValueA);
-       transStatusList->add(t1->commitTransaction());*/
+       transStatusList->add(t1->commitTransaction());
+       
+       sprintf(keyBuffer, "humid0");
+       IoTString * iKeyB = new IoTString(keyBuffer);
+       sprintf(dataBuffer, "data6");
+       IoTString * iValueB = new IoTString(dataBuffer);
+       t1->createNewKey(iKeyB, MACHINE_ID);
+       t1->startTransaction();
+       t1->put(iKeyB, iValueB);
+       transStatusList->add(t1->commitTransaction());
        t1->update();
        
-       //iKeyA->releaseRef();
-       //iValueA->releaseRef();
+       iKeyB->releaseRef();
+       iValueB->releaseRef();
+       iKeyA->releaseRef();
+       iValueA->releaseRef();
 
        for (uint i = 0; i < transStatusList->size(); i++) {
                TransactionStatus * status = transStatusList->get(i);
index 71140b8..295fa6b 100644 (file)
@@ -14,7 +14,7 @@ class Read {
                for(IoTString key : keySet) {
                        System.out.print("Key: " + key.toString() + " -> ");
                IoTString val = t1.getCommitted(key);
-                       System.out.println("Value: " + val.toString());         
+                       System.out.println("Value: " + val.toString());
                }
     }
 }