6 #define READ_MULT_REQUEST 2
8 #define MOVE_MULT_REQUEST 4
9 #define TRANS_REQUEST 5
11 #define TRANS_COMMIT 7
12 #define TRANS_ABORT_BUT_RETRY_COMMIT 8
13 #define TRANS_ABORT_BUT_RETRY_COMMIT_WITH_RELOCATING 9
15 //Participant Messages
16 #define OBJECT_FOUND 10
17 #define OBJECT_NOT_FOUND 11
18 #define OBJECTS_FOUND 12
19 #define OBJECTS_NOT_FOUND 13
20 #define TRANS_AGREE 17
21 #define TRANS_DISAGREE 18
22 #define TRANS_AGREE_BUT_MISSING_OBJECTS 19
23 #define TRANS_SOFT_ABORT 20
24 #define TRANS_SUCESSFUL 21
26 //Control bits for status of objects in Machine pile
27 #define OBJ_LOCKED_BUT_VERSION_MATCH 14
28 #define OBJ_UNLOCK_BUT_VERSION_MATCH 15
29 #define VERSION_NO_MATCH 16
31 #define NO_MISSING_OIDS 22
32 #define MISSING_OIDS_PRESENT 23
41 #define DEFAULT_OBJ_STORE_SIZE 1048510 //1MB
43 //bit designations for status field of objheader
48 typedef struct objheader {
51 unsigned short version;
52 unsigned short rcount;
56 typedef struct objstr {
57 unsigned int size; //this many bytes are allocated after this header
62 typedef struct transrecord {
64 chashtable_t *lookupTable;
73 // Structure that keeps track of responses from the participants
74 typedef struct thread_response {
78 // Structure that holds fixed data sizes to be sent along with TRANS_REQUEST
79 typedef struct fixed_data {
81 char trans_id[TID_LEN];
82 int mcount; // Machine count
83 short numread; // Number of objects read
84 short nummod; // Number of objects modified
85 int sum_bytes; // Total bytes modified
88 // Structure that holds variable data sizes per machine participant
89 typedef struct trans_req_data {
91 unsigned int *listmid;
96 #define PRINT_TID(PTR) printf("DEBUG -> %x %d\n", PTR->mid, PTR->thread_id);
97 //structure for passing multiple arguments to thread
98 typedef struct thread_data_array {
102 trans_req_data_t *buffer;
103 thread_response_t *recvmsg;//shared datastructure to keep track of the control message receiv
104 pthread_cond_t *threshold; //threshhold for waking up a thread
105 pthread_mutex_t *lock; //lock the count variable
106 int *count; //variable to count responses of TRANS_REQUEST protocol from all participants
107 transrecord_t *rec; // To send modified objects
108 }thread_data_array_t;
110 // Structure to save information about an oid necesaary for the decideControl()
111 typedef struct objinfo {
113 int poss_val; //Status of object(locked but version matches, version mismatch, oid not present in machine etc)
116 // Structure passed to dstmAcceptinfo() on server side to complete TRANS_COMMIT process
117 typedef struct trans_commit_data{
118 unsigned int *objmod;
119 unsigned int *objlocked;
120 unsigned int *objnotfound;
125 }trans_commit_data_t;
126 /* Initialize main object store and lookup tables, start server thread. */
129 /* Prototypes for object header */
130 unsigned int getNewOID(void);
131 unsigned int objSize(objheader_t *object);
132 /* end object header */
134 /* Prototypes for object store */
135 objstr_t *objstrCreate(unsigned int size); //size in bytes
136 void objstrDelete(objstr_t *store); //traverse and free entire list
137 void *objstrAlloc(objstr_t *store, unsigned int size); //size in bytes
138 /* end object store */
140 /* Prototypes for server portion */
142 void *dstmAccept(void *);
143 int readClientReq(int, trans_commit_data_t *);
144 char handleTransReq(int, fixed_data_t *, trans_commit_data_t *, unsigned int *, char *, void *);
145 /* end server portion */
147 /* Prototypes for transactions */
148 transrecord_t *transStart();
149 objheader_t *transRead(transrecord_t *record, unsigned int oid);
150 objheader_t *transCreateObj(transrecord_t *record, unsigned short type); //returns oid
151 int decideResponse(thread_data_array_t *tdata, int sd, int status);// Coordinator decides what response to send to the participant
152 void *transRequest(void *); //the C routine that the thread will execute when TRANS_REQUEST begins
153 int transCommit(transrecord_t *record); //return 0 if successful
154 void *getRemoteObj(transrecord_t *, unsigned int, unsigned int);
155 int transCommitProcess(trans_commit_data_t *, int);
156 /* end transactions */
158 void *getRemoteObj(transrecord_t *, unsigned int, unsigned int);