2009-10-14 18:57:50 +00:00
|
|
|
/*
|
|
|
|
* transactionTable.h
|
|
|
|
*
|
|
|
|
* Created on: Oct 14, 2009
|
|
|
|
* Author: sears
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TRANSACTIONTABLE_H_
|
|
|
|
#define TRANSACTIONTABLE_H_
|
|
|
|
|
|
|
|
#include <stasis/common.h>
|
2009-10-14 21:22:50 +00:00
|
|
|
|
|
|
|
typedef struct stasis_transaction_table_entry_t stasis_transaction_table_entry_t;
|
|
|
|
typedef struct stasis_transaction_table_t stasis_transaction_table_t;
|
2009-10-14 18:57:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Contains the state needed by the logging layer to perform
|
|
|
|
operations on a transaction.
|
|
|
|
*/
|
2009-10-14 21:22:50 +00:00
|
|
|
struct stasis_transaction_table_entry_t {
|
2009-10-14 18:57:50 +00:00
|
|
|
int xid;
|
|
|
|
lsn_t prevLSN;
|
|
|
|
lsn_t recLSN;
|
|
|
|
pthread_mutex_t mut;
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
Initialize Stasis' transaction table. Called by Tinit() and unit
|
|
|
|
tests that wish to test portions of Stasis in isolation.
|
|
|
|
*/
|
2009-10-14 21:22:50 +00:00
|
|
|
stasis_transaction_table_t* stasis_transaction_table_init();
|
2009-10-14 18:57:50 +00:00
|
|
|
/** Free resources associated with the transaction table */
|
2009-10-14 21:22:50 +00:00
|
|
|
void stasis_transaction_table_deinit(stasis_transaction_table_t*);
|
2009-10-14 18:57:50 +00:00
|
|
|
|
2009-10-14 21:22:50 +00:00
|
|
|
int stasis_transaction_table_roll_forward(stasis_transaction_table_t*,int xid, lsn_t lsn, lsn_t prevLSN);
|
2009-10-14 18:57:50 +00:00
|
|
|
/**
|
|
|
|
@todo update Tprepare() to not write reclsn to log, then remove
|
|
|
|
this function.
|
|
|
|
*/
|
2009-10-14 21:22:50 +00:00
|
|
|
int stasis_transaction_table_roll_forward_with_reclsn(stasis_transaction_table_t*,int xid, lsn_t lsn,
|
2009-10-14 18:57:50 +00:00
|
|
|
lsn_t prevLSN,
|
|
|
|
lsn_t recLSN);
|
|
|
|
/**
|
|
|
|
This is used by log truncation.
|
|
|
|
*/
|
2009-10-14 21:22:50 +00:00
|
|
|
lsn_t stasis_transaction_table_minRecLSN(stasis_transaction_table_t*);
|
2009-10-14 18:57:50 +00:00
|
|
|
|
2009-10-14 21:22:50 +00:00
|
|
|
stasis_transaction_table_entry_t * stasis_transaction_table_begin(stasis_transaction_table_t*,int * xid);
|
|
|
|
stasis_transaction_table_entry_t * stasis_transaction_table_get(stasis_transaction_table_t*,int xid);
|
|
|
|
int stasis_transaction_table_commit(stasis_transaction_table_t*,int xid);
|
|
|
|
int stasis_transaction_table_forget(stasis_transaction_table_t*,int xid);
|
2009-10-14 18:57:50 +00:00
|
|
|
|
2009-10-14 21:22:50 +00:00
|
|
|
int stasis_transaction_table_num_active(stasis_transaction_table_t*);
|
|
|
|
int* stasis_transaction_table_list_active(stasis_transaction_table_t*);
|
|
|
|
int stasis_transaction_table_is_active(stasis_transaction_table_t*, int xid);
|
2009-10-14 18:57:50 +00:00
|
|
|
|
|
|
|
#endif /* TRANSACTIONTABLE_H_ */
|