}
srcObj = mhashSearch(oid);
h = (objheader_t *) srcObj;
- size = sizeof(objheader_t) + sizeof(classsize[h->type]);
+ size = sizeof(objheader_t) + sizeof(classsize[TYPE(h)]);
if (h == NULL) {
ctrl = OBJECT_NOT_FOUND;
if(send((int)acceptfd, &ctrl, sizeof(char), MSG_NOSIGNAL) < sizeof(char)) {
for(i = 0; i< fixed->nummod; i++) {
tmp_header = (objheader_t *)ptr;
tmp_header->rcount = 1;
- ptr += sizeof(objheader_t) + classsize[tmp_header->type];
+ ptr += sizeof(objheader_t) + classsize[TYPE(tmp_header)];
}
/* Unlock objects that was locked due to this transaction */
for(i = 0; i< transinfo->numlocked; i++) {
version = *((short *)(objread + incr));
} else {//Objs modified
headptr = (objheader_t *) ptr;
- oid = headptr->oid;
+ oid = OID(headptr);
oidmod[objmod] = oid;//Array containing modified oids
objmod++;
version = headptr->version;
- ptr += sizeof(objheader_t) + classsize[headptr->type];
+ ptr += sizeof(objheader_t) + classsize[TYPE(headptr)];
}
/* Check if object is still present in the machine since the beginning of TRANS_REQUEST */
if ((mobj = mhashSearch(oid)) == NULL) {/* Obj not found */
/* Save the oids not found and number of oids not found for later use */
- //oidnotfound[objnotfound] = ((objheader_t *)mobj)->oid;
+ //oidnotfound[objnotfound] = OID(((objheader_t *)mobj));
oidnotfound[objnotfound] = oid;
objnotfound++;
} else { /* If Obj found in machine (i.e. has not moved) */
randomdelay();
/* Save all object oids that are locked on this machine during this transaction request call */
- oidlocked[objlocked] = ((objheader_t *)mobj)->oid;
+ oidlocked[objlocked] = OID(((objheader_t *)mobj));
objlocked++;
if (version == ((objheader_t *)mobj)->version) { /* Check if versions match */
v_matchnolock++;
printf("DEBUG -> removing object oid = %d\n", transinfo->objmod[i]);
mhashRemove(transinfo->objmod[i]);
mhashInsert(transinfo->objmod[i], (transinfo->modptr + offset));
- offset += sizeof(objheader_t) + classsize[header->type];
+ offset += sizeof(objheader_t) + classsize[TYPE(header)];
/* Update object version number */
header = (objheader_t *) mhashSearch(transinfo->objmod[i]);
/* send the oid, it's size, it's header and data */
header = (char *) mobj;
head = (objheader_t *) header;
- size = sizeof(objheader_t) + sizeof(classsize[head->type]);
+ size = sizeof(objheader_t) + sizeof(classsize[TYPE(head)]);
*(buffer + index) = OBJECT_FOUND;
index += sizeof(char);
memcpy(buffer+index, &oid, sizeof(unsigned int));
} else {/* Obj Found */
/* send the oid, it's size, it's header and data */
head = (objheader_t *) header;
- size = sizeof(objheader_t) + sizeof(classsize[head->type]);
+ size = sizeof(objheader_t) + sizeof(classsize[TYPE(head)]);
*(buffer + index) = OBJECT_FOUND;
index += sizeof(char);
memcpy(buffer+index, &oid, sizeof(unsigned int));
record = transStart();
printf("DEBUG -> Init done\n");
h1 = transRead(record, 1);
- printf("oid = %d\tsize = %d\n", h1->oid,classsize[h1->type]);
+ printf("oid = %d\tsize = %d\n", OID(h1),classsize[h1->type]);
h3 = transRead(record, 3);
- printf("oid = %d\tsize = %d\n", h3->oid,classsize[h3->type]);
+ printf("oid = %d\tsize = %d\n", OID(h3),classsize[h3->type]);
h4 = transRead(record, 4);
- printf("oid = %d\tsize = %d\n", h4->oid,classsize[h4->type]);
+ printf("oid = %d\tsize = %d\n", OID(h4),classsize[h4->type]);
h2 = transRead(record, 2);
- printf("oid = %d\tsize = %d\n", h2->oid,classsize[h2->type]);
+ printf("oid = %d\tsize = %d\n", OID(h2),classsize[h2->type]);
h4 = transRead(record, 4);
- printf("oid = %d\tsize = %d\n", h4->oid,classsize[h4->type]);
+ printf("oid = %d\tsize = %d\n", OID(h4),classsize[h4->type]);
h3 = transRead(record, 3);
- printf("oid = %d\tsize = %d\n", h3->oid,classsize[h3->type]);
+ printf("oid = %d\tsize = %d\n", OID(h3),classsize[h3->type]);
h5 = transRead(record, 5);
- printf("oid = %d\tsize = %d\n", h5->oid,classsize[h5->type]);
+ printf("oid = %d\tsize = %d\n", OID(h5),classsize[h5->type]);
}
int test2(void) {
lhashInsert(6,1);
printf("DEBUG -> Init done\n");
h1 = transRead(record, 1);
- lhashInsert(h1->oid, 1);
+ lhashInsert(OID(h1), 1);
h2 = transRead(record, 2);
- lhashInsert(h2->oid, 1);
+ lhashInsert(OID(h2), 1);
h3 = transRead(record, 3);
- lhashInsert(h3->oid, 1);
+ lhashInsert(OID(h3), 1);
h4 = transRead(record, 4);
- lhashInsert(h4->oid, 1);
+ lhashInsert(OID(h4), 1);
h5 = transRead(record, 5);
- lhashInsert(h5->oid, 1);
+ lhashInsert(OID(h5), 1);
h6 = transRead(record, 6);
- lhashInsert(h6->oid, 1);
+ lhashInsert(OID(h6), 1);
transCommit(record);
//Create and Insert Oid 20
size = sizeof(objheader_t) + classsize[2] ;
header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 20;
+ 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(header->oid, header);
+ mhashInsert(OID(header), header);
mid = iptoMid("128.200.9.29");
- lhashInsert(header->oid, mid);
+ lhashInsert(OID(header), mid);
//Create and Insert Oid 21
size = sizeof(objheader_t) + classsize[1] ;
header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 21;
+ 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(header->oid, header);
+ mhashInsert(OID(header), header);
mid = iptoMid("128.200.9.29");
- lhashInsert(header->oid, mid);
+ lhashInsert(OID(header), mid);
//Create and Insert Oid 22
size = sizeof(objheader_t) + classsize[3] ;
header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 22;
+ 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(header->oid, header);
+ mhashInsert(OID(header), header);
mid = iptoMid("128.200.9.29");
- lhashInsert(header->oid, mid);
+ lhashInsert(OID(header), mid);
//Inserting into lhashtable
mid = iptoMid("128.195.175.69"); //dw-1.eecs.uci.edu
//Create and Insert Oid 20
size = sizeof(objheader_t) + classsize[2] ;
header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 20;
+ 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(header->oid, header);
+ mhashInsert(OID(header), header);
mid = iptoMid("128.200.9.29");
- lhashInsert(header->oid, mid);
+ lhashInsert(OID(header), mid);
//Create and Insert Oid 21
size = sizeof(objheader_t) + classsize[1] ;
header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 21;
+ 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(header->oid, header);
+ mhashInsert(OID(header), header);
mid = iptoMid("128.200.9.29");
- lhashInsert(header->oid, mid);
+ lhashInsert(OID(header), mid);
//Create and Insert Oid 22
size = sizeof(objheader_t) + classsize[3] ;
header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 22;
+ 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(header->oid, header);
+ mhashInsert(OID(header), header);
mid = iptoMid("128.200.9.29");
- lhashInsert(header->oid, mid);
+ lhashInsert(OID(header), mid);
//Inserting into lhashtable
mid = iptoMid("128.195.175.69"); //dw-1.eecs.uci.edu
//Create and Insert Oid 20
size = sizeof(objheader_t) + classsize[2] ;
header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 20;
+ 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(header->oid, header);
+ mhashInsert(OID(header), header);
mid = iptoMid("128.200.9.29");
- lhashInsert(header->oid, mid);
+ lhashInsert(OID(header), mid);
//Create and Insert Oid 21
size = sizeof(objheader_t) + classsize[1] ;
header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 21;
+ 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(header->oid, header);
+ mhashInsert(OID(header), header);
mid = iptoMid("128.200.9.29");
- lhashInsert(header->oid, mid);
+ lhashInsert(OID(header), mid);
//Create and Insert Oid 22
size = sizeof(objheader_t) + classsize[3] ;
header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 22;
+ 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(header->oid, header);
+ mhashInsert(OID(header), header);
mid = iptoMid("128.200.9.29");
- lhashInsert(header->oid, mid);
+ lhashInsert(OID(header), mid);
//Inserting into lhashtable
mid = iptoMid("128.195.175.69"); //dw-1.eecs.uci.edu
//Create and Insert Oid 20
size = sizeof(objheader_t) + classsize[2] ;
header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 20;
+ 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(header->oid, header);
+ mhashInsert(OID(header), header);
mid = iptoMid("128.200.9.29");
- lhashInsert(header->oid, mid);
+ lhashInsert(OID(header), mid);
//Create and Insert Oid 21
size = sizeof(objheader_t) + classsize[1] ;
header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 21;
+ OID(header) = 21;
header->type = 1;
//read object 31 (found on dw-1)
if((h2 = transRead(myTrans, 31)) == NULL) {
//Create and Insert Oid 20
size = sizeof(objheader_t) + classsize[2] ;
header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 20;
+ 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(header->oid, header);
+ mhashInsert(OID(header), header);
mid = iptoMid("128.200.9.29");
- lhashInsert(header->oid, mid);
+ lhashInsert(OID(header), mid);
//Create and Insert Oid 21
size = sizeof(objheader_t) + classsize[1] ;
header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 21;
+ 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(header->oid, header);
+ mhashInsert(OID(header), header);
mid = iptoMid("128.200.9.29");
- lhashInsert(header->oid, mid);
+ lhashInsert(OID(header), mid);
//Create and Insert Oid 22
size = sizeof(objheader_t) + classsize[3] ;
header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 22;
+ 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(header->oid, header);
+ mhashInsert(OID(header), header);
mid = iptoMid("128.200.9.29");
- lhashInsert(header->oid, mid);
+ lhashInsert(OID(header), mid);
//Inserting into lhashtable
mid = iptoMid("128.195.175.69"); //dw-1.eecs.uci.edu
//Create and Insert Oid 20
size = sizeof(objheader_t) + classsize[2] ;
header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 20;
+ 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(header->oid, header);
+ mhashInsert(OID(header), header);
mid = iptoMid("128.200.9.29");
- lhashInsert(header->oid, mid);
+ lhashInsert(OID(header), mid);
//Create and Insert Oid 21
size = sizeof(objheader_t) + classsize[1] ;
header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 21;
+ 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(header->oid, header);
+ mhashInsert(OID(header), header);
mid = iptoMid("128.200.9.29");
- lhashInsert(header->oid, mid);
+ lhashInsert(OID(header), mid);
//Create and Insert Oid 22
size = sizeof(objheader_t) + classsize[3] ;
header = (objheader_t *) objstrAlloc(mainobjstore, size);
- header->oid = 22;
+ 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(header->oid, header);
+ mhashInsert(OID(header), header);
mid = iptoMid("128.200.9.29");
- lhashInsert(header->oid, mid);
+ lhashInsert(OID(header), mid);
//Inserting into lhashtable
mid = iptoMid("128.195.175.69"); //dw-1.eecs.uci.edu
} else if ((objheader = (objheader_t *) mhashSearch(oid)) != NULL) {
/* Look up in machine lookup table and copy into cache*/
tmp = mhashSearch(oid);
- size = sizeof(objheader_t)+classsize[tmp->type];
+ size = sizeof(objheader_t)+classsize[TYPE(tmp)];
objcopy = objstrAlloc(record->cache, size);
memcpy(objcopy, (void *)objheader, size);
/* Insert into cache's lookup table */
- chashInsert(record->lookupTable, objheader->oid, objcopy);
+ chashInsert(record->lookupTable, OID(objheader), objcopy);
return(objcopy);
} else if((tmp = (objheader_t *) prehashSearch(oid)) != NULL) { /* Look up in prefetch cache */
found = 1;
- size = sizeof(objheader_t)+classsize[tmp->type];
+ size = sizeof(objheader_t)+classsize[TYPE(tmp)];
objcopy = objstrAlloc(record->cache, size);
memcpy(objcopy, (void *)tmp, size);
/* Insert into cache's lookup table */
- chashInsert(record->lookupTable, tmp->oid, objcopy);
+ chashInsert(record->lookupTable, OID(tmp), objcopy);
return(objcopy);
} else { /* If not found anywhere, then block until object appears in prefetch cache */
pthread_mutex_lock(&pflookup.lock);
/* Check Prefetch cache again */
if((tmp = (objheader_t *) prehashSearch(oid)) != NULL) { /* Look up in prefetch cache */
found = 1;
- size = sizeof(objheader_t)+classsize[tmp->type];
+ size = sizeof(objheader_t)+classsize[TYPE(tmp)];
objcopy = objstrAlloc(record->cache, size);
memcpy(objcopy, (void *)tmp, size);
/* Insert into cache's lookup table */
- chashInsert(record->lookupTable, tmp->oid, objcopy);
+ chashInsert(record->lookupTable, OID(tmp), objcopy);
return(objcopy);
} else {
pthread_mutex_unlock(&pflookup.lock);
objheader_t *transCreateObj(transrecord_t *record, unsigned short type)
{
objheader_t *tmp = (objheader_t *) objstrAlloc(record->cache, (sizeof(objheader_t) + classsize[type]));
- tmp->oid = getNewOID();
- tmp->type = type;
+ OID(tmp) = getNewOID();
+ TYPE(tmp) = type;
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);
+ chashInsert(record->lookupTable, OID(tmp), tmp);
return tmp;
}
for(i = 0; i < tdata->buffer->f.nummod ; i++) {
int size;
headeraddr = chashSearch(tdata->rec->lookupTable, tdata->buffer->oidmod[i]);
- size=sizeof(objheader_t)+classsize[headeraddr->type];
+ size=sizeof(objheader_t)+classsize[TYPE(headeraddr)];
if (send(sd, headeraddr, size, MSG_NOSIGNAL) < size) {
perror("Error sending obj modified for thread\n");
return NULL;
version = *((short *)(localtdata->tdata->buffer->objread + incr));
} else {//Objs modified
headptr = (objheader_t *) ptr;
- oid = headptr->oid;
+ oid = OID(headptr);
oidmod[objmod] = oid;//Array containing modified oids
objmod++;
version = headptr->version;
- ptr += sizeof(objheader_t) + classsize[headptr->type];
+ ptr += sizeof(objheader_t) + classsize[TYPE(headptr)];
}
/* Check if object is still present in the machine since the beginning of TRANS_REQUEST */
if ((mobj = mhashSearch(oid)) == NULL) {/* Obj not found */
/* Save the oids not found and number of oids not found for later use */
- oidnotfound[objnotfound] = ((objheader_t *)mobj)->oid;
+ oidnotfound[objnotfound] = OID(((objheader_t *)mobj));
objnotfound++;
} else { /* If Obj found in machine (i.e. has not moved) */
/* Check if Obj is locked by any previous transaction */
randomdelay();
/* Save all object oids that are locked on this machine during this transaction request call */
- oidlocked[objlocked] = ((objheader_t *)mobj)->oid;
+ oidlocked[objlocked] = OID(((objheader_t *)mobj));
objlocked++;
if (version == ((objheader_t *)mobj)->version) { /* Check if versions match */
v_matchnolock++;
for(i = 0; i< nummod; i++) {
tmp_header = (objheader_t *)ptr;
tmp_header->rcount = 1;
- ptr += sizeof(objheader_t) + classsize[tmp_header->type];
+ ptr += sizeof(objheader_t) + classsize[TYPE(tmp_header)];
}
/* Unlock objects that was locked due to this transaction */
for(i = 0; i< numlocked; i++) {
/* Change ptr address in mhash table */
mhashRemove(transinfo->objmod[i]);
mhashInsert(transinfo->objmod[i], (transinfo->modptr + offset));
- offset += sizeof(objheader_t) + classsize[header->type];
+ offset += sizeof(objheader_t) + classsize[TYPE(header)];
/* Update object version number */
header = (objheader_t *) mhashSearch(transinfo->objmod[i]);