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 14
21 #define TRANS_DISAGREE 15
22 #define TRANS_AGREE_BUT_MISSING_OBJECTS 16
23 #define TRANS_SOFT_ABORT 17
24 #define TRANS_SUCESSFUL 18
32 #define DEFAULT_OBJ_STORE_SIZE 1048510 //1MB
34 //bit designations for status field of objheader
39 typedef struct objheader {
42 unsigned short version;
43 unsigned short rcount;
47 typedef struct objstr {
48 unsigned int size; //this many bytes are allocated after this header
53 typedef struct transrecord {
55 chashtable_t *lookupTable;
64 // Structure that keeps track of responses from the participants
65 typedef struct thread_response {
69 // Structure that holds fixed data sizes to be sent along with TRANS_REQUEST
70 typedef struct fixed_data {
72 char trans_id[TID_LEN];
73 int mcount; // Machine count
74 short numread; // Number of objects read
75 short nummod; // Number of objects modified
76 int sum_bytes; // Total bytes modified
79 // Structure that holds variable data sizes per machine participant
80 typedef struct trans_req_data {
82 unsigned int *listmid;
87 //structure for passing multiple arguments to thread
88 typedef struct thread_data_array {
92 trans_req_data_t *buffer;
93 thread_response_t *recvmsg;//shared datastructure to keep track of the control message receiv
94 pthread_cond_t *threshold; //threshhold for waking up a thread
95 pthread_mutex_t *lock; //lock the count variable
96 int *count; //count variable
97 transrecord_t *rec; // To send modified objects
100 /* Initialize main object store and lookup tables, start server thread. */
103 /* Prototypes for object header */
104 unsigned int getNewOID(void);
105 unsigned int objSize(objheader_t *object);
106 /* end object header */
108 /* Prototypes for object store */
109 objstr_t *objstrCreate(unsigned int size); //size in bytes
110 void objstrDelete(objstr_t *store); //traverse and free entire list
111 void *objstrAlloc(objstr_t *store, unsigned int size); //size in bytes
112 /* end object store */
114 /* Prototypes for server portion */
116 void *dstmAccept(void *);
117 /* end server portion */
119 /* Prototypes for transactions */
120 transrecord_t *transStart();
121 objheader_t *transRead(transrecord_t *record, unsigned int oid);
122 objheader_t *transCreateObj(transrecord_t *record, unsigned short type); //returns oid
123 void *transRequest(void *); //the C routine that the thread will execute when TRANS_REQUEST begins
124 int transCommit(transrecord_t *record); //return 0 if successful
125 int decideResponse(thread_data_array_t *tdata, char *buffer, int sd);// Coordinator decides what response to send to the participant
126 /* end transactions */
128 void *getRemoteObj(transrecord_t *, unsigned int, unsigned int);