var pManager = new PageManager (); pManager.timeoutHandler(); function PageManager () { var ret = (function(self) { return function() { self.timeoutHandler(); }; })(this); this.timeoutHandler = function () { $.ajax ({ url: '/echo/json/', type: 'post', cache: false, success: function (data) { setTimeout (ret, 750); } }); }; }
/** * Insert at forced location, use only for defragmentation !! * @param logicalRowId * @param physLoc * @throws IOException */ void forceInsert(long logicalRowId, long physLoc) throws IOException { //create pages until we reach requested block long lastBlock = pageman.getLast(Magic.TRANSLATION_PAGE); while(lastBlock!=Location.getBlock(logicalRowId)){ lastBlock = pageman.allocate(Magic.TRANSLATION_PAGE); if(lastBlock>Location.getBlock(logicalRowId)) throw new Error("outallocated"); } if(fetch(logicalRowId) != 0) throw new Error("can not forceInsert, record already exists: "+logicalRowId); update(logicalRowId, physLoc); }
/** * Closes the record manager. * * @throws IOException when one of the underlying I/O operations fails. */ public void close() throws IOException { checkIfClosed(); pageMgr.close(); pageMgr = null; recordFile.close(); recordFile = null; }
/** * Creates a new logical rowid pointing to the indicated physical id */ long insert(long loc) throws IOException { // check whether there's a free rowid to reuse long retval = freeman.get(); if (retval == 0) { // no. This means that we bootstrap things by allocating // a new translation page and freeing all the rowids on it. long firstPage = pageman.allocate(Magic.TRANSLATION_PAGE); short curOffset = TranslationPage.O_TRANS; for (int i = 0; i < ELEMS_PER_PAGE; i++) { freeman.put(Location.toLong(firstPage, curOffset)); curOffset += PageHeader.PhysicalRowId_SIZE; } retval = freeman.get(); if (retval == 0) { throw new Error("couldn't obtain free translation"); } } // write the translation. update(retval, loc); return retval; }
/** * Returns the indicated root rowid. * * @see #getRootCount */ public synchronized long getRoot( int id ) throws IOException { checkIfClosed(); return pageMgr.getFileHeader().getRoot( id ); }
pageman.free(Magic.FREELOGIDS_PAGE, curs.getCurrent());
/** * Allocate a new rowid with the indicated size. */ private Location alloc( int size ) throws IOException { Location retval = freeman.get( size ); if ( retval == null ) { // temporary work around for DIRSERVER-1459 retval = allocNew( size * 2, pageManager.getLast( Magic.USED_PAGE ) ); } return retval; }
/** * Returns the previous value of the cursor */ long prev() throws IOException { current = pageman.getPrev( current ); return current; } }
header.setFirstOf(Magic.FREE_PAGE, getNext(retval));
/** * Creates a new logical rowid pointing to the indicated physical * id */ Location insert(Location loc) throws IOException { // check whether there's a free rowid to reuse Location retval = freeman.get(); if (retval == null) { // no. This means that we bootstrap things by allocating // a new translation page and freeing all the rowids on it. long firstPage = pageman.allocate(Magic.TRANSLATION_PAGE); short curOffset = TranslationPage.O_TRANS; for (int i = 0; i < TranslationPage.ELEMS_PER_PAGE; i++) { freeman.put(new Location(firstPage, curOffset)); curOffset += PhysicalRowId.SIZE; } retval = freeman.get(); if (retval == null) { throw new Error( I18n.err( I18n.ERR_545 ) ); } } // write the translation. update(retval, loc); return retval; }
public synchronized void setRoot( int id, long rowid ) throws IOException { checkIfClosed(); _physPageman.getFileHeader().setRoot( id, rowid ); }
pageManager.free( Magic.FREELOGIDS_PAGE, cursor.getBlockId() );
/** * Allocate a new rowid with the indicated size. */ private Location alloc( int size ) throws IOException { Location retval = freeman.get( size ); if ( retval == null ) { // temporary work around for DIRSERVER-1459 retval = allocNew( size * 2, pageman.getLast( Magic.USED_PAGE ) ); } return retval; }
/** * @return the previous blockId */ long prev() throws IOException { blockId = pageManager.getPrev( blockId ); return blockId; }
/** * Commit (make persistent) all changes since beginning of transaction. */ public void commit() throws IOException { checkIfClosed(); pageMgr.commit(); }
header.setFirstOf( Magic.FREE_PAGE, getNext( retval ) );