+++ /dev/null
-#include<stdio.h>
-#include<pthread.h>
-#include "dstm.h"
-#include "llookup.h"
-#include "ip.h"
-
-#define LISTEN_PORT 2156
-
-extern objstr_t *mainobjstore;
-typedef struct testobj1 {
- int x;
- char z;
-} testobj1_t;
-
-typedef struct testobj2 {
- char z[10];
- char c;
- testobj1_t *y;
-} testobj2_t;
-
-typedef struct testobj3 {
- short p;
- testobj1_t *q;
- testobj2_t *r;
-} testobj3_t;
-
-typedef struct testobj4 {
- int b;
- void *q;
- testobj3_t *a;
-} testobj4_t;
-
-typedef struct testobj5 {
- testobj4_t *a;
-} testobj5_t;
-
-
-int classsize[]={sizeof(int),sizeof(char),sizeof(short), sizeof(void *), sizeof(testobj1_t),
- sizeof(testobj2_t), sizeof(testobj3_t), sizeof(testobj4_t), sizeof(testobj5_t)};
-
-unsigned int createObjects(transrecord_t *record) {
- objheader_t *header, *tmp;
- unsigned int size, mid;
- int i = 0;
- for(i = 20 ; i< 23; i++) {
- size = sizeof(objheader_t) + classsize[i-20] ;
- tmp = (objheader_t *)objstrAlloc(record->cache, size);
- tmp->oid = i;
- tmp->type = (i-20);
- tmp->version = 1;
- tmp->rcount = 0; //? not sure how to handle this yet
- tmp->status = 0;
- tmp->status |= NEW;
- chashInsert(record->lookupTable, tmp->oid, tmp);
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- memcpy(header, tmp, size);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.27");//machine d-2
- printf("DEBUG -> createObjects mid is %x\n", mid);
- lhashInsert(header->oid, mid);
- }
- // printf("Insert oid = %d at address %x\n",tmp->oid, tmp);
- size = sizeof(objheader_t) + classsize[0] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 30;
- header->type = 0;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.27");
- lhashInsert(header->oid, mid);
- size = sizeof(objheader_t) + classsize[1] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 28;
- header->type = 1;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= LOCK;
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.27");
- lhashInsert(header->oid, mid);
- size = sizeof(objheader_t) + classsize[2] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 29;
- header->type = 2;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= LOCK;
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.27");
- lhashInsert(header->oid, mid);
- return 0;
-}
-
-int main()
-{
-// test2();
-// test3();
-// test4();
- test5();
-// test5a();
-// test2a();
-// test2b();
-// test7();
-
-}
-
-int test1(void) {
-
- transrecord_t *record;
- objheader_t *h1,*h2,*h3,*h4,*h5, *h6;
-
- dstmInit();
- record = transStart();
- printf("DEBUG -> Init done\n");
- h1 = transRead(record, 1);
- printf("oid = %d\tsize = %d\n", h1->oid,classsize[h1->type]);
- h3 = transRead(record, 3);
- printf("oid = %d\tsize = %d\n", h3->oid,classsize[h3->type]);
- h4 = transRead(record, 4);
- printf("oid = %d\tsize = %d\n", h4->oid,classsize[h4->type]);
- h2 = transRead(record, 2);
- printf("oid = %d\tsize = %d\n", h2->oid,classsize[h2->type]);
- h4 = transRead(record, 4);
- printf("oid = %d\tsize = %d\n", h4->oid,classsize[h4->type]);
- h3 = transRead(record, 3);
- printf("oid = %d\tsize = %d\n", h3->oid,classsize[h3->type]);
- h5 = transRead(record, 5);
- printf("oid = %d\tsize = %d\n", h5->oid,classsize[h5->type]);
-// getRemoteObj(&record, 0,1);
-}
-
-int test2(void) {
-
- transrecord_t *record;
- objheader_t *h1,*h2,*h3,*h4,*h5, *h6;
-
- dstmInit();
- record = transStart();
-
- lhashInsert(1,1);
- lhashInsert(2,1);
- lhashInsert(3,1);
- lhashInsert(4,1);
- lhashInsert(5,1);
- lhashInsert(6,1);
- printf("DEBUG -> Init done\n");
- h1 = transRead(record, 1);
- lhashInsert(h1->oid, 1);
- h2 = transRead(record, 2);
- lhashInsert(h2->oid, 1);
- h3 = transRead(record, 3);
- lhashInsert(h3->oid, 1);
- h4 = transRead(record, 4);
- lhashInsert(h4->oid, 1);
-// h4->status |= DIRTY;
- h5 = transRead(record, 5);
- lhashInsert(h5->oid, 1);
- h6 = transRead(record, 6);
- lhashInsert(h6->oid, 1);
-// h6->status |= DIRTY;
-
- transCommit(record);
-
- return 0;
-}
-
-//Read objects when objects are found in remote location
-int test2a(void) {
- unsigned int val, mid;
- transrecord_t *myTrans;
- unsigned int size;
- objheader_t *header, *h1, *h2;
- pthread_t thread_Listen;
- pthread_attr_t attr;
-
- dstmInit();
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
- //Create and Insert Oid 20
- size = sizeof(objheader_t) + classsize[2] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 20;
- header->type = 2;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.27");
- lhashInsert(header->oid, mid);
-
- //Create and Insert Oid 21
- size = sizeof(objheader_t) + classsize[1] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 21;
- header->type = 1;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.27");
- lhashInsert(header->oid, mid);
-
- //Create and Insert Oid 22
- size = sizeof(objheader_t) + classsize[3] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 22;
- header->type = 3;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.27");
- lhashInsert(header->oid, mid);
-
- //Inserting into lhashtable
- mid = iptoMid("128.200.9.26"); //d-1.eecs.uci.edu
- lhashInsert(31, mid);
- lhashInsert(32, mid);
-
- mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
- //Inserting into lhashtable
- lhashInsert(1, mid);
- lhashInsert(2, mid);
- lhashInsert(3, mid);
- lhashInsert(4, mid);
-
- pthread_create(&thread_Listen, &attr, dstmListen, NULL);
-
- //Check if machine demsky is up and running
- checkServer(mid, "128.200.9.10");
- mid = iptoMid("128.200.9.26");
- //Check if machine d-1 is up and running
- checkServer(mid, "128.200.9.26");
-
- // Start Transaction
- myTrans = transStart();
-
- sleep(2);
- //read object 1
- if((h1 = transRead(myTrans, 1)) == NULL){
- printf("Object not found\n");
- }
- //read object 2
- if((h2 = transRead(myTrans, 2)) == NULL) {
- printf("Object not found\n");
- }
-
- pthread_join(thread_Listen, NULL);
- return 0;
-}
-
-//Read objects that are both remote and local and are available on machines
-int test2b(void) {
-
- unsigned int val, mid;
- transrecord_t *myTrans;
- unsigned int size;
- objheader_t *header, *h1, *h2, *h3, *h4;
- pthread_t thread_Listen;
- pthread_attr_t attr;
-
- dstmInit();
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
- //Create and Insert Oid 20
- size = sizeof(objheader_t) + classsize[2] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 20;
- header->type = 2;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.27");
- lhashInsert(header->oid, mid);
-
- //Create and Insert Oid 21
- size = sizeof(objheader_t) + classsize[1] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 21;
- header->type = 1;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.27");
- lhashInsert(header->oid, mid);
-
- //Create and Insert Oid 22
- size = sizeof(objheader_t) + classsize[3] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 22;
- header->type = 3;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.27");
- lhashInsert(header->oid, mid);
-
- //Inserting into lhashtable
- mid = iptoMid("128.200.9.26"); //d-1.eecs.uci.edu
- lhashInsert(31, mid);
- lhashInsert(32, mid);
- lhashInsert(33, mid);
-
- mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
- //Inserting into lhashtable
- lhashInsert(1, mid);
- lhashInsert(2, mid);
- lhashInsert(3, mid);
- lhashInsert(4, mid);
-
- pthread_create(&thread_Listen, &attr, dstmListen, NULL);
-
- //Check if machine demsky is up and running
- checkServer(mid, "128.200.9.10");
- mid = iptoMid("128.200.9.26");
- //Check if machine d-1 is up and running
- checkServer(mid, "128.200.9.26");
-
- // Start Transaction
- myTrans = transStart();
-
- //sleep(2);
- //read object 1 (found on demksy)
- if((h1 = transRead(myTrans, 1)) == NULL){
- printf("Object not found\n");
- }
- //read object 2 (found on demsky)
- if((h2 = transRead(myTrans, 2)) == NULL) {
- printf("Object not found\n");
- }
-
- //read object 21 (found on local)
- if((h3 = transRead(myTrans, 21)) == NULL) {
- printf("Object not found\n");
- }
-
- //read object 32 (found on d-1)
- if((h4 = transRead(myTrans, 32)) == NULL) {
- printf("Object not found\n");
- }
-
- pthread_join(thread_Listen, NULL);
- return 0;
-
-}
-
-
-//Read objects when objects are not found in any participant
-int test3(void){
- transrecord_t *record;
- objheader_t *h1,*h2;
-
- dstmInit();
- record = transStart();
- printf("DEBUG -> Init done\n");
- //read object 11
- if((h1 = transRead(record, 11)) == NULL){
- printf("Object not found\n");
- }
- //read object 12
- if((h2 = transRead(record, 12)) == NULL) {
- printf("Object not found\n");
- }
- transCommit(record);
-
- return 0;
-}
-
-//Read objects when some objects are found and other objects not found in any participant
-int test4(void) {
- transrecord_t *record;
- objheader_t *h1,*h2, *h3, *h4;
-
- dstmInit();
- record = transStart();
- printf("DEBUG -> Init done\n");
- //read object 1
- if((h1 = transRead(record, 1)) == NULL){
- printf("Object not found\n");
- }
- //read object 2
- if((h2 = transRead(record, 2)) == NULL) {
- printf("Object not found\n");
- }
- //read object 11
- if((h3 = transRead(record, 11)) == NULL) {
- printf("Object not found\n");
- }
- //read object 13
- if((h4 = transRead(record, 13)) == NULL) {
- printf("Object not found\n");
- }
- if((h1 != NULL) && (h2 != NULL) && (h3 != NULL) && h4 !=NULL) {
- transCommit(record);
- }else {
- printf("Cannot complete this transaction\n");
- }
-
- return 0;
-}
-
-//Commit for transaction objects when the objs are part of other
-//transactions running simultaneously
-int test5(void) {
- unsigned int val, mid;
- transrecord_t *myTrans;
- unsigned int size;
- objheader_t *header, *h1, *h2, *h3, *h4, *h5, *h6;
- pthread_t thread_Listen;
- pthread_attr_t attr;
-
- dstmInit();
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
- //Create and Insert Oid 20
- size = sizeof(objheader_t) + classsize[2] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 20;
- header->type = 2;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.27");
- lhashInsert(header->oid, mid);
-
- //Create and Insert Oid 21
- size = sizeof(objheader_t) + classsize[1] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 21;
- header->type = 1;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.27");
- lhashInsert(header->oid, mid);
-
- //Create and Insert Oid 22
- size = sizeof(objheader_t) + classsize[3] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 22;
- header->type = 3;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.27");
- lhashInsert(header->oid, mid);
-
- //Inserting into lhashtable
- mid = iptoMid("128.200.9.26"); //d-1.eecs.uci.edu
- lhashInsert(31, mid);
- lhashInsert(32, mid);
- lhashInsert(33, mid);
-
- mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
- //Inserting into lhashtable
- lhashInsert(1, mid);
- lhashInsert(2, mid);
- lhashInsert(3, mid);
- lhashInsert(4, mid);
-
- pthread_create(&thread_Listen, &attr, dstmListen, NULL);
-
- //Check if machine demsky is up and running
- checkServer(mid, "128.200.9.10");
- mid = iptoMid("128.200.9.26");
- //Check if machine d-1 is up and running
- checkServer(mid, "128.200.9.26");
-
- // Start Transaction
- myTrans = transStart();
-
- //read object 1 (found on demksy)
- if((h1 = transRead(myTrans, 1)) == NULL){
- printf("Object not found\n");
- }
- //read object 31 (found on d-1)
- if((h2 = transRead(myTrans, 31)) == NULL) {
- printf("Object not found\n");
- }
-
- //read object 22 (found locally)
- if((h3 = transRead(myTrans, 22)) == NULL) {
- printf("Object not found\n");
- }
-
- //read object 2 (found on demsky)
- if((h4 = transRead(myTrans, 2)) == NULL) {
- printf("Object not found\n");
- }
-
- //read object 21 (found locally)
- if((h5 = transRead(myTrans, 21)) == NULL) {
- printf("Object not found\n");
- }
-
- //read object 32 (found on d-2)
- if((h6 = transRead(myTrans, 32)) == NULL) {
- printf("Object not found\n");
- }
-
- //Commit transaction
- if((h1 != NULL) && (h2 != NULL) && (h3 != NULL) && (h4 !=NULL) && (h5 != NULL) && (h6 != NULL))
- transCommit(myTrans);
- else
- printf("Cannot complete this transaction \n");
-
- pthread_join(thread_Listen, NULL);
- return 0;
-}
-int test5a(void) {
- unsigned int val, mid;
- transrecord_t *myTrans;
- unsigned int size;
- objheader_t *header, *h1, *h2, *h3;
- pthread_t thread_Listen;
- pthread_attr_t attr;
-
- dstmInit();
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
- //Create and Insert Oid 20
- size = sizeof(objheader_t) + classsize[2] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 20;
- header->type = 2;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.27");
- lhashInsert(header->oid, mid);
-
- //Create and Insert Oid 21
- size = sizeof(objheader_t) + classsize[1] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 21;
- header->type = 1;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.27");
- lhashInsert(header->oid, mid);
-
- //Create and Insert Oid 22
- size = sizeof(objheader_t) + classsize[3] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 22;
- header->type = 3;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.27");
- lhashInsert(header->oid, mid);
-
- //Inserting into lhashtable
- mid = iptoMid("128.200.9.26"); //d-1.eecs.uci.edu
- lhashInsert(31, mid);
- lhashInsert(32, mid);
- lhashInsert(33, mid);
-
- mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
- //Inserting into lhashtable
- lhashInsert(1, mid);
- lhashInsert(2, mid);
- lhashInsert(3, mid);
- lhashInsert(4, mid);
-
- pthread_create(&thread_Listen, &attr, dstmListen, NULL);
-
- //Check if machine demsky is up and running
- checkServer(mid, "128.200.9.10");
- mid = iptoMid("128.200.9.26");
- //Check if machine d-1 is up and running
- checkServer(mid, "128.200.9.26");
-
- // Start Transaction
- myTrans = transStart();
-
- //read object 1 (found on demksy)
- if((h1 = transRead(myTrans, 1)) == NULL){
- printf("Object not found\n");
- }
- //read object 31 (found on d-1)
- if((h2 = transRead(myTrans, 32)) == NULL) {
- printf("Object not found\n");
- }
-
- //read object 22 (found locally)
- if((h3 = transRead(myTrans, 22)) == NULL) {
- printf("Object not found\n");
- }
-
- //Commit transaction
- if((h1 != NULL) && (h2 != NULL) && (h3 != NULL))
- transCommit(myTrans);
- else
- printf("Cannot complete this transaction \n");
-
- pthread_join(thread_Listen, NULL);
- return 0;
-}
-
-int test6(void) {
- transrecord_t *record;
- objheader_t *header;
- unsigned int size, mid;
- pthread_t thread_Listen;
- pthread_attr_t attr;
- objheader_t *h1,*h2, *h3, *h4, *h5, *h6;
- int tmpsd;
-
- dstmInit();
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
- //pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-
- record = transStart();
- //printf("DEBUG -> Init done\n");
- mid = iptoMid("128.200.9.10");// Machine demsky.eecs.uci.edu
- lhashInsert(1,mid);
- lhashInsert(2,mid);
- lhashInsert(3,mid);
- lhashInsert(4,mid);
- lhashInsert(5,mid);
- lhashInsert(6,mid);
-
- mid = iptoMid("128.200.9.26");// Machine demsky.eecs.uci.edu
- lhashInsert(31,mid);
- lhashInsert(32,mid);
- lhashInsert(33,mid);
-
- pthread_create(&thread_Listen, &attr, dstmListen, NULL);
-
- checkServer(mid, "128.200.9.26");
- mid = iptoMid("128.200.9.10");
- checkServer(mid, "128.200.9.10");
-
- //Create and Insert Oid 20
- size = sizeof(objheader_t) + classsize[2] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 20;
- header->type = 2;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.27");
- lhashInsert(header->oid, mid);
-
- //Create and Insert Oid 21
- size = sizeof(objheader_t) + classsize[1] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 21;
- header->type = 1;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.27");
- lhashInsert(header->oid, mid);
- sleep(3);
- //read object 1 //from demsky
- if((h1 = transRead(record, 1)) == NULL){
- printf("Object not found\n");
- }
- //read object 2
- if((h2 = transRead(record, 2)) == NULL) {
- printf("Object not found\n");
- }
- //read object 31 //Found in d-1
- if((h2 = transRead(record, 31)) == NULL) {
- printf("Object not found\n");
- }
- //read object 32 //Found in d-1
- if((h2 = transRead(record, 32)) == NULL) {
- printf("Object not found\n");
- }
- //read object 20(present in local machine)
- if((h3 = transRead(record, 20)) == NULL) {
- printf("Object not found\n");
- }
- //read object 21(present in local machine)
- if((h4 = transRead(record, 21)) == NULL) {
- printf("Object not found\n");
- }
- transCommit(record);
- pthread_join(thread_Listen, NULL);
- return 0;
-}
-//Commit transactions on local and remote objects that are NOT a part of
-//any other transaction
-int test7(void) {
- unsigned int val, mid;
- transrecord_t *myTrans;
- unsigned int size;
- objheader_t *header, *h1, *h2, *h3;
- pthread_t thread_Listen;
- pthread_attr_t attr;
-
- dstmInit();
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
- //Create and Insert Oid 20
- size = sizeof(objheader_t) + classsize[2] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 20;
- header->type = 2;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.27");
- lhashInsert(header->oid, mid);
-
- //Create and Insert Oid 21
- size = sizeof(objheader_t) + classsize[1] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 21;
- header->type = 1;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.27");
- lhashInsert(header->oid, mid);
-
- //Create and Insert Oid 22
- size = sizeof(objheader_t) + classsize[3] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 22;
- header->type = 3;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.27");
- lhashInsert(header->oid, mid);
-
- //Inserting into lhashtable
- mid = iptoMid("128.200.9.26"); //d-1.eecs.uci.edu
- lhashInsert(31, mid);
- lhashInsert(32, mid);
- lhashInsert(33, mid);
-
- mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
- //Inserting into lhashtable
- lhashInsert(1, mid);
- lhashInsert(2, mid);
- lhashInsert(3, mid);
- lhashInsert(4, mid);
-
- pthread_create(&thread_Listen, &attr, dstmListen, NULL);
-
- //Check if machine demsky is up and running
- checkServer(mid, "128.200.9.10");
- mid = iptoMid("128.200.9.26");
- //Check if machine d-1 is up and running
- checkServer(mid, "128.200.9.26");
-
- // Start Transaction
- myTrans = transStart();
-
- //read object 3 (found on demksy)
- if((h1 = transRead(myTrans, 3)) == NULL){
- printf("Object not found\n");
- }
- //read object 32 (found on d-1)
- if((h2 = transRead(myTrans, 32)) == NULL) {
- printf("Object not found\n");
- }
-
- //read object 22 (found locally)
- if((h3 = transRead(myTrans, 22)) == NULL) {
- printf("Object not found\n");
- }
-
- //Commit transaction
- transCommit(myTrans);
-
- pthread_join(thread_Listen, NULL);
- return 0;
-}
+++ /dev/null
-#include <stdio.h>
-#include "clookup.h"
-
-main()
-{
- int i;
- void *val;
- chashtable_t *ctable;
-
- if (( ctable = chashCreate(1000, 0.40)) == NULL) {
- printf("chashCreate error\n"); //creates hashtable
- }
-
- for (i = 1; i <= 2000; i++) { // Checks the insert() and resize()
- if (chashInsert(ctable, 10*i, &i) == 1)
- printf("chashInsert error\n");
- }
-
- i = chashRemove(ctable, 10);//Delete first element in the hashtable
- if(i == 1)
- printf("chashRemove error ");
-
- for (i = 1; i <= 2000; i++) { // Check if it can search for all keys in hash table
- val = chashSearch(ctable, 10*i);
- if (val != &i)
- printf("chashSearch error - val = %d\n", val);
- else
- printf("chashSearch key = %d val = %x\n",10*i, val);
- }
-
- i = chashRemove(ctable, 30);
- if(i == 1)
- printf("chashRemove error\n ");
- i = chashRemove(ctable, 40);
- if(i == 1)
- printf("chashRemove error\n ");
- i = chashRemove(ctable, 80);
- if(i == 1)
- printf("chashRemove error\n ");
- i = chashRemove(ctable, 100);
- if(i == 1)
- printf("chashRemove error\n ");
- i = chashRemove(ctable, 90);
- if(i == 1)
- printf("chashRemove error\n ");
-
- for (i = 1; i <= 2000; i++) { //Prints all left over elements inside hash after deletion and prints error if element not found in hash
- val = chashSearch(ctable, 10*i);
- if (val != &i)
- printf("chashSearch error - val = %d\n", val);
- else
- printf("chashSearch key = %d val = %x\n",10*i, val);
- }
-
- printf("The total number of elements in table : %d\n", ctable->numelements);
-
- chashDelete(ctable);
-}
+++ /dev/null
-#include<stdio.h>
-#include<pthread.h>
-#include "dstm.h"
-#include "llookup.h"
-#include "ip.h"
-
-#define LISTEN_PORT 2156
-
-extern objstr_t *mainobjstore;
-
-int classsize[]={sizeof(int),sizeof(char),sizeof(short), sizeof(void *)};
-
-int main()
-{
-// test2();
-// test3();
-// test4();
- test5();
-// test5a();
-// test2a();
-// test2b();
-// test7();
-
-}
-
-int test1(void) {
-
- transrecord_t *record;
- objheader_t *h1,*h2,*h3,*h4,*h5, *h6;
-
- dstmInit();
- record = transStart();
- printf("DEBUG -> Init done\n");
- h1 = transRead(record, 1);
- printf("oid = %d\tsize = %d\n", OID(h1),classsize[h1->type]);
- h3 = transRead(record, 3);
- printf("oid = %d\tsize = %d\n", OID(h3),classsize[h3->type]);
- h4 = transRead(record, 4);
- printf("oid = %d\tsize = %d\n", OID(h4),classsize[h4->type]);
- h2 = transRead(record, 2);
- printf("oid = %d\tsize = %d\n", OID(h2),classsize[h2->type]);
- h4 = transRead(record, 4);
- printf("oid = %d\tsize = %d\n", OID(h4),classsize[h4->type]);
- h3 = transRead(record, 3);
- printf("oid = %d\tsize = %d\n", OID(h3),classsize[h3->type]);
- h5 = transRead(record, 5);
- printf("oid = %d\tsize = %d\n", OID(h5),classsize[h5->type]);
-}
-
-int test2(void) {
-
- transrecord_t *record;
- objheader_t *h1,*h2,*h3,*h4,*h5, *h6;
-
- dstmInit();
- record = transStart();
-
- lhashInsert(1,1);
- lhashInsert(2,1);
- lhashInsert(3,1);
- lhashInsert(4,1);
- lhashInsert(5,1);
- lhashInsert(6,1);
- printf("DEBUG -> Init done\n");
- h1 = transRead(record, 1);
- lhashInsert(OID(h1), 1);
- h2 = transRead(record, 2);
- lhashInsert(OID(h2), 1);
- h3 = transRead(record, 3);
- lhashInsert(OID(h3), 1);
- h4 = transRead(record, 4);
- lhashInsert(OID(h4), 1);
- h5 = transRead(record, 5);
- lhashInsert(OID(h5), 1);
- h6 = transRead(record, 6);
- lhashInsert(OID(h6), 1);
-
- transCommit(record);
-
- return 0;
-}
-
-//Read objects when objects are found in remote location
-int test2a(void) {
- unsigned int val, mid;
- transrecord_t *myTrans;
- unsigned int size;
- objheader_t *header, *h1, *h2;
- pthread_t thread_Listen;
- pthread_attr_t attr;
-
- dstmInit();
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
- //Create and Insert Oid 20
- size = sizeof(objheader_t) + classsize[2] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- OID(header) = 20;
- header->type = 2;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(OID(header), header);
- mid = iptoMid("128.200.9.29");
- lhashInsert(OID(header), mid);
-
- //Create and Insert Oid 21
- size = sizeof(objheader_t) + classsize[1] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- OID(header) = 21;
- header->type = 1;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(OID(header), header);
- mid = iptoMid("128.200.9.29");
- lhashInsert(OID(header), mid);
-
- //Create and Insert Oid 22
- size = sizeof(objheader_t) + classsize[3] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- OID(header) = 22;
- header->type = 3;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(OID(header), header);
- mid = iptoMid("128.200.9.29");
- lhashInsert(OID(header), mid);
-
- //Inserting into lhashtable
- mid = iptoMid("128.195.175.69"); //dw-1.eecs.uci.edu
- lhashInsert(31, mid);
- lhashInsert(32, mid);
-
- mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
- //Inserting into lhashtable
- lhashInsert(1, mid);
- lhashInsert(2, mid);
- lhashInsert(3, mid);
- lhashInsert(4, mid);
-
- pthread_create(&thread_Listen, &attr, dstmListen, NULL);
-
- //Check if machine demsky is up and running
- checkServer(mid, "128.200.9.10");
- mid = iptoMid("128.195.175.69");
- //Check if machine dw-1 is up and running
- checkServer(mid, "128.195.175.69");
-
- // Start Transaction
- myTrans = transStart();
-
- //read object 1
- if((h1 = transRead(myTrans, 1)) == NULL){
- printf("Object not found\n");
- }
- //read object 2
- if((h2 = transRead(myTrans, 2)) == NULL) {
- printf("Object not found\n");
- }
-
- pthread_join(thread_Listen, NULL);
- return 0;
-}
-
-//Read objects that are both remote and local and are available on machines
-int test2b(void) {
-
- unsigned int val, mid;
- transrecord_t *myTrans;
- unsigned int size;
- objheader_t *header, *h1, *h2, *h3, *h4;
- pthread_t thread_Listen;
- pthread_attr_t attr;
-
- dstmInit();
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
- //Create and Insert Oid 20
- size = sizeof(objheader_t) + classsize[2] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- OID(header) = 20;
- header->type = 2;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(OID(header), header);
- mid = iptoMid("128.200.9.29");
- lhashInsert(OID(header), mid);
-
- //Create and Insert Oid 21
- size = sizeof(objheader_t) + classsize[1] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- OID(header) = 21;
- header->type = 1;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(OID(header), header);
- mid = iptoMid("128.200.9.29");
- lhashInsert(OID(header), mid);
-
- //Create and Insert Oid 22
- size = sizeof(objheader_t) + classsize[3] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- OID(header) = 22;
- header->type = 3;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(OID(header), header);
- mid = iptoMid("128.200.9.29");
- lhashInsert(OID(header), mid);
-
- //Inserting into lhashtable
- mid = iptoMid("128.195.175.69"); //dw-1.eecs.uci.edu
- lhashInsert(31, mid);
- lhashInsert(32, mid);
- lhashInsert(33, mid);
-
- mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
- //Inserting into lhashtable
- lhashInsert(1, mid);
- lhashInsert(2, mid);
- lhashInsert(3, mid);
- lhashInsert(4, mid);
-
- pthread_create(&thread_Listen, &attr, dstmListen, NULL);
-
- //Check if machine demsky is up and running
- checkServer(mid, "128.200.9.10");
- mid = iptoMid("128.195.175.69");
- //Check if machine dw-1 is up and running
- checkServer(mid, "128.195.175.69");
-
- // Start Transaction
- myTrans = transStart();
-
- //read object 1 (found on demksy)
- if((h1 = transRead(myTrans, 1)) == NULL){
- printf("Object not found\n");
- }
- //read object 2 (found on demsky)
- if((h2 = transRead(myTrans, 2)) == NULL) {
- printf("Object not found\n");
- }
-
- //read object 21 (found on local)
- if((h3 = transRead(myTrans, 21)) == NULL) {
- printf("Object not found\n");
- }
-
- //read object 32 (found on dw-1)
- if((h4 = transRead(myTrans, 32)) == NULL) {
- printf("Object not found\n");
- }
-
- pthread_join(thread_Listen, NULL);
- return 0;
-
-}
-
-
-//Read objects when objects are not found in any participant
-int test3(void){
- transrecord_t *record;
- objheader_t *h1,*h2;
-
- dstmInit();
- record = transStart();
- printf("DEBUG -> Init done\n");
- //read object 11
- if((h1 = transRead(record, 11)) == NULL){
- printf("Object not found\n");
- }
- //read object 12
- if((h2 = transRead(record, 12)) == NULL) {
- printf("Object not found\n");
- }
- transCommit(record);
-
- return 0;
-}
-
-//Read objects when some objects are found and other objects not found in any participant
-int test4(void) {
- transrecord_t *record;
- objheader_t *h1,*h2, *h3, *h4;
-
- dstmInit();
- record = transStart();
- printf("DEBUG -> Init done\n");
- //read object 1
- if((h1 = transRead(record, 1)) == NULL){
- printf("Object not found\n");
- }
- //read object 2
- if((h2 = transRead(record, 2)) == NULL) {
- printf("Object not found\n");
- }
- //read object 11
- if((h3 = transRead(record, 11)) == NULL) {
- printf("Object not found\n");
- }
- //read object 13
- if((h4 = transRead(record, 13)) == NULL) {
- printf("Object not found\n");
- }
- if((h1 != NULL) && (h2 != NULL) && (h3 != NULL) && h4 !=NULL) {
- transCommit(record);
- }else {
- printf("Cannot complete this transaction\n");
- }
-
- return 0;
-}
-
-//Commit for transaction objects when the objs are part of other
-//transactions running simultaneously
-int test5(void) {
- unsigned int val, mid;
- transrecord_t *myTrans;
- unsigned int size;
- objheader_t *header, *h1, *h2, *h3, *h4, *h5, *h6;
- pthread_t thread_Listen;
- pthread_attr_t attr;
-
- dstmInit();
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
- //Create and Insert Oid 20
- size = sizeof(objheader_t) + classsize[2] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- OID(header) = 20;
- header->type = 2;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(OID(header), header);
- mid = iptoMid("128.200.9.29");
- lhashInsert(OID(header), mid);
-
- //Create and Insert Oid 21
- size = sizeof(objheader_t) + classsize[1] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- OID(header) = 21;
- header->type = 1;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(OID(header), header);
- mid = iptoMid("128.200.9.29");
- lhashInsert(OID(header), mid);
-
- //Create and Insert Oid 22
- size = sizeof(objheader_t) + classsize[3] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- OID(header) = 22;
- header->type = 3;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(OID(header), header);
- mid = iptoMid("128.200.9.29");
- lhashInsert(OID(header), mid);
-
- //Inserting into lhashtable
- mid = iptoMid("128.195.175.69"); //dw-1.eecs.uci.edu
- lhashInsert(31, mid);
- lhashInsert(32, mid);
- lhashInsert(33, mid);
-
- mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
- //Inserting into lhashtable
- lhashInsert(1, mid);
- lhashInsert(2, mid);
- lhashInsert(3, mid);
- lhashInsert(4, mid);
-
- pthread_create(&thread_Listen, &attr, dstmListen, NULL);
- //Check if machine demsky is up and running
- checkServer(mid, "128.200.9.10");
- mid = iptoMid("128.195.175.69");
- //Check if machine dw-1 is up and running
- checkServer(mid, "128.195.175.69");
-
- // Start Transaction
- myTrans = transStart();
-
- //read object 1 (found on demksy)
- if((h1 = transRead(myTrans, 1)) == NULL){
- printf("Object not found\n");
- }
- //read object 2 (found on demksy)
- if((h2 = transRead(myTrans,2)) == NULL){
- printf("Object not found\n");
- }
- //read object 22 (found locally )
- if((h3 = transRead(myTrans, 22)) == NULL) {
- printf("Object not found\n");
- }
-
- //Commit transaction
- transCommit(myTrans);
-
- pthread_join(thread_Listen, NULL);
- return 0;
-}
-int test5a(void) {
- unsigned int val, mid;
- transrecord_t *myTrans;
- unsigned int size;
- objheader_t *header, *h1, *h2, *h3;
- pthread_t thread_Listen;
- pthread_attr_t attr;
-
- dstmInit();
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
- //Create and Insert Oid 20
- size = sizeof(objheader_t) + classsize[2] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- OID(header) = 20;
- header->type = 2;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(OID(header), header);
- mid = iptoMid("128.200.9.29");
- lhashInsert(OID(header), mid);
-
- //Create and Insert Oid 21
- size = sizeof(objheader_t) + classsize[1] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- OID(header) = 21;
- header->type = 1;
- //read object 31 (found on dw-1)
- if((h2 = transRead(myTrans, 31)) == NULL) {
- printf("Object not found\n");
- }
-
- //Commit transaction
- transCommit(myTrans);
-
- pthread_join(thread_Listen, NULL);
- return 0;
-}
-int test5b(void) {
- unsigned int val, mid;
- transrecord_t *myTrans;
- unsigned int size;
- objheader_t *header, *h1, *h2, *h3;
- pthread_t thread_Listen;
- pthread_attr_t attr;
-
- dstmInit();
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
- //Create and Insert Oid 20
- size = sizeof(objheader_t) + classsize[2] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- OID(header) = 20;
- header->type = 2;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(OID(header), header);
- mid = iptoMid("128.200.9.29");
- lhashInsert(OID(header), mid);
-
- //Create and Insert Oid 21
- size = sizeof(objheader_t) + classsize[1] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- OID(header) = 21;
- header->type = 1;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(OID(header), header);
- mid = iptoMid("128.200.9.29");
- lhashInsert(OID(header), mid);
-
- //Create and Insert Oid 22
- size = sizeof(objheader_t) + classsize[3] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- OID(header) = 22;
- header->type = 3;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(OID(header), header);
- mid = iptoMid("128.200.9.29");
- lhashInsert(OID(header), mid);
-
- //Inserting into lhashtable
- mid = iptoMid("128.195.175.69"); //dw-1.eecs.uci.edu
- lhashInsert(31, mid);
- lhashInsert(32, mid);
- lhashInsert(33, mid);
-
- mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
- //Inserting into lhashtable
- lhashInsert(1, mid);
- lhashInsert(2, mid);
- lhashInsert(3, mid);
- lhashInsert(4, mid);
-
- pthread_create(&thread_Listen, &attr, dstmListen, NULL);
-
- //Check if machine demsky is up and running
- checkServer(mid, "128.200.9.10");
- mid = iptoMid("128.195.175.69");
- //Check if machine dw-1 is up and running
- checkServer(mid, "128.195.175.69");
-
- // Start Transaction
- myTrans = transStart();
-
- //read object 1 (found on demksy)
- if((h1 = transRead(myTrans, 1)) == NULL){
- printf("Object not found\n");
- }
- //read object 31 (found on dw-1)
- if((h2 = transRead(myTrans, 31)) == NULL) {
- printf("Object not found\n");
- }
-
- //read object 22 (found locally)
- if((h3 = transRead(myTrans, 22)) == NULL) {
- printf("Object not found\n");
- }
-
- //Commit transaction
- if((h1 != NULL) && (h2 != NULL) && (h3 != NULL))
- transCommit(myTrans);
- else
- printf("Cannot complete this transaction \n");
-
- pthread_join(thread_Listen, NULL);
- return 0;
-}
-//Commit transactions on local and remote objects that are NOT a part of
-//any other transaction
-int test7(void) {
- unsigned int val, mid;
- transrecord_t *myTrans;
- unsigned int size;
- objheader_t *header, *h1, *h2, *h3;
- pthread_t thread_Listen;
- pthread_attr_t attr;
-
- dstmInit();
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
- //Create and Insert Oid 20
- size = sizeof(objheader_t) + classsize[2] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- OID(header) = 20;
- header->type = 2;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(OID(header), header);
- mid = iptoMid("128.200.9.29");
- lhashInsert(OID(header), mid);
-
- //Create and Insert Oid 21
- size = sizeof(objheader_t) + classsize[1] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- OID(header) = 21;
- header->type = 1;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(OID(header), header);
- mid = iptoMid("128.200.9.29");
- lhashInsert(OID(header), mid);
-
- //Create and Insert Oid 22
- size = sizeof(objheader_t) + classsize[3] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- OID(header) = 22;
- header->type = 3;
- header->version = 1;
- header->rcount = 0; //? not sure how to handle this yet
- header->status = 0;
- header->status |= NEW;
- mhashInsert(OID(header), header);
- mid = iptoMid("128.200.9.29");
- lhashInsert(OID(header), mid);
-
- //Inserting into lhashtable
- mid = iptoMid("128.195.175.69"); //dw-1.eecs.uci.edu
- lhashInsert(31, mid);
- lhashInsert(32, mid);
- lhashInsert(33, mid);
-
- mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
- //Inserting into lhashtable
- lhashInsert(1, mid);
- lhashInsert(2, mid);
- lhashInsert(3, mid);
- lhashInsert(4, mid);
-
- pthread_create(&thread_Listen, &attr, dstmListen, NULL);
-
- //Check if machine demsky is up and running
- checkServer(mid, "128.200.9.10");
- mid = iptoMid("128.195.175.69");
- //Check if machine dw-1 is up and running
- checkServer(mid, "128.195.175.69");
-
- // Start Transaction
- myTrans = transStart();
-
- //read object 3 (found on demksy)
- if((h1 = transRead(myTrans, 3)) == NULL){
- printf("Object not found\n");
- }
- //read object 32 (found on dw-1)
- if((h2 = transRead(myTrans, 32)) == NULL) {
- printf("Object not found\n");
- }
-
- //read object 22 (found locally)
- if((h3 = transRead(myTrans, 22)) == NULL) {
- printf("Object not found\n");
- }
-
- //Commit transaction
- transCommit(myTrans);
-
- pthread_join(thread_Listen, NULL);
- return 0;
-}
+++ /dev/null
-#include <pthread.h>
-#include "dstm.h"
-
-extern objstr_t *mainobjstore;
-int classsize[]={sizeof(int),sizeof(char),sizeof(short), sizeof(void *)};
-
-int main()
-{
- test1();
-// test2();
-// test3();
-// test4();
-}
-
-void init_obj(objheader_t *h, unsigned int oid, unsigned short type, \
- unsigned short version,\
- unsigned short rcount, char status) {
- h->oid = oid;
- h->type = type;
- h->version = version;
- h->rcount = rcount;
- h->status |= status;
- return;
-}
-
-//Test case to create objects and do nothing else
-int test1() {
- unsigned int val, mid;
- unsigned int size;
- transrecord_t *myTrans;
- objheader_t *header;
- pthread_t thread_Listen;
- pthread_attr_t attr;
-
- dstmInit();
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
- //Create and Insert Oid 31
- size = sizeof(objheader_t) + classsize[2] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 31, 2, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.195.175.69");
- lhashInsert(header->oid, mid);
-
- //Create and Insert Oid 32
- size = sizeof(objheader_t) + classsize[1] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 32, 1, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.195.175.69");
- lhashInsert(header->oid, mid);
-
- //Create and Insert Oid 33
- size = sizeof(objheader_t) + classsize[0] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 33, 0, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.195.175.69");
- lhashInsert(header->oid, mid);
-
- //Inserting into lhashtable into d-3.eecs
- mid = iptoMid("128.200.9.29"); //d-3.eecs.uci.edu
- lhashInsert(20, mid);
- lhashInsert(21, mid);
- lhashInsert(22, mid);
-
- mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
- //Inserting into lhashtable of demsky.eecs
- lhashInsert(1, mid);
- lhashInsert(2, mid);
- lhashInsert(3, mid);
- lhashInsert(4, mid);
-
- pthread_create(&thread_Listen, &attr, dstmListen, NULL);
- //Check if machine demsky is up and running
- checkServer(mid, "128.200.9.10");
- mid = iptoMid("128.200.9.29");
- //Check if machine d-3 is up and running
- checkServer(mid, "128.200.9.29");
-
- pthread_join(thread_Listen, NULL);
-
- return 0;
-}
-
-//Read objects from remote and local machines ; NOTE objects are all available
-int test2() {
-
- unsigned int val, mid;
- unsigned int size;
- transrecord_t *myTrans;
- objheader_t *header, *h1, *h2, *h3, *h4;
- pthread_t thread_Listen;
- pthread_attr_t attr;
-
- dstmInit();
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
- //Create and Insert Oid 31
- size = sizeof(objheader_t) + classsize[2] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 31, 2, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.195.175.69");
- lhashInsert(header->oid, mid);
-
- //Create and Insert Oid 32
- size = sizeof(objheader_t) + classsize[1] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 32, 1, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.195.175.69");
- lhashInsert(header->oid, mid);
-
- //Create and Insert Oid 33
- size = sizeof(objheader_t) + classsize[0] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 33, 0, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.195.175.69");
- lhashInsert(header->oid, mid);
-
- //Inserting into lhashtable into d-3.eecs
- mid = iptoMid("128.200.9.29"); //d-3.eecs.uci.edu
- lhashInsert(20, mid);
- lhashInsert(21, mid);
- lhashInsert(22, mid);
-
- mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
- //Inserting into lhashtable of demsky.eecs
- lhashInsert(1, mid);
- lhashInsert(2, mid);
- lhashInsert(3, mid);
- lhashInsert(4, mid);
-
- pthread_create(&thread_Listen, &attr, dstmListen, NULL);
-
- //Check if machine demsky is up and running
- checkServer(mid, "128.200.9.10");
- mid = iptoMid("128.200.9.29");
- //Check if machine d-2 is up and running
- checkServer(mid, "128.200.9.29");
-
- // Start Transaction
- myTrans = transStart();
-
- //read object 1 (found on demksy)
- if((h1 = transRead(myTrans, 1)) == NULL){
- printf("Object not found\n");
- }
-
- //read object 33 (found on local)
- if((h2 = transRead(myTrans, 33)) == NULL){
- printf("Object not found\n");
- }
-
- //read object 21 (found on d-3)
- if((h3 = transRead(myTrans, 21)) == NULL){
- printf("Object not found\n");
- }
-
- //read object 32 (found on local)
- if((h4 = transRead(myTrans, 32)) == NULL){
- printf("Object not found\n");
- }
-
- pthread_join(thread_Listen, NULL);
-
- return 0;
-}
-
-int test3() {
-
- unsigned int val, mid;
- unsigned int size;
- transrecord_t *myTrans;
- objheader_t *header, *h1, *h2, *h3;
- pthread_t thread_Listen;
- pthread_attr_t attr;
-
- dstmInit();
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
- //Create and Insert Oid 31
- size = sizeof(objheader_t) + classsize[2] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 31, 2, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.195.175.69");
- lhashInsert(header->oid, mid);
-
- //Create and Insert Oid 32
- size = sizeof(objheader_t) + classsize[1] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 32, 1, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.195.175.69");
- lhashInsert(header->oid, mid);
-
- //Create and Insert Oid 33
- size = sizeof(objheader_t) + classsize[0] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 33, 0, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.195.175.69");
- lhashInsert(header->oid, mid);
-
- //Inserting into lhashtable into d-3.eecs
- mid = iptoMid("128.200.9.29"); //d-3.eecs.uci.edu
- lhashInsert(20, mid);
- lhashInsert(21, mid);
- lhashInsert(22, mid);
-
- mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
- //Inserting into lhashtable of demsky.eecs
- lhashInsert(1, mid);
- lhashInsert(2, mid);
- lhashInsert(3, mid);
- lhashInsert(4, mid);
-
- pthread_create(&thread_Listen, &attr, dstmListen, NULL);
-
- //Check if machine demsky is up and running
- checkServer(mid, "128.200.9.10");
- mid = iptoMid("128.200.9.29");
- //Check if machine d-3 is up and running
- checkServer(mid, "128.200.9.29");
-
- // Start Transaction
- myTrans = transStart();
-
- //read object 4 (found on demksy)
- if((h1 = transRead(myTrans, 4)) == NULL){
- printf("Object not found\n");
- }
- //read object 33 (found on local)
- if((h2 = transRead(myTrans, 33)) == NULL){
- printf("Object not found\n");
- }
- //read object 20 (found on d-3)
- if((h3 = transRead(myTrans, 20)) == NULL){
- printf("Object not found\n");
- }
-
- //Commit transaction
- transCommit(myTrans);
-
- pthread_join(thread_Listen, NULL);
-
- return 0;
-}
-//Commit transaction for some objects that are available and some that are
-//not available anywhere
-int test4() {
- unsigned int val, mid;
- unsigned int size;
- transrecord_t *myTrans;
- objheader_t *header, *h1, *h2, *h3, *h4;
- pthread_t thread_Listen;
- pthread_attr_t attr;
-
- dstmInit();
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
- //Create and Insert Oid 31
- size = sizeof(objheader_t) + classsize[2] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 31, 2, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.195.175.69");
- lhashInsert(header->oid, mid);
-
- //Create and Insert Oid 32
- size = sizeof(objheader_t) + classsize[1] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 32, 1, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.195.175.69");
- lhashInsert(header->oid, mid);
-
- //Create and Insert Oid 33
- size = sizeof(objheader_t) + classsize[0] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 33, 0, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.195.175.69");
- lhashInsert(header->oid, mid);
-
- //Inserting into lhashtable into d-3.eecs
- mid = iptoMid("128.200.9.29"); //d-3.eecs.uci.edu
- lhashInsert(20, mid);
- lhashInsert(21, mid);
- lhashInsert(22, mid);
-
- mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
- //Inserting into lhashtable of demsky.eecs
- lhashInsert(1, mid);
- lhashInsert(2, mid);
- lhashInsert(3, mid);
- lhashInsert(4, mid);
-
- pthread_create(&thread_Listen, &attr, dstmListen, NULL);
-
- //Check if machine demsky is up and running
- checkServer(mid, "128.200.9.10");
- mid = iptoMid("128.200.9.29");
- //Check if machine d-2 is up and running
- checkServer(mid, "128.200.9.29");
-
- // Start Transaction
- myTrans = transStart();
-
- //read object 4 (found on demksy)
- if((h1 = transRead(myTrans, 4)) == NULL){
- printf("Object not found\n");
- }
- //read object 33 (found on local)
- if((h2 = transRead(myTrans, 33)) == NULL){
- printf("Object not found\n");
- }
- //read object 24 (found nowhere)
- if((h3 = transRead(myTrans, 24)) == NULL){
- printf("Object not found\n");
- }
- //read object 50 (found nowhere)
- if((h4 = transRead(myTrans, 50)) == NULL){
- printf("Object not found\n");
- }
-
- //Commit transaction
- if((h1 != NULL) && (h2 != NULL) && (h3 != NULL) && (h4 !=NULL))
- transCommit(myTrans);
- else
- printf("Cannot complete this transaction\n");
-
- pthread_join(thread_Listen, NULL);
- return 0;
-
-}
+++ /dev/null
-#include <stdio.h>
-#include "dht.h"
-#include "clookup.h"
-
-#define NUM_ITEMS 100000
-
-int main()
-{
- unsigned int key;
- unsigned int val;
- unsigned int vals[NUM_ITEMS];
- int retval;
- int error;
- chashtable_t *localHash;
-
- dhtInit(0x80C3AF45, DHT_NO_KEY_LIMIT);
-
- localHash = chashCreate(HASH_SIZE, LOADFACTOR);
- srandom(time(0));
-
- for (key = 1; key < NUM_ITEMS; key++)
- {
- vals[key] = random();
- }
-
- sleep(5);
-
- printf("testing dhtInsert() and dhtSearch()\n");
-
- for (key = 0; key < NUM_ITEMS; key++)
- {
- dhtInsert(key, vals[key]);
- }
-
- error = 0;
- for (key = 1; key < NUM_ITEMS; key++)
- {
- retval = dhtSearch(key, &val);
- if (retval == 1)
- {
- printf("item not found: key = %d, expected val = %d\n", key, vals[key]);
- error = 1;
- }
- else if (retval == -1)
- {
- printf("internal error: key = %d, expected val = %d\n", key, vals[key]);
- error = 1;
- }
- else if (retval == 0)
- {
- if (vals[key] != val)
- {
- printf("unexpected value: key = %d, expected val = %d, val = %d\n", key, vals[key], val);
- error = 1;
- }
- }
- }
- if (!error)
- printf("test completed successfully\n");
- else
- printf("one or more errors occurred\n");
-
- printf("(this currently fails if key = 0 OR val = 0, due to underlying hash table)\n");
- printf("testing underlying hash table (clookup.h)\n");
-
- for (key = 1; key < NUM_ITEMS; key++)
- {
- chashInsert(localHash, key, (void *)vals[key]);
- }
-
- error = 0;
- for (key = 1; key < NUM_ITEMS; key++)
- {
- val = (unsigned int)chashSearch(localHash, key);
- if ((void *)val == NULL)
- {
- printf("item not found: key = %d, expected val = %d\n", key, vals[key]);
- error = 1;
- }
- else
- {
- if (vals[key] != val)
- {
- printf("unexpected value: key = %d, expected val = %d, val = %d\n", key, vals[key], val);
- error = 1;
- }
- }
- for (key = NUM_ITEMS; key < NUM_ITEMS + 20; key++)
- {
- val = (unsigned int)chashSearch(localHash, key);
- if ((void *)val != NULL)
- {
- printf("error: returned value for key that wasn't inserted: key = %d, val = %d\n", key, val);
- error = 1;
- }
- }
- }
-
- if (!error)
- printf("test completed successfully\n");
- else
- printf("one or more errors occurred\n");
-
- printf("testing dhtRemove(), removing half of the keys, and verifying that the other half is still there\n");
-
- for (key = 0; key < NUM_ITEMS / 2; key++)
- {
- dhtRemove(key);
- }
- error = 0;
- for (key = 0; key < NUM_ITEMS / 2; key++)
- {
- retval = dhtSearch(key, &val);
- if (retval == 0)
- {
- printf("error: found removed item: key = %d, val = %d\n", key, val);
- error = 1;
- }
- else if (retval == -1)
- {
- printf("internal error: key = %d, val = %d\n", key, val);
- error = 1;
- }
- }
- for (key = NUM_ITEMS / 2; key < NUM_ITEMS; key++)
- {
- retval = dhtSearch(key, &val);
- if (retval == 1)
- {
- printf("item not found: key = %d, expected val = %d\n", key, vals[key]);
- error = 1;
- }
- else if (retval == -1)
- {
- printf("internal error: key = %d, expected val = %d\n", key, vals[key]);
- error = 1;
- }
- else if (retval == 0)
- {
- if (vals[key] != val)
- {
- printf("unexpected value: key = %d, expected val = %d, val = %d\n", key, vals[key], val);
- error = 1;
- }
- }
- }
-
- if (!error)
- printf("test completed successfully\n");
- else
- printf("one or more errors occurred\n");
-
- sleep(5);
-
- dhtExit();
-
- return 0;
-}
-
+++ /dev/null
-#include <stdio.h>
-#include "llookup.h"
-extern lhashtable_t llookup;
-
-main()
-{
- int i, mid;
-
- if (lhashCreate(10, 0.20) == 1) {
- printf("lhashCreate error\n"); //creates hashtable
- }
- for (i = 1; i <= 7; i++) { // Checks the insert() and resize()
- if (lhashInsert(10*i, i) == 1)
- printf("lhashInsert error\n");
- }
-
- i = lhashRemove(10);//Delete first element in the hashtable
- if(i == 1)
- printf("lhashRemove error ");
-
- for (i = 1; i <=7; i++) { // Check if it can search for all oids in hash table
- mid = lhashSearch(10*i);
- if (mid != i)
- printf("lhashSearch error - mid = %d\n", mid);
- else
- printf("lhashSearch oid = %d mid = %d\n",10*i, mid);
- }
-
- i = lhashRemove(60);
- if(i == 1)
- printf("lhashRemove error ");
-
- for (i = 1; i <= 7; i++) { //Prints all left over elements inside hash after deletion and prints error if element not found in hash
- mid = lhashSearch(10*i);
- if (mid != i)
- printf("lhashSearch error - mid = %d\n", mid);
- else
- printf("lhashSearch oid = %d mid = %d\n",10*i, mid);
- }
-
- printf(" The total number of elements in table : %d\n", llookup.numelements);
-
-}
+++ /dev/null
-#include <stdio.h>
-#include "mlookup.h"
-extern mhashtable_t mlookup;
-
-main()
-{
- int i;
- void *val;
- val = NULL;
-
- if (mhashCreate(10, 0.20) == 1) {
- printf("mhashCreate error\n"); //creates hashtable
- }
- for (i = 1; i <= 7; i++) { // Checks the insert() and resize()
- if (mhashInsert(10*i, &i) == 1)
- printf("mhashInsert error\n");
- }
-
- i = mhashRemove(60);//Delete first element in the hashtable
- if(i == 1)
- printf("mhashRemove error ");
-
- for (i = 1; i <=7; i++) { // Check if it can search for all oids in hash table
- val = mhashSearch(10*i);
- if (val != &i)
- printf("mhashSearch error - val = %d\n", val);
- else
- printf("mhashSearch oid = %d val = %x\n",10*i, val);
- }
-
- i = mhashRemove(30);
- if(i == 1)
- printf("mhashRemove error ");
-
- for (i = 1; i <= 7; i++) { //Prints all left over elements inside hash after deletion and prints error if element not found in hash
- val = mhashSearch(10*i);
- if (val != &i)
- printf("mhashSearch error - val = %d\n", val);
- else
- printf("mhashSearch oid = %d val = %x\n",10*i, val);
- }
-
- printf("The total number of elements in table : %d\n", mlookup.numelements);
-
-}
+++ /dev/null
-#include "dstm.h"
-
-#define NUMITEMS 1000000 //uses four object stores
-
-int main(void)
-{
- objstr_t *myObjStr = objstrCreate(1048510);
- int i;
- int *j[NUMITEMS];
- int data[NUMITEMS];
- int fail = 0;
-
- for (i = 0; i < NUMITEMS; i++)
- {
- j[i] = objstrAlloc(myObjStr, sizeof(int));
- *j[i] = data[i] = i;
- }
- for (i = 0; i < NUMITEMS; i++)
- {
- if (data[i] != *j[i])
- fail = 1;
- }
-
- if (fail)
- printf("test failed\n");
- else
- printf("test succeeded\n");
-
- objstrDelete(myObjStr);
- return 0;
-}
-
--- /dev/null
+#include<stdio.h>
+#include<pthread.h>
+#include "dstm.h"
+#include "llookup.h"
+#include "ip.h"
+
+#define LISTEN_PORT 2156
+
+extern objstr_t *mainobjstore;
+typedef struct testobj1 {
+ int x;
+ char z;
+} testobj1_t;
+
+typedef struct testobj2 {
+ char z[10];
+ char c;
+ testobj1_t *y;
+} testobj2_t;
+
+typedef struct testobj3 {
+ short p;
+ testobj1_t *q;
+ testobj2_t *r;
+} testobj3_t;
+
+typedef struct testobj4 {
+ int b;
+ void *q;
+ testobj3_t *a;
+} testobj4_t;
+
+typedef struct testobj5 {
+ testobj4_t *a;
+} testobj5_t;
+
+
+int classsize[]={sizeof(int),sizeof(char),sizeof(short), sizeof(void *), sizeof(testobj1_t),
+ sizeof(testobj2_t), sizeof(testobj3_t), sizeof(testobj4_t), sizeof(testobj5_t)};
+
+unsigned int createObjects(transrecord_t *record) {
+ objheader_t *header, *tmp;
+ unsigned int size, mid;
+ int i = 0;
+ for(i = 20 ; i< 23; i++) {
+ size = sizeof(objheader_t) + classsize[i-20] ;
+ tmp = (objheader_t *)objstrAlloc(record->cache, size);
+ tmp->oid = i;
+ tmp->type = (i-20);
+ tmp->version = 1;
+ tmp->rcount = 0; //? not sure how to handle this yet
+ tmp->status = 0;
+ tmp->status |= NEW;
+ chashInsert(record->lookupTable, tmp->oid, tmp);
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ memcpy(header, tmp, size);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.27");//machine d-2
+ printf("DEBUG -> createObjects mid is %x\n", mid);
+ lhashInsert(header->oid, mid);
+ }
+ // printf("Insert oid = %d at address %x\n",tmp->oid, tmp);
+ size = sizeof(objheader_t) + classsize[0] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ header->oid = 30;
+ header->type = 0;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.27");
+ lhashInsert(header->oid, mid);
+ size = sizeof(objheader_t) + classsize[1] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ header->oid = 28;
+ header->type = 1;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= LOCK;
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.27");
+ lhashInsert(header->oid, mid);
+ size = sizeof(objheader_t) + classsize[2] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ header->oid = 29;
+ header->type = 2;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= LOCK;
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.27");
+ lhashInsert(header->oid, mid);
+ return 0;
+}
+
+int main()
+{
+// test2();
+// test3();
+// test4();
+ test5();
+// test5a();
+// test2a();
+// test2b();
+// test7();
+
+}
+
+int test1(void) {
+
+ transrecord_t *record;
+ objheader_t *h1,*h2,*h3,*h4,*h5, *h6;
+
+ dstmInit();
+ record = transStart();
+ printf("DEBUG -> Init done\n");
+ h1 = transRead(record, 1);
+ printf("oid = %d\tsize = %d\n", h1->oid,classsize[h1->type]);
+ h3 = transRead(record, 3);
+ printf("oid = %d\tsize = %d\n", h3->oid,classsize[h3->type]);
+ h4 = transRead(record, 4);
+ printf("oid = %d\tsize = %d\n", h4->oid,classsize[h4->type]);
+ h2 = transRead(record, 2);
+ printf("oid = %d\tsize = %d\n", h2->oid,classsize[h2->type]);
+ h4 = transRead(record, 4);
+ printf("oid = %d\tsize = %d\n", h4->oid,classsize[h4->type]);
+ h3 = transRead(record, 3);
+ printf("oid = %d\tsize = %d\n", h3->oid,classsize[h3->type]);
+ h5 = transRead(record, 5);
+ printf("oid = %d\tsize = %d\n", h5->oid,classsize[h5->type]);
+// getRemoteObj(&record, 0,1);
+}
+
+int test2(void) {
+
+ transrecord_t *record;
+ objheader_t *h1,*h2,*h3,*h4,*h5, *h6;
+
+ dstmInit();
+ record = transStart();
+
+ lhashInsert(1,1);
+ lhashInsert(2,1);
+ lhashInsert(3,1);
+ lhashInsert(4,1);
+ lhashInsert(5,1);
+ lhashInsert(6,1);
+ printf("DEBUG -> Init done\n");
+ h1 = transRead(record, 1);
+ lhashInsert(h1->oid, 1);
+ h2 = transRead(record, 2);
+ lhashInsert(h2->oid, 1);
+ h3 = transRead(record, 3);
+ lhashInsert(h3->oid, 1);
+ h4 = transRead(record, 4);
+ lhashInsert(h4->oid, 1);
+// h4->status |= DIRTY;
+ h5 = transRead(record, 5);
+ lhashInsert(h5->oid, 1);
+ h6 = transRead(record, 6);
+ lhashInsert(h6->oid, 1);
+// h6->status |= DIRTY;
+
+ transCommit(record);
+
+ return 0;
+}
+
+//Read objects when objects are found in remote location
+int test2a(void) {
+ unsigned int val, mid;
+ transrecord_t *myTrans;
+ unsigned int size;
+ objheader_t *header, *h1, *h2;
+ pthread_t thread_Listen;
+ pthread_attr_t attr;
+
+ dstmInit();
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+ //Create and Insert Oid 20
+ size = sizeof(objheader_t) + classsize[2] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ header->oid = 20;
+ header->type = 2;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.27");
+ lhashInsert(header->oid, mid);
+
+ //Create and Insert Oid 21
+ size = sizeof(objheader_t) + classsize[1] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ header->oid = 21;
+ header->type = 1;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.27");
+ lhashInsert(header->oid, mid);
+
+ //Create and Insert Oid 22
+ size = sizeof(objheader_t) + classsize[3] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ header->oid = 22;
+ header->type = 3;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.27");
+ lhashInsert(header->oid, mid);
+
+ //Inserting into lhashtable
+ mid = iptoMid("128.200.9.26"); //d-1.eecs.uci.edu
+ lhashInsert(31, mid);
+ lhashInsert(32, mid);
+
+ mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
+ //Inserting into lhashtable
+ lhashInsert(1, mid);
+ lhashInsert(2, mid);
+ lhashInsert(3, mid);
+ lhashInsert(4, mid);
+
+ pthread_create(&thread_Listen, &attr, dstmListen, NULL);
+
+ //Check if machine demsky is up and running
+ checkServer(mid, "128.200.9.10");
+ mid = iptoMid("128.200.9.26");
+ //Check if machine d-1 is up and running
+ checkServer(mid, "128.200.9.26");
+
+ // Start Transaction
+ myTrans = transStart();
+
+ sleep(2);
+ //read object 1
+ if((h1 = transRead(myTrans, 1)) == NULL){
+ printf("Object not found\n");
+ }
+ //read object 2
+ if((h2 = transRead(myTrans, 2)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ pthread_join(thread_Listen, NULL);
+ return 0;
+}
+
+//Read objects that are both remote and local and are available on machines
+int test2b(void) {
+
+ unsigned int val, mid;
+ transrecord_t *myTrans;
+ unsigned int size;
+ objheader_t *header, *h1, *h2, *h3, *h4;
+ pthread_t thread_Listen;
+ pthread_attr_t attr;
+
+ dstmInit();
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+ //Create and Insert Oid 20
+ size = sizeof(objheader_t) + classsize[2] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ header->oid = 20;
+ header->type = 2;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.27");
+ lhashInsert(header->oid, mid);
+
+ //Create and Insert Oid 21
+ size = sizeof(objheader_t) + classsize[1] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ header->oid = 21;
+ header->type = 1;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.27");
+ lhashInsert(header->oid, mid);
+
+ //Create and Insert Oid 22
+ size = sizeof(objheader_t) + classsize[3] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ header->oid = 22;
+ header->type = 3;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.27");
+ lhashInsert(header->oid, mid);
+
+ //Inserting into lhashtable
+ mid = iptoMid("128.200.9.26"); //d-1.eecs.uci.edu
+ lhashInsert(31, mid);
+ lhashInsert(32, mid);
+ lhashInsert(33, mid);
+
+ mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
+ //Inserting into lhashtable
+ lhashInsert(1, mid);
+ lhashInsert(2, mid);
+ lhashInsert(3, mid);
+ lhashInsert(4, mid);
+
+ pthread_create(&thread_Listen, &attr, dstmListen, NULL);
+
+ //Check if machine demsky is up and running
+ checkServer(mid, "128.200.9.10");
+ mid = iptoMid("128.200.9.26");
+ //Check if machine d-1 is up and running
+ checkServer(mid, "128.200.9.26");
+
+ // Start Transaction
+ myTrans = transStart();
+
+ //sleep(2);
+ //read object 1 (found on demksy)
+ if((h1 = transRead(myTrans, 1)) == NULL){
+ printf("Object not found\n");
+ }
+ //read object 2 (found on demsky)
+ if((h2 = transRead(myTrans, 2)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ //read object 21 (found on local)
+ if((h3 = transRead(myTrans, 21)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ //read object 32 (found on d-1)
+ if((h4 = transRead(myTrans, 32)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ pthread_join(thread_Listen, NULL);
+ return 0;
+
+}
+
+
+//Read objects when objects are not found in any participant
+int test3(void){
+ transrecord_t *record;
+ objheader_t *h1,*h2;
+
+ dstmInit();
+ record = transStart();
+ printf("DEBUG -> Init done\n");
+ //read object 11
+ if((h1 = transRead(record, 11)) == NULL){
+ printf("Object not found\n");
+ }
+ //read object 12
+ if((h2 = transRead(record, 12)) == NULL) {
+ printf("Object not found\n");
+ }
+ transCommit(record);
+
+ return 0;
+}
+
+//Read objects when some objects are found and other objects not found in any participant
+int test4(void) {
+ transrecord_t *record;
+ objheader_t *h1,*h2, *h3, *h4;
+
+ dstmInit();
+ record = transStart();
+ printf("DEBUG -> Init done\n");
+ //read object 1
+ if((h1 = transRead(record, 1)) == NULL){
+ printf("Object not found\n");
+ }
+ //read object 2
+ if((h2 = transRead(record, 2)) == NULL) {
+ printf("Object not found\n");
+ }
+ //read object 11
+ if((h3 = transRead(record, 11)) == NULL) {
+ printf("Object not found\n");
+ }
+ //read object 13
+ if((h4 = transRead(record, 13)) == NULL) {
+ printf("Object not found\n");
+ }
+ if((h1 != NULL) && (h2 != NULL) && (h3 != NULL) && h4 !=NULL) {
+ transCommit(record);
+ }else {
+ printf("Cannot complete this transaction\n");
+ }
+
+ return 0;
+}
+
+//Commit for transaction objects when the objs are part of other
+//transactions running simultaneously
+int test5(void) {
+ unsigned int val, mid;
+ transrecord_t *myTrans;
+ unsigned int size;
+ objheader_t *header, *h1, *h2, *h3, *h4, *h5, *h6;
+ pthread_t thread_Listen;
+ pthread_attr_t attr;
+
+ dstmInit();
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+ //Create and Insert Oid 20
+ size = sizeof(objheader_t) + classsize[2] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ header->oid = 20;
+ header->type = 2;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.27");
+ lhashInsert(header->oid, mid);
+
+ //Create and Insert Oid 21
+ size = sizeof(objheader_t) + classsize[1] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ header->oid = 21;
+ header->type = 1;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.27");
+ lhashInsert(header->oid, mid);
+
+ //Create and Insert Oid 22
+ size = sizeof(objheader_t) + classsize[3] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ header->oid = 22;
+ header->type = 3;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.27");
+ lhashInsert(header->oid, mid);
+
+ //Inserting into lhashtable
+ mid = iptoMid("128.200.9.26"); //d-1.eecs.uci.edu
+ lhashInsert(31, mid);
+ lhashInsert(32, mid);
+ lhashInsert(33, mid);
+
+ mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
+ //Inserting into lhashtable
+ lhashInsert(1, mid);
+ lhashInsert(2, mid);
+ lhashInsert(3, mid);
+ lhashInsert(4, mid);
+
+ pthread_create(&thread_Listen, &attr, dstmListen, NULL);
+
+ //Check if machine demsky is up and running
+ checkServer(mid, "128.200.9.10");
+ mid = iptoMid("128.200.9.26");
+ //Check if machine d-1 is up and running
+ checkServer(mid, "128.200.9.26");
+
+ // Start Transaction
+ myTrans = transStart();
+
+ //read object 1 (found on demksy)
+ if((h1 = transRead(myTrans, 1)) == NULL){
+ printf("Object not found\n");
+ }
+ //read object 31 (found on d-1)
+ if((h2 = transRead(myTrans, 31)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ //read object 22 (found locally)
+ if((h3 = transRead(myTrans, 22)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ //read object 2 (found on demsky)
+ if((h4 = transRead(myTrans, 2)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ //read object 21 (found locally)
+ if((h5 = transRead(myTrans, 21)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ //read object 32 (found on d-2)
+ if((h6 = transRead(myTrans, 32)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ //Commit transaction
+ if((h1 != NULL) && (h2 != NULL) && (h3 != NULL) && (h4 !=NULL) && (h5 != NULL) && (h6 != NULL))
+ transCommit(myTrans);
+ else
+ printf("Cannot complete this transaction \n");
+
+ pthread_join(thread_Listen, NULL);
+ return 0;
+}
+int test5a(void) {
+ unsigned int val, mid;
+ transrecord_t *myTrans;
+ unsigned int size;
+ objheader_t *header, *h1, *h2, *h3;
+ pthread_t thread_Listen;
+ pthread_attr_t attr;
+
+ dstmInit();
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+ //Create and Insert Oid 20
+ size = sizeof(objheader_t) + classsize[2] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ header->oid = 20;
+ header->type = 2;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.27");
+ lhashInsert(header->oid, mid);
+
+ //Create and Insert Oid 21
+ size = sizeof(objheader_t) + classsize[1] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ header->oid = 21;
+ header->type = 1;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.27");
+ lhashInsert(header->oid, mid);
+
+ //Create and Insert Oid 22
+ size = sizeof(objheader_t) + classsize[3] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ header->oid = 22;
+ header->type = 3;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.27");
+ lhashInsert(header->oid, mid);
+
+ //Inserting into lhashtable
+ mid = iptoMid("128.200.9.26"); //d-1.eecs.uci.edu
+ lhashInsert(31, mid);
+ lhashInsert(32, mid);
+ lhashInsert(33, mid);
+
+ mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
+ //Inserting into lhashtable
+ lhashInsert(1, mid);
+ lhashInsert(2, mid);
+ lhashInsert(3, mid);
+ lhashInsert(4, mid);
+
+ pthread_create(&thread_Listen, &attr, dstmListen, NULL);
+
+ //Check if machine demsky is up and running
+ checkServer(mid, "128.200.9.10");
+ mid = iptoMid("128.200.9.26");
+ //Check if machine d-1 is up and running
+ checkServer(mid, "128.200.9.26");
+
+ // Start Transaction
+ myTrans = transStart();
+
+ //read object 1 (found on demksy)
+ if((h1 = transRead(myTrans, 1)) == NULL){
+ printf("Object not found\n");
+ }
+ //read object 31 (found on d-1)
+ if((h2 = transRead(myTrans, 32)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ //read object 22 (found locally)
+ if((h3 = transRead(myTrans, 22)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ //Commit transaction
+ if((h1 != NULL) && (h2 != NULL) && (h3 != NULL))
+ transCommit(myTrans);
+ else
+ printf("Cannot complete this transaction \n");
+
+ pthread_join(thread_Listen, NULL);
+ return 0;
+}
+
+int test6(void) {
+ transrecord_t *record;
+ objheader_t *header;
+ unsigned int size, mid;
+ pthread_t thread_Listen;
+ pthread_attr_t attr;
+ objheader_t *h1,*h2, *h3, *h4, *h5, *h6;
+ int tmpsd;
+
+ dstmInit();
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+ //pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
+ record = transStart();
+ //printf("DEBUG -> Init done\n");
+ mid = iptoMid("128.200.9.10");// Machine demsky.eecs.uci.edu
+ lhashInsert(1,mid);
+ lhashInsert(2,mid);
+ lhashInsert(3,mid);
+ lhashInsert(4,mid);
+ lhashInsert(5,mid);
+ lhashInsert(6,mid);
+
+ mid = iptoMid("128.200.9.26");// Machine demsky.eecs.uci.edu
+ lhashInsert(31,mid);
+ lhashInsert(32,mid);
+ lhashInsert(33,mid);
+
+ pthread_create(&thread_Listen, &attr, dstmListen, NULL);
+
+ checkServer(mid, "128.200.9.26");
+ mid = iptoMid("128.200.9.10");
+ checkServer(mid, "128.200.9.10");
+
+ //Create and Insert Oid 20
+ size = sizeof(objheader_t) + classsize[2] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ header->oid = 20;
+ header->type = 2;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.27");
+ lhashInsert(header->oid, mid);
+
+ //Create and Insert Oid 21
+ size = sizeof(objheader_t) + classsize[1] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ header->oid = 21;
+ header->type = 1;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.27");
+ lhashInsert(header->oid, mid);
+ sleep(3);
+ //read object 1 //from demsky
+ if((h1 = transRead(record, 1)) == NULL){
+ printf("Object not found\n");
+ }
+ //read object 2
+ if((h2 = transRead(record, 2)) == NULL) {
+ printf("Object not found\n");
+ }
+ //read object 31 //Found in d-1
+ if((h2 = transRead(record, 31)) == NULL) {
+ printf("Object not found\n");
+ }
+ //read object 32 //Found in d-1
+ if((h2 = transRead(record, 32)) == NULL) {
+ printf("Object not found\n");
+ }
+ //read object 20(present in local machine)
+ if((h3 = transRead(record, 20)) == NULL) {
+ printf("Object not found\n");
+ }
+ //read object 21(present in local machine)
+ if((h4 = transRead(record, 21)) == NULL) {
+ printf("Object not found\n");
+ }
+ transCommit(record);
+ pthread_join(thread_Listen, NULL);
+ return 0;
+}
+//Commit transactions on local and remote objects that are NOT a part of
+//any other transaction
+int test7(void) {
+ unsigned int val, mid;
+ transrecord_t *myTrans;
+ unsigned int size;
+ objheader_t *header, *h1, *h2, *h3;
+ pthread_t thread_Listen;
+ pthread_attr_t attr;
+
+ dstmInit();
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+ //Create and Insert Oid 20
+ size = sizeof(objheader_t) + classsize[2] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ header->oid = 20;
+ header->type = 2;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.27");
+ lhashInsert(header->oid, mid);
+
+ //Create and Insert Oid 21
+ size = sizeof(objheader_t) + classsize[1] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ header->oid = 21;
+ header->type = 1;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.27");
+ lhashInsert(header->oid, mid);
+
+ //Create and Insert Oid 22
+ size = sizeof(objheader_t) + classsize[3] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ header->oid = 22;
+ header->type = 3;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.27");
+ lhashInsert(header->oid, mid);
+
+ //Inserting into lhashtable
+ mid = iptoMid("128.200.9.26"); //d-1.eecs.uci.edu
+ lhashInsert(31, mid);
+ lhashInsert(32, mid);
+ lhashInsert(33, mid);
+
+ mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
+ //Inserting into lhashtable
+ lhashInsert(1, mid);
+ lhashInsert(2, mid);
+ lhashInsert(3, mid);
+ lhashInsert(4, mid);
+
+ pthread_create(&thread_Listen, &attr, dstmListen, NULL);
+
+ //Check if machine demsky is up and running
+ checkServer(mid, "128.200.9.10");
+ mid = iptoMid("128.200.9.26");
+ //Check if machine d-1 is up and running
+ checkServer(mid, "128.200.9.26");
+
+ // Start Transaction
+ myTrans = transStart();
+
+ //read object 3 (found on demksy)
+ if((h1 = transRead(myTrans, 3)) == NULL){
+ printf("Object not found\n");
+ }
+ //read object 32 (found on d-1)
+ if((h2 = transRead(myTrans, 32)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ //read object 22 (found locally)
+ if((h3 = transRead(myTrans, 22)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ //Commit transaction
+ transCommit(myTrans);
+
+ pthread_join(thread_Listen, NULL);
+ return 0;
+}
--- /dev/null
+#include <stdio.h>
+#include "clookup.h"
+
+main()
+{
+ int i;
+ void *val;
+ chashtable_t *ctable;
+
+ if (( ctable = chashCreate(1000, 0.40)) == NULL) {
+ printf("chashCreate error\n"); //creates hashtable
+ }
+
+ for (i = 1; i <= 2000; i++) { // Checks the insert() and resize()
+ if (chashInsert(ctable, 10*i, &i) == 1)
+ printf("chashInsert error\n");
+ }
+
+ i = chashRemove(ctable, 10);//Delete first element in the hashtable
+ if(i == 1)
+ printf("chashRemove error ");
+
+ for (i = 1; i <= 2000; i++) { // Check if it can search for all keys in hash table
+ val = chashSearch(ctable, 10*i);
+ if (val != &i)
+ printf("chashSearch error - val = %d\n", val);
+ else
+ printf("chashSearch key = %d val = %x\n",10*i, val);
+ }
+
+ i = chashRemove(ctable, 30);
+ if(i == 1)
+ printf("chashRemove error\n ");
+ i = chashRemove(ctable, 40);
+ if(i == 1)
+ printf("chashRemove error\n ");
+ i = chashRemove(ctable, 80);
+ if(i == 1)
+ printf("chashRemove error\n ");
+ i = chashRemove(ctable, 100);
+ if(i == 1)
+ printf("chashRemove error\n ");
+ i = chashRemove(ctable, 90);
+ if(i == 1)
+ printf("chashRemove error\n ");
+
+ for (i = 1; i <= 2000; i++) { //Prints all left over elements inside hash after deletion and prints error if element not found in hash
+ val = chashSearch(ctable, 10*i);
+ if (val != &i)
+ printf("chashSearch error - val = %d\n", val);
+ else
+ printf("chashSearch key = %d val = %x\n",10*i, val);
+ }
+
+ printf("The total number of elements in table : %d\n", ctable->numelements);
+
+ chashDelete(ctable);
+}
--- /dev/null
+#include<stdio.h>
+#include<pthread.h>
+#include "dstm.h"
+#include "llookup.h"
+#include "ip.h"
+
+#define LISTEN_PORT 2156
+
+extern objstr_t *mainobjstore;
+
+int classsize[]={sizeof(int),sizeof(char),sizeof(short), sizeof(void *)};
+
+int main()
+{
+// test2();
+// test3();
+// test4();
+ test5();
+// test5a();
+// test2a();
+// test2b();
+// test7();
+
+}
+
+int test1(void) {
+
+ transrecord_t *record;
+ objheader_t *h1,*h2,*h3,*h4,*h5, *h6;
+
+ dstmInit();
+ record = transStart();
+ printf("DEBUG -> Init done\n");
+ h1 = transRead(record, 1);
+ printf("oid = %d\tsize = %d\n", OID(h1),classsize[h1->type]);
+ h3 = transRead(record, 3);
+ printf("oid = %d\tsize = %d\n", OID(h3),classsize[h3->type]);
+ h4 = transRead(record, 4);
+ printf("oid = %d\tsize = %d\n", OID(h4),classsize[h4->type]);
+ h2 = transRead(record, 2);
+ printf("oid = %d\tsize = %d\n", OID(h2),classsize[h2->type]);
+ h4 = transRead(record, 4);
+ printf("oid = %d\tsize = %d\n", OID(h4),classsize[h4->type]);
+ h3 = transRead(record, 3);
+ printf("oid = %d\tsize = %d\n", OID(h3),classsize[h3->type]);
+ h5 = transRead(record, 5);
+ printf("oid = %d\tsize = %d\n", OID(h5),classsize[h5->type]);
+}
+
+int test2(void) {
+
+ transrecord_t *record;
+ objheader_t *h1,*h2,*h3,*h4,*h5, *h6;
+
+ dstmInit();
+ record = transStart();
+
+ lhashInsert(1,1);
+ lhashInsert(2,1);
+ lhashInsert(3,1);
+ lhashInsert(4,1);
+ lhashInsert(5,1);
+ lhashInsert(6,1);
+ printf("DEBUG -> Init done\n");
+ h1 = transRead(record, 1);
+ lhashInsert(OID(h1), 1);
+ h2 = transRead(record, 2);
+ lhashInsert(OID(h2), 1);
+ h3 = transRead(record, 3);
+ lhashInsert(OID(h3), 1);
+ h4 = transRead(record, 4);
+ lhashInsert(OID(h4), 1);
+ h5 = transRead(record, 5);
+ lhashInsert(OID(h5), 1);
+ h6 = transRead(record, 6);
+ lhashInsert(OID(h6), 1);
+
+ transCommit(record);
+
+ return 0;
+}
+
+//Read objects when objects are found in remote location
+int test2a(void) {
+ unsigned int val, mid;
+ transrecord_t *myTrans;
+ unsigned int size;
+ objheader_t *header, *h1, *h2;
+ pthread_t thread_Listen;
+ pthread_attr_t attr;
+
+ dstmInit();
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+ //Create and Insert Oid 20
+ size = sizeof(objheader_t) + classsize[2] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ OID(header) = 20;
+ header->type = 2;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(OID(header), header);
+ mid = iptoMid("128.200.9.29");
+ lhashInsert(OID(header), mid);
+
+ //Create and Insert Oid 21
+ size = sizeof(objheader_t) + classsize[1] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ OID(header) = 21;
+ header->type = 1;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(OID(header), header);
+ mid = iptoMid("128.200.9.29");
+ lhashInsert(OID(header), mid);
+
+ //Create and Insert Oid 22
+ size = sizeof(objheader_t) + classsize[3] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ OID(header) = 22;
+ header->type = 3;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(OID(header), header);
+ mid = iptoMid("128.200.9.29");
+ lhashInsert(OID(header), mid);
+
+ //Inserting into lhashtable
+ mid = iptoMid("128.195.175.69"); //dw-1.eecs.uci.edu
+ lhashInsert(31, mid);
+ lhashInsert(32, mid);
+
+ mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
+ //Inserting into lhashtable
+ lhashInsert(1, mid);
+ lhashInsert(2, mid);
+ lhashInsert(3, mid);
+ lhashInsert(4, mid);
+
+ pthread_create(&thread_Listen, &attr, dstmListen, NULL);
+
+ //Check if machine demsky is up and running
+ checkServer(mid, "128.200.9.10");
+ mid = iptoMid("128.195.175.69");
+ //Check if machine dw-1 is up and running
+ checkServer(mid, "128.195.175.69");
+
+ // Start Transaction
+ myTrans = transStart();
+
+ //read object 1
+ if((h1 = transRead(myTrans, 1)) == NULL){
+ printf("Object not found\n");
+ }
+ //read object 2
+ if((h2 = transRead(myTrans, 2)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ pthread_join(thread_Listen, NULL);
+ return 0;
+}
+
+//Read objects that are both remote and local and are available on machines
+int test2b(void) {
+
+ unsigned int val, mid;
+ transrecord_t *myTrans;
+ unsigned int size;
+ objheader_t *header, *h1, *h2, *h3, *h4;
+ pthread_t thread_Listen;
+ pthread_attr_t attr;
+
+ dstmInit();
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+ //Create and Insert Oid 20
+ size = sizeof(objheader_t) + classsize[2] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ OID(header) = 20;
+ header->type = 2;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(OID(header), header);
+ mid = iptoMid("128.200.9.29");
+ lhashInsert(OID(header), mid);
+
+ //Create and Insert Oid 21
+ size = sizeof(objheader_t) + classsize[1] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ OID(header) = 21;
+ header->type = 1;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(OID(header), header);
+ mid = iptoMid("128.200.9.29");
+ lhashInsert(OID(header), mid);
+
+ //Create and Insert Oid 22
+ size = sizeof(objheader_t) + classsize[3] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ OID(header) = 22;
+ header->type = 3;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(OID(header), header);
+ mid = iptoMid("128.200.9.29");
+ lhashInsert(OID(header), mid);
+
+ //Inserting into lhashtable
+ mid = iptoMid("128.195.175.69"); //dw-1.eecs.uci.edu
+ lhashInsert(31, mid);
+ lhashInsert(32, mid);
+ lhashInsert(33, mid);
+
+ mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
+ //Inserting into lhashtable
+ lhashInsert(1, mid);
+ lhashInsert(2, mid);
+ lhashInsert(3, mid);
+ lhashInsert(4, mid);
+
+ pthread_create(&thread_Listen, &attr, dstmListen, NULL);
+
+ //Check if machine demsky is up and running
+ checkServer(mid, "128.200.9.10");
+ mid = iptoMid("128.195.175.69");
+ //Check if machine dw-1 is up and running
+ checkServer(mid, "128.195.175.69");
+
+ // Start Transaction
+ myTrans = transStart();
+
+ //read object 1 (found on demksy)
+ if((h1 = transRead(myTrans, 1)) == NULL){
+ printf("Object not found\n");
+ }
+ //read object 2 (found on demsky)
+ if((h2 = transRead(myTrans, 2)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ //read object 21 (found on local)
+ if((h3 = transRead(myTrans, 21)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ //read object 32 (found on dw-1)
+ if((h4 = transRead(myTrans, 32)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ pthread_join(thread_Listen, NULL);
+ return 0;
+
+}
+
+
+//Read objects when objects are not found in any participant
+int test3(void){
+ transrecord_t *record;
+ objheader_t *h1,*h2;
+
+ dstmInit();
+ record = transStart();
+ printf("DEBUG -> Init done\n");
+ //read object 11
+ if((h1 = transRead(record, 11)) == NULL){
+ printf("Object not found\n");
+ }
+ //read object 12
+ if((h2 = transRead(record, 12)) == NULL) {
+ printf("Object not found\n");
+ }
+ transCommit(record);
+
+ return 0;
+}
+
+//Read objects when some objects are found and other objects not found in any participant
+int test4(void) {
+ transrecord_t *record;
+ objheader_t *h1,*h2, *h3, *h4;
+
+ dstmInit();
+ record = transStart();
+ printf("DEBUG -> Init done\n");
+ //read object 1
+ if((h1 = transRead(record, 1)) == NULL){
+ printf("Object not found\n");
+ }
+ //read object 2
+ if((h2 = transRead(record, 2)) == NULL) {
+ printf("Object not found\n");
+ }
+ //read object 11
+ if((h3 = transRead(record, 11)) == NULL) {
+ printf("Object not found\n");
+ }
+ //read object 13
+ if((h4 = transRead(record, 13)) == NULL) {
+ printf("Object not found\n");
+ }
+ if((h1 != NULL) && (h2 != NULL) && (h3 != NULL) && h4 !=NULL) {
+ transCommit(record);
+ }else {
+ printf("Cannot complete this transaction\n");
+ }
+
+ return 0;
+}
+
+//Commit for transaction objects when the objs are part of other
+//transactions running simultaneously
+int test5(void) {
+ unsigned int val, mid;
+ transrecord_t *myTrans;
+ unsigned int size;
+ objheader_t *header, *h1, *h2, *h3, *h4, *h5, *h6;
+ pthread_t thread_Listen;
+ pthread_attr_t attr;
+
+ dstmInit();
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+ //Create and Insert Oid 20
+ size = sizeof(objheader_t) + classsize[2] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ OID(header) = 20;
+ header->type = 2;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(OID(header), header);
+ mid = iptoMid("128.200.9.29");
+ lhashInsert(OID(header), mid);
+
+ //Create and Insert Oid 21
+ size = sizeof(objheader_t) + classsize[1] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ OID(header) = 21;
+ header->type = 1;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(OID(header), header);
+ mid = iptoMid("128.200.9.29");
+ lhashInsert(OID(header), mid);
+
+ //Create and Insert Oid 22
+ size = sizeof(objheader_t) + classsize[3] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ OID(header) = 22;
+ header->type = 3;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(OID(header), header);
+ mid = iptoMid("128.200.9.29");
+ lhashInsert(OID(header), mid);
+
+ //Inserting into lhashtable
+ mid = iptoMid("128.195.175.69"); //dw-1.eecs.uci.edu
+ lhashInsert(31, mid);
+ lhashInsert(32, mid);
+ lhashInsert(33, mid);
+
+ mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
+ //Inserting into lhashtable
+ lhashInsert(1, mid);
+ lhashInsert(2, mid);
+ lhashInsert(3, mid);
+ lhashInsert(4, mid);
+
+ pthread_create(&thread_Listen, &attr, dstmListen, NULL);
+ //Check if machine demsky is up and running
+ checkServer(mid, "128.200.9.10");
+ mid = iptoMid("128.195.175.69");
+ //Check if machine dw-1 is up and running
+ checkServer(mid, "128.195.175.69");
+
+ // Start Transaction
+ myTrans = transStart();
+
+ //read object 1 (found on demksy)
+ if((h1 = transRead(myTrans, 1)) == NULL){
+ printf("Object not found\n");
+ }
+ //read object 2 (found on demksy)
+ if((h2 = transRead(myTrans,2)) == NULL){
+ printf("Object not found\n");
+ }
+ //read object 22 (found locally )
+ if((h3 = transRead(myTrans, 22)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ //Commit transaction
+ transCommit(myTrans);
+
+ pthread_join(thread_Listen, NULL);
+ return 0;
+}
+int test5a(void) {
+ unsigned int val, mid;
+ transrecord_t *myTrans;
+ unsigned int size;
+ objheader_t *header, *h1, *h2, *h3;
+ pthread_t thread_Listen;
+ pthread_attr_t attr;
+
+ dstmInit();
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+ //Create and Insert Oid 20
+ size = sizeof(objheader_t) + classsize[2] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ OID(header) = 20;
+ header->type = 2;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(OID(header), header);
+ mid = iptoMid("128.200.9.29");
+ lhashInsert(OID(header), mid);
+
+ //Create and Insert Oid 21
+ size = sizeof(objheader_t) + classsize[1] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ OID(header) = 21;
+ header->type = 1;
+ //read object 31 (found on dw-1)
+ if((h2 = transRead(myTrans, 31)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ //Commit transaction
+ transCommit(myTrans);
+
+ pthread_join(thread_Listen, NULL);
+ return 0;
+}
+int test5b(void) {
+ unsigned int val, mid;
+ transrecord_t *myTrans;
+ unsigned int size;
+ objheader_t *header, *h1, *h2, *h3;
+ pthread_t thread_Listen;
+ pthread_attr_t attr;
+
+ dstmInit();
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+ //Create and Insert Oid 20
+ size = sizeof(objheader_t) + classsize[2] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ OID(header) = 20;
+ header->type = 2;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(OID(header), header);
+ mid = iptoMid("128.200.9.29");
+ lhashInsert(OID(header), mid);
+
+ //Create and Insert Oid 21
+ size = sizeof(objheader_t) + classsize[1] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ OID(header) = 21;
+ header->type = 1;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(OID(header), header);
+ mid = iptoMid("128.200.9.29");
+ lhashInsert(OID(header), mid);
+
+ //Create and Insert Oid 22
+ size = sizeof(objheader_t) + classsize[3] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ OID(header) = 22;
+ header->type = 3;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(OID(header), header);
+ mid = iptoMid("128.200.9.29");
+ lhashInsert(OID(header), mid);
+
+ //Inserting into lhashtable
+ mid = iptoMid("128.195.175.69"); //dw-1.eecs.uci.edu
+ lhashInsert(31, mid);
+ lhashInsert(32, mid);
+ lhashInsert(33, mid);
+
+ mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
+ //Inserting into lhashtable
+ lhashInsert(1, mid);
+ lhashInsert(2, mid);
+ lhashInsert(3, mid);
+ lhashInsert(4, mid);
+
+ pthread_create(&thread_Listen, &attr, dstmListen, NULL);
+
+ //Check if machine demsky is up and running
+ checkServer(mid, "128.200.9.10");
+ mid = iptoMid("128.195.175.69");
+ //Check if machine dw-1 is up and running
+ checkServer(mid, "128.195.175.69");
+
+ // Start Transaction
+ myTrans = transStart();
+
+ //read object 1 (found on demksy)
+ if((h1 = transRead(myTrans, 1)) == NULL){
+ printf("Object not found\n");
+ }
+ //read object 31 (found on dw-1)
+ if((h2 = transRead(myTrans, 31)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ //read object 22 (found locally)
+ if((h3 = transRead(myTrans, 22)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ //Commit transaction
+ if((h1 != NULL) && (h2 != NULL) && (h3 != NULL))
+ transCommit(myTrans);
+ else
+ printf("Cannot complete this transaction \n");
+
+ pthread_join(thread_Listen, NULL);
+ return 0;
+}
+//Commit transactions on local and remote objects that are NOT a part of
+//any other transaction
+int test7(void) {
+ unsigned int val, mid;
+ transrecord_t *myTrans;
+ unsigned int size;
+ objheader_t *header, *h1, *h2, *h3;
+ pthread_t thread_Listen;
+ pthread_attr_t attr;
+
+ dstmInit();
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+ //Create and Insert Oid 20
+ size = sizeof(objheader_t) + classsize[2] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ OID(header) = 20;
+ header->type = 2;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(OID(header), header);
+ mid = iptoMid("128.200.9.29");
+ lhashInsert(OID(header), mid);
+
+ //Create and Insert Oid 21
+ size = sizeof(objheader_t) + classsize[1] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ OID(header) = 21;
+ header->type = 1;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(OID(header), header);
+ mid = iptoMid("128.200.9.29");
+ lhashInsert(OID(header), mid);
+
+ //Create and Insert Oid 22
+ size = sizeof(objheader_t) + classsize[3] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ OID(header) = 22;
+ header->type = 3;
+ header->version = 1;
+ header->rcount = 0; //? not sure how to handle this yet
+ header->status = 0;
+ header->status |= NEW;
+ mhashInsert(OID(header), header);
+ mid = iptoMid("128.200.9.29");
+ lhashInsert(OID(header), mid);
+
+ //Inserting into lhashtable
+ mid = iptoMid("128.195.175.69"); //dw-1.eecs.uci.edu
+ lhashInsert(31, mid);
+ lhashInsert(32, mid);
+ lhashInsert(33, mid);
+
+ mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
+ //Inserting into lhashtable
+ lhashInsert(1, mid);
+ lhashInsert(2, mid);
+ lhashInsert(3, mid);
+ lhashInsert(4, mid);
+
+ pthread_create(&thread_Listen, &attr, dstmListen, NULL);
+
+ //Check if machine demsky is up and running
+ checkServer(mid, "128.200.9.10");
+ mid = iptoMid("128.195.175.69");
+ //Check if machine dw-1 is up and running
+ checkServer(mid, "128.195.175.69");
+
+ // Start Transaction
+ myTrans = transStart();
+
+ //read object 3 (found on demksy)
+ if((h1 = transRead(myTrans, 3)) == NULL){
+ printf("Object not found\n");
+ }
+ //read object 32 (found on dw-1)
+ if((h2 = transRead(myTrans, 32)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ //read object 22 (found locally)
+ if((h3 = transRead(myTrans, 22)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ //Commit transaction
+ transCommit(myTrans);
+
+ pthread_join(thread_Listen, NULL);
+ return 0;
+}
--- /dev/null
+#include <pthread.h>
+#include "dstm.h"
+
+extern objstr_t *mainobjstore;
+int classsize[]={sizeof(int),sizeof(char),sizeof(short), sizeof(void *)};
+
+int main()
+{
+ test1();
+// test2();
+// test3();
+// test4();
+}
+
+void init_obj(objheader_t *h, unsigned int oid, unsigned short type, \
+ unsigned short version,\
+ unsigned short rcount, char status) {
+ h->oid = oid;
+ h->type = type;
+ h->version = version;
+ h->rcount = rcount;
+ h->status |= status;
+ return;
+}
+
+//Test case to create objects and do nothing else
+int test1() {
+ unsigned int val, mid;
+ unsigned int size;
+ transrecord_t *myTrans;
+ objheader_t *header;
+ pthread_t thread_Listen;
+ pthread_attr_t attr;
+
+ dstmInit();
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+ //Create and Insert Oid 31
+ size = sizeof(objheader_t) + classsize[2] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 31, 2, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.195.175.69");
+ lhashInsert(header->oid, mid);
+
+ //Create and Insert Oid 32
+ size = sizeof(objheader_t) + classsize[1] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 32, 1, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.195.175.69");
+ lhashInsert(header->oid, mid);
+
+ //Create and Insert Oid 33
+ size = sizeof(objheader_t) + classsize[0] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 33, 0, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.195.175.69");
+ lhashInsert(header->oid, mid);
+
+ //Inserting into lhashtable into d-3.eecs
+ mid = iptoMid("128.200.9.29"); //d-3.eecs.uci.edu
+ lhashInsert(20, mid);
+ lhashInsert(21, mid);
+ lhashInsert(22, mid);
+
+ mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
+ //Inserting into lhashtable of demsky.eecs
+ lhashInsert(1, mid);
+ lhashInsert(2, mid);
+ lhashInsert(3, mid);
+ lhashInsert(4, mid);
+
+ pthread_create(&thread_Listen, &attr, dstmListen, NULL);
+ //Check if machine demsky is up and running
+ checkServer(mid, "128.200.9.10");
+ mid = iptoMid("128.200.9.29");
+ //Check if machine d-3 is up and running
+ checkServer(mid, "128.200.9.29");
+
+ pthread_join(thread_Listen, NULL);
+
+ return 0;
+}
+
+//Read objects from remote and local machines ; NOTE objects are all available
+int test2() {
+
+ unsigned int val, mid;
+ unsigned int size;
+ transrecord_t *myTrans;
+ objheader_t *header, *h1, *h2, *h3, *h4;
+ pthread_t thread_Listen;
+ pthread_attr_t attr;
+
+ dstmInit();
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+ //Create and Insert Oid 31
+ size = sizeof(objheader_t) + classsize[2] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 31, 2, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.195.175.69");
+ lhashInsert(header->oid, mid);
+
+ //Create and Insert Oid 32
+ size = sizeof(objheader_t) + classsize[1] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 32, 1, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.195.175.69");
+ lhashInsert(header->oid, mid);
+
+ //Create and Insert Oid 33
+ size = sizeof(objheader_t) + classsize[0] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 33, 0, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.195.175.69");
+ lhashInsert(header->oid, mid);
+
+ //Inserting into lhashtable into d-3.eecs
+ mid = iptoMid("128.200.9.29"); //d-3.eecs.uci.edu
+ lhashInsert(20, mid);
+ lhashInsert(21, mid);
+ lhashInsert(22, mid);
+
+ mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
+ //Inserting into lhashtable of demsky.eecs
+ lhashInsert(1, mid);
+ lhashInsert(2, mid);
+ lhashInsert(3, mid);
+ lhashInsert(4, mid);
+
+ pthread_create(&thread_Listen, &attr, dstmListen, NULL);
+
+ //Check if machine demsky is up and running
+ checkServer(mid, "128.200.9.10");
+ mid = iptoMid("128.200.9.29");
+ //Check if machine d-2 is up and running
+ checkServer(mid, "128.200.9.29");
+
+ // Start Transaction
+ myTrans = transStart();
+
+ //read object 1 (found on demksy)
+ if((h1 = transRead(myTrans, 1)) == NULL){
+ printf("Object not found\n");
+ }
+
+ //read object 33 (found on local)
+ if((h2 = transRead(myTrans, 33)) == NULL){
+ printf("Object not found\n");
+ }
+
+ //read object 21 (found on d-3)
+ if((h3 = transRead(myTrans, 21)) == NULL){
+ printf("Object not found\n");
+ }
+
+ //read object 32 (found on local)
+ if((h4 = transRead(myTrans, 32)) == NULL){
+ printf("Object not found\n");
+ }
+
+ pthread_join(thread_Listen, NULL);
+
+ return 0;
+}
+
+int test3() {
+
+ unsigned int val, mid;
+ unsigned int size;
+ transrecord_t *myTrans;
+ objheader_t *header, *h1, *h2, *h3;
+ pthread_t thread_Listen;
+ pthread_attr_t attr;
+
+ dstmInit();
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+ //Create and Insert Oid 31
+ size = sizeof(objheader_t) + classsize[2] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 31, 2, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.195.175.69");
+ lhashInsert(header->oid, mid);
+
+ //Create and Insert Oid 32
+ size = sizeof(objheader_t) + classsize[1] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 32, 1, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.195.175.69");
+ lhashInsert(header->oid, mid);
+
+ //Create and Insert Oid 33
+ size = sizeof(objheader_t) + classsize[0] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 33, 0, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.195.175.69");
+ lhashInsert(header->oid, mid);
+
+ //Inserting into lhashtable into d-3.eecs
+ mid = iptoMid("128.200.9.29"); //d-3.eecs.uci.edu
+ lhashInsert(20, mid);
+ lhashInsert(21, mid);
+ lhashInsert(22, mid);
+
+ mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
+ //Inserting into lhashtable of demsky.eecs
+ lhashInsert(1, mid);
+ lhashInsert(2, mid);
+ lhashInsert(3, mid);
+ lhashInsert(4, mid);
+
+ pthread_create(&thread_Listen, &attr, dstmListen, NULL);
+
+ //Check if machine demsky is up and running
+ checkServer(mid, "128.200.9.10");
+ mid = iptoMid("128.200.9.29");
+ //Check if machine d-3 is up and running
+ checkServer(mid, "128.200.9.29");
+
+ // Start Transaction
+ myTrans = transStart();
+
+ //read object 4 (found on demksy)
+ if((h1 = transRead(myTrans, 4)) == NULL){
+ printf("Object not found\n");
+ }
+ //read object 33 (found on local)
+ if((h2 = transRead(myTrans, 33)) == NULL){
+ printf("Object not found\n");
+ }
+ //read object 20 (found on d-3)
+ if((h3 = transRead(myTrans, 20)) == NULL){
+ printf("Object not found\n");
+ }
+
+ //Commit transaction
+ transCommit(myTrans);
+
+ pthread_join(thread_Listen, NULL);
+
+ return 0;
+}
+//Commit transaction for some objects that are available and some that are
+//not available anywhere
+int test4() {
+ unsigned int val, mid;
+ unsigned int size;
+ transrecord_t *myTrans;
+ objheader_t *header, *h1, *h2, *h3, *h4;
+ pthread_t thread_Listen;
+ pthread_attr_t attr;
+
+ dstmInit();
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+ //Create and Insert Oid 31
+ size = sizeof(objheader_t) + classsize[2] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 31, 2, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.195.175.69");
+ lhashInsert(header->oid, mid);
+
+ //Create and Insert Oid 32
+ size = sizeof(objheader_t) + classsize[1] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 32, 1, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.195.175.69");
+ lhashInsert(header->oid, mid);
+
+ //Create and Insert Oid 33
+ size = sizeof(objheader_t) + classsize[0] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 33, 0, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.195.175.69");
+ lhashInsert(header->oid, mid);
+
+ //Inserting into lhashtable into d-3.eecs
+ mid = iptoMid("128.200.9.29"); //d-3.eecs.uci.edu
+ lhashInsert(20, mid);
+ lhashInsert(21, mid);
+ lhashInsert(22, mid);
+
+ mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
+ //Inserting into lhashtable of demsky.eecs
+ lhashInsert(1, mid);
+ lhashInsert(2, mid);
+ lhashInsert(3, mid);
+ lhashInsert(4, mid);
+
+ pthread_create(&thread_Listen, &attr, dstmListen, NULL);
+
+ //Check if machine demsky is up and running
+ checkServer(mid, "128.200.9.10");
+ mid = iptoMid("128.200.9.29");
+ //Check if machine d-2 is up and running
+ checkServer(mid, "128.200.9.29");
+
+ // Start Transaction
+ myTrans = transStart();
+
+ //read object 4 (found on demksy)
+ if((h1 = transRead(myTrans, 4)) == NULL){
+ printf("Object not found\n");
+ }
+ //read object 33 (found on local)
+ if((h2 = transRead(myTrans, 33)) == NULL){
+ printf("Object not found\n");
+ }
+ //read object 24 (found nowhere)
+ if((h3 = transRead(myTrans, 24)) == NULL){
+ printf("Object not found\n");
+ }
+ //read object 50 (found nowhere)
+ if((h4 = transRead(myTrans, 50)) == NULL){
+ printf("Object not found\n");
+ }
+
+ //Commit transaction
+ if((h1 != NULL) && (h2 != NULL) && (h3 != NULL) && (h4 !=NULL))
+ transCommit(myTrans);
+ else
+ printf("Cannot complete this transaction\n");
+
+ pthread_join(thread_Listen, NULL);
+ return 0;
+
+}
--- /dev/null
+#include <stdio.h>
+#include "dht.h"
+#include "clookup.h"
+
+#define NUM_ITEMS 100000
+
+int main()
+{
+ unsigned int key;
+ unsigned int val;
+ unsigned int vals[NUM_ITEMS];
+ int retval;
+ int error;
+ chashtable_t *localHash;
+
+ dhtInit(0x80C3AF45, DHT_NO_KEY_LIMIT);
+
+ localHash = chashCreate(HASH_SIZE, LOADFACTOR);
+ srandom(time(0));
+
+ for (key = 1; key < NUM_ITEMS; key++)
+ {
+ vals[key] = random();
+ }
+
+ sleep(5);
+
+ printf("testing dhtInsert() and dhtSearch()\n");
+
+ for (key = 0; key < NUM_ITEMS; key++)
+ {
+ dhtInsert(key, vals[key]);
+ }
+
+ error = 0;
+ for (key = 1; key < NUM_ITEMS; key++)
+ {
+ retval = dhtSearch(key, &val);
+ if (retval == 1)
+ {
+ printf("item not found: key = %d, expected val = %d\n", key, vals[key]);
+ error = 1;
+ }
+ else if (retval == -1)
+ {
+ printf("internal error: key = %d, expected val = %d\n", key, vals[key]);
+ error = 1;
+ }
+ else if (retval == 0)
+ {
+ if (vals[key] != val)
+ {
+ printf("unexpected value: key = %d, expected val = %d, val = %d\n", key, vals[key], val);
+ error = 1;
+ }
+ }
+ }
+ if (!error)
+ printf("test completed successfully\n");
+ else
+ printf("one or more errors occurred\n");
+
+ printf("(this currently fails if key = 0 OR val = 0, due to underlying hash table)\n");
+ printf("testing underlying hash table (clookup.h)\n");
+
+ for (key = 1; key < NUM_ITEMS; key++)
+ {
+ chashInsert(localHash, key, (void *)vals[key]);
+ }
+
+ error = 0;
+ for (key = 1; key < NUM_ITEMS; key++)
+ {
+ val = (unsigned int)chashSearch(localHash, key);
+ if ((void *)val == NULL)
+ {
+ printf("item not found: key = %d, expected val = %d\n", key, vals[key]);
+ error = 1;
+ }
+ else
+ {
+ if (vals[key] != val)
+ {
+ printf("unexpected value: key = %d, expected val = %d, val = %d\n", key, vals[key], val);
+ error = 1;
+ }
+ }
+ for (key = NUM_ITEMS; key < NUM_ITEMS + 20; key++)
+ {
+ val = (unsigned int)chashSearch(localHash, key);
+ if ((void *)val != NULL)
+ {
+ printf("error: returned value for key that wasn't inserted: key = %d, val = %d\n", key, val);
+ error = 1;
+ }
+ }
+ }
+
+ if (!error)
+ printf("test completed successfully\n");
+ else
+ printf("one or more errors occurred\n");
+
+ printf("testing dhtRemove(), removing half of the keys, and verifying that the other half is still there\n");
+
+ for (key = 0; key < NUM_ITEMS / 2; key++)
+ {
+ dhtRemove(key);
+ }
+ error = 0;
+ for (key = 0; key < NUM_ITEMS / 2; key++)
+ {
+ retval = dhtSearch(key, &val);
+ if (retval == 0)
+ {
+ printf("error: found removed item: key = %d, val = %d\n", key, val);
+ error = 1;
+ }
+ else if (retval == -1)
+ {
+ printf("internal error: key = %d, val = %d\n", key, val);
+ error = 1;
+ }
+ }
+ for (key = NUM_ITEMS / 2; key < NUM_ITEMS; key++)
+ {
+ retval = dhtSearch(key, &val);
+ if (retval == 1)
+ {
+ printf("item not found: key = %d, expected val = %d\n", key, vals[key]);
+ error = 1;
+ }
+ else if (retval == -1)
+ {
+ printf("internal error: key = %d, expected val = %d\n", key, vals[key]);
+ error = 1;
+ }
+ else if (retval == 0)
+ {
+ if (vals[key] != val)
+ {
+ printf("unexpected value: key = %d, expected val = %d, val = %d\n", key, vals[key], val);
+ error = 1;
+ }
+ }
+ }
+
+ if (!error)
+ printf("test completed successfully\n");
+ else
+ printf("one or more errors occurred\n");
+
+ sleep(5);
+
+ dhtExit();
+
+ return 0;
+}
+
--- /dev/null
+#include <stdio.h>
+#include "llookup.h"
+extern lhashtable_t llookup;
+
+main()
+{
+ int i, mid;
+
+ if (lhashCreate(10, 0.20) == 1) {
+ printf("lhashCreate error\n"); //creates hashtable
+ }
+ for (i = 1; i <= 7; i++) { // Checks the insert() and resize()
+ if (lhashInsert(10*i, i) == 1)
+ printf("lhashInsert error\n");
+ }
+
+ i = lhashRemove(10);//Delete first element in the hashtable
+ if(i == 1)
+ printf("lhashRemove error ");
+
+ for (i = 1; i <=7; i++) { // Check if it can search for all oids in hash table
+ mid = lhashSearch(10*i);
+ if (mid != i)
+ printf("lhashSearch error - mid = %d\n", mid);
+ else
+ printf("lhashSearch oid = %d mid = %d\n",10*i, mid);
+ }
+
+ i = lhashRemove(60);
+ if(i == 1)
+ printf("lhashRemove error ");
+
+ for (i = 1; i <= 7; i++) { //Prints all left over elements inside hash after deletion and prints error if element not found in hash
+ mid = lhashSearch(10*i);
+ if (mid != i)
+ printf("lhashSearch error - mid = %d\n", mid);
+ else
+ printf("lhashSearch oid = %d mid = %d\n",10*i, mid);
+ }
+
+ printf(" The total number of elements in table : %d\n", llookup.numelements);
+
+}
--- /dev/null
+#include <stdio.h>
+#include "mlookup.h"
+extern mhashtable_t mlookup;
+
+main()
+{
+ int i;
+ void *val;
+ val = NULL;
+
+ if (mhashCreate(10, 0.20) == 1) {
+ printf("mhashCreate error\n"); //creates hashtable
+ }
+ for (i = 1; i <= 7; i++) { // Checks the insert() and resize()
+ if (mhashInsert(10*i, &i) == 1)
+ printf("mhashInsert error\n");
+ }
+
+ i = mhashRemove(60);//Delete first element in the hashtable
+ if(i == 1)
+ printf("mhashRemove error ");
+
+ for (i = 1; i <=7; i++) { // Check if it can search for all oids in hash table
+ val = mhashSearch(10*i);
+ if (val != &i)
+ printf("mhashSearch error - val = %d\n", val);
+ else
+ printf("mhashSearch oid = %d val = %x\n",10*i, val);
+ }
+
+ i = mhashRemove(30);
+ if(i == 1)
+ printf("mhashRemove error ");
+
+ for (i = 1; i <= 7; i++) { //Prints all left over elements inside hash after deletion and prints error if element not found in hash
+ val = mhashSearch(10*i);
+ if (val != &i)
+ printf("mhashSearch error - val = %d\n", val);
+ else
+ printf("mhashSearch oid = %d val = %x\n",10*i, val);
+ }
+
+ printf("The total number of elements in table : %d\n", mlookup.numelements);
+
+}
--- /dev/null
+#include "dstm.h"
+
+#define NUMITEMS 1000000 //uses four object stores
+
+int main(void)
+{
+ objstr_t *myObjStr = objstrCreate(1048510);
+ int i;
+ int *j[NUMITEMS];
+ int data[NUMITEMS];
+ int fail = 0;
+
+ for (i = 0; i < NUMITEMS; i++)
+ {
+ j[i] = objstrAlloc(myObjStr, sizeof(int));
+ *j[i] = data[i] = i;
+ }
+ for (i = 0; i < NUMITEMS; i++)
+ {
+ if (data[i] != *j[i])
+ fail = 1;
+ }
+
+ if (fail)
+ printf("test failed\n");
+ else
+ printf("test succeeded\n");
+
+ objstrDelete(myObjStr);
+ return 0;
+}
+
--- /dev/null
+#include <pthread.h>
+#include "dstm.h"
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include "ip.h"
+
+extern objstr_t *mainobjstore;
+typedef struct testobj1 {
+ int x;
+ char z;
+} testobj1_t;
+
+typedef struct testobj2 {
+ char z[10];
+ char c;
+ testobj1_t *y;
+} testobj2_t;
+
+typedef struct testobj3 {
+ short p;
+ testobj1_t *q;
+ testobj2_t *r;
+} testobj3_t;
+
+typedef struct testobj4 {
+ int b;
+ void *q;
+ testobj3_t *a;
+} testobj4_t;
+
+typedef struct testobj5 {
+ testobj4_t *a;
+} testobj5_t;
+
+
+int classsize[]={sizeof(int),sizeof(char),sizeof(short), sizeof(void *), sizeof(testobj1_t),
+ sizeof(testobj2_t), sizeof(testobj3_t), sizeof(testobj4_t), sizeof(testobj5_t)};
+
+
+//int classsize[]={sizeof(int),sizeof(char),sizeof(short), sizeof(void *)};
+
+int test1(void);
+int test2(void);
+int test3(void);
+
+unsigned int createObjects(transrecord_t *record, unsigned short type) {
+ objheader_t *header, *tmp;
+ struct sockaddr_in antelope;
+ unsigned int size, mid;
+ size = sizeof(objheader_t) + classsize[type] ;
+ //Inserts in chashtable
+ header = transCreateObj(record, type);
+ tmp = (objheader_t *) objstrAlloc(mainobjstore, size);
+ memcpy(tmp, header, size);
+ mhashInsert(tmp->oid, tmp);
+ mid = iptoMid("128.200.9.10");
+ lhashInsert(tmp->oid, mid);
+ //Lock oid 3 object
+// if(tmp->oid == 3)
+// tmp->status |= LOCK;
+ return 0;
+}
+
+void init_obj(objheader_t *h, unsigned int oid, unsigned short type, \
+ unsigned short version,\
+ unsigned short rcount, char status) {
+ h->oid = oid;
+ h->type = type;
+ h->version = version;
+ h->rcount = rcount;
+ h->status |= status;
+ return;
+}
+
+
+int main()
+{
+// test1();
+// test3();
+ test4();
+}
+
+int test1()
+{
+ unsigned int val;
+ transrecord_t *myTrans;
+ pthread_t thread_Listen;
+
+ dstmInit();
+ pthread_create(&thread_Listen, NULL, dstmListen, NULL);
+ // Start Transaction
+ myTrans = transStart();
+
+ printf("Creating Transaction\n");
+ //Create Object1
+ if((val = createObjects(myTrans, 0)) != 0) {
+ printf("Error transCreateObj1");
+ }
+ //Create Object2
+ if((val = createObjects(myTrans, 1)) != 0) {
+ printf("Error transCreateObj2");
+ }
+ //Create Object3
+ if((val = createObjects(myTrans, 2)) != 0) {
+ printf("Error transCreateObj3");
+ }
+ //Create Object4
+ if((val = createObjects(myTrans, 3)) != 0) {
+ printf("Error transCreateObj4");
+ }
+ //Create Object5
+ if((val = createObjects(myTrans, 0)) != 0) {
+ printf("Error transCreateObj5");
+ }
+ //Create Object6
+ if((val = createObjects(myTrans, 1)) != 0) {
+ printf("Error transCreateObj6");
+ }
+ pthread_join(thread_Listen, NULL);
+ return 0;
+}
+
+int test2() {
+
+ unsigned int val, mid;
+ transrecord_t *myTrans;
+ pthread_t thread_Listen;
+
+ dstmInit();
+ mid = iptoMid("128.200.9.27"); //d-2.eecs.uci.edu
+ //Inserting into lhashtable
+ lhashInsert(20, mid);
+ lhashInsert(21, mid);
+ lhashInsert(22, mid);
+ lhashInsert(23, mid);
+ lhashInsert(30, mid);
+ lhashInsert(28, mid);
+ lhashInsert(29, mid);
+ pthread_create(&thread_Listen, NULL, dstmListen, NULL);
+ // Start Transaction
+ myTrans = transStart();
+
+ printf("Creating Transaction\n");
+ //Create Object1
+ if((val = createObjects(myTrans, 0)) != 0) {
+ printf("Error transCreateObj1");
+ }
+ //Create Object2
+ if((val = createObjects(myTrans, 1)) != 0) {
+ printf("Error transCreateObj2");
+ }
+ //Create Object3
+ if((val = createObjects(myTrans, 2)) != 0) {
+ printf("Error transCreateObj3");
+ }
+ //Create Object4
+ if((val = createObjects(myTrans, 3)) != 0) {
+ printf("Error transCreateObj4");
+ }
+ //Create Object5
+ if((val = createObjects(myTrans, 0)) != 0) {
+ printf("Error transCreateObj5");
+ }
+ //Create Object6
+ if((val = createObjects(myTrans, 1)) != 0) {
+ printf("Error transCreateObj6");
+ }
+ pthread_join(thread_Listen, NULL);
+}
+//Commit transaction with all locally available objects
+int test3() {
+ unsigned int val, mid;
+ transrecord_t *myTrans;
+ unsigned int size;
+ objheader_t *header;
+ pthread_t thread_Listen;
+ pthread_attr_t attr;
+ objheader_t *h1, *h2, *h3;//h1,h2,h3 from local
+
+ dstmInit();
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+ // Create and Insert Oid 1
+ size = sizeof(objheader_t) + classsize[0] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 1, 0, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.10");
+ lhashInsert(header->oid, mid);
+
+ // Create and Insert Oid 2
+ size = sizeof(objheader_t) + classsize[1] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 2, 1, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.10");
+ lhashInsert(header->oid, mid);
+
+
+ // Create and Insert Oid 3
+ size = sizeof(objheader_t) + classsize[2] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 3, 2, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.10");
+ lhashInsert(header->oid, mid);
+
+ // Create and Insert Oid 4
+ size = sizeof(objheader_t) + classsize[3] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 4, 3, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.10");
+ lhashInsert(header->oid, mid);
+
+ //Inserting into lhashtable
+ mid = iptoMid("128.195.175.70"); //dw-2.eecs.uci.edu
+ lhashInsert(20, mid);
+ lhashInsert(21, mid);
+ lhashInsert(22, mid);
+
+ mid = iptoMid("128.195.175.69"); //dw-1.eecs.uci.edu
+ //Inserting into lhashtable
+ lhashInsert(31, mid);
+ lhashInsert(32, mid);
+ lhashInsert(33, mid);
+ pthread_create(&thread_Listen, &attr, dstmListen, NULL);
+
+ //Check if machine dw-1 is up and running
+ checkServer(mid, "128.195.175.69");
+ mid = iptoMid("128.195.175.70");
+ //Check if machine dw-2 is up and running
+ checkServer(mid, "128.195.175.70");
+
+ // Start Transaction
+ myTrans = transStart();
+
+ //read object 1(present in local machine)
+ if((h1 = transRead(myTrans, 1)) == NULL){
+ printf("Object not found\n");
+ }
+ //read object 2present in local machine)
+ if((h2 = transRead(myTrans, 2)) == NULL) {
+ printf("Object not found\n");
+ }
+ //read object 3(present in local machine)
+ if((h3 = transRead(myTrans, 3)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ // Commit transaction
+ transCommit(myTrans);
+
+ pthread_join(thread_Listen, NULL);
+
+ return 0;
+}
+
+//Commit transaction with few locally available objects and other objects from machine d-1
+// and d-2
+int test4() {
+
+ unsigned int val, mid;
+ transrecord_t *myTrans;
+ unsigned int size;
+ objheader_t *header;
+ pthread_t thread_Listen;
+ pthread_attr_t attr;
+ objheader_t *h1, *h2, *h3, *h4;//h1,h2 from local ; h3 from d-1 , h-4 from d-2
+
+ dstmInit();
+ transInit();
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+ // Create and Insert Oid 1
+ size = sizeof(objheader_t) + classsize[0] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 1, 0, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.10");
+ lhashInsert(header->oid, mid);
+
+ // Create and Insert Oid 2
+ size = sizeof(objheader_t) + classsize[1] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 2, 1, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.10");
+ lhashInsert(header->oid, mid);
+
+
+ // Create and Insert Oid 3
+ size = sizeof(objheader_t) + classsize[2] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 3, 2, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.10");
+ lhashInsert(header->oid, mid);
+
+ // Create and Insert Oid 4
+ size = sizeof(objheader_t) + classsize[3] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 4, 3, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.10");
+ lhashInsert(header->oid, mid);
+
+ //Inserting into lhashtable
+ mid = iptoMid("128.195.175.70"); //dw-2.eecs.uci.edu
+ lhashInsert(20, mid);
+ lhashInsert(21, mid);
+ lhashInsert(22, mid);
+
+ mid = iptoMid("128.195.175.69"); //dw-1.eecs.uci.edu
+ //Inserting into lhashtable
+ lhashInsert(31, mid);
+ lhashInsert(32, mid);
+ lhashInsert(33, mid);
+
+ pthread_create(&thread_Listen, &attr, dstmListen, NULL);
+ //Check if machine dw-1 is up and running
+ checkServer(mid, "128.195.175.69");
+ mid = iptoMid("128.195.175.70");
+ //Check if machine dw-2 is up and running
+ checkServer(mid, "128.195.175.70");
+
+ // Start Transaction
+ myTrans = transStart();
+
+ //read object 1(present in local machine)
+ if((h1 = transRead(myTrans, 2)) == NULL){
+ printf("Object not found\n");
+ }
+
+ //read object 2present in local machine)
+ if((h2 = transRead(myTrans, 1)) == NULL) {
+ printf("Object not found\n");
+ }
+ //read object 31(present in dw-1 machine)
+ if((h3 = transRead(myTrans, 31)) == NULL) {
+ printf("Object not found\n");
+ }
+ //read object 21(present in dw-2 machine)
+ if((h4 = transRead(myTrans, 21)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ // Commit transaction
+ transCommit(myTrans);
+
+ pthread_join(thread_Listen, NULL);
+
+ return 0;
+}
+int test5() {
+
+ unsigned int val, mid;
+ transrecord_t *myTrans;
+ unsigned int size;
+ objheader_t *header;
+ pthread_t thread_Listen;
+ pthread_attr_t attr;
+ objheader_t *h1, *h2, *h3, *h4, *h5;
+
+ dstmInit();
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+ mid = iptoMid("128.200.9.27"); //d-2.eecs.uci.edu
+ //Inserting into lhashtable
+ lhashInsert(20, mid);
+ lhashInsert(21, mid);
+ lhashInsert(22, mid);
+
+ mid = iptoMid("128.200.9.26"); //d-1.eecs.uci.edu
+ //Inserting into lhashtable
+ lhashInsert(31, mid);
+ lhashInsert(32, mid);
+ lhashInsert(33, mid);
+ pthread_create(&thread_Listen, &attr, dstmListen, NULL);
+
+ printf("DEBUG -> mid = %d\n", mid);
+ checkServer(mid, "128.200.9.26");
+ mid = iptoMid("128.200.9.27");
+ printf("DEBUG -> mid = %d\n", mid);
+ checkServer(mid, "128.200.9.27");
+
+ // Start Transaction
+ myTrans = transStart();
+
+ // Create and Insert Oid 1
+ size = sizeof(objheader_t) + classsize[0] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 1, 0, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.10");
+ lhashInsert(header->oid, mid);
+
+ // Create and Insert Oid 2
+ size = sizeof(objheader_t) + classsize[1] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 2, 1, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.10");
+ lhashInsert(header->oid, mid);
+
+
+ // Create and Insert Oid 3
+ size = sizeof(objheader_t) + classsize[2] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 3, 2, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.10");
+ lhashInsert(header->oid, mid);
+
+ // Create and Insert Oid 4
+ size = sizeof(objheader_t) + classsize[3] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 4, 3, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.10");
+ lhashInsert(header->oid, mid);
+
+ // Create and Insert Oid 5
+ size = sizeof(objheader_t) + classsize[0] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 5, 0, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.10");
+ lhashInsert(header->oid, mid);
+
+ // Create and Insert Oid 6
+ size = sizeof(objheader_t) + classsize[1] ;
+ header = (objheader_t *) objstrAlloc(mainobjstore, size);
+ init_obj(header, 6, 1, 1, 0, NEW);
+ mhashInsert(header->oid, header);
+ mid = iptoMid("128.200.9.10");
+ lhashInsert(header->oid, mid);
+
+ //read object 1(present in local machine)
+ if((h1 = transRead(myTrans, 1)) == NULL){
+ printf("Object not found\n");
+ }
+ //read object 2present in local machine)
+ if((h2 = transRead(myTrans, 2)) == NULL) {
+ printf("Object not found\n");
+ }
+ //read object 3(present in local machine)
+ if((h3 = transRead(myTrans, 3)) == NULL) {
+ printf("Object not found\n");
+ }
+ //read object 31 (present in d-1. eecs)
+ if((h4 = transRead(myTrans, 31)) == NULL) {
+ printf("Object not found\n");
+ }
+ //read object 20 (present in d-2. eecs)
+ if((h5 = transRead(myTrans, 20)) == NULL) {
+ printf("Object not found\n");
+ }
+
+ transCommit(myTrans);
+
+ pthread_join(thread_Listen, NULL);
+
+ return 0;
+}
+++ /dev/null
-#include <pthread.h>
-#include "dstm.h"
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include "ip.h"
-
-extern objstr_t *mainobjstore;
-typedef struct testobj1 {
- int x;
- char z;
-} testobj1_t;
-
-typedef struct testobj2 {
- char z[10];
- char c;
- testobj1_t *y;
-} testobj2_t;
-
-typedef struct testobj3 {
- short p;
- testobj1_t *q;
- testobj2_t *r;
-} testobj3_t;
-
-typedef struct testobj4 {
- int b;
- void *q;
- testobj3_t *a;
-} testobj4_t;
-
-typedef struct testobj5 {
- testobj4_t *a;
-} testobj5_t;
-
-
-int classsize[]={sizeof(int),sizeof(char),sizeof(short), sizeof(void *), sizeof(testobj1_t),
- sizeof(testobj2_t), sizeof(testobj3_t), sizeof(testobj4_t), sizeof(testobj5_t)};
-
-
-//int classsize[]={sizeof(int),sizeof(char),sizeof(short), sizeof(void *)};
-
-int test1(void);
-int test2(void);
-int test3(void);
-
-unsigned int createObjects(transrecord_t *record, unsigned short type) {
- objheader_t *header, *tmp;
- struct sockaddr_in antelope;
- unsigned int size, mid;
- size = sizeof(objheader_t) + classsize[type] ;
- //Inserts in chashtable
- header = transCreateObj(record, type);
- tmp = (objheader_t *) objstrAlloc(mainobjstore, size);
- memcpy(tmp, header, size);
- mhashInsert(tmp->oid, tmp);
- mid = iptoMid("128.200.9.10");
- lhashInsert(tmp->oid, mid);
- //Lock oid 3 object
-// if(tmp->oid == 3)
-// tmp->status |= LOCK;
- return 0;
-}
-
-void init_obj(objheader_t *h, unsigned int oid, unsigned short type, \
- unsigned short version,\
- unsigned short rcount, char status) {
- h->oid = oid;
- h->type = type;
- h->version = version;
- h->rcount = rcount;
- h->status |= status;
- return;
-}
-
-
-int main()
-{
-// test1();
-// test3();
- test4();
-}
-
-int test1()
-{
- unsigned int val;
- transrecord_t *myTrans;
- pthread_t thread_Listen;
-
- dstmInit();
- pthread_create(&thread_Listen, NULL, dstmListen, NULL);
- // Start Transaction
- myTrans = transStart();
-
- printf("Creating Transaction\n");
- //Create Object1
- if((val = createObjects(myTrans, 0)) != 0) {
- printf("Error transCreateObj1");
- }
- //Create Object2
- if((val = createObjects(myTrans, 1)) != 0) {
- printf("Error transCreateObj2");
- }
- //Create Object3
- if((val = createObjects(myTrans, 2)) != 0) {
- printf("Error transCreateObj3");
- }
- //Create Object4
- if((val = createObjects(myTrans, 3)) != 0) {
- printf("Error transCreateObj4");
- }
- //Create Object5
- if((val = createObjects(myTrans, 0)) != 0) {
- printf("Error transCreateObj5");
- }
- //Create Object6
- if((val = createObjects(myTrans, 1)) != 0) {
- printf("Error transCreateObj6");
- }
- pthread_join(thread_Listen, NULL);
- return 0;
-}
-
-int test2() {
-
- unsigned int val, mid;
- transrecord_t *myTrans;
- pthread_t thread_Listen;
-
- dstmInit();
- mid = iptoMid("128.200.9.27"); //d-2.eecs.uci.edu
- //Inserting into lhashtable
- lhashInsert(20, mid);
- lhashInsert(21, mid);
- lhashInsert(22, mid);
- lhashInsert(23, mid);
- lhashInsert(30, mid);
- lhashInsert(28, mid);
- lhashInsert(29, mid);
- pthread_create(&thread_Listen, NULL, dstmListen, NULL);
- // Start Transaction
- myTrans = transStart();
-
- printf("Creating Transaction\n");
- //Create Object1
- if((val = createObjects(myTrans, 0)) != 0) {
- printf("Error transCreateObj1");
- }
- //Create Object2
- if((val = createObjects(myTrans, 1)) != 0) {
- printf("Error transCreateObj2");
- }
- //Create Object3
- if((val = createObjects(myTrans, 2)) != 0) {
- printf("Error transCreateObj3");
- }
- //Create Object4
- if((val = createObjects(myTrans, 3)) != 0) {
- printf("Error transCreateObj4");
- }
- //Create Object5
- if((val = createObjects(myTrans, 0)) != 0) {
- printf("Error transCreateObj5");
- }
- //Create Object6
- if((val = createObjects(myTrans, 1)) != 0) {
- printf("Error transCreateObj6");
- }
- pthread_join(thread_Listen, NULL);
-}
-//Commit transaction with all locally available objects
-int test3() {
- unsigned int val, mid;
- transrecord_t *myTrans;
- unsigned int size;
- objheader_t *header;
- pthread_t thread_Listen;
- pthread_attr_t attr;
- objheader_t *h1, *h2, *h3;//h1,h2,h3 from local
-
- dstmInit();
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
- // Create and Insert Oid 1
- size = sizeof(objheader_t) + classsize[0] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 1, 0, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.10");
- lhashInsert(header->oid, mid);
-
- // Create and Insert Oid 2
- size = sizeof(objheader_t) + classsize[1] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 2, 1, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.10");
- lhashInsert(header->oid, mid);
-
-
- // Create and Insert Oid 3
- size = sizeof(objheader_t) + classsize[2] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 3, 2, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.10");
- lhashInsert(header->oid, mid);
-
- // Create and Insert Oid 4
- size = sizeof(objheader_t) + classsize[3] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 4, 3, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.10");
- lhashInsert(header->oid, mid);
-
- //Inserting into lhashtable
- mid = iptoMid("128.195.175.70"); //dw-2.eecs.uci.edu
- lhashInsert(20, mid);
- lhashInsert(21, mid);
- lhashInsert(22, mid);
-
- mid = iptoMid("128.195.175.69"); //dw-1.eecs.uci.edu
- //Inserting into lhashtable
- lhashInsert(31, mid);
- lhashInsert(32, mid);
- lhashInsert(33, mid);
- pthread_create(&thread_Listen, &attr, dstmListen, NULL);
-
- //Check if machine dw-1 is up and running
- checkServer(mid, "128.195.175.69");
- mid = iptoMid("128.195.175.70");
- //Check if machine dw-2 is up and running
- checkServer(mid, "128.195.175.70");
-
- // Start Transaction
- myTrans = transStart();
-
- //read object 1(present in local machine)
- if((h1 = transRead(myTrans, 1)) == NULL){
- printf("Object not found\n");
- }
- //read object 2present in local machine)
- if((h2 = transRead(myTrans, 2)) == NULL) {
- printf("Object not found\n");
- }
- //read object 3(present in local machine)
- if((h3 = transRead(myTrans, 3)) == NULL) {
- printf("Object not found\n");
- }
-
- // Commit transaction
- transCommit(myTrans);
-
- pthread_join(thread_Listen, NULL);
-
- return 0;
-}
-
-//Commit transaction with few locally available objects and other objects from machine d-1
-// and d-2
-int test4() {
-
- unsigned int val, mid;
- transrecord_t *myTrans;
- unsigned int size;
- objheader_t *header;
- pthread_t thread_Listen;
- pthread_attr_t attr;
- objheader_t *h1, *h2, *h3, *h4;//h1,h2 from local ; h3 from d-1 , h-4 from d-2
-
- dstmInit();
- transInit();
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
- // Create and Insert Oid 1
- size = sizeof(objheader_t) + classsize[0] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 1, 0, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.10");
- lhashInsert(header->oid, mid);
-
- // Create and Insert Oid 2
- size = sizeof(objheader_t) + classsize[1] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 2, 1, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.10");
- lhashInsert(header->oid, mid);
-
-
- // Create and Insert Oid 3
- size = sizeof(objheader_t) + classsize[2] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 3, 2, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.10");
- lhashInsert(header->oid, mid);
-
- // Create and Insert Oid 4
- size = sizeof(objheader_t) + classsize[3] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 4, 3, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.10");
- lhashInsert(header->oid, mid);
-
- //Inserting into lhashtable
- mid = iptoMid("128.195.175.70"); //dw-2.eecs.uci.edu
- lhashInsert(20, mid);
- lhashInsert(21, mid);
- lhashInsert(22, mid);
-
- mid = iptoMid("128.195.175.69"); //dw-1.eecs.uci.edu
- //Inserting into lhashtable
- lhashInsert(31, mid);
- lhashInsert(32, mid);
- lhashInsert(33, mid);
-
- pthread_create(&thread_Listen, &attr, dstmListen, NULL);
- //Check if machine dw-1 is up and running
- checkServer(mid, "128.195.175.69");
- mid = iptoMid("128.195.175.70");
- //Check if machine dw-2 is up and running
- checkServer(mid, "128.195.175.70");
-
- // Start Transaction
- myTrans = transStart();
-
- //read object 1(present in local machine)
- if((h1 = transRead(myTrans, 2)) == NULL){
- printf("Object not found\n");
- }
-
- //read object 2present in local machine)
- if((h2 = transRead(myTrans, 1)) == NULL) {
- printf("Object not found\n");
- }
- //read object 31(present in dw-1 machine)
- if((h3 = transRead(myTrans, 31)) == NULL) {
- printf("Object not found\n");
- }
- //read object 21(present in dw-2 machine)
- if((h4 = transRead(myTrans, 21)) == NULL) {
- printf("Object not found\n");
- }
-
- // Commit transaction
- transCommit(myTrans);
-
- pthread_join(thread_Listen, NULL);
-
- return 0;
-}
-int test5() {
-
- unsigned int val, mid;
- transrecord_t *myTrans;
- unsigned int size;
- objheader_t *header;
- pthread_t thread_Listen;
- pthread_attr_t attr;
- objheader_t *h1, *h2, *h3, *h4, *h5;
-
- dstmInit();
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
- mid = iptoMid("128.200.9.27"); //d-2.eecs.uci.edu
- //Inserting into lhashtable
- lhashInsert(20, mid);
- lhashInsert(21, mid);
- lhashInsert(22, mid);
-
- mid = iptoMid("128.200.9.26"); //d-1.eecs.uci.edu
- //Inserting into lhashtable
- lhashInsert(31, mid);
- lhashInsert(32, mid);
- lhashInsert(33, mid);
- pthread_create(&thread_Listen, &attr, dstmListen, NULL);
-
- printf("DEBUG -> mid = %d\n", mid);
- checkServer(mid, "128.200.9.26");
- mid = iptoMid("128.200.9.27");
- printf("DEBUG -> mid = %d\n", mid);
- checkServer(mid, "128.200.9.27");
-
- // Start Transaction
- myTrans = transStart();
-
- // Create and Insert Oid 1
- size = sizeof(objheader_t) + classsize[0] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 1, 0, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.10");
- lhashInsert(header->oid, mid);
-
- // Create and Insert Oid 2
- size = sizeof(objheader_t) + classsize[1] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 2, 1, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.10");
- lhashInsert(header->oid, mid);
-
-
- // Create and Insert Oid 3
- size = sizeof(objheader_t) + classsize[2] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 3, 2, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.10");
- lhashInsert(header->oid, mid);
-
- // Create and Insert Oid 4
- size = sizeof(objheader_t) + classsize[3] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 4, 3, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.10");
- lhashInsert(header->oid, mid);
-
- // Create and Insert Oid 5
- size = sizeof(objheader_t) + classsize[0] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 5, 0, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.10");
- lhashInsert(header->oid, mid);
-
- // Create and Insert Oid 6
- size = sizeof(objheader_t) + classsize[1] ;
- header = (objheader_t *) objstrAlloc(mainobjstore, size);
- init_obj(header, 6, 1, 1, 0, NEW);
- mhashInsert(header->oid, header);
- mid = iptoMid("128.200.9.10");
- lhashInsert(header->oid, mid);
-
- //read object 1(present in local machine)
- if((h1 = transRead(myTrans, 1)) == NULL){
- printf("Object not found\n");
- }
- //read object 2present in local machine)
- if((h2 = transRead(myTrans, 2)) == NULL) {
- printf("Object not found\n");
- }
- //read object 3(present in local machine)
- if((h3 = transRead(myTrans, 3)) == NULL) {
- printf("Object not found\n");
- }
- //read object 31 (present in d-1. eecs)
- if((h4 = transRead(myTrans, 31)) == NULL) {
- printf("Object not found\n");
- }
- //read object 20 (present in d-2. eecs)
- if((h5 = transRead(myTrans, 20)) == NULL) {
- printf("Object not found\n");
- }
-
- transCommit(myTrans);
-
- pthread_join(thread_Listen, NULL);
-
- return 0;
-}