|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object global.AbstractBufMgr bufmgr.BufMgr
The buffer manager class, it allocates new pages for the buffer pool, pins and unpins the frame, frees the frame page, and uses the replacement algorithm to replace the page.
Field Summary |
Fields inherited from interface global.GlobalConst |
INVALID_PAGE, MAX_NAME, MAXATTRNAME, MAXFILENAME, MAXINDEXNAME, MINIBASE_BUFFER_POOL_SIZE, MINIBASE_DB_SIZE, MINIBASE_DEFAULT_SHAREDMEM_SIZE, MINIBASE_MAX_TRANSACTIONS, MINIBASE_MAXARRSIZE, NUMBUF, PAGE_SIZE, PAGESIZE |
Constructor Summary | |
BufMgr(int numbufs,
java.lang.String replacerArg)
Create a buffer manager object. |
Method Summary | |
void |
flushAllPages()
Flushes all pages of the buffer pool to disk |
void |
flushPage(PageId pageid)
Added to flush a particular page of the buffer pool to disk |
void |
freePage(PageId globalPageId)
User should call this method if she needs to delete a page. |
AbstractBufMgrFrameDesc[] |
getFrameTable()
A few routines currently need direct access to the FrameTable. |
int |
getNumBuffers()
Gets the total number of buffers. |
int |
getNumUnpinnedBuffers()
Gets the total number of unpinned buffer frames. |
PageId |
newPage(Page firstpage,
int howmany)
Call DB object to allocate a run of new pages and find a frame in the buffer pool for the first page and pin it. |
void |
pinPage(PageId pin_pgid,
Page page,
boolean emptyPage)
Check if this page is in buffer pool, otherwise find a frame for this page, read in and pin it. |
void |
unpinPage(PageId PageId_in_a_DB,
boolean dirty)
To unpin a page specified by a pageId. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public BufMgr(int numbufs, java.lang.String replacerArg) throws InvalidReplacerException
numbufs
- number of buffers in the buffer pool.replacerArg
- name of the buffer replacement policy.
InvalidReplacerException
Method Detail |
public void pinPage(PageId pin_pgid, Page page, boolean emptyPage) throws ReplacerException, HashOperationException, PageUnpinnedException, InvalidFrameNumberException, PageNotReadException, BufferPoolExceededException, PagePinnedException, BufMgrException, java.io.IOException
pinPage
in class AbstractBufMgr
page
- the pointer poit to the page.emptyPage
- true (empty page); false (non-empty page)
ReplacerException
- if there is a replacer error.
HashOperationException
- if there is a hashtable error.
PageUnpinnedException
- if there is a page that is already unpinned.
InvalidFrameNumberException
- if there is an invalid frame number .
PageNotReadException
- if a page cannot be read.
BufferPoolExceededException
- if the buffer pool is full.
PagePinnedException
- if a page is left pinned .
BufMgrException
- other error occured in bufmgr layer
java.io.IOException
- if there is other kinds of I/O error.public void unpinPage(PageId PageId_in_a_DB, boolean dirty) throws ReplacerException, PageUnpinnedException, HashEntryNotFoundException, InvalidFrameNumberException
unpinPage
in class AbstractBufMgr
dirty
- the dirty bit of the frame
ReplacerException
- if there is a replacer error.
PageUnpinnedException
- if there is a page that is already unpinned.
InvalidFrameNumberException
- if there is an invalid frame number .
HashEntryNotFoundException
- if there is no entry of page in the hash table.public PageId newPage(Page firstpage, int howmany) throws BufferPoolExceededException, HashOperationException, ReplacerException, HashEntryNotFoundException, InvalidFrameNumberException, PagePinnedException, PageUnpinnedException, PageNotReadException, BufMgrException, DiskMgrException, java.io.IOException
newPage
in class AbstractBufMgr
firstpage
- the address of the first page.howmany
- total number of allocated new pages.
BufferPoolExceededException
- if the buffer pool is full.
HashOperationException
- if there is a hashtable error.
ReplacerException
- if there is a replacer error.
HashEntryNotFoundException
- if there is no entry of page in the hash table.
InvalidFrameNumberException
- if there is an invalid frame number.
PageUnpinnedException
- if there is a page that is already unpinned.
PagePinnedException
- if a page is left pinned.
PageNotReadException
- if a page cannot be read.
java.io.IOException
- if there is other kinds of I/O error.
BufMgrException
- other error occured in bufmgr layer
DiskMgrException
- other error occured in diskmgr layerpublic void freePage(PageId globalPageId) throws InvalidBufferException, ReplacerException, HashOperationException, InvalidFrameNumberException, PageNotReadException, BufferPoolExceededException, PagePinnedException, PageUnpinnedException, HashEntryNotFoundException, BufMgrException, DiskMgrException, java.io.IOException
freePage
in class AbstractBufMgr
globalPageId
- the page number in the data base.
InvalidBufferException
- if buffer pool corrupted.
ReplacerException
- if there is a replacer error.
HashOperationException
- if there is a hash table error.
InvalidFrameNumberException
- if there is an invalid frame number.
PageNotReadException
- if a page cannot be read.
BufferPoolExceededException
- if the buffer pool is already full.
PagePinnedException
- if a page is left pinned.
PageUnpinnedException
- if there is a page that is already unpinned.
HashEntryNotFoundException
- if there is no entry of page in the hash table.
java.io.IOException
- if there is other kinds of I/O error.
BufMgrException
- other error occured in bufmgr layer
DiskMgrException
- other error occured in diskmgr layerpublic void flushPage(PageId pageid) throws HashOperationException, PageUnpinnedException, PagePinnedException, PageNotFoundException, BufMgrException, java.io.IOException
flushPage
in class AbstractBufMgr
pageid
- the page number in the database.
HashOperationException
- if there is a hashtable error.
PageUnpinnedException
- if there is a page that is already unpinned.
PagePinnedException
- if a page is left pinned.
PageNotFoundException
- if a page is not found.
BufMgrException
- other error occured in bufmgr layer
java.io.IOException
- if there is other kinds of I/O error.public void flushAllPages() throws HashOperationException, PageUnpinnedException, PagePinnedException, PageNotFoundException, BufMgrException, java.io.IOException
flushAllPages
in class AbstractBufMgr
HashOperationException
- if there is a hashtable error.
PageUnpinnedException
- if there is a page that is already unpinned.
PagePinnedException
- if a page is left pinned.
PageNotFoundException
- if a page is not found.
BufMgrException
- other error occured in bufmgr layer
java.io.IOException
- if there is other kinds of I/O error.public int getNumBuffers()
getNumBuffers
in class AbstractBufMgr
public int getNumUnpinnedBuffers()
getNumUnpinnedBuffers
in class AbstractBufMgr
public AbstractBufMgrFrameDesc[] getFrameTable()
getFrameTable
in class AbstractBufMgr
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |