/** * Added to flush a particular page of the buffer pool to disk * * @param pageid the page number in the database. * @exception HashOperationException if there is a hashtable error. * @exception PageUnpinnedException if there is a page that is already unpinned. * @exception PagePinnedException if a page is left pinned. * @exception PageNotFoundException if a page is not found. * @exception BufMgrException other error occured in bufmgr layer * @exception IOException if there is other kinds of I/O error. */ public void flushPage(PageId pageId) throws HashOperationException, PageUnpinnedException, PagePinnedException, PageNotFoundException, BufMgrException, IOException { BufMgrFrameDesc frame = pageTable.get(pageId); if (frame != null) { if (frame.isDirty()) { try { SystemDefs.JavabaseDB.write_page(pageId, new Page(frame.getData())); } catch (Exception e) { throw new BufMgrException(e, "BufrMgr::flushPage: page cant be freed by diskmanager"); } } frame.setDirtybit(false); if (frame.getPinCount() > 0) { throw new PagePinnedException(null, "BufrMgr::flushPage: page is still pinned"); } } else { throw new PageNotFoundException(null, "BufrMgr::flushPage: page to be flushed not loaded"); } }
private void returnPageInfo(Page page, BufMgrFrameDesc frame) throws InvalidFrameNumberException { frame.pin(); replacer.pin(frame.getFrameNumber()); page.setpage(frame.getData()); }