adding a test case
[IRC.git] / Robust / src / Runtime / DSTM / interface / tests / testclient.c
1 #include<stdio.h>
2 #include<pthread.h>
3 #include "dstm.h"
4 #include "llookup.h"
5 #include "ip.h"
6
7 #define LISTEN_PORT 2156
8
9 extern objstr_t *mainobjstore;
10 typedef struct testobj1 {
11         int x;
12         char z;
13 } testobj1_t;
14
15 typedef struct testobj2 {
16         char z[10];
17         char c;
18         testobj1_t *y;
19 } testobj2_t;
20
21 typedef struct testobj3 {
22         short p;
23         testobj1_t *q;
24         testobj2_t *r;
25 } testobj3_t;
26
27 typedef struct testobj4 {
28         int b;
29         void *q;
30         testobj3_t *a;
31 } testobj4_t;
32
33 typedef struct testobj5 {
34         testobj4_t *a;
35 } testobj5_t;
36
37
38 int classsize[]={sizeof(int),sizeof(char),sizeof(short), sizeof(void *), sizeof(testobj1_t), 
39         sizeof(testobj2_t), sizeof(testobj3_t), sizeof(testobj4_t), sizeof(testobj5_t)};        
40
41 unsigned int createObjects(transrecord_t *record) {
42         objheader_t *header, *tmp;
43         unsigned int size, mid;
44         int i = 0;
45         for(i = 20 ; i< 23; i++) {
46                 size = sizeof(objheader_t) + classsize[i-20] ;
47                 tmp = (objheader_t *)objstrAlloc(record->cache, size);
48                 tmp->oid = i;
49                 tmp->type = (i-20);
50                 tmp->version = 1;
51                 tmp->rcount = 0; //? not sure how to handle this yet
52                 tmp->status = 0;
53                 tmp->status |= NEW;
54                 chashInsert(record->lookupTable, tmp->oid, tmp);
55                 header = (objheader_t *) objstrAlloc(mainobjstore, size);
56                 memcpy(header, tmp, size);
57                 mhashInsert(header->oid, header);
58                 mid = iptoMid("128.200.9.27");//machine d-2
59                 printf("DEBUG -> createObjects mid is %x\n", mid);
60                 lhashInsert(header->oid, mid);
61         }
62         //      printf("Insert oid = %d at address %x\n",tmp->oid, tmp);
63         size = sizeof(objheader_t) + classsize[0] ;
64         header = (objheader_t *) objstrAlloc(mainobjstore, size);
65         header->oid = 30;
66         header->type = 0;
67         header->version = 1;
68         header->rcount = 0; //? not sure how to handle this yet
69         header->status = 0;
70         header->status |= NEW;
71         mhashInsert(header->oid, header);
72         mid = iptoMid("128.200.9.27");
73         lhashInsert(header->oid, mid);
74         size = sizeof(objheader_t) + classsize[1] ;
75         header = (objheader_t *) objstrAlloc(mainobjstore, size);
76         header->oid = 28;
77         header->type = 1;
78         header->version = 1;
79         header->rcount = 0; //? not sure how to handle this yet
80         header->status = 0;
81         header->status |= LOCK;
82         mhashInsert(header->oid, header);
83         mid = iptoMid("128.200.9.27");
84         lhashInsert(header->oid, mid);
85         size = sizeof(objheader_t) + classsize[2] ;
86         header = (objheader_t *) objstrAlloc(mainobjstore, size);
87         header->oid = 29;
88         header->type = 2;
89         header->version = 1;
90         header->rcount = 0; //? not sure how to handle this yet
91         header->status = 0;
92         header->status |= LOCK;
93         mhashInsert(header->oid, header);
94         mid = iptoMid("128.200.9.27");
95         lhashInsert(header->oid, mid);
96         return 0;
97 }
98
99 int main() 
100 {
101 //      test2();
102 //      test3();
103 //      test4();
104         test5();
105 //      test5a();
106 //      test2a();
107 //      test2b();
108 //      test7();
109
110 }
111
112 int test1(void) {
113
114         transrecord_t *record;
115         objheader_t *h1,*h2,*h3,*h4,*h5, *h6;
116
117         dstmInit();
118         record = transStart();
119         printf("DEBUG -> Init done\n");
120         h1 = transRead(record, 1);
121         printf("oid = %d\tsize = %d\n", h1->oid,classsize[h1->type]);
122         h3 = transRead(record, 3);
123         printf("oid = %d\tsize = %d\n", h3->oid,classsize[h3->type]);
124         h4 = transRead(record, 4);
125         printf("oid = %d\tsize = %d\n", h4->oid,classsize[h4->type]);
126         h2 = transRead(record, 2);
127         printf("oid = %d\tsize = %d\n", h2->oid,classsize[h2->type]);
128         h4 = transRead(record, 4);
129         printf("oid = %d\tsize = %d\n", h4->oid,classsize[h4->type]);
130         h3 = transRead(record, 3);
131         printf("oid = %d\tsize = %d\n", h3->oid,classsize[h3->type]);
132         h5 = transRead(record, 5);
133         printf("oid = %d\tsize = %d\n", h5->oid,classsize[h5->type]);
134 //      getRemoteObj(&record, 0,1);
135 }
136
137 int test2(void) {
138
139         transrecord_t *record;
140         objheader_t *h1,*h2,*h3,*h4,*h5, *h6;
141
142         dstmInit();
143         record = transStart();
144
145         lhashInsert(1,1);
146         lhashInsert(2,1);
147         lhashInsert(3,1);
148         lhashInsert(4,1);
149         lhashInsert(5,1);
150         lhashInsert(6,1);
151         printf("DEBUG -> Init done\n");
152         h1 = transRead(record, 1);
153         lhashInsert(h1->oid, 1);
154         h2 = transRead(record, 2);
155         lhashInsert(h2->oid, 1);
156         h3 = transRead(record, 3);
157         lhashInsert(h3->oid, 1);
158         h4 = transRead(record, 4);
159         lhashInsert(h4->oid, 1);
160 //      h4->status |= DIRTY;
161         h5 = transRead(record, 5);
162         lhashInsert(h5->oid, 1);
163         h6 = transRead(record, 6);
164         lhashInsert(h6->oid, 1);
165 //      h6->status |= DIRTY;
166         
167         transCommit(record);
168
169         return 0;
170 }
171
172 //Read objects when objects are found in remote location
173 int test2a(void) {
174          unsigned int val, mid;
175          transrecord_t *myTrans;
176          unsigned int size;
177          objheader_t *header, *h1, *h2;
178          pthread_t thread_Listen;
179          pthread_attr_t attr;
180
181          dstmInit();
182          pthread_attr_init(&attr);
183          pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
184
185          //Create and Insert Oid 20
186          size = sizeof(objheader_t) + classsize[2] ;
187          header = (objheader_t *) objstrAlloc(mainobjstore, size);
188          header->oid = 20;
189          header->type = 2;
190          header->version = 1;
191          header->rcount = 0; //? not sure how to handle this yet
192          header->status = 0;
193          header->status |= NEW;
194          mhashInsert(header->oid, header);
195          mid = iptoMid("128.200.9.27");
196          lhashInsert(header->oid, mid);
197
198          //Create and Insert Oid 21
199          size = sizeof(objheader_t) + classsize[1] ;
200          header = (objheader_t *) objstrAlloc(mainobjstore, size);
201          header->oid = 21;
202          header->type = 1;
203          header->version = 1;
204          header->rcount = 0; //? not sure how to handle this yet
205          header->status = 0;
206          header->status |= NEW;
207          mhashInsert(header->oid, header);
208          mid = iptoMid("128.200.9.27");
209          lhashInsert(header->oid, mid);
210
211          //Create and Insert Oid 22
212          size = sizeof(objheader_t) + classsize[3] ;
213          header = (objheader_t *) objstrAlloc(mainobjstore, size);
214          header->oid = 22;
215          header->type = 3;
216          header->version = 1;
217          header->rcount = 0; //? not sure how to handle this yet
218          header->status = 0;
219          header->status |= NEW;
220          mhashInsert(header->oid, header);
221          mid = iptoMid("128.200.9.27");
222          lhashInsert(header->oid, mid);
223
224          //Inserting into lhashtable
225          mid = iptoMid("128.200.9.26"); //d-1.eecs.uci.edu
226          lhashInsert(31, mid);
227          lhashInsert(32, mid);
228
229          mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
230          //Inserting into lhashtable
231          lhashInsert(1, mid);
232          lhashInsert(2, mid);
233          lhashInsert(3, mid);
234          lhashInsert(4, mid);
235
236          pthread_create(&thread_Listen, &attr, dstmListen, NULL);
237
238          //Check if machine demsky is up and running
239          checkServer(mid, "128.200.9.10");
240          mid = iptoMid("128.200.9.26");
241          //Check if machine d-1 is up and running
242          checkServer(mid, "128.200.9.26");
243
244          // Start Transaction    
245          myTrans = transStart();
246
247          sleep(2);
248          //read object 1
249          if((h1 = transRead(myTrans, 1)) == NULL){
250                  printf("Object not found\n");
251          }
252          //read object 2
253          if((h2 = transRead(myTrans, 2)) == NULL) {
254                  printf("Object not found\n");
255          }
256
257          pthread_join(thread_Listen, NULL);
258          return 0;
259 }
260
261 //Read objects that are both remote and local and are available on machines
262 int test2b(void) {
263
264         unsigned int val, mid;
265         transrecord_t *myTrans;
266         unsigned int size;
267         objheader_t *header, *h1, *h2, *h3, *h4;
268         pthread_t thread_Listen;
269         pthread_attr_t attr;
270
271         dstmInit();
272         pthread_attr_init(&attr);
273         pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
274
275         //Create and Insert Oid 20
276         size = sizeof(objheader_t) + classsize[2] ;
277         header = (objheader_t *) objstrAlloc(mainobjstore, size);
278         header->oid = 20;
279         header->type = 2;
280         header->version = 1;
281         header->rcount = 0; //? not sure how to handle this yet
282         header->status = 0;
283         header->status |= NEW;
284         mhashInsert(header->oid, header);
285         mid = iptoMid("128.200.9.27");
286         lhashInsert(header->oid, mid);
287
288         //Create and Insert Oid 21
289         size = sizeof(objheader_t) + classsize[1] ;
290         header = (objheader_t *) objstrAlloc(mainobjstore, size);
291         header->oid = 21;
292         header->type = 1;
293         header->version = 1;
294         header->rcount = 0; //? not sure how to handle this yet
295         header->status = 0;
296         header->status |= NEW;
297         mhashInsert(header->oid, header);
298         mid = iptoMid("128.200.9.27");
299         lhashInsert(header->oid, mid);
300
301         //Create and Insert Oid 22
302         size = sizeof(objheader_t) + classsize[3] ;
303         header = (objheader_t *) objstrAlloc(mainobjstore, size);
304         header->oid = 22;
305         header->type = 3;
306         header->version = 1;
307         header->rcount = 0; //? not sure how to handle this yet
308         header->status = 0;
309         header->status |= NEW;
310         mhashInsert(header->oid, header);
311         mid = iptoMid("128.200.9.27");
312         lhashInsert(header->oid, mid);
313
314         //Inserting into lhashtable
315         mid = iptoMid("128.200.9.26"); //d-1.eecs.uci.edu
316         lhashInsert(31, mid);
317         lhashInsert(32, mid);
318         lhashInsert(33, mid);
319
320         mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
321         //Inserting into lhashtable
322         lhashInsert(1, mid);
323         lhashInsert(2, mid);
324         lhashInsert(3, mid);
325         lhashInsert(4, mid);
326
327         pthread_create(&thread_Listen, &attr, dstmListen, NULL);
328
329         //Check if machine demsky is up and running
330         checkServer(mid, "128.200.9.10");
331         mid = iptoMid("128.200.9.26");
332         //Check if machine d-1 is up and running
333         checkServer(mid, "128.200.9.26");
334
335         // Start Transaction    
336         myTrans = transStart();
337
338         //sleep(2);
339         //read object 1 (found on demksy)
340         if((h1 = transRead(myTrans, 1)) == NULL){
341                 printf("Object not found\n");
342         }
343         //read object 2 (found on demsky)
344         if((h2 = transRead(myTrans, 2)) == NULL) {
345                 printf("Object not found\n");
346         }
347         
348         //read object 21 (found on local)
349         if((h3 = transRead(myTrans, 21)) == NULL) {
350                 printf("Object not found\n");
351         }
352         
353         //read object 32 (found on d-1)
354         if((h4 = transRead(myTrans, 32)) == NULL) {
355                 printf("Object not found\n");
356         }
357
358         pthread_join(thread_Listen, NULL);
359         return 0;
360
361 }
362
363
364 //Read objects when objects are not found in  any participant 
365 int test3(void){
366         transrecord_t *record;
367         objheader_t *h1,*h2;
368
369         dstmInit();
370         record = transStart();
371         printf("DEBUG -> Init done\n");
372         //read object 11
373         if((h1 = transRead(record, 11)) == NULL){
374                 printf("Object not found\n");
375         }
376         //read object 12
377         if((h2 = transRead(record, 12)) == NULL) {
378                 printf("Object not found\n");
379         }
380         transCommit(record);
381
382         return 0;
383 }
384
385 //Read objects when some objects are found and other objects not found in  any participant 
386 int test4(void) {
387         transrecord_t *record;
388         objheader_t *h1,*h2, *h3, *h4;
389
390         dstmInit();
391         record = transStart();
392         printf("DEBUG -> Init done\n");
393         //read object 1
394         if((h1 = transRead(record, 1)) == NULL){
395                 printf("Object not found\n");
396         }
397         //read object 2
398         if((h2 = transRead(record, 2)) == NULL) {
399                 printf("Object not found\n");
400         }
401         //read object 11
402         if((h3 = transRead(record, 11)) == NULL) {
403                 printf("Object not found\n");
404         }
405         //read object 13
406         if((h4 = transRead(record, 13)) == NULL) {
407                 printf("Object not found\n");
408         }
409         if((h1 != NULL) && (h2 != NULL) && (h3 != NULL) && h4 !=NULL) { 
410                 transCommit(record);
411         }else {
412                 printf("Cannot complete this transaction\n");
413         }
414
415         return 0;
416 }
417
418 //Commit for transaction objects when the objs are part of other 
419 //transactions running simultaneously
420 int test5(void) {
421         unsigned int val, mid;
422         transrecord_t *myTrans;
423         unsigned int size;
424         objheader_t *header, *h1, *h2, *h3, *h4, *h5, *h6;
425         pthread_t thread_Listen;
426         pthread_attr_t attr;
427
428         dstmInit();
429         pthread_attr_init(&attr);
430         pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
431
432         //Create and Insert Oid 20
433         size = sizeof(objheader_t) + classsize[2] ;
434         header = (objheader_t *) objstrAlloc(mainobjstore, size);
435         header->oid = 20;
436         header->type = 2;
437         header->version = 1;
438         header->rcount = 0; //? not sure how to handle this yet
439         header->status = 0;
440         header->status |= NEW;
441         mhashInsert(header->oid, header);
442         mid = iptoMid("128.200.9.27");
443         lhashInsert(header->oid, mid);
444
445         //Create and Insert Oid 21
446         size = sizeof(objheader_t) + classsize[1] ;
447         header = (objheader_t *) objstrAlloc(mainobjstore, size);
448         header->oid = 21;
449         header->type = 1;
450         header->version = 1;
451         header->rcount = 0; //? not sure how to handle this yet
452         header->status = 0;
453         header->status |= NEW;
454         mhashInsert(header->oid, header);
455         mid = iptoMid("128.200.9.27");
456         lhashInsert(header->oid, mid);
457
458         //Create and Insert Oid 22
459         size = sizeof(objheader_t) + classsize[3] ;
460         header = (objheader_t *) objstrAlloc(mainobjstore, size);
461         header->oid = 22;
462         header->type = 3;
463         header->version = 1;
464         header->rcount = 0; //? not sure how to handle this yet
465         header->status = 0;
466         header->status |= NEW;
467         mhashInsert(header->oid, header);
468         mid = iptoMid("128.200.9.27");
469         lhashInsert(header->oid, mid);
470
471         //Inserting into lhashtable
472         mid = iptoMid("128.200.9.26"); //d-1.eecs.uci.edu
473         lhashInsert(31, mid);
474         lhashInsert(32, mid);
475         lhashInsert(33, mid);
476
477         mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
478         //Inserting into lhashtable
479         lhashInsert(1, mid);
480         lhashInsert(2, mid);
481         lhashInsert(3, mid);
482         lhashInsert(4, mid);
483
484         pthread_create(&thread_Listen, &attr, dstmListen, NULL);
485
486         //Check if machine demsky is up and running
487         checkServer(mid, "128.200.9.10");
488         mid = iptoMid("128.200.9.26");
489         //Check if machine d-1 is up and running
490         checkServer(mid, "128.200.9.26");
491
492         // Start Transaction    
493         myTrans = transStart();
494
495         //read object 1 (found on demksy)
496         if((h1 = transRead(myTrans, 1)) == NULL){
497                 printf("Object not found\n");
498         }
499         //read object 31 (found on d-1)
500         if((h2 = transRead(myTrans, 31)) == NULL) {
501                 printf("Object not found\n");
502         }
503         
504         //read object 22 (found locally)
505         if((h3 = transRead(myTrans, 22)) == NULL) {
506                 printf("Object not found\n");
507         }
508         
509         //read object 2 (found on demsky)
510         if((h4 = transRead(myTrans, 2)) == NULL) {
511                 printf("Object not found\n");
512         }
513         
514         //read object 21 (found locally)
515         if((h5 = transRead(myTrans, 21)) == NULL) {
516                 printf("Object not found\n");
517         }
518         
519         //read object 32 (found on d-2)
520         if((h6 = transRead(myTrans, 32)) == NULL) {
521                 printf("Object not found\n");
522         }
523
524         //Commit transaction
525         if((h1 != NULL) && (h2 != NULL) && (h3 != NULL) && (h4 !=NULL) && (h5 != NULL) && (h6 != NULL))
526                 transCommit(myTrans);
527         else
528                 printf("Cannot complete this transaction \n");
529
530         pthread_join(thread_Listen, NULL);
531         return 0;
532 }
533 int test5a(void) {
534         unsigned int val, mid;
535         transrecord_t *myTrans;
536         unsigned int size;
537         objheader_t *header, *h1, *h2, *h3;
538         pthread_t thread_Listen;
539         pthread_attr_t attr;
540
541         dstmInit();
542         pthread_attr_init(&attr);
543         pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
544
545         //Create and Insert Oid 20
546         size = sizeof(objheader_t) + classsize[2] ;
547         header = (objheader_t *) objstrAlloc(mainobjstore, size);
548         header->oid = 20;
549         header->type = 2;
550         header->version = 1;
551         header->rcount = 0; //? not sure how to handle this yet
552         header->status = 0;
553         header->status |= NEW;
554         mhashInsert(header->oid, header);
555         mid = iptoMid("128.200.9.27");
556         lhashInsert(header->oid, mid);
557
558         //Create and Insert Oid 21
559         size = sizeof(objheader_t) + classsize[1] ;
560         header = (objheader_t *) objstrAlloc(mainobjstore, size);
561         header->oid = 21;
562         header->type = 1;
563         header->version = 1;
564         header->rcount = 0; //? not sure how to handle this yet
565         header->status = 0;
566         header->status |= NEW;
567         mhashInsert(header->oid, header);
568         mid = iptoMid("128.200.9.27");
569         lhashInsert(header->oid, mid);
570
571         //Create and Insert Oid 22
572         size = sizeof(objheader_t) + classsize[3] ;
573         header = (objheader_t *) objstrAlloc(mainobjstore, size);
574         header->oid = 22;
575         header->type = 3;
576         header->version = 1;
577         header->rcount = 0; //? not sure how to handle this yet
578         header->status = 0;
579         header->status |= NEW;
580         mhashInsert(header->oid, header);
581         mid = iptoMid("128.200.9.27");
582         lhashInsert(header->oid, mid);
583
584         //Inserting into lhashtable
585         mid = iptoMid("128.200.9.26"); //d-1.eecs.uci.edu
586         lhashInsert(31, mid);
587         lhashInsert(32, mid);
588         lhashInsert(33, mid);
589
590         mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
591         //Inserting into lhashtable
592         lhashInsert(1, mid);
593         lhashInsert(2, mid);
594         lhashInsert(3, mid);
595         lhashInsert(4, mid);
596
597         pthread_create(&thread_Listen, &attr, dstmListen, NULL);
598
599         //Check if machine demsky is up and running
600         checkServer(mid, "128.200.9.10");
601         mid = iptoMid("128.200.9.26");
602         //Check if machine d-1 is up and running
603         checkServer(mid, "128.200.9.26");
604
605         // Start Transaction    
606         myTrans = transStart();
607
608         //read object 1 (found on demksy)
609         if((h1 = transRead(myTrans, 1)) == NULL){
610                 printf("Object not found\n");
611         }
612         //read object 31 (found on d-1)
613         if((h2 = transRead(myTrans, 32)) == NULL) {
614                 printf("Object not found\n");
615         }
616         
617         //read object 22 (found locally)
618         if((h3 = transRead(myTrans, 22)) == NULL) {
619                 printf("Object not found\n");
620         }
621         
622         //Commit transaction
623         if((h1 != NULL) && (h2 != NULL) && (h3 != NULL))
624                 transCommit(myTrans);
625         else
626                 printf("Cannot complete this transaction \n");
627
628         pthread_join(thread_Listen, NULL);
629         return 0;
630 }
631
632 int test6(void) {
633         transrecord_t *record;
634         objheader_t *header;
635         unsigned int size, mid;
636         pthread_t thread_Listen;
637         pthread_attr_t attr;
638         objheader_t *h1,*h2, *h3, *h4, *h5, *h6;
639         int tmpsd;
640
641         dstmInit();
642         pthread_attr_init(&attr);
643         pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
644         //pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
645
646         record = transStart();
647         //printf("DEBUG -> Init done\n");
648         mid = iptoMid("128.200.9.10");// Machine demsky.eecs.uci.edu    
649         lhashInsert(1,mid);
650         lhashInsert(2,mid);
651         lhashInsert(3,mid);
652         lhashInsert(4,mid);
653         lhashInsert(5,mid);
654         lhashInsert(6,mid);
655         
656         mid = iptoMid("128.200.9.26");// Machine demsky.eecs.uci.edu    
657         lhashInsert(31,mid);
658         lhashInsert(32,mid);
659         lhashInsert(33,mid);
660         
661         pthread_create(&thread_Listen, &attr, dstmListen, NULL);
662         
663         checkServer(mid, "128.200.9.26");
664         mid = iptoMid("128.200.9.10");
665         checkServer(mid, "128.200.9.10");
666
667         //Create and Insert Oid 20
668         size = sizeof(objheader_t) + classsize[2] ;
669         header = (objheader_t *) objstrAlloc(mainobjstore, size);
670         header->oid = 20;
671         header->type = 2;
672         header->version = 1;
673         header->rcount = 0; //? not sure how to handle this yet
674         header->status = 0;
675         header->status |= NEW;
676         mhashInsert(header->oid, header);
677         mid = iptoMid("128.200.9.27");
678         lhashInsert(header->oid, mid);
679
680         //Create and Insert Oid 21
681         size = sizeof(objheader_t) + classsize[1] ;
682         header = (objheader_t *) objstrAlloc(mainobjstore, size);
683         header->oid = 21;
684         header->type = 1;
685         header->version = 1;
686         header->rcount = 0; //? not sure how to handle this yet
687         header->status = 0;
688         header->status |= NEW;
689         mhashInsert(header->oid, header);
690         mid = iptoMid("128.200.9.27");
691         lhashInsert(header->oid, mid);
692         sleep(3);       
693         //read object 1  //from demsky
694         if((h1 = transRead(record, 1)) == NULL){
695                 printf("Object not found\n");
696         }
697         //read object 2
698         if((h2 = transRead(record, 2)) == NULL) {
699                 printf("Object not found\n");
700         }
701         //read object 31 //Found in d-1
702         if((h2 = transRead(record, 31)) == NULL) {
703                 printf("Object not found\n");
704         }
705         //read object 32 //Found in d-1
706         if((h2 = transRead(record, 32)) == NULL) {
707                 printf("Object not found\n");
708         }
709         //read object 20(present in local machine)
710         if((h3 = transRead(record, 20)) == NULL) {
711                 printf("Object not found\n");
712         }
713         //read object 21(present in local machine)
714         if((h4 = transRead(record, 21)) == NULL) {
715                 printf("Object not found\n");
716         }
717         transCommit(record);
718         pthread_join(thread_Listen, NULL);
719         return 0;
720 }
721 //Commit transactions on local and remote objects that are NOT a part of 
722 //any other transaction
723 int test7(void) {
724         unsigned int val, mid;
725         transrecord_t *myTrans;
726         unsigned int size;
727         objheader_t *header, *h1, *h2, *h3;
728         pthread_t thread_Listen;
729         pthread_attr_t attr;
730
731         dstmInit();
732         pthread_attr_init(&attr);
733         pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
734
735         //Create and Insert Oid 20
736         size = sizeof(objheader_t) + classsize[2] ;
737         header = (objheader_t *) objstrAlloc(mainobjstore, size);
738         header->oid = 20;
739         header->type = 2;
740         header->version = 1;
741         header->rcount = 0; //? not sure how to handle this yet
742         header->status = 0;
743         header->status |= NEW;
744         mhashInsert(header->oid, header);
745         mid = iptoMid("128.200.9.27");
746         lhashInsert(header->oid, mid);
747
748         //Create and Insert Oid 21
749         size = sizeof(objheader_t) + classsize[1] ;
750         header = (objheader_t *) objstrAlloc(mainobjstore, size);
751         header->oid = 21;
752         header->type = 1;
753         header->version = 1;
754         header->rcount = 0; //? not sure how to handle this yet
755         header->status = 0;
756         header->status |= NEW;
757         mhashInsert(header->oid, header);
758         mid = iptoMid("128.200.9.27");
759         lhashInsert(header->oid, mid);
760
761         //Create and Insert Oid 22
762         size = sizeof(objheader_t) + classsize[3] ;
763         header = (objheader_t *) objstrAlloc(mainobjstore, size);
764         header->oid = 22;
765         header->type = 3;
766         header->version = 1;
767         header->rcount = 0; //? not sure how to handle this yet
768         header->status = 0;
769         header->status |= NEW;
770         mhashInsert(header->oid, header);
771         mid = iptoMid("128.200.9.27");
772         lhashInsert(header->oid, mid);
773
774         //Inserting into lhashtable
775         mid = iptoMid("128.200.9.26"); //d-1.eecs.uci.edu
776         lhashInsert(31, mid);
777         lhashInsert(32, mid);
778         lhashInsert(33, mid);
779
780         mid = iptoMid("128.200.9.10"); //demsky.eecs.uci.edu
781         //Inserting into lhashtable
782         lhashInsert(1, mid);
783         lhashInsert(2, mid);
784         lhashInsert(3, mid);
785         lhashInsert(4, mid);
786
787         pthread_create(&thread_Listen, &attr, dstmListen, NULL);
788
789         //Check if machine demsky is up and running
790         checkServer(mid, "128.200.9.10");
791         mid = iptoMid("128.200.9.26");
792         //Check if machine d-1 is up and running
793         checkServer(mid, "128.200.9.26");
794
795         // Start Transaction    
796         myTrans = transStart();
797
798         //read object 3 (found on demksy)
799         if((h1 = transRead(myTrans, 3)) == NULL){
800                 printf("Object not found\n");
801         }
802         //read object 32 (found on d-1)
803         if((h2 = transRead(myTrans, 32)) == NULL) {
804                 printf("Object not found\n");
805         }
806         
807         //read object 22 (found locally)
808         if((h3 = transRead(myTrans, 22)) == NULL) {
809                 printf("Object not found\n");
810         }
811         
812         //Commit transaction
813         transCommit(myTrans);
814
815         pthread_join(thread_Listen, NULL);
816         return 0;
817 }