+
+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, *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);
+// pthread_create(&thread_Listen, NULL, 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 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");
+ }
+
+ */
+ // 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;
+}