Added ability to override default bufferManager implementation with

-DUSE_BUFFER_MANAGER
This commit is contained in:
Sears Russell 2007-03-06 00:00:26 +00:00
parent 44aef7e8ea
commit 237bbe0fbe
9 changed files with 30 additions and 9 deletions

View file

@ -96,6 +96,20 @@ BEGIN_C_DECLS
typedef struct Page_s Page_s;
typedef struct Page_s Page;
/**
This is the type of buffer manager that is being used.
Before Stasis is intialized, it will be set to a default value.
It may be changed before Tinit() is called, or overridden at
compile time by defining USE_BUFFER_MANAGER
(eg: gcc ... -DUSE_BUFFER_MANAGER=BUFFER_MANAGER_FOO)
@see constants.h for a list of recognized log implementations.
*/
extern int bufferManagerType;
/**
* @param xid The transaction that is pinning the page (used by page-level locking implementations.)
* @param pageid ID of the page you want to load
@ -133,6 +147,8 @@ extern void (*writeBackPage)(Page * p);
*/
extern void (*forcePages)();
extern void (*simulateBufferManagerCrash)();
int bufInit(int type);
/**
* will write out any dirty pages, assumes that there are no running

View file

@ -98,6 +98,12 @@ pthread_mutex_t pinCount_mutex = PTHREAD_MUTEX_INITIALIZER;
int pinCount = 0;
#endif
#ifdef USE_BUFFER_MANAGER
int bufferManagerType = USE_BUFFER_MANAGER;
#else
int bufferManagerType = BUFFER_MANAGER_HASH;
#endif
static struct LH_ENTRY(table) *activePages; /* page lookup */
/*static Page * activePagePtrs[MAX_BUFFER_SIZE];*/
@ -111,6 +117,7 @@ static pthread_key_t lastPage;
static void bufManBufDeinit();
static compensated_function Page *bufManLoadPage(int xid, int pageid);
static void bufManReleasePage (Page * p);
static void bufManSimulateBufferManagerCrash();
static int bufManBufInit() {
@ -119,7 +126,7 @@ static int bufManBufInit() {
writeBackPage = pageWrite;
forcePages = forcePageFile;
bufDeinit = bufManBufDeinit;
simulateBufferManagerCrash = bufManSimulateBufferManagerCrash;
bufferPoolInit();
@ -183,7 +190,7 @@ static void bufManBufDeinit() {
Just close file descriptors, don't do any other clean up. (For
testing.)
*/
void simulateBufferManagerCrash() {
void bufManSimulateBufferManagerCrash() {
closePageFile();
#ifdef PIN_COUNT
pinCount = 0;
@ -501,8 +508,10 @@ void (*releasePage)(Page * p) = 0;
void (*writeBackPage)(Page * p) = 0;
void (*forcePages)() = 0;
void (*bufDeinit)() = 0;
void (*simulateBufferManagerCrash)() = 0;
int bufInit(int type) {
bufferManagerType = type;
static int lastType = 0;
if(type == BUFFER_MANAGER_REOPEN) {
type = lastType;

View file

@ -54,6 +54,7 @@ static void paBufDeinit() {
}
}
}
void paBufInit () {
releasePage = paReleasePage;
@ -61,6 +62,7 @@ void paBufInit () {
writeBackPage = paWriteBackPage;
forcePages = paForcePages;
bufDeinit = paBufDeinit;
simulateBufferManagerCrash = paBufDeinit;
pageCount = 0;
pageMap = 0;

View file

@ -112,8 +112,7 @@ int Tinit() {
dirtyPagesInit();
LogInit(loggerType);
pageInit();
bufInit(BUFFER_MANAGER_HASH);
//bufInit(BUFFER_MANAGER_MEM_ARRAY);
bufInit(bufferManagerType);
pageOperationsInit();
initNestedTopActions();
TallocInit();

View file

@ -384,7 +384,6 @@ END_TEST
} END_TEST
*/
void simulateBufferManagerCrash();
extern int numActiveXactions;
/**
@test

View file

@ -55,7 +55,6 @@ terms specified in this license.
#include "../check_includes.h"
#include <lladd/truncation.h>
void simulateBufferManagerCrash();
extern int numActiveXactions;
#define LOG_NAME "check_logWriter.log"

View file

@ -54,7 +54,6 @@ terms specified in this license.
#include <stdio.h>
void simulateBufferManagerCrash();
extern int numActiveXactions;
/**
@test

View file

@ -58,7 +58,6 @@ terms specified in this license.
#define LOG_NAME "check_pageOperations.log"
#include "../../src/lladd/logger/logWriter.h"
void simulateBufferManagerCrash();
extern int numActiveXactions;
START_TEST(pageOpCheckRecovery) {

View file

@ -334,7 +334,6 @@ START_TEST(recovery_clr) {
} END_TEST
void simulateBufferManagerCrash();
extern int numActiveXactions;
/**
@test