Added ability to override default bufferManager implementation with
-DUSE_BUFFER_MANAGER
This commit is contained in:
parent
44aef7e8ea
commit
237bbe0fbe
9 changed files with 30 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -112,8 +112,7 @@ int Tinit() {
|
|||
dirtyPagesInit();
|
||||
LogInit(loggerType);
|
||||
pageInit();
|
||||
bufInit(BUFFER_MANAGER_HASH);
|
||||
//bufInit(BUFFER_MANAGER_MEM_ARRAY);
|
||||
bufInit(bufferManagerType);
|
||||
pageOperationsInit();
|
||||
initNestedTopActions();
|
||||
TallocInit();
|
||||
|
|
|
@ -384,7 +384,6 @@ END_TEST
|
|||
|
||||
} END_TEST
|
||||
*/
|
||||
void simulateBufferManagerCrash();
|
||||
extern int numActiveXactions;
|
||||
/**
|
||||
@test
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -54,7 +54,6 @@ terms specified in this license.
|
|||
#include <stdio.h>
|
||||
|
||||
|
||||
void simulateBufferManagerCrash();
|
||||
extern int numActiveXactions;
|
||||
/**
|
||||
@test
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -334,7 +334,6 @@ START_TEST(recovery_clr) {
|
|||
|
||||
} END_TEST
|
||||
|
||||
void simulateBufferManagerCrash();
|
||||
extern int numActiveXactions;
|
||||
/**
|
||||
@test
|
||||
|
|
Loading…
Reference in a new issue