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